PluginProbe
Gutenberg / 23.6.2
Gutenberg v23.6.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.6.2, at build/widgets/news/render.js

27,428 lines 955.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var __create = Object.create;
2 var __defProp = Object.defineProperty;
3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4 var __getOwnPropNames = Object.getOwnPropertyNames;
5 var __getProtoOf = Object.getPrototypeOf;
6 var __hasOwnProp = Object.prototype.hasOwnProperty;
7 var __commonJS = (cb, mod) => function __require() {
8 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9 };
10 var __export = (target, all) => {
11 for (var name in all)
12 __defProp(target, name, { get: all[name], enumerable: true });
13 };
14 var __copyProps = (to, from, except, desc) => {
15 if (from && typeof from === "object" || typeof from === "function") {
16 for (let key of __getOwnPropNames(from))
17 if (!__hasOwnProp.call(to, key) && key !== except)
18 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19 }
20 return to;
21 };
22 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23 // If the importer is in node compatibility mode or this is not an ESM
24 // file that has been converted to a CommonJS file using a Babel-
25 // compatible transform (i.e. "__esModule" has not been set), then set
26 // "default" to the CommonJS "module.exports" for node compatibility.
27 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28 mod
29 ));
30
31 // package-external:@wordpress/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 === React49.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 = useState37({
86 inst: { value, getSnapshot }
87 });
88 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
89 useLayoutEffect5(
90 function() {
91 inst.value = value;
92 inst.getSnapshot = getSnapshot;
93 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
94 },
95 [subscribe2, value, getSnapshot]
96 );
97 useEffect33(
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 React49 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState37 = React49.useState, useEffect33 = React49.useEffect, useLayoutEffect5 = React49.useLayoutEffect, useDebugValue2 = React49.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 !== React49.useSyncExternalStore ? React49.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 React49 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef48 = React49.useRef, useEffect33 = React49.useEffect, useMemo41 = React49.useMemo, useDebugValue2 = React49.useDebugValue;
152 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
153 var instRef = useRef48(null);
154 if (null === instRef.current) {
155 var inst = { hasValue: false, value: null };
156 instRef.current = inst;
157 } else inst = instRef.current;
158 instRef = useMemo41(
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 useEffect33(
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/rich-text
823 var require_rich_text = __commonJS({
824 "package-external:@wordpress/rich-text"(exports, module) {
825 module.exports = window.wp.richText;
826 }
827 });
828
829 // package-external:@wordpress/html-entities
830 var require_html_entities = __commonJS({
831 "package-external:@wordpress/html-entities"(exports, module) {
832 module.exports = window.wp.htmlEntities;
833 }
834 });
835
836 // widgets/news/render.tsx
837 var import_i18n46 = __toESM(require_i18n());
838
839 // node_modules/clsx/dist/clsx.mjs
840 function r(e2) {
841 var t2, f2, n2 = "";
842 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
843 else if ("object" == typeof e2) if (Array.isArray(e2)) {
844 var o2 = e2.length;
845 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
846 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
847 return n2;
848 }
849 function clsx() {
850 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
851 return n2;
852 }
853 var clsx_default = clsx;
854
855 // node_modules/@base-ui/utils/safeReact.mjs
856 var React = __toESM(require_react(), 1);
857 var SafeReact = {
858 ...React
859 };
860
861 // node_modules/@base-ui/utils/useRefWithInit.mjs
862 var React2 = __toESM(require_react(), 1);
863 var UNINITIALIZED = {};
864 function useRefWithInit(init2, initArg) {
865 const ref = React2.useRef(UNINITIALIZED);
866 if (ref.current === UNINITIALIZED) {
867 ref.current = init2(initArg);
868 }
869 return ref;
870 }
871
872 // node_modules/@base-ui/utils/useStableCallback.mjs
873 var useInsertionEffect = SafeReact.useInsertionEffect;
874 var useSafeInsertionEffect = (
875 // React 17 doesn't have useInsertionEffect.
876 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
877 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn()
878 );
879 function useStableCallback(callback) {
880 const stable = useRefWithInit(createStableCallback).current;
881 stable.next = callback;
882 useSafeInsertionEffect(stable.effect);
883 return stable.trampoline;
884 }
885 function createStableCallback() {
886 const stable = {
887 next: void 0,
888 callback: assertNotCalled,
889 trampoline: (...args) => stable.callback?.(...args),
890 effect: () => {
891 stable.callback = stable.next;
892 }
893 };
894 return stable;
895 }
896 function assertNotCalled() {
897 if (true) {
898 throw (
899 /* minify-error-disabled */
900 new Error("Base UI: Cannot call an event handler while rendering.")
901 );
902 }
903 }
904
905 // node_modules/@base-ui/utils/useIsoLayoutEffect.mjs
906 var React3 = __toESM(require_react(), 1);
907 var noop = () => {
908 };
909 var useIsoLayoutEffect = typeof document !== "undefined" ? React3.useLayoutEffect : noop;
910
911 // node_modules/@base-ui/utils/warn.mjs
912 var set;
913 if (true) {
914 set = /* @__PURE__ */ new Set();
915 }
916 function warn(...messages) {
917 if (true) {
918 const messageKey = messages.join(" ");
919 if (!set.has(messageKey)) {
920 set.add(messageKey);
921 console.warn(`Base UI: ${messageKey}`);
922 }
923 }
924 }
925
926 // node_modules/@base-ui/react/internals/direction-context/DirectionContext.mjs
927 var React4 = __toESM(require_react(), 1);
928 var DirectionContext = /* @__PURE__ */ React4.createContext(void 0);
929 if (true) DirectionContext.displayName = "DirectionContext";
930 function useDirection() {
931 const context = React4.useContext(DirectionContext);
932 return context?.direction ?? "ltr";
933 }
934
935 // node_modules/@base-ui/react/internals/useRenderElement.mjs
936 var React7 = __toESM(require_react(), 1);
937
938 // node_modules/@base-ui/utils/useMergedRefs.mjs
939 function useMergedRefs(a2, b2, c2, d2) {
940 const forkRef = useRefWithInit(createForkRef).current;
941 if (didChange(forkRef, a2, b2, c2, d2)) {
942 update(forkRef, [a2, b2, c2, d2]);
943 }
944 return forkRef.callback;
945 }
946 function useMergedRefsN(refs) {
947 const forkRef = useRefWithInit(createForkRef).current;
948 if (didChangeN(forkRef, refs)) {
949 update(forkRef, refs);
950 }
951 return forkRef.callback;
952 }
953 function createForkRef() {
954 return {
955 callback: null,
956 cleanup: null,
957 refs: []
958 };
959 }
960 function didChange(forkRef, a2, b2, c2, d2) {
961 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
962 }
963 function didChangeN(forkRef, newRefs) {
964 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
965 }
966 function update(forkRef, refs) {
967 forkRef.refs = refs;
968 if (refs.every((ref) => ref == null)) {
969 forkRef.callback = null;
970 return;
971 }
972 forkRef.callback = (instance) => {
973 if (forkRef.cleanup) {
974 forkRef.cleanup();
975 forkRef.cleanup = null;
976 }
977 if (instance != null) {
978 const cleanupCallbacks = Array(refs.length).fill(null);
979 for (let i2 = 0; i2 < refs.length; i2 += 1) {
980 const ref = refs[i2];
981 if (ref == null) {
982 continue;
983 }
984 switch (typeof ref) {
985 case "function": {
986 const refCleanup = ref(instance);
987 if (typeof refCleanup === "function") {
988 cleanupCallbacks[i2] = refCleanup;
989 }
990 break;
991 }
992 case "object": {
993 ref.current = instance;
994 break;
995 }
996 default:
997 }
998 }
999 forkRef.cleanup = () => {
1000 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1001 const ref = refs[i2];
1002 if (ref == null) {
1003 continue;
1004 }
1005 switch (typeof ref) {
1006 case "function": {
1007 const cleanupCallback = cleanupCallbacks[i2];
1008 if (typeof cleanupCallback === "function") {
1009 cleanupCallback();
1010 } else {
1011 ref(null);
1012 }
1013 break;
1014 }
1015 case "object": {
1016 ref.current = null;
1017 break;
1018 }
1019 default:
1020 }
1021 }
1022 };
1023 }
1024 };
1025 }
1026
1027 // node_modules/@base-ui/utils/getReactElementRef.mjs
1028 var React6 = __toESM(require_react(), 1);
1029
1030 // node_modules/@base-ui/utils/reactVersion.mjs
1031 var React5 = __toESM(require_react(), 1);
1032 var majorVersion = parseInt(React5.version, 10);
1033 function isReactVersionAtLeast(reactVersionToCheck) {
1034 return majorVersion >= reactVersionToCheck;
1035 }
1036
1037 // node_modules/@base-ui/utils/getReactElementRef.mjs
1038 function getReactElementRef(element) {
1039 if (!/* @__PURE__ */ React6.isValidElement(element)) {
1040 return null;
1041 }
1042 const reactElement = element;
1043 const propsWithRef = reactElement.props;
1044 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1045 }
1046
1047 // node_modules/@base-ui/utils/mergeObjects.mjs
1048 function mergeObjects(a2, b2) {
1049 if (a2 && !b2) {
1050 return a2;
1051 }
1052 if (!a2 && b2) {
1053 return b2;
1054 }
1055 if (a2 || b2) {
1056 return {
1057 ...a2,
1058 ...b2
1059 };
1060 }
1061 return void 0;
1062 }
1063
1064 // node_modules/@base-ui/utils/empty.mjs
1065 function NOOP() {
1066 }
1067 var EMPTY_ARRAY = Object.freeze([]);
1068 var EMPTY_OBJECT = Object.freeze({});
1069
1070 // node_modules/@base-ui/react/internals/getStateAttributesProps.mjs
1071 function getStateAttributesProps(state, customMapping) {
1072 const props = {};
1073 for (const key in state) {
1074 const value = state[key];
1075 if (customMapping?.hasOwnProperty(key)) {
1076 const customProps = customMapping[key](value);
1077 if (customProps != null) {
1078 Object.assign(props, customProps);
1079 }
1080 continue;
1081 }
1082 if (value === true) {
1083 props[`data-${key.toLowerCase()}`] = "";
1084 } else if (value) {
1085 props[`data-${key.toLowerCase()}`] = value.toString();
1086 }
1087 }
1088 return props;
1089 }
1090
1091 // node_modules/@base-ui/react/utils/resolveClassName.mjs
1092 function resolveClassName(className, state) {
1093 return typeof className === "function" ? className(state) : className;
1094 }
1095
1096 // node_modules/@base-ui/react/utils/resolveStyle.mjs
1097 function resolveStyle(style, state) {
1098 return typeof style === "function" ? style(state) : style;
1099 }
1100
1101 // node_modules/@base-ui/react/merge-props/mergeProps.mjs
1102 var EMPTY_PROPS = {};
1103 function mergeProps(a2, b2, c2, d2, e2) {
1104 if (!c2 && !d2 && !e2 && !a2) {
1105 return createInitialMergedProps(b2);
1106 }
1107 let merged = createInitialMergedProps(a2);
1108 if (b2) {
1109 merged = mergeInto(merged, b2);
1110 }
1111 if (c2) {
1112 merged = mergeInto(merged, c2);
1113 }
1114 if (d2) {
1115 merged = mergeInto(merged, d2);
1116 }
1117 if (e2) {
1118 merged = mergeInto(merged, e2);
1119 }
1120 return merged;
1121 }
1122 function mergePropsN(props) {
1123 if (props.length === 0) {
1124 return EMPTY_PROPS;
1125 }
1126 if (props.length === 1) {
1127 return createInitialMergedProps(props[0]);
1128 }
1129 let merged = createInitialMergedProps(props[0]);
1130 for (let i2 = 1; i2 < props.length; i2 += 1) {
1131 merged = mergeInto(merged, props[i2]);
1132 }
1133 return merged;
1134 }
1135 function createInitialMergedProps(inputProps) {
1136 if (isPropsGetter(inputProps)) {
1137 return {
1138 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1139 };
1140 }
1141 return copyInitialProps(inputProps);
1142 }
1143 function mergeInto(merged, inputProps) {
1144 if (isPropsGetter(inputProps)) {
1145 return resolvePropsGetter(inputProps, merged);
1146 }
1147 return mutablyMergeInto(merged, inputProps);
1148 }
1149 function copyInitialProps(inputProps) {
1150 const copiedProps = {
1151 ...inputProps
1152 };
1153 for (const propName in copiedProps) {
1154 const propValue = copiedProps[propName];
1155 if (isEventHandler(propName, propValue)) {
1156 copiedProps[propName] = wrapEventHandler(propValue);
1157 }
1158 }
1159 return copiedProps;
1160 }
1161 function mutablyMergeInto(mergedProps, externalProps) {
1162 if (!externalProps) {
1163 return mergedProps;
1164 }
1165 for (const propName in externalProps) {
1166 const externalPropValue = externalProps[propName];
1167 switch (propName) {
1168 case "style": {
1169 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1170 break;
1171 }
1172 case "className": {
1173 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1174 break;
1175 }
1176 default: {
1177 if (isEventHandler(propName, externalPropValue)) {
1178 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1179 } else {
1180 mergedProps[propName] = externalPropValue;
1181 }
1182 }
1183 }
1184 }
1185 return mergedProps;
1186 }
1187 function isEventHandler(key, value) {
1188 const code0 = key.charCodeAt(0);
1189 const code1 = key.charCodeAt(1);
1190 const code2 = key.charCodeAt(2);
1191 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1192 }
1193 function isPropsGetter(inputProps) {
1194 return typeof inputProps === "function";
1195 }
1196 function resolvePropsGetter(inputProps, previousProps) {
1197 if (isPropsGetter(inputProps)) {
1198 return inputProps(previousProps);
1199 }
1200 return inputProps ?? EMPTY_PROPS;
1201 }
1202 function mergeEventHandlers(ourHandler, theirHandler) {
1203 if (!theirHandler) {
1204 return ourHandler;
1205 }
1206 if (!ourHandler) {
1207 return wrapEventHandler(theirHandler);
1208 }
1209 return (...args) => {
1210 const event = args[0];
1211 if (isSyntheticEvent(event)) {
1212 const baseUIEvent = event;
1213 makeEventPreventable(baseUIEvent);
1214 const result2 = theirHandler(...args);
1215 if (!baseUIEvent.baseUIHandlerPrevented) {
1216 ourHandler?.(...args);
1217 }
1218 return result2;
1219 }
1220 const result = theirHandler(...args);
1221 ourHandler?.(...args);
1222 return result;
1223 };
1224 }
1225 function wrapEventHandler(handler) {
1226 if (!handler) {
1227 return handler;
1228 }
1229 return (...args) => {
1230 const event = args[0];
1231 if (isSyntheticEvent(event)) {
1232 makeEventPreventable(event);
1233 }
1234 return handler(...args);
1235 };
1236 }
1237 function makeEventPreventable(event) {
1238 event.preventBaseUIHandler = () => {
1239 event.baseUIHandlerPrevented = true;
1240 };
1241 return event;
1242 }
1243 function mergeClassNames(ourClassName, theirClassName) {
1244 if (theirClassName) {
1245 if (ourClassName) {
1246 return theirClassName + " " + ourClassName;
1247 }
1248 return theirClassName;
1249 }
1250 return ourClassName;
1251 }
1252 function isSyntheticEvent(event) {
1253 return event != null && typeof event === "object" && "nativeEvent" in event;
1254 }
1255
1256 // node_modules/@base-ui/react/internals/useRenderElement.mjs
1257 var import_react = __toESM(require_react(), 1);
1258 function useRenderElement(element, componentProps, params = {}) {
1259 const renderProp = componentProps.render;
1260 const outProps = useRenderElementProps(componentProps, params);
1261 if (params.enabled === false) {
1262 return null;
1263 }
1264 const state = params.state ?? EMPTY_OBJECT;
1265 return evaluateRenderProp(element, renderProp, outProps, state);
1266 }
1267 function useRenderElementProps(componentProps, params = {}) {
1268 const {
1269 className: classNameProp,
1270 style: styleProp,
1271 render: renderProp
1272 } = componentProps;
1273 const {
1274 state = EMPTY_OBJECT,
1275 ref,
1276 props,
1277 stateAttributesMapping: stateAttributesMapping3,
1278 enabled = true
1279 } = params;
1280 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1281 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1282 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
1283 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1284 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1285 if (typeof document !== "undefined") {
1286 if (!enabled) {
1287 useMergedRefs(null, null);
1288 } else if (Array.isArray(ref)) {
1289 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1290 } else {
1291 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1292 }
1293 }
1294 if (!enabled) {
1295 return EMPTY_OBJECT;
1296 }
1297 if (className !== void 0) {
1298 outProps.className = mergeClassNames(outProps.className, className);
1299 }
1300 if (style !== void 0) {
1301 outProps.style = mergeObjects(outProps.style, style);
1302 }
1303 return outProps;
1304 }
1305 function resolveRenderFunctionProps(props) {
1306 if (Array.isArray(props)) {
1307 return mergePropsN(props);
1308 }
1309 return mergeProps(void 0, props);
1310 }
1311 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1312 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1313 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1314 function evaluateRenderProp(element, render4, props, state) {
1315 if (render4) {
1316 if (typeof render4 === "function") {
1317 if (true) {
1318 warnIfRenderPropLooksLikeComponent(render4);
1319 }
1320 return render4(props, state);
1321 }
1322 const mergedProps = mergeProps(props, render4.props);
1323 mergedProps.ref = props.ref;
1324 let newElement = render4;
1325 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1326 const children = React7.Children.toArray(render4);
1327 newElement = children[0];
1328 }
1329 if (true) {
1330 if (!/* @__PURE__ */ React7.isValidElement(newElement)) {
1331 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"));
1332 }
1333 }
1334 return /* @__PURE__ */ React7.cloneElement(newElement, mergedProps);
1335 }
1336 if (element) {
1337 if (typeof element === "string") {
1338 return renderTag(element, props);
1339 }
1340 }
1341 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1342 }
1343 function warnIfRenderPropLooksLikeComponent(renderFn) {
1344 const functionName = renderFn.name;
1345 if (functionName.length === 0) {
1346 return;
1347 }
1348 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1349 return;
1350 }
1351 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1352 return;
1353 }
1354 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");
1355 }
1356 function renderTag(Tag, props) {
1357 if (Tag === "button") {
1358 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1359 type: "button",
1360 ...props,
1361 key: props.key
1362 });
1363 }
1364 if (Tag === "img") {
1365 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1366 alt: "",
1367 ...props,
1368 key: props.key
1369 });
1370 }
1371 return /* @__PURE__ */ React7.createElement(Tag, props);
1372 }
1373
1374 // node_modules/@base-ui/utils/useId.mjs
1375 var React8 = __toESM(require_react(), 1);
1376 var globalId = 0;
1377 function useGlobalId(idOverride, prefix = "mui") {
1378 const [defaultId, setDefaultId] = React8.useState(idOverride);
1379 const id = idOverride || defaultId;
1380 React8.useEffect(() => {
1381 if (defaultId == null) {
1382 globalId += 1;
1383 setDefaultId(`${prefix}-${globalId}`);
1384 }
1385 }, [defaultId, prefix]);
1386 return id;
1387 }
1388 var maybeReactUseId = SafeReact.useId;
1389 function useId(idOverride, prefix) {
1390 if (maybeReactUseId !== void 0) {
1391 const reactId = maybeReactUseId();
1392 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1393 }
1394 return useGlobalId(idOverride, prefix);
1395 }
1396
1397 // node_modules/@base-ui/react/internals/useBaseUiId.mjs
1398 function useBaseUiId(idOverride) {
1399 return useId(idOverride, "base-ui");
1400 }
1401
1402 // node_modules/@base-ui/react/internals/reason-parts.mjs
1403 var reason_parts_exports = {};
1404 __export(reason_parts_exports, {
1405 cancelOpen: () => cancelOpen,
1406 chipRemovePress: () => chipRemovePress,
1407 clearPress: () => clearPress,
1408 closePress: () => closePress,
1409 closeWatcher: () => closeWatcher,
1410 decrementPress: () => decrementPress,
1411 disabled: () => disabled,
1412 drag: () => drag,
1413 escapeKey: () => escapeKey,
1414 focusOut: () => focusOut,
1415 imperativeAction: () => imperativeAction,
1416 incrementPress: () => incrementPress,
1417 initial: () => initial,
1418 inputBlur: () => inputBlur,
1419 inputChange: () => inputChange,
1420 inputClear: () => inputClear,
1421 inputPaste: () => inputPaste,
1422 inputPress: () => inputPress,
1423 itemPress: () => itemPress,
1424 keyboard: () => keyboard,
1425 linkPress: () => linkPress,
1426 listNavigation: () => listNavigation,
1427 missing: () => missing,
1428 none: () => none,
1429 outsidePress: () => outsidePress,
1430 pointer: () => pointer,
1431 scrub: () => scrub,
1432 siblingOpen: () => siblingOpen,
1433 swipe: () => swipe,
1434 trackPress: () => trackPress,
1435 triggerFocus: () => triggerFocus,
1436 triggerHover: () => triggerHover,
1437 triggerPress: () => triggerPress,
1438 wheel: () => wheel,
1439 windowResize: () => windowResize
1440 });
1441 var none = "none";
1442 var triggerPress = "trigger-press";
1443 var triggerHover = "trigger-hover";
1444 var triggerFocus = "trigger-focus";
1445 var outsidePress = "outside-press";
1446 var itemPress = "item-press";
1447 var closePress = "close-press";
1448 var linkPress = "link-press";
1449 var clearPress = "clear-press";
1450 var chipRemovePress = "chip-remove-press";
1451 var trackPress = "track-press";
1452 var incrementPress = "increment-press";
1453 var decrementPress = "decrement-press";
1454 var inputChange = "input-change";
1455 var inputClear = "input-clear";
1456 var inputBlur = "input-blur";
1457 var inputPaste = "input-paste";
1458 var inputPress = "input-press";
1459 var focusOut = "focus-out";
1460 var escapeKey = "escape-key";
1461 var closeWatcher = "close-watcher";
1462 var listNavigation = "list-navigation";
1463 var keyboard = "keyboard";
1464 var pointer = "pointer";
1465 var drag = "drag";
1466 var wheel = "wheel";
1467 var scrub = "scrub";
1468 var cancelOpen = "cancel-open";
1469 var siblingOpen = "sibling-open";
1470 var disabled = "disabled";
1471 var missing = "missing";
1472 var initial = "initial";
1473 var imperativeAction = "imperative-action";
1474 var swipe = "swipe";
1475 var windowResize = "window-resize";
1476
1477 // node_modules/@base-ui/react/internals/createBaseUIEventDetails.mjs
1478 function createChangeEventDetails(reason, event, trigger, customProperties) {
1479 let canceled = false;
1480 let allowPropagation = false;
1481 const custom = customProperties ?? EMPTY_OBJECT;
1482 const details = {
1483 reason,
1484 event: event ?? new Event("base-ui"),
1485 cancel() {
1486 canceled = true;
1487 },
1488 allowPropagation() {
1489 allowPropagation = true;
1490 },
1491 get isCanceled() {
1492 return canceled;
1493 },
1494 get isPropagationAllowed() {
1495 return allowPropagation;
1496 },
1497 trigger,
1498 ...custom
1499 };
1500 return details;
1501 }
1502
1503 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs
1504 var React10 = __toESM(require_react(), 1);
1505
1506 // node_modules/@base-ui/utils/useOnMount.mjs
1507 var React9 = __toESM(require_react(), 1);
1508 var EMPTY = [];
1509 function useOnMount(fn) {
1510 React9.useEffect(fn, EMPTY);
1511 }
1512
1513 // node_modules/@base-ui/utils/useAnimationFrame.mjs
1514 var EMPTY2 = null;
1515 var LAST_RAF = globalThis.requestAnimationFrame;
1516 var Scheduler = class {
1517 /* This implementation uses an array as a backing data-structure for frame callbacks.
1518 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1519 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1520 * be much more efficient if there is a call pattern that alterns as
1521 * "request-cancel-request-cancel-…".
1522 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1523 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1524 callbacks = [];
1525 callbacksCount = 0;
1526 nextId = 1;
1527 startId = 1;
1528 isScheduled = false;
1529 tick = (timestamp) => {
1530 this.isScheduled = false;
1531 const currentCallbacks = this.callbacks;
1532 const currentCallbacksCount = this.callbacksCount;
1533 this.callbacks = [];
1534 this.callbacksCount = 0;
1535 this.startId = this.nextId;
1536 if (currentCallbacksCount > 0) {
1537 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1538 currentCallbacks[i2]?.(timestamp);
1539 }
1540 }
1541 };
1542 request(fn) {
1543 const id = this.nextId;
1544 this.nextId += 1;
1545 this.callbacks.push(fn);
1546 this.callbacksCount += 1;
1547 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1548 if (!this.isScheduled || didRAFChange) {
1549 requestAnimationFrame(this.tick);
1550 this.isScheduled = true;
1551 }
1552 return id;
1553 }
1554 cancel(id) {
1555 const index2 = id - this.startId;
1556 if (index2 < 0 || index2 >= this.callbacks.length) {
1557 return;
1558 }
1559 this.callbacks[index2] = null;
1560 this.callbacksCount -= 1;
1561 }
1562 };
1563 var scheduler = new Scheduler();
1564 var AnimationFrame = class _AnimationFrame {
1565 static create() {
1566 return new _AnimationFrame();
1567 }
1568 static request(fn) {
1569 return scheduler.request(fn);
1570 }
1571 static cancel(id) {
1572 return scheduler.cancel(id);
1573 }
1574 currentId = EMPTY2;
1575 /**
1576 * Executes `fn` after `delay`, clearing any previously scheduled call.
1577 */
1578 request(fn) {
1579 this.cancel();
1580 this.currentId = scheduler.request(() => {
1581 this.currentId = EMPTY2;
1582 fn();
1583 });
1584 }
1585 cancel = () => {
1586 if (this.currentId !== EMPTY2) {
1587 scheduler.cancel(this.currentId);
1588 this.currentId = EMPTY2;
1589 }
1590 };
1591 disposeEffect = () => {
1592 return this.cancel;
1593 };
1594 };
1595 function useAnimationFrame() {
1596 const timeout = useRefWithInit(AnimationFrame.create).current;
1597 useOnMount(timeout.disposeEffect);
1598 return timeout;
1599 }
1600
1601 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs
1602 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1603 const [transitionStatus, setTransitionStatus] = React10.useState(open && enableIdleState ? "idle" : void 0);
1604 const [mounted, setMounted] = React10.useState(open);
1605 if (open && !mounted) {
1606 setMounted(true);
1607 setTransitionStatus("starting");
1608 }
1609 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1610 setTransitionStatus("ending");
1611 }
1612 if (!open && !mounted && transitionStatus === "ending") {
1613 setTransitionStatus(void 0);
1614 }
1615 useIsoLayoutEffect(() => {
1616 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1617 const frame = AnimationFrame.request(() => {
1618 setTransitionStatus("ending");
1619 });
1620 return () => {
1621 AnimationFrame.cancel(frame);
1622 };
1623 }
1624 return void 0;
1625 }, [open, mounted, transitionStatus, deferEndingState]);
1626 useIsoLayoutEffect(() => {
1627 if (!open || enableIdleState) {
1628 return void 0;
1629 }
1630 const frame = AnimationFrame.request(() => {
1631 setTransitionStatus(void 0);
1632 });
1633 return () => {
1634 AnimationFrame.cancel(frame);
1635 };
1636 }, [enableIdleState, open]);
1637 useIsoLayoutEffect(() => {
1638 if (!open || !enableIdleState) {
1639 return void 0;
1640 }
1641 if (open && mounted && transitionStatus !== "idle") {
1642 setTransitionStatus("starting");
1643 }
1644 const frame = AnimationFrame.request(() => {
1645 setTransitionStatus("idle");
1646 });
1647 return () => {
1648 AnimationFrame.cancel(frame);
1649 };
1650 }, [enableIdleState, open, mounted, transitionStatus]);
1651 return {
1652 mounted,
1653 setMounted,
1654 transitionStatus
1655 };
1656 }
1657
1658 // node_modules/@base-ui/react/internals/stateAttributesMapping.mjs
1659 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1660 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1661 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1662 return TransitionStatusDataAttributes2;
1663 })({});
1664 var STARTING_HOOK = {
1665 [TransitionStatusDataAttributes.startingStyle]: ""
1666 };
1667 var ENDING_HOOK = {
1668 [TransitionStatusDataAttributes.endingStyle]: ""
1669 };
1670 var transitionStatusMapping = {
1671 transitionStatus(value) {
1672 if (value === "starting") {
1673 return STARTING_HOOK;
1674 }
1675 if (value === "ending") {
1676 return ENDING_HOOK;
1677 }
1678 return null;
1679 }
1680 };
1681
1682 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
1683 function hasWindow() {
1684 return typeof window !== "undefined";
1685 }
1686 function getNodeName(node) {
1687 if (isNode(node)) {
1688 return (node.nodeName || "").toLowerCase();
1689 }
1690 return "#document";
1691 }
1692 function getWindow(node) {
1693 var _node$ownerDocument;
1694 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1695 }
1696 function getDocumentElement(node) {
1697 var _ref;
1698 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1699 }
1700 function isNode(value) {
1701 if (!hasWindow()) {
1702 return false;
1703 }
1704 return value instanceof Node || value instanceof getWindow(value).Node;
1705 }
1706 function isElement(value) {
1707 if (!hasWindow()) {
1708 return false;
1709 }
1710 return value instanceof Element || value instanceof getWindow(value).Element;
1711 }
1712 function isHTMLElement(value) {
1713 if (!hasWindow()) {
1714 return false;
1715 }
1716 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1717 }
1718 function isShadowRoot(value) {
1719 if (!hasWindow() || typeof ShadowRoot === "undefined") {
1720 return false;
1721 }
1722 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1723 }
1724 function isOverflowElement(element) {
1725 const {
1726 overflow,
1727 overflowX,
1728 overflowY,
1729 display
1730 } = getComputedStyle2(element);
1731 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
1732 }
1733 function isTableElement(element) {
1734 return /^(table|td|th)$/.test(getNodeName(element));
1735 }
1736 function isTopLayer(element) {
1737 try {
1738 if (element.matches(":popover-open")) {
1739 return true;
1740 }
1741 } catch (_e) {
1742 }
1743 try {
1744 return element.matches(":modal");
1745 } catch (_e) {
1746 return false;
1747 }
1748 }
1749 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
1750 var containRe = /paint|layout|strict|content/;
1751 var isNotNone = (value) => !!value && value !== "none";
1752 var isWebKitValue;
1753 function isContainingBlock(elementOrCss) {
1754 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
1755 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 || "");
1756 }
1757 function getContainingBlock(element) {
1758 let currentNode = getParentNode(element);
1759 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1760 if (isContainingBlock(currentNode)) {
1761 return currentNode;
1762 } else if (isTopLayer(currentNode)) {
1763 return null;
1764 }
1765 currentNode = getParentNode(currentNode);
1766 }
1767 return null;
1768 }
1769 function isWebKit() {
1770 if (isWebKitValue == null) {
1771 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
1772 }
1773 return isWebKitValue;
1774 }
1775 function isLastTraversableNode(node) {
1776 return /^(html|body|#document)$/.test(getNodeName(node));
1777 }
1778 function getComputedStyle2(element) {
1779 return getWindow(element).getComputedStyle(element);
1780 }
1781 function getNodeScroll(element) {
1782 if (isElement(element)) {
1783 return {
1784 scrollLeft: element.scrollLeft,
1785 scrollTop: element.scrollTop
1786 };
1787 }
1788 return {
1789 scrollLeft: element.scrollX,
1790 scrollTop: element.scrollY
1791 };
1792 }
1793 function getParentNode(node) {
1794 if (getNodeName(node) === "html") {
1795 return node;
1796 }
1797 const result = (
1798 // Step into the shadow DOM of the parent of a slotted node.
1799 node.assignedSlot || // DOM Element detected.
1800 node.parentNode || // ShadowRoot detected.
1801 isShadowRoot(node) && node.host || // Fallback.
1802 getDocumentElement(node)
1803 );
1804 return isShadowRoot(result) ? result.host : result;
1805 }
1806 function getNearestOverflowAncestor(node) {
1807 const parentNode = getParentNode(node);
1808 if (isLastTraversableNode(parentNode)) {
1809 return node.ownerDocument ? node.ownerDocument.body : node.body;
1810 }
1811 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1812 return parentNode;
1813 }
1814 return getNearestOverflowAncestor(parentNode);
1815 }
1816 function getOverflowAncestors(node, list, traverseIframes) {
1817 var _node$ownerDocument2;
1818 if (list === void 0) {
1819 list = [];
1820 }
1821 if (traverseIframes === void 0) {
1822 traverseIframes = true;
1823 }
1824 const scrollableAncestor = getNearestOverflowAncestor(node);
1825 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1826 const win = getWindow(scrollableAncestor);
1827 if (isBody) {
1828 const frameElement = getFrameElement(win);
1829 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1830 } else {
1831 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1832 }
1833 }
1834 function getFrameElement(win) {
1835 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1836 }
1837
1838 // node_modules/@base-ui/utils/addEventListener.mjs
1839 function addEventListener(target, type, listener, options) {
1840 target.addEventListener(type, listener, options);
1841 return () => {
1842 target.removeEventListener(type, listener, options);
1843 };
1844 }
1845
1846 // node_modules/@base-ui/utils/useValueAsRef.mjs
1847 function useValueAsRef(value) {
1848 const latest = useRefWithInit(createLatestRef, value).current;
1849 latest.next = value;
1850 useIsoLayoutEffect(latest.effect);
1851 return latest;
1852 }
1853 function createLatestRef(value) {
1854 const latest = {
1855 current: value,
1856 next: value,
1857 effect: () => {
1858 latest.current = latest.next;
1859 }
1860 };
1861 return latest;
1862 }
1863
1864 // node_modules/@base-ui/utils/owner.mjs
1865 function ownerDocument(node) {
1866 return node?.ownerDocument || document;
1867 }
1868
1869 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs
1870 var React11 = __toESM(require_react(), 1);
1871
1872 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs
1873 var ReactDOM = __toESM(require_react_dom(), 1);
1874
1875 // node_modules/@base-ui/react/utils/resolveRef.mjs
1876 function resolveRef(maybeRef) {
1877 if (maybeRef == null) {
1878 return maybeRef;
1879 }
1880 return "current" in maybeRef ? maybeRef.current : maybeRef;
1881 }
1882
1883 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs
1884 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
1885 const frame = useAnimationFrame();
1886 return useStableCallback((fnToExecute, signal = null) => {
1887 frame.cancel();
1888 const element = resolveRef(elementOrRef);
1889 if (element == null) {
1890 return;
1891 }
1892 const resolvedElement = element;
1893 const done = () => {
1894 ReactDOM.flushSync(fnToExecute);
1895 };
1896 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
1897 fnToExecute();
1898 return;
1899 }
1900 function exec() {
1901 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
1902 if (!signal?.aborted) {
1903 done();
1904 }
1905 }).catch(() => {
1906 if (treatAbortedAsFinished) {
1907 if (!signal?.aborted) {
1908 done();
1909 }
1910 return;
1911 }
1912 const currentAnimations = resolvedElement.getAnimations();
1913 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
1914 exec();
1915 }
1916 });
1917 }
1918 if (waitForStartingStyleRemoved) {
1919 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
1920 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1921 frame.request(exec);
1922 return;
1923 }
1924 const attributeObserver = new MutationObserver(() => {
1925 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1926 attributeObserver.disconnect();
1927 exec();
1928 }
1929 });
1930 attributeObserver.observe(resolvedElement, {
1931 attributes: true,
1932 attributeFilter: [startingStyleAttribute]
1933 });
1934 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
1935 once: true
1936 });
1937 return;
1938 }
1939 frame.request(exec);
1940 });
1941 }
1942
1943 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs
1944 function useOpenChangeComplete(parameters) {
1945 const {
1946 enabled = true,
1947 open,
1948 ref,
1949 onComplete: onCompleteParam
1950 } = parameters;
1951 const onComplete = useStableCallback(onCompleteParam);
1952 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
1953 React11.useEffect(() => {
1954 if (!enabled) {
1955 return void 0;
1956 }
1957 const abortController = new AbortController();
1958 runOnceAnimationsFinish(onComplete, abortController.signal);
1959 return () => {
1960 abortController.abort();
1961 };
1962 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
1963 }
1964
1965 // node_modules/@base-ui/utils/useOnFirstRender.mjs
1966 var React12 = __toESM(require_react(), 1);
1967 function useOnFirstRender(fn) {
1968 const ref = React12.useRef(true);
1969 if (ref.current) {
1970 ref.current = false;
1971 fn();
1972 }
1973 }
1974
1975 // node_modules/@base-ui/utils/platform/parts.mjs
1976 var parts_exports = {};
1977 __export(parts_exports, {
1978 engine: () => engine_exports,
1979 env: () => env_exports,
1980 os: () => os_exports,
1981 screenReader: () => screen_reader_exports
1982 });
1983
1984 // node_modules/@base-ui/utils/platform/os.mjs
1985 var os_exports = {};
1986 __export(os_exports, {
1987 android: () => android,
1988 apple: () => apple,
1989 ios: () => ios,
1990 linux: () => linux,
1991 mac: () => mac,
1992 windows: () => windows
1993 });
1994
1995 // node_modules/@base-ui/utils/platform/shared.mjs
1996 function readRawData() {
1997 if (typeof navigator === "undefined") {
1998 return {
1999 userAgent: "",
2000 platform: "",
2001 maxTouchPoints: 0
2002 };
2003 }
2004 if (true) {
2005 const uaData = navigator.userAgentData;
2006 if (uaData && Array.isArray(uaData.brands)) {
2007 return {
2008 userAgent: uaData.brands.map(({
2009 brand,
2010 version: version2
2011 }) => `${brand}/${version2}`).join(" "),
2012 platform: uaData.platform ?? navigator.platform ?? "",
2013 maxTouchPoints: navigator.maxTouchPoints ?? 0
2014 };
2015 }
2016 }
2017 return {
2018 userAgent: navigator.userAgent,
2019 platform: navigator.platform ?? "",
2020 maxTouchPoints: navigator.maxTouchPoints ?? 0
2021 };
2022 }
2023 var {
2024 userAgent,
2025 platform,
2026 maxTouchPoints
2027 } = readRawData();
2028 var lowerUserAgent = userAgent.toLowerCase();
2029 var lowerPlatform = platform.toLowerCase();
2030
2031 // node_modules/@base-ui/utils/platform/os.mjs
2032 var ios = /^i(os$|p)/.test(lowerPlatform) || lowerPlatform === "macintel" && maxTouchPoints > 1;
2033 var ANDROID_STRING = "android";
2034 var android = lowerPlatform === ANDROID_STRING || lowerUserAgent.includes(ANDROID_STRING);
2035 var mac = !ios && lowerPlatform.startsWith("mac");
2036 var windows = lowerPlatform.startsWith("win");
2037 var linux = !android && /^(linux|chrome os)/.test(lowerPlatform);
2038 var apple = mac || ios;
2039
2040 // node_modules/@base-ui/utils/platform/engine.mjs
2041 var engine_exports = {};
2042 __export(engine_exports, {
2043 blink: () => blink,
2044 gecko: () => gecko,
2045 webkit: () => webkit
2046 });
2047 var webkit = typeof CSS !== "undefined" && !!CSS.supports?.("-webkit-backdrop-filter:none");
2048 var gecko = !webkit && lowerUserAgent.includes("firefox");
2049 var blink = !webkit && lowerUserAgent.includes("chrom");
2050
2051 // node_modules/@base-ui/utils/platform/screen-reader.mjs
2052 var screen_reader_exports = {};
2053 __export(screen_reader_exports, {
2054 voiceOver: () => voiceOver
2055 });
2056 var voiceOver = apple;
2057
2058 // node_modules/@base-ui/utils/platform/env.mjs
2059 var env_exports = {};
2060 __export(env_exports, {
2061 jsdom: () => jsdom
2062 });
2063 var jsdom = /jsdom|happydom/.test(lowerUserAgent);
2064
2065 // node_modules/@base-ui/utils/useTimeout.mjs
2066 var EMPTY3 = 0;
2067 var Timeout = class _Timeout {
2068 static create() {
2069 return new _Timeout();
2070 }
2071 currentId = EMPTY3;
2072 /**
2073 * Executes `fn` after `delay`, clearing any previously scheduled call.
2074 */
2075 start(delay, fn) {
2076 this.clear();
2077 this.currentId = setTimeout(() => {
2078 this.currentId = EMPTY3;
2079 fn();
2080 }, delay);
2081 }
2082 isStarted() {
2083 return this.currentId !== EMPTY3;
2084 }
2085 clear = () => {
2086 if (this.currentId !== EMPTY3) {
2087 clearTimeout(this.currentId);
2088 this.currentId = EMPTY3;
2089 }
2090 };
2091 disposeEffect = () => {
2092 return this.clear;
2093 };
2094 };
2095 function useTimeout() {
2096 const timeout = useRefWithInit(Timeout.create).current;
2097 useOnMount(timeout.disposeEffect);
2098 return timeout;
2099 }
2100
2101 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs
2102 var React13 = __toESM(require_react(), 1);
2103
2104 // node_modules/@base-ui/react/floating-ui-react/utils/event.mjs
2105 function isReactEvent(event) {
2106 return "nativeEvent" in event;
2107 }
2108 function isMouseLikePointerType(pointerType, strict) {
2109 const values = ["mouse", "pen"];
2110 if (!strict) {
2111 values.push("", void 0);
2112 }
2113 return values.includes(pointerType);
2114 }
2115 function isClickLikeEvent(event) {
2116 const type = event.type;
2117 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2118 }
2119
2120 // node_modules/@base-ui/react/floating-ui-react/utils/constants.mjs
2121 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
2122 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
2123
2124 // node_modules/@base-ui/react/internals/shadowDom.mjs
2125 function activeElement(doc) {
2126 let element = doc.activeElement;
2127 while (element?.shadowRoot?.activeElement != null) {
2128 element = element.shadowRoot.activeElement;
2129 }
2130 return element;
2131 }
2132 function contains(parent, child) {
2133 if (!parent || !child) {
2134 return false;
2135 }
2136 const rootNode = child.getRootNode?.();
2137 if (parent.contains(child)) {
2138 return true;
2139 }
2140 if (rootNode && isShadowRoot(rootNode)) {
2141 let next = child;
2142 while (next) {
2143 if (parent === next) {
2144 return true;
2145 }
2146 next = next.parentNode || next.host;
2147 }
2148 }
2149 return false;
2150 }
2151 function getTarget(event) {
2152 if ("composedPath" in event) {
2153 return event.composedPath()[0];
2154 }
2155 return event.target;
2156 }
2157
2158 // node_modules/@base-ui/react/floating-ui-react/utils/element.mjs
2159 function isTargetInsideEnabledTrigger(target, triggerElements) {
2160 if (!isElement(target)) {
2161 return false;
2162 }
2163 const targetElement = target;
2164 if (triggerElements.hasElement(targetElement)) {
2165 return !targetElement.hasAttribute("data-trigger-disabled");
2166 }
2167 for (const [, trigger] of triggerElements.entries()) {
2168 if (contains(trigger, targetElement)) {
2169 return !trigger.hasAttribute("data-trigger-disabled");
2170 }
2171 }
2172 return false;
2173 }
2174 function isEventTargetWithin(event, node) {
2175 if (node == null) {
2176 return false;
2177 }
2178 if ("composedPath" in event) {
2179 return event.composedPath().includes(node);
2180 }
2181 const eventAgain = event;
2182 return eventAgain.target != null && node.contains(eventAgain.target);
2183 }
2184 function isRootElement(element) {
2185 return element.matches("html,body");
2186 }
2187 function isTypeableElement(element) {
2188 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
2189 }
2190 function isInteractiveElement(element) {
2191 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
2192 }
2193 function matchesFocusVisible(element) {
2194 if (!element || parts_exports.env.jsdom) {
2195 return true;
2196 }
2197 try {
2198 return element.matches(":focus-visible");
2199 } catch (_e) {
2200 return true;
2201 }
2202 }
2203
2204 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverShared.mjs
2205 function resolveValue(value, pointerType) {
2206 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
2207 return 0;
2208 }
2209 if (typeof value === "function") {
2210 return value();
2211 }
2212 return value;
2213 }
2214 function getDelay(value, prop, pointerType) {
2215 const result = resolveValue(value, pointerType);
2216 if (typeof result === "number") {
2217 return result;
2218 }
2219 return result?.[prop];
2220 }
2221 function getRestMs(value) {
2222 if (typeof value === "function") {
2223 return value();
2224 }
2225 return value;
2226 }
2227 function isClickLikeOpenEvent(openEventType, interactedInside) {
2228 return interactedInside || openEventType === "click" || openEventType === "mousedown";
2229 }
2230 function isHoverOpenEvent(openEventType) {
2231 return openEventType?.includes("mouse") && openEventType !== "mousedown";
2232 }
2233
2234 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs
2235 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
2236 var FloatingDelayGroupContext = /* @__PURE__ */ React13.createContext({
2237 hasProvider: false,
2238 timeoutMs: 0,
2239 delayRef: {
2240 current: 0
2241 },
2242 initialDelayRef: {
2243 current: 0
2244 },
2245 timeout: new Timeout(),
2246 currentIdRef: {
2247 current: null
2248 },
2249 currentContextRef: {
2250 current: null
2251 }
2252 });
2253 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
2254 function resetDelayRef(delayRef, initialDelayRef) {
2255 delayRef.current = initialDelayRef.current;
2256 }
2257 function FloatingDelayGroup(props) {
2258 const {
2259 children,
2260 delay,
2261 timeoutMs = 0
2262 } = props;
2263 const delayRef = React13.useRef(delay);
2264 const initialDelayRef = React13.useRef(delay);
2265 const currentIdRef = React13.useRef(null);
2266 const currentContextRef = React13.useRef(null);
2267 const timeout = useTimeout();
2268 useIsoLayoutEffect(() => {
2269 initialDelayRef.current = delay;
2270 if (!currentIdRef.current) {
2271 delayRef.current = delay;
2272 return;
2273 }
2274 delayRef.current = {
2275 open: getDelay(delayRef.current, "open"),
2276 close: getDelay(delay, "close")
2277 };
2278 }, [delay, currentIdRef, delayRef, initialDelayRef]);
2279 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
2280 value: React13.useMemo(() => ({
2281 hasProvider: true,
2282 delayRef,
2283 initialDelayRef,
2284 currentIdRef,
2285 timeoutMs,
2286 currentContextRef,
2287 timeout
2288 }), [timeoutMs, timeout]),
2289 children
2290 });
2291 }
2292 function useDelayGroup(context, options = {
2293 open: false
2294 }) {
2295 const {
2296 open
2297 } = options;
2298 const store = "rootStore" in context ? context.rootStore : context;
2299 const floatingId = store.useState("floatingId");
2300 const groupContext = React13.useContext(FloatingDelayGroupContext);
2301 const {
2302 currentIdRef,
2303 delayRef,
2304 timeoutMs,
2305 initialDelayRef,
2306 currentContextRef,
2307 hasProvider,
2308 timeout
2309 } = groupContext;
2310 const [isInstantPhase, setIsInstantPhase] = React13.useState(false);
2311 const openRef = React13.useRef(open);
2312 const isUnmountedRef = React13.useRef(false);
2313 useIsoLayoutEffect(() => {
2314 openRef.current = open;
2315 }, [open]);
2316 useIsoLayoutEffect(() => {
2317 return () => {
2318 isUnmountedRef.current = true;
2319 };
2320 }, []);
2321 useIsoLayoutEffect(() => {
2322 function unset() {
2323 if (!isUnmountedRef.current) {
2324 setIsInstantPhase(false);
2325 }
2326 currentContextRef.current?.setIsInstantPhase(false);
2327 currentIdRef.current = null;
2328 currentContextRef.current = null;
2329 delayRef.current = initialDelayRef.current;
2330 timeout.clear();
2331 }
2332 if (!currentIdRef.current) {
2333 return void 0;
2334 }
2335 if (!open && currentIdRef.current === floatingId) {
2336 setIsInstantPhase(false);
2337 if (timeoutMs) {
2338 const closingId = floatingId;
2339 timeout.start(timeoutMs, () => {
2340 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
2341 return;
2342 }
2343 unset();
2344 });
2345 return () => {
2346 if (openRef.current || currentIdRef.current !== closingId) {
2347 timeout.clear();
2348 }
2349 };
2350 }
2351 unset();
2352 }
2353 return void 0;
2354 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
2355 useIsoLayoutEffect(() => {
2356 if (!open) {
2357 return;
2358 }
2359 const prevContext = currentContextRef.current;
2360 const prevId = currentIdRef.current;
2361 timeout.clear();
2362 currentContextRef.current = {
2363 onOpenChange: store.setOpen,
2364 setIsInstantPhase
2365 };
2366 currentIdRef.current = floatingId;
2367 delayRef.current = {
2368 open: 0,
2369 close: getDelay(initialDelayRef.current, "close")
2370 };
2371 if (prevId !== null && prevId !== floatingId) {
2372 setIsInstantPhase(true);
2373 prevContext?.setIsInstantPhase(true);
2374 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
2375 } else {
2376 setIsInstantPhase(false);
2377 prevContext?.setIsInstantPhase(false);
2378 }
2379 }, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
2380 useIsoLayoutEffect(() => {
2381 return () => {
2382 if (currentIdRef.current === floatingId) {
2383 currentContextRef.current = null;
2384 if (!openRef.current) {
2385 return;
2386 }
2387 currentIdRef.current = null;
2388 resetDelayRef(delayRef, initialDelayRef);
2389 timeout.clear();
2390 }
2391 };
2392 }, [currentContextRef, currentIdRef, delayRef, floatingId, initialDelayRef, timeout]);
2393 return React13.useMemo(() => ({
2394 hasProvider,
2395 delayRef,
2396 isInstantPhase
2397 }), [hasProvider, delayRef, isInstantPhase]);
2398 }
2399
2400 // node_modules/@base-ui/utils/mergeCleanups.mjs
2401 function mergeCleanups(...cleanups) {
2402 return () => {
2403 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
2404 const cleanup = cleanups[i2];
2405 if (cleanup) {
2406 cleanup();
2407 }
2408 }
2409 };
2410 }
2411
2412 // node_modules/@base-ui/react/utils/FocusGuard.mjs
2413 var React14 = __toESM(require_react(), 1);
2414
2415 // node_modules/@base-ui/utils/visuallyHidden.mjs
2416 var visuallyHiddenBase = {
2417 clipPath: "inset(50%)",
2418 overflow: "hidden",
2419 whiteSpace: "nowrap",
2420 border: 0,
2421 padding: 0,
2422 width: 1,
2423 height: 1,
2424 margin: -1
2425 };
2426 var visuallyHidden = {
2427 ...visuallyHiddenBase,
2428 position: "fixed",
2429 top: 0,
2430 left: 0
2431 };
2432 var visuallyHiddenInput = {
2433 ...visuallyHiddenBase,
2434 position: "absolute"
2435 };
2436
2437 // node_modules/@base-ui/react/utils/FocusGuard.mjs
2438 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
2439 var FocusGuard = /* @__PURE__ */ React14.forwardRef(function FocusGuard2(props, ref) {
2440 const [role, setRole] = React14.useState();
2441 useIsoLayoutEffect(() => {
2442 if (parts_exports.screenReader.voiceOver && parts_exports.engine.webkit) {
2443 setRole("button");
2444 }
2445 }, []);
2446 const restProps = {
2447 tabIndex: 0,
2448 // Role is only for VoiceOver
2449 role
2450 };
2451 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
2452 ...props,
2453 ref,
2454 style: visuallyHidden,
2455 "aria-hidden": role ? void 0 : true,
2456 ...restProps,
2457 "data-base-ui-focus-guard": ""
2458 });
2459 });
2460 if (true) FocusGuard.displayName = "FocusGuard";
2461
2462 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2463 var sides = ["top", "right", "bottom", "left"];
2464 var min = Math.min;
2465 var max = Math.max;
2466 var round = Math.round;
2467 var floor = Math.floor;
2468 var createCoords = (v2) => ({
2469 x: v2,
2470 y: v2
2471 });
2472 var oppositeSideMap = {
2473 left: "right",
2474 right: "left",
2475 bottom: "top",
2476 top: "bottom"
2477 };
2478 function clamp(start, value, end) {
2479 return max(start, min(value, end));
2480 }
2481 function evaluate(value, param) {
2482 return typeof value === "function" ? value(param) : value;
2483 }
2484 function getSide(placement) {
2485 return placement.split("-")[0];
2486 }
2487 function getAlignment(placement) {
2488 return placement.split("-")[1];
2489 }
2490 function getOppositeAxis(axis) {
2491 return axis === "x" ? "y" : "x";
2492 }
2493 function getAxisLength(axis) {
2494 return axis === "y" ? "height" : "width";
2495 }
2496 function getSideAxis(placement) {
2497 const firstChar = placement[0];
2498 return firstChar === "t" || firstChar === "b" ? "y" : "x";
2499 }
2500 function getAlignmentAxis(placement) {
2501 return getOppositeAxis(getSideAxis(placement));
2502 }
2503 function getAlignmentSides(placement, rects, rtl) {
2504 if (rtl === void 0) {
2505 rtl = false;
2506 }
2507 const alignment = getAlignment(placement);
2508 const alignmentAxis = getAlignmentAxis(placement);
2509 const length = getAxisLength(alignmentAxis);
2510 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
2511 if (rects.reference[length] > rects.floating[length]) {
2512 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
2513 }
2514 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
2515 }
2516 function getExpandedPlacements(placement) {
2517 const oppositePlacement = getOppositePlacement(placement);
2518 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
2519 }
2520 function getOppositeAlignmentPlacement(placement) {
2521 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
2522 }
2523 var lrPlacement = ["left", "right"];
2524 var rlPlacement = ["right", "left"];
2525 var tbPlacement = ["top", "bottom"];
2526 var btPlacement = ["bottom", "top"];
2527 function getSideList(side, isStart, rtl) {
2528 switch (side) {
2529 case "top":
2530 case "bottom":
2531 if (rtl) return isStart ? rlPlacement : lrPlacement;
2532 return isStart ? lrPlacement : rlPlacement;
2533 case "left":
2534 case "right":
2535 return isStart ? tbPlacement : btPlacement;
2536 default:
2537 return [];
2538 }
2539 }
2540 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
2541 const alignment = getAlignment(placement);
2542 let list = getSideList(getSide(placement), direction === "start", rtl);
2543 if (alignment) {
2544 list = list.map((side) => side + "-" + alignment);
2545 if (flipAlignment) {
2546 list = list.concat(list.map(getOppositeAlignmentPlacement));
2547 }
2548 }
2549 return list;
2550 }
2551 function getOppositePlacement(placement) {
2552 const side = getSide(placement);
2553 return oppositeSideMap[side] + placement.slice(side.length);
2554 }
2555 function expandPaddingObject(padding) {
2556 return {
2557 top: 0,
2558 right: 0,
2559 bottom: 0,
2560 left: 0,
2561 ...padding
2562 };
2563 }
2564 function getPaddingObject(padding) {
2565 return typeof padding !== "number" ? expandPaddingObject(padding) : {
2566 top: padding,
2567 right: padding,
2568 bottom: padding,
2569 left: padding
2570 };
2571 }
2572 function rectToClientRect(rect) {
2573 const {
2574 x: x2,
2575 y: y2,
2576 width,
2577 height
2578 } = rect;
2579 return {
2580 width,
2581 height,
2582 top: y2,
2583 left: x2,
2584 right: x2 + width,
2585 bottom: y2 + height,
2586 x: x2,
2587 y: y2
2588 };
2589 }
2590
2591 // node_modules/@base-ui/react/floating-ui-react/utils/composite.mjs
2592 function isHiddenByStyles(styles) {
2593 return styles.visibility === "hidden" || styles.visibility === "collapse";
2594 }
2595 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
2596 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
2597 return false;
2598 }
2599 if (typeof element.checkVisibility === "function") {
2600 return element.checkVisibility();
2601 }
2602 return styles.display !== "none" && styles.display !== "contents";
2603 }
2604
2605 // node_modules/@base-ui/react/floating-ui-react/utils/tabbable.mjs
2606 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
2607 function getParentElement(element) {
2608 const assignedSlot = element.assignedSlot;
2609 if (assignedSlot) {
2610 return assignedSlot;
2611 }
2612 if (element.parentElement) {
2613 return element.parentElement;
2614 }
2615 const rootNode = element.getRootNode();
2616 return isShadowRoot(rootNode) ? rootNode.host : null;
2617 }
2618 function getDetailsSummary(details) {
2619 for (const child of Array.from(details.children)) {
2620 if (getNodeName(child) === "summary") {
2621 return child;
2622 }
2623 }
2624 return null;
2625 }
2626 function isWithinOpenDetailsSummary(element, details) {
2627 const summary = getDetailsSummary(details);
2628 return !!summary && (element === summary || contains(summary, element));
2629 }
2630 function isFocusableCandidate(element) {
2631 const nodeName = element ? getNodeName(element) : "";
2632 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");
2633 }
2634 function isFocusableElement(element) {
2635 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
2636 return false;
2637 }
2638 for (let current = element; current; current = getParentElement(current)) {
2639 const isAncestor = current !== element;
2640 const isSlot = getNodeName(current) === "slot";
2641 if (current.hasAttribute("inert")) {
2642 return false;
2643 }
2644 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
2645 return false;
2646 }
2647 }
2648 return true;
2649 }
2650 function isVisibleInTabbableTree(element, isAncestor) {
2651 const styles = getComputedStyle2(element);
2652 if (!isAncestor) {
2653 return isElementVisible(element, styles);
2654 }
2655 return styles.display !== "none";
2656 }
2657 function getTabIndex(element) {
2658 const tabIndex = element.tabIndex;
2659 if (tabIndex < 0) {
2660 const nodeName = getNodeName(element);
2661 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
2662 return 0;
2663 }
2664 }
2665 return tabIndex;
2666 }
2667 function getNamedRadioInput(element) {
2668 if (getNodeName(element) !== "input") {
2669 return null;
2670 }
2671 const input = element;
2672 return input.type === "radio" && input.name !== "" ? input : null;
2673 }
2674 function isTabbableRadio(element, candidates) {
2675 const input = getNamedRadioInput(element);
2676 if (!input) {
2677 return true;
2678 }
2679 const checkedRadio = candidates.find((candidate) => {
2680 const radio = getNamedRadioInput(candidate);
2681 return radio?.name === input.name && radio.form === input.form && radio.checked;
2682 });
2683 if (checkedRadio) {
2684 return checkedRadio === input;
2685 }
2686 return candidates.find((candidate) => {
2687 const radio = getNamedRadioInput(candidate);
2688 return radio?.name === input.name && radio.form === input.form;
2689 }) === input;
2690 }
2691 function getComposedChildren(container) {
2692 if (isHTMLElement(container) && getNodeName(container) === "slot") {
2693 const assignedElements = container.assignedElements({
2694 flatten: true
2695 });
2696 if (assignedElements.length > 0) {
2697 return assignedElements;
2698 }
2699 }
2700 if (isHTMLElement(container) && container.shadowRoot) {
2701 return Array.from(container.shadowRoot.children);
2702 }
2703 return Array.from(container.children);
2704 }
2705 function appendCandidates(container, list) {
2706 getComposedChildren(container).forEach((child) => {
2707 if (isFocusableCandidate(child)) {
2708 list.push(child);
2709 }
2710 appendCandidates(child, list);
2711 });
2712 }
2713 function appendMatchingElements(container, selector2, list) {
2714 getComposedChildren(container).forEach((child) => {
2715 if (isHTMLElement(child) && child.matches(selector2)) {
2716 list.push(child);
2717 }
2718 appendMatchingElements(child, selector2, list);
2719 });
2720 }
2721 function focusable(container) {
2722 const candidates = [];
2723 appendCandidates(container, candidates);
2724 return candidates.filter(isFocusableElement);
2725 }
2726 function tabbable(container) {
2727 const candidates = focusable(container);
2728 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
2729 }
2730 function getTabbableIn(container, dir) {
2731 const list = tabbable(container);
2732 const len = list.length;
2733 if (len === 0) {
2734 return void 0;
2735 }
2736 const active = activeElement(ownerDocument(container));
2737 const index2 = list.indexOf(active);
2738 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
2739 return list[nextIndex];
2740 }
2741 function getNextTabbable(referenceElement) {
2742 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
2743 }
2744 function getPreviousTabbable(referenceElement) {
2745 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
2746 }
2747 function isOutsideEvent(event, container) {
2748 const containerElement = container || event.currentTarget;
2749 const relatedTarget = event.relatedTarget;
2750 return !relatedTarget || !contains(containerElement, relatedTarget);
2751 }
2752 function disableFocusInside(container) {
2753 const tabbableElements = tabbable(container);
2754 tabbableElements.forEach((element) => {
2755 element.dataset.tabindex = element.getAttribute("tabindex") || "";
2756 element.setAttribute("tabindex", "-1");
2757 });
2758 }
2759 function enableFocusInside(container) {
2760 const elements = [];
2761 appendMatchingElements(container, "[data-tabindex]", elements);
2762 elements.forEach((element) => {
2763 const tabindex = element.dataset.tabindex;
2764 delete element.dataset.tabindex;
2765 if (tabindex) {
2766 element.setAttribute("tabindex", tabindex);
2767 } else {
2768 element.removeAttribute("tabindex");
2769 }
2770 });
2771 }
2772
2773 // node_modules/@base-ui/react/floating-ui-react/utils/nodes.mjs
2774 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
2775 const directChildren = nodes.filter((node) => node.parentId === id);
2776 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
2777 }
2778
2779 // node_modules/@base-ui/react/floating-ui-react/utils/createAttribute.mjs
2780 function createAttribute(name) {
2781 return `data-base-ui-${name}`;
2782 }
2783
2784 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs
2785 var React15 = __toESM(require_react(), 1);
2786 var ReactDOM2 = __toESM(require_react_dom(), 1);
2787
2788 // node_modules/@base-ui/react/internals/constants.mjs
2789 var DISABLED_TRANSITIONS_STYLE = {
2790 style: {
2791 transition: "none"
2792 }
2793 };
2794 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
2795 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
2796 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
2797 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
2798 var POPUP_COLLISION_AVOIDANCE = {
2799 fallbackAxisSide: "end"
2800 };
2801 var ownerVisuallyHidden = {
2802 clipPath: "inset(50%)",
2803 position: "fixed",
2804 top: 0,
2805 left: 0
2806 };
2807
2808 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs
2809 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
2810 var PortalContext = /* @__PURE__ */ React15.createContext(null);
2811 if (true) PortalContext.displayName = "PortalContext";
2812 var usePortalContext = () => React15.useContext(PortalContext);
2813 var attr = createAttribute("portal");
2814 function useFloatingPortalNode(props = {}) {
2815 const {
2816 ref,
2817 container: containerProp,
2818 componentProps = EMPTY_OBJECT,
2819 elementProps
2820 } = props;
2821 const uniqueId = useId();
2822 const portalContext = usePortalContext();
2823 const parentPortalNode = portalContext?.portalNode;
2824 const [containerElement, setContainerElement] = React15.useState(null);
2825 const [portalNode, setPortalNode] = React15.useState(null);
2826 const setPortalNodeRef = useStableCallback((node) => {
2827 if (node !== null) {
2828 setPortalNode(node);
2829 }
2830 });
2831 const containerRef = React15.useRef(null);
2832 useIsoLayoutEffect(() => {
2833 if (containerProp === null) {
2834 if (containerRef.current) {
2835 containerRef.current = null;
2836 setPortalNode(null);
2837 setContainerElement(null);
2838 }
2839 return;
2840 }
2841 if (uniqueId == null) {
2842 return;
2843 }
2844 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
2845 if (resolvedContainer == null) {
2846 if (containerRef.current) {
2847 containerRef.current = null;
2848 setPortalNode(null);
2849 setContainerElement(null);
2850 }
2851 return;
2852 }
2853 if (containerRef.current !== resolvedContainer) {
2854 containerRef.current = resolvedContainer;
2855 setPortalNode(null);
2856 setContainerElement(resolvedContainer);
2857 }
2858 }, [containerProp, parentPortalNode, uniqueId]);
2859 const portalElement = useRenderElement("div", componentProps, {
2860 ref: [ref, setPortalNodeRef],
2861 props: [{
2862 id: uniqueId,
2863 [attr]: ""
2864 }, elementProps]
2865 });
2866 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
2867 return {
2868 portalNode,
2869 portalSubtree
2870 };
2871 }
2872 var FloatingPortal = /* @__PURE__ */ React15.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
2873 const {
2874 render: render4,
2875 className,
2876 style,
2877 children,
2878 container,
2879 renderGuards,
2880 ...elementProps
2881 } = componentProps;
2882 const {
2883 portalNode,
2884 portalSubtree
2885 } = useFloatingPortalNode({
2886 container,
2887 ref: forwardedRef,
2888 componentProps,
2889 elementProps
2890 });
2891 const beforeOutsideRef = React15.useRef(null);
2892 const afterOutsideRef = React15.useRef(null);
2893 const beforeInsideRef = React15.useRef(null);
2894 const afterInsideRef = React15.useRef(null);
2895 const [focusManagerState, setFocusManagerState] = React15.useState(null);
2896 const focusInsideDisabledRef = React15.useRef(false);
2897 const modal = focusManagerState?.modal;
2898 const open = focusManagerState?.open;
2899 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
2900 React15.useEffect(() => {
2901 if (!portalNode || modal) {
2902 return void 0;
2903 }
2904 function onFocus(event) {
2905 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
2906 if (event.type === "focusin") {
2907 if (focusInsideDisabledRef.current) {
2908 enableFocusInside(portalNode);
2909 focusInsideDisabledRef.current = false;
2910 }
2911 } else {
2912 disableFocusInside(portalNode);
2913 focusInsideDisabledRef.current = true;
2914 }
2915 }
2916 }
2917 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
2918 }, [portalNode, modal]);
2919 useIsoLayoutEffect(() => {
2920 if (!portalNode || open !== true || !focusInsideDisabledRef.current) {
2921 return;
2922 }
2923 enableFocusInside(portalNode);
2924 focusInsideDisabledRef.current = false;
2925 }, [open, portalNode]);
2926 const portalContextValue = React15.useMemo(() => ({
2927 beforeOutsideRef,
2928 afterOutsideRef,
2929 beforeInsideRef,
2930 afterInsideRef,
2931 portalNode,
2932 setFocusManagerState
2933 }), [portalNode]);
2934 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React15.Fragment, {
2935 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
2936 value: portalContextValue,
2937 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
2938 "data-type": "outside",
2939 ref: beforeOutsideRef,
2940 onFocus: (event) => {
2941 if (isOutsideEvent(event, portalNode)) {
2942 beforeInsideRef.current?.focus();
2943 } else {
2944 const domReference = focusManagerState ? focusManagerState.domReference : null;
2945 const prevTabbable = getPreviousTabbable(domReference);
2946 prevTabbable?.focus();
2947 }
2948 }
2949 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
2950 "aria-owns": portalNode.id,
2951 style: ownerVisuallyHidden
2952 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
2953 "data-type": "outside",
2954 ref: afterOutsideRef,
2955 onFocus: (event) => {
2956 if (isOutsideEvent(event, portalNode)) {
2957 afterInsideRef.current?.focus();
2958 } else {
2959 const domReference = focusManagerState ? focusManagerState.domReference : null;
2960 const nextTabbable = getNextTabbable(domReference);
2961 nextTabbable?.focus();
2962 if (focusManagerState?.closeOnFocusOut) {
2963 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
2964 }
2965 }
2966 }
2967 })]
2968 })]
2969 });
2970 });
2971 if (true) FloatingPortal.displayName = "FloatingPortal";
2972
2973 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs
2974 var React16 = __toESM(require_react(), 1);
2975
2976 // node_modules/@base-ui/react/floating-ui-react/utils/createEventEmitter.mjs
2977 function createEventEmitter() {
2978 const map = /* @__PURE__ */ new Map();
2979 return {
2980 emit(event, data) {
2981 map.get(event)?.forEach((listener) => listener(data));
2982 },
2983 on(event, listener) {
2984 if (!map.has(event)) {
2985 map.set(event, /* @__PURE__ */ new Set());
2986 }
2987 map.get(event).add(listener);
2988 },
2989 off(event, listener) {
2990 map.get(event)?.delete(listener);
2991 }
2992 };
2993 }
2994
2995 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs
2996 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
2997 var FloatingNodeContext = /* @__PURE__ */ React16.createContext(null);
2998 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
2999 var FloatingTreeContext = /* @__PURE__ */ React16.createContext(null);
3000 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3001 var useFloatingParentNodeId = () => React16.useContext(FloatingNodeContext)?.id || null;
3002 var useFloatingTree = (externalTree) => {
3003 const contextTree = React16.useContext(FloatingTreeContext);
3004 return externalTree ?? contextTree;
3005 };
3006
3007 // node_modules/@base-ui/react/floating-ui-react/hooks/useClientPoint.mjs
3008 var React17 = __toESM(require_react(), 1);
3009 function createVirtualElement(domElement, data) {
3010 let offsetX = null;
3011 let offsetY = null;
3012 let isAutoUpdateEvent = false;
3013 return {
3014 contextElement: domElement || void 0,
3015 getBoundingClientRect() {
3016 const domRect = domElement?.getBoundingClientRect() || {
3017 width: 0,
3018 height: 0,
3019 x: 0,
3020 y: 0
3021 };
3022 const isXAxis = data.axis === "x" || data.axis === "both";
3023 const isYAxis = data.axis === "y" || data.axis === "both";
3024 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
3025 let width = domRect.width;
3026 let height = domRect.height;
3027 let x2 = domRect.x;
3028 let y2 = domRect.y;
3029 if (offsetX == null && data.x && isXAxis) {
3030 offsetX = domRect.x - data.x;
3031 }
3032 if (offsetY == null && data.y && isYAxis) {
3033 offsetY = domRect.y - data.y;
3034 }
3035 x2 -= offsetX || 0;
3036 y2 -= offsetY || 0;
3037 width = 0;
3038 height = 0;
3039 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
3040 width = data.axis === "y" ? domRect.width : 0;
3041 height = data.axis === "x" ? domRect.height : 0;
3042 x2 = isXAxis && data.x != null ? data.x : x2;
3043 y2 = isYAxis && data.y != null ? data.y : y2;
3044 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
3045 height = data.axis === "x" ? domRect.height : height;
3046 width = data.axis === "y" ? domRect.width : width;
3047 }
3048 isAutoUpdateEvent = true;
3049 return {
3050 width,
3051 height,
3052 x: x2,
3053 y: y2,
3054 top: y2,
3055 right: x2 + width,
3056 bottom: y2 + height,
3057 left: x2
3058 };
3059 }
3060 };
3061 }
3062 function isMouseBasedEvent(event) {
3063 return event != null && event.clientX != null;
3064 }
3065 function useClientPoint(context, props = {}) {
3066 const {
3067 enabled = true,
3068 axis = "both"
3069 } = props;
3070 const store = "rootStore" in context ? context.rootStore : context;
3071 const open = store.useState("open");
3072 const floating = store.useState("floatingElement");
3073 const domReference = store.useState("domReferenceElement");
3074 const dataRef = store.context.dataRef;
3075 const initialRef = React17.useRef(false);
3076 const cleanupListenerRef = React17.useRef(null);
3077 const [pointerType, setPointerType] = React17.useState();
3078 const [reactive, setReactive] = React17.useState([]);
3079 const resetReference = useStableCallback((reference2) => {
3080 store.set("positionReference", reference2);
3081 });
3082 const setReference = useStableCallback((newX, newY, referenceElement) => {
3083 if (initialRef.current) {
3084 return;
3085 }
3086 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3087 return;
3088 }
3089 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3090 x: newX,
3091 y: newY,
3092 axis,
3093 dataRef,
3094 pointerType
3095 }));
3096 });
3097 const handleReferenceEnterOrMove = useStableCallback((event) => {
3098 if (!open) {
3099 setReference(event.clientX, event.clientY, event.currentTarget);
3100 } else if (!cleanupListenerRef.current) {
3101 setReference(event.clientX, event.clientY, event.currentTarget);
3102 setReactive([]);
3103 }
3104 });
3105 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
3106 React17.useEffect(() => {
3107 if (!enabled) {
3108 resetReference(domReference);
3109 return void 0;
3110 }
3111 if (!openCheck) {
3112 return void 0;
3113 }
3114 function cleanupListener() {
3115 cleanupListenerRef.current?.();
3116 cleanupListenerRef.current = null;
3117 }
3118 const win = getWindow(floating);
3119 function handleMouseMove(event) {
3120 const target = getTarget(event);
3121 if (!contains(floating, target)) {
3122 setReference(event.clientX, event.clientY);
3123 } else {
3124 cleanupListener();
3125 }
3126 }
3127 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3128 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3129 } else {
3130 resetReference(domReference);
3131 }
3132 return cleanupListener;
3133 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference, resetReference, reactive]);
3134 React17.useEffect(() => () => {
3135 store.set("positionReference", null);
3136 }, [store]);
3137 React17.useEffect(() => {
3138 if (enabled && !floating) {
3139 initialRef.current = false;
3140 }
3141 }, [enabled, floating]);
3142 React17.useEffect(() => {
3143 if (!enabled && open) {
3144 initialRef.current = true;
3145 }
3146 }, [enabled, open]);
3147 const reference = React17.useMemo(() => {
3148 function setPointerTypeRef(event) {
3149 setPointerType(event.pointerType);
3150 }
3151 return {
3152 onPointerDown: setPointerTypeRef,
3153 onPointerEnter: setPointerTypeRef,
3154 onMouseMove: handleReferenceEnterOrMove,
3155 onMouseEnter: handleReferenceEnterOrMove
3156 };
3157 }, [handleReferenceEnterOrMove]);
3158 return React17.useMemo(() => enabled ? {
3159 reference,
3160 trigger: reference
3161 } : {}, [enabled, reference]);
3162 }
3163
3164 // node_modules/@base-ui/react/floating-ui-react/hooks/useDismiss.mjs
3165 var React18 = __toESM(require_react(), 1);
3166 function alwaysFalse() {
3167 return false;
3168 }
3169 function normalizeProp(normalizable) {
3170 return {
3171 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
3172 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
3173 };
3174 }
3175 function useDismiss(context, props = {}) {
3176 const {
3177 enabled = true,
3178 escapeKey: escapeKey2 = true,
3179 outsidePress: outsidePressProp = true,
3180 outsidePressEvent = "sloppy",
3181 referencePress = alwaysFalse,
3182 bubbles,
3183 externalTree
3184 } = props;
3185 const store = "rootStore" in context ? context.rootStore : context;
3186 const open = store.useState("open");
3187 const floatingElement = store.useState("floatingElement");
3188 const {
3189 dataRef
3190 } = store.context;
3191 const tree = useFloatingTree(externalTree);
3192 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
3193 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
3194 const outsidePressEnabled = outsidePress2 !== false;
3195 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
3196 const {
3197 escapeKey: escapeKeyBubbles,
3198 outsidePress: outsidePressBubbles
3199 } = normalizeProp(bubbles);
3200 const pressStartedInsideRef = React18.useRef(false);
3201 const pressStartPreventedRef = React18.useRef(false);
3202 const suppressNextOutsideClickRef = React18.useRef(false);
3203 const isComposingRef = React18.useRef(false);
3204 const currentPointerTypeRef = React18.useRef("");
3205 const touchStateRef = React18.useRef(null);
3206 const cancelDismissOnEndTimeout = useTimeout();
3207 const clearInsideReactTreeTimeout = useTimeout();
3208 const clearInsideReactTree = useStableCallback(() => {
3209 clearInsideReactTreeTimeout.clear();
3210 dataRef.current.insideReactTree = false;
3211 });
3212 const hasBlockingChild = useStableCallback((bubbleKey) => {
3213 const nodeId = dataRef.current.floatingContext?.nodeId;
3214 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3215 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
3216 });
3217 const isEventWithinOwnElements = useStableCallback((event) => {
3218 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"));
3219 });
3220 const closeOnReferencePress = useStableCallback((event) => {
3221 if (!referencePress()) {
3222 return;
3223 }
3224 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3225 });
3226 const closeOnEscapeKeyDown = useStableCallback((event) => {
3227 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
3228 return;
3229 }
3230 if (isComposingRef.current) {
3231 return;
3232 }
3233 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
3234 return;
3235 }
3236 const native = isReactEvent(event) ? event.nativeEvent : event;
3237 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
3238 store.setOpen(false, eventDetails);
3239 if (!eventDetails.isCanceled) {
3240 event.preventDefault();
3241 }
3242 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
3243 event.stopPropagation();
3244 }
3245 });
3246 const markInsideReactTree = useStableCallback(() => {
3247 dataRef.current.insideReactTree = true;
3248 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
3249 });
3250 const markPressStartedInsideReactTree = useStableCallback((event) => {
3251 if (!open || !enabled || event.button !== 0) {
3252 return;
3253 }
3254 const target = getTarget(event.nativeEvent);
3255 if (!contains(store.select("floatingElement"), target)) {
3256 return;
3257 }
3258 if (!pressStartedInsideRef.current) {
3259 pressStartedInsideRef.current = true;
3260 pressStartPreventedRef.current = false;
3261 }
3262 });
3263 const markInsidePressStartPrevented = useStableCallback((event) => {
3264 if (!open || !enabled) {
3265 return;
3266 }
3267 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
3268 return;
3269 }
3270 if (pressStartedInsideRef.current) {
3271 pressStartPreventedRef.current = true;
3272 }
3273 });
3274 React18.useEffect(() => {
3275 if (!open || !enabled) {
3276 return void 0;
3277 }
3278 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
3279 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
3280 const compositionTimeout = new Timeout();
3281 const preventedPressSuppressionTimeout = new Timeout();
3282 function handleCompositionStart() {
3283 compositionTimeout.clear();
3284 isComposingRef.current = true;
3285 }
3286 function handleCompositionEnd() {
3287 compositionTimeout.start(
3288 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
3289 // Only apply to WebKit for the test to remain 0ms.
3290 parts_exports.engine.webkit ? 5 : 0,
3291 () => {
3292 isComposingRef.current = false;
3293 }
3294 );
3295 }
3296 function suppressImmediateOutsideClickAfterPreventedStart() {
3297 suppressNextOutsideClickRef.current = true;
3298 preventedPressSuppressionTimeout.start(0, () => {
3299 suppressNextOutsideClickRef.current = false;
3300 });
3301 }
3302 function resetPressStartState() {
3303 pressStartedInsideRef.current = false;
3304 pressStartPreventedRef.current = false;
3305 }
3306 function getOutsidePressEvent() {
3307 const type = currentPointerTypeRef.current;
3308 const computedType = type === "pen" || !type ? "mouse" : type;
3309 const outsidePressEventValue = getOutsidePressEventProp();
3310 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
3311 if (typeof resolved === "string") {
3312 return resolved;
3313 }
3314 return resolved[computedType];
3315 }
3316 function shouldIgnoreEvent(event) {
3317 const computedOutsidePressEvent = getOutsidePressEvent();
3318 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
3319 }
3320 function isEventWithinFloatingTree(event) {
3321 const nodeId = dataRef.current.floatingContext?.nodeId;
3322 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
3323 return isEventWithinOwnElements(event) || targetIsInsideChildren;
3324 }
3325 function closeOnPressOutside(event) {
3326 if (shouldIgnoreEvent(event)) {
3327 if (event.type !== "click" && !isEventWithinOwnElements(event)) {
3328 preventedPressSuppressionTimeout.clear();
3329 suppressNextOutsideClickRef.current = false;
3330 }
3331 clearInsideReactTree();
3332 return;
3333 }
3334 if (dataRef.current.insideReactTree) {
3335 clearInsideReactTree();
3336 return;
3337 }
3338 const target = getTarget(event);
3339 const inertSelector = `[${createAttribute("inert")}]`;
3340 const targetRoot = isElement(target) ? target.getRootNode() : null;
3341 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
3342 const triggers = store.context.triggerElements;
3343 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
3344 return;
3345 }
3346 let targetRootAncestor = isElement(target) ? target : null;
3347 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
3348 const nextParent = getParentNode(targetRootAncestor);
3349 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
3350 break;
3351 }
3352 targetRootAncestor = nextParent;
3353 }
3354 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
3355 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
3356 // element was injected after the floating element rendered.
3357 markers.every((marker) => !contains(targetRootAncestor, marker))) {
3358 return;
3359 }
3360 if (isHTMLElement(target) && !("touches" in event)) {
3361 const lastTraversableNode = isLastTraversableNode(target);
3362 const style = getComputedStyle2(target);
3363 const scrollRe = /auto|scroll/;
3364 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
3365 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
3366 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
3367 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
3368 const isRTL7 = style.direction === "rtl";
3369 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
3370 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
3371 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
3372 return;
3373 }
3374 }
3375 if (isEventWithinFloatingTree(event)) {
3376 return;
3377 }
3378 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
3379 preventedPressSuppressionTimeout.clear();
3380 suppressNextOutsideClickRef.current = false;
3381 return;
3382 }
3383 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3384 return;
3385 }
3386 if (hasBlockingChild("__outsidePressBubbles")) {
3387 return;
3388 }
3389 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
3390 clearInsideReactTree();
3391 }
3392 function handlePointerDown(event) {
3393 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
3394 return;
3395 }
3396 closeOnPressOutside(event);
3397 }
3398 function handleTouchStart(event) {
3399 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
3400 return;
3401 }
3402 const touch = event.touches[0];
3403 if (touch) {
3404 touchStateRef.current = {
3405 startTime: Date.now(),
3406 startX: touch.clientX,
3407 startY: touch.clientY,
3408 dismissOnTouchEnd: false,
3409 dismissOnMouseDown: true
3410 };
3411 cancelDismissOnEndTimeout.start(1e3, () => {
3412 if (touchStateRef.current) {
3413 touchStateRef.current.dismissOnTouchEnd = false;
3414 touchStateRef.current.dismissOnMouseDown = false;
3415 }
3416 });
3417 }
3418 }
3419 function addTargetEventListenerOnce(event, listener) {
3420 const target = getTarget(event);
3421 if (!target) {
3422 return;
3423 }
3424 const unsubscribe2 = addEventListener(target, event.type, () => {
3425 listener(event);
3426 unsubscribe2();
3427 });
3428 }
3429 function handleTouchStartCapture(event) {
3430 currentPointerTypeRef.current = "touch";
3431 addTargetEventListenerOnce(event, handleTouchStart);
3432 }
3433 function closeOnPressOutsideCapture(event) {
3434 cancelDismissOnEndTimeout.clear();
3435 if (event.type === "pointerdown") {
3436 currentPointerTypeRef.current = event.pointerType;
3437 }
3438 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
3439 return;
3440 }
3441 addTargetEventListenerOnce(event, (targetEvent) => {
3442 if (targetEvent.type === "pointerdown") {
3443 handlePointerDown(targetEvent);
3444 } else {
3445 closeOnPressOutside(targetEvent);
3446 }
3447 });
3448 }
3449 function handlePressEndCapture(event) {
3450 if (!pressStartedInsideRef.current) {
3451 return;
3452 }
3453 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
3454 resetPressStartState();
3455 if (getOutsidePressEvent() !== "intentional") {
3456 return;
3457 }
3458 if (event.type === "pointercancel") {
3459 if (pressStartedInsideDefaultPrevented) {
3460 suppressImmediateOutsideClickAfterPreventedStart();
3461 }
3462 return;
3463 }
3464 if (isEventWithinFloatingTree(event)) {
3465 return;
3466 }
3467 if (pressStartedInsideDefaultPrevented) {
3468 suppressImmediateOutsideClickAfterPreventedStart();
3469 return;
3470 }
3471 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3472 return;
3473 }
3474 preventedPressSuppressionTimeout.clear();
3475 suppressNextOutsideClickRef.current = true;
3476 clearInsideReactTree();
3477 }
3478 function handleTouchMove(event) {
3479 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
3480 return;
3481 }
3482 const touch = event.touches[0];
3483 if (!touch) {
3484 return;
3485 }
3486 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
3487 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
3488 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
3489 if (distance > 5) {
3490 touchStateRef.current.dismissOnTouchEnd = true;
3491 }
3492 if (distance > 10) {
3493 closeOnPressOutside(event);
3494 cancelDismissOnEndTimeout.clear();
3495 touchStateRef.current = null;
3496 }
3497 }
3498 function handleTouchMoveCapture(event) {
3499 addTargetEventListenerOnce(event, handleTouchMove);
3500 }
3501 function handleTouchEnd(event) {
3502 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
3503 return;
3504 }
3505 if (touchStateRef.current.dismissOnTouchEnd) {
3506 closeOnPressOutside(event);
3507 }
3508 cancelDismissOnEndTimeout.clear();
3509 touchStateRef.current = null;
3510 }
3511 function handleTouchEndCapture(event) {
3512 addTargetEventListenerOnce(event, handleTouchEnd);
3513 }
3514 const doc = ownerDocument(floatingElement);
3515 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)));
3516 return () => {
3517 unsubscribe();
3518 compositionTimeout.clear();
3519 preventedPressSuppressionTimeout.clear();
3520 resetPressStartState();
3521 suppressNextOutsideClickRef.current = false;
3522 };
3523 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store, cancelDismissOnEndTimeout]);
3524 React18.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
3525 const reference = React18.useMemo(() => ({
3526 onKeyDown: closeOnEscapeKeyDown,
3527 onPointerDown: closeOnReferencePress,
3528 onClick: closeOnReferencePress
3529 }), [closeOnEscapeKeyDown, closeOnReferencePress]);
3530 const floating = React18.useMemo(() => ({
3531 onKeyDown: closeOnEscapeKeyDown,
3532 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
3533 // `onPointerDown`, such as with <NumberField.ScrubArea>.
3534 // See https://github.com/mui/base-ui/pull/3379
3535 onPointerDown: markInsidePressStartPrevented,
3536 onMouseDown: markInsidePressStartPrevented,
3537 onClickCapture: markInsideReactTree,
3538 onMouseDownCapture(event) {
3539 markInsideReactTree();
3540 markPressStartedInsideReactTree(event);
3541 },
3542 onPointerDownCapture(event) {
3543 markInsideReactTree();
3544 markPressStartedInsideReactTree(event);
3545 },
3546 onMouseUpCapture: markInsideReactTree,
3547 onTouchEndCapture: markInsideReactTree,
3548 onTouchMoveCapture: markInsideReactTree
3549 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
3550 return React18.useMemo(() => enabled ? {
3551 reference,
3552 floating,
3553 trigger: reference
3554 } : {}, [enabled, reference, floating]);
3555 }
3556
3557 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs
3558 var React25 = __toESM(require_react(), 1);
3559
3560 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
3561 function computeCoordsFromPlacement(_ref, placement, rtl) {
3562 let {
3563 reference,
3564 floating
3565 } = _ref;
3566 const sideAxis = getSideAxis(placement);
3567 const alignmentAxis = getAlignmentAxis(placement);
3568 const alignLength = getAxisLength(alignmentAxis);
3569 const side = getSide(placement);
3570 const isVertical = sideAxis === "y";
3571 const commonX = reference.x + reference.width / 2 - floating.width / 2;
3572 const commonY = reference.y + reference.height / 2 - floating.height / 2;
3573 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
3574 let coords;
3575 switch (side) {
3576 case "top":
3577 coords = {
3578 x: commonX,
3579 y: reference.y - floating.height
3580 };
3581 break;
3582 case "bottom":
3583 coords = {
3584 x: commonX,
3585 y: reference.y + reference.height
3586 };
3587 break;
3588 case "right":
3589 coords = {
3590 x: reference.x + reference.width,
3591 y: commonY
3592 };
3593 break;
3594 case "left":
3595 coords = {
3596 x: reference.x - floating.width,
3597 y: commonY
3598 };
3599 break;
3600 default:
3601 coords = {
3602 x: reference.x,
3603 y: reference.y
3604 };
3605 }
3606 switch (getAlignment(placement)) {
3607 case "start":
3608 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
3609 break;
3610 case "end":
3611 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
3612 break;
3613 }
3614 return coords;
3615 }
3616 async function detectOverflow(state, options) {
3617 var _await$platform$isEle;
3618 if (options === void 0) {
3619 options = {};
3620 }
3621 const {
3622 x: x2,
3623 y: y2,
3624 platform: platform3,
3625 rects,
3626 elements,
3627 strategy
3628 } = state;
3629 const {
3630 boundary = "clippingAncestors",
3631 rootBoundary = "viewport",
3632 elementContext = "floating",
3633 altBoundary = false,
3634 padding = 0
3635 } = evaluate(options, state);
3636 const paddingObject = getPaddingObject(padding);
3637 const altContext = elementContext === "floating" ? "reference" : "floating";
3638 const element = elements[altBoundary ? altContext : elementContext];
3639 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
3640 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)),
3641 boundary,
3642 rootBoundary,
3643 strategy
3644 }));
3645 const rect = elementContext === "floating" ? {
3646 x: x2,
3647 y: y2,
3648 width: rects.floating.width,
3649 height: rects.floating.height
3650 } : rects.reference;
3651 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
3652 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
3653 x: 1,
3654 y: 1
3655 } : {
3656 x: 1,
3657 y: 1
3658 };
3659 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
3660 elements,
3661 rect,
3662 offsetParent,
3663 strategy
3664 }) : rect);
3665 return {
3666 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
3667 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
3668 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
3669 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
3670 };
3671 }
3672 var MAX_RESET_COUNT = 50;
3673 var computePosition = async (reference, floating, config) => {
3674 const {
3675 placement = "bottom",
3676 strategy = "absolute",
3677 middleware = [],
3678 platform: platform3
3679 } = config;
3680 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
3681 ...platform3,
3682 detectOverflow
3683 };
3684 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
3685 let rects = await platform3.getElementRects({
3686 reference,
3687 floating,
3688 strategy
3689 });
3690 let {
3691 x: x2,
3692 y: y2
3693 } = computeCoordsFromPlacement(rects, placement, rtl);
3694 let statefulPlacement = placement;
3695 let resetCount = 0;
3696 const middlewareData = {};
3697 for (let i2 = 0; i2 < middleware.length; i2++) {
3698 const currentMiddleware = middleware[i2];
3699 if (!currentMiddleware) {
3700 continue;
3701 }
3702 const {
3703 name,
3704 fn
3705 } = currentMiddleware;
3706 const {
3707 x: nextX,
3708 y: nextY,
3709 data,
3710 reset
3711 } = await fn({
3712 x: x2,
3713 y: y2,
3714 initialPlacement: placement,
3715 placement: statefulPlacement,
3716 strategy,
3717 middlewareData,
3718 rects,
3719 platform: platformWithDetectOverflow,
3720 elements: {
3721 reference,
3722 floating
3723 }
3724 });
3725 x2 = nextX != null ? nextX : x2;
3726 y2 = nextY != null ? nextY : y2;
3727 middlewareData[name] = {
3728 ...middlewareData[name],
3729 ...data
3730 };
3731 if (reset && resetCount < MAX_RESET_COUNT) {
3732 resetCount++;
3733 if (typeof reset === "object") {
3734 if (reset.placement) {
3735 statefulPlacement = reset.placement;
3736 }
3737 if (reset.rects) {
3738 rects = reset.rects === true ? await platform3.getElementRects({
3739 reference,
3740 floating,
3741 strategy
3742 }) : reset.rects;
3743 }
3744 ({
3745 x: x2,
3746 y: y2
3747 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
3748 }
3749 i2 = -1;
3750 }
3751 }
3752 return {
3753 x: x2,
3754 y: y2,
3755 placement: statefulPlacement,
3756 strategy,
3757 middlewareData
3758 };
3759 };
3760 var flip = function(options) {
3761 if (options === void 0) {
3762 options = {};
3763 }
3764 return {
3765 name: "flip",
3766 options,
3767 async fn(state) {
3768 var _middlewareData$arrow, _middlewareData$flip;
3769 const {
3770 placement,
3771 middlewareData,
3772 rects,
3773 initialPlacement,
3774 platform: platform3,
3775 elements
3776 } = state;
3777 const {
3778 mainAxis: checkMainAxis = true,
3779 crossAxis: checkCrossAxis = true,
3780 fallbackPlacements: specifiedFallbackPlacements,
3781 fallbackStrategy = "bestFit",
3782 fallbackAxisSideDirection = "none",
3783 flipAlignment = true,
3784 ...detectOverflowOptions
3785 } = evaluate(options, state);
3786 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
3787 return {};
3788 }
3789 const side = getSide(placement);
3790 const initialSideAxis = getSideAxis(initialPlacement);
3791 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
3792 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
3793 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
3794 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
3795 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
3796 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
3797 }
3798 const placements2 = [initialPlacement, ...fallbackPlacements];
3799 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
3800 const overflows = [];
3801 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
3802 if (checkMainAxis) {
3803 overflows.push(overflow[side]);
3804 }
3805 if (checkCrossAxis) {
3806 const sides2 = getAlignmentSides(placement, rects, rtl);
3807 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
3808 }
3809 overflowsData = [...overflowsData, {
3810 placement,
3811 overflows
3812 }];
3813 if (!overflows.every((side2) => side2 <= 0)) {
3814 var _middlewareData$flip2, _overflowsData$filter;
3815 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
3816 const nextPlacement = placements2[nextIndex];
3817 if (nextPlacement) {
3818 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
3819 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
3820 // overflows the main axis.
3821 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
3822 return {
3823 data: {
3824 index: nextIndex,
3825 overflows: overflowsData
3826 },
3827 reset: {
3828 placement: nextPlacement
3829 }
3830 };
3831 }
3832 }
3833 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;
3834 if (!resetPlacement) {
3835 switch (fallbackStrategy) {
3836 case "bestFit": {
3837 var _overflowsData$filter2;
3838 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
3839 if (hasFallbackAxisSideDirection) {
3840 const currentSideAxis = getSideAxis(d2.placement);
3841 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
3842 // reading directions favoring greater width.
3843 currentSideAxis === "y";
3844 }
3845 return true;
3846 }).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];
3847 if (placement2) {
3848 resetPlacement = placement2;
3849 }
3850 break;
3851 }
3852 case "initialPlacement":
3853 resetPlacement = initialPlacement;
3854 break;
3855 }
3856 }
3857 if (placement !== resetPlacement) {
3858 return {
3859 reset: {
3860 placement: resetPlacement
3861 }
3862 };
3863 }
3864 }
3865 return {};
3866 }
3867 };
3868 };
3869 function getSideOffsets(overflow, rect) {
3870 return {
3871 top: overflow.top - rect.height,
3872 right: overflow.right - rect.width,
3873 bottom: overflow.bottom - rect.height,
3874 left: overflow.left - rect.width
3875 };
3876 }
3877 function isAnySideFullyClipped(overflow) {
3878 return sides.some((side) => overflow[side] >= 0);
3879 }
3880 var hide = function(options) {
3881 if (options === void 0) {
3882 options = {};
3883 }
3884 return {
3885 name: "hide",
3886 options,
3887 async fn(state) {
3888 const {
3889 rects,
3890 platform: platform3
3891 } = state;
3892 const {
3893 strategy = "referenceHidden",
3894 ...detectOverflowOptions
3895 } = evaluate(options, state);
3896 switch (strategy) {
3897 case "referenceHidden": {
3898 const overflow = await platform3.detectOverflow(state, {
3899 ...detectOverflowOptions,
3900 elementContext: "reference"
3901 });
3902 const offsets = getSideOffsets(overflow, rects.reference);
3903 return {
3904 data: {
3905 referenceHiddenOffsets: offsets,
3906 referenceHidden: isAnySideFullyClipped(offsets)
3907 }
3908 };
3909 }
3910 case "escaped": {
3911 const overflow = await platform3.detectOverflow(state, {
3912 ...detectOverflowOptions,
3913 altBoundary: true
3914 });
3915 const offsets = getSideOffsets(overflow, rects.floating);
3916 return {
3917 data: {
3918 escapedOffsets: offsets,
3919 escaped: isAnySideFullyClipped(offsets)
3920 }
3921 };
3922 }
3923 default: {
3924 return {};
3925 }
3926 }
3927 }
3928 };
3929 };
3930 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
3931 async function convertValueToCoords(state, options) {
3932 const {
3933 placement,
3934 platform: platform3,
3935 elements
3936 } = state;
3937 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
3938 const side = getSide(placement);
3939 const alignment = getAlignment(placement);
3940 const isVertical = getSideAxis(placement) === "y";
3941 const mainAxisMulti = originSides.has(side) ? -1 : 1;
3942 const crossAxisMulti = rtl && isVertical ? -1 : 1;
3943 const rawValue = evaluate(options, state);
3944 let {
3945 mainAxis,
3946 crossAxis,
3947 alignmentAxis
3948 } = typeof rawValue === "number" ? {
3949 mainAxis: rawValue,
3950 crossAxis: 0,
3951 alignmentAxis: null
3952 } : {
3953 mainAxis: rawValue.mainAxis || 0,
3954 crossAxis: rawValue.crossAxis || 0,
3955 alignmentAxis: rawValue.alignmentAxis
3956 };
3957 if (alignment && typeof alignmentAxis === "number") {
3958 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
3959 }
3960 return isVertical ? {
3961 x: crossAxis * crossAxisMulti,
3962 y: mainAxis * mainAxisMulti
3963 } : {
3964 x: mainAxis * mainAxisMulti,
3965 y: crossAxis * crossAxisMulti
3966 };
3967 }
3968 var offset = function(options) {
3969 if (options === void 0) {
3970 options = 0;
3971 }
3972 return {
3973 name: "offset",
3974 options,
3975 async fn(state) {
3976 var _middlewareData$offse, _middlewareData$arrow;
3977 const {
3978 x: x2,
3979 y: y2,
3980 placement,
3981 middlewareData
3982 } = state;
3983 const diffCoords = await convertValueToCoords(state, options);
3984 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
3985 return {};
3986 }
3987 return {
3988 x: x2 + diffCoords.x,
3989 y: y2 + diffCoords.y,
3990 data: {
3991 ...diffCoords,
3992 placement
3993 }
3994 };
3995 }
3996 };
3997 };
3998 var shift = function(options) {
3999 if (options === void 0) {
4000 options = {};
4001 }
4002 return {
4003 name: "shift",
4004 options,
4005 async fn(state) {
4006 const {
4007 x: x2,
4008 y: y2,
4009 placement,
4010 platform: platform3
4011 } = state;
4012 const {
4013 mainAxis: checkMainAxis = true,
4014 crossAxis: checkCrossAxis = false,
4015 limiter = {
4016 fn: (_ref) => {
4017 let {
4018 x: x3,
4019 y: y3
4020 } = _ref;
4021 return {
4022 x: x3,
4023 y: y3
4024 };
4025 }
4026 },
4027 ...detectOverflowOptions
4028 } = evaluate(options, state);
4029 const coords = {
4030 x: x2,
4031 y: y2
4032 };
4033 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4034 const crossAxis = getSideAxis(getSide(placement));
4035 const mainAxis = getOppositeAxis(crossAxis);
4036 let mainAxisCoord = coords[mainAxis];
4037 let crossAxisCoord = coords[crossAxis];
4038 if (checkMainAxis) {
4039 const minSide = mainAxis === "y" ? "top" : "left";
4040 const maxSide = mainAxis === "y" ? "bottom" : "right";
4041 const min2 = mainAxisCoord + overflow[minSide];
4042 const max2 = mainAxisCoord - overflow[maxSide];
4043 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
4044 }
4045 if (checkCrossAxis) {
4046 const minSide = crossAxis === "y" ? "top" : "left";
4047 const maxSide = crossAxis === "y" ? "bottom" : "right";
4048 const min2 = crossAxisCoord + overflow[minSide];
4049 const max2 = crossAxisCoord - overflow[maxSide];
4050 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
4051 }
4052 const limitedCoords = limiter.fn({
4053 ...state,
4054 [mainAxis]: mainAxisCoord,
4055 [crossAxis]: crossAxisCoord
4056 });
4057 return {
4058 ...limitedCoords,
4059 data: {
4060 x: limitedCoords.x - x2,
4061 y: limitedCoords.y - y2,
4062 enabled: {
4063 [mainAxis]: checkMainAxis,
4064 [crossAxis]: checkCrossAxis
4065 }
4066 }
4067 };
4068 }
4069 };
4070 };
4071 var limitShift = function(options) {
4072 if (options === void 0) {
4073 options = {};
4074 }
4075 return {
4076 options,
4077 fn(state) {
4078 const {
4079 x: x2,
4080 y: y2,
4081 placement,
4082 rects,
4083 middlewareData
4084 } = state;
4085 const {
4086 offset: offset4 = 0,
4087 mainAxis: checkMainAxis = true,
4088 crossAxis: checkCrossAxis = true
4089 } = evaluate(options, state);
4090 const coords = {
4091 x: x2,
4092 y: y2
4093 };
4094 const crossAxis = getSideAxis(placement);
4095 const mainAxis = getOppositeAxis(crossAxis);
4096 let mainAxisCoord = coords[mainAxis];
4097 let crossAxisCoord = coords[crossAxis];
4098 const rawOffset = evaluate(offset4, state);
4099 const computedOffset = typeof rawOffset === "number" ? {
4100 mainAxis: rawOffset,
4101 crossAxis: 0
4102 } : {
4103 mainAxis: 0,
4104 crossAxis: 0,
4105 ...rawOffset
4106 };
4107 if (checkMainAxis) {
4108 const len = mainAxis === "y" ? "height" : "width";
4109 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
4110 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
4111 if (mainAxisCoord < limitMin) {
4112 mainAxisCoord = limitMin;
4113 } else if (mainAxisCoord > limitMax) {
4114 mainAxisCoord = limitMax;
4115 }
4116 }
4117 if (checkCrossAxis) {
4118 var _middlewareData$offse, _middlewareData$offse2;
4119 const len = mainAxis === "y" ? "width" : "height";
4120 const isOriginSide = originSides.has(getSide(placement));
4121 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);
4122 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);
4123 if (crossAxisCoord < limitMin) {
4124 crossAxisCoord = limitMin;
4125 } else if (crossAxisCoord > limitMax) {
4126 crossAxisCoord = limitMax;
4127 }
4128 }
4129 return {
4130 [mainAxis]: mainAxisCoord,
4131 [crossAxis]: crossAxisCoord
4132 };
4133 }
4134 };
4135 };
4136 var size = function(options) {
4137 if (options === void 0) {
4138 options = {};
4139 }
4140 return {
4141 name: "size",
4142 options,
4143 async fn(state) {
4144 var _state$middlewareData, _state$middlewareData2;
4145 const {
4146 placement,
4147 rects,
4148 platform: platform3,
4149 elements
4150 } = state;
4151 const {
4152 apply = () => {
4153 },
4154 ...detectOverflowOptions
4155 } = evaluate(options, state);
4156 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4157 const side = getSide(placement);
4158 const alignment = getAlignment(placement);
4159 const isYAxis = getSideAxis(placement) === "y";
4160 const {
4161 width,
4162 height
4163 } = rects.floating;
4164 let heightSide;
4165 let widthSide;
4166 if (side === "top" || side === "bottom") {
4167 heightSide = side;
4168 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
4169 } else {
4170 widthSide = side;
4171 heightSide = alignment === "end" ? "top" : "bottom";
4172 }
4173 const maximumClippingHeight = height - overflow.top - overflow.bottom;
4174 const maximumClippingWidth = width - overflow.left - overflow.right;
4175 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
4176 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
4177 const noShift = !state.middlewareData.shift;
4178 let availableHeight = overflowAvailableHeight;
4179 let availableWidth = overflowAvailableWidth;
4180 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
4181 availableWidth = maximumClippingWidth;
4182 }
4183 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
4184 availableHeight = maximumClippingHeight;
4185 }
4186 if (noShift && !alignment) {
4187 const xMin = max(overflow.left, 0);
4188 const xMax = max(overflow.right, 0);
4189 const yMin = max(overflow.top, 0);
4190 const yMax = max(overflow.bottom, 0);
4191 if (isYAxis) {
4192 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
4193 } else {
4194 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
4195 }
4196 }
4197 await apply({
4198 ...state,
4199 availableWidth,
4200 availableHeight
4201 });
4202 const nextDimensions = await platform3.getDimensions(elements.floating);
4203 if (width !== nextDimensions.width || height !== nextDimensions.height) {
4204 return {
4205 reset: {
4206 rects: true
4207 }
4208 };
4209 }
4210 return {};
4211 }
4212 };
4213 };
4214
4215 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
4216 function getCssDimensions(element) {
4217 const css = getComputedStyle2(element);
4218 let width = parseFloat(css.width) || 0;
4219 let height = parseFloat(css.height) || 0;
4220 const hasOffset = isHTMLElement(element);
4221 const offsetWidth = hasOffset ? element.offsetWidth : width;
4222 const offsetHeight = hasOffset ? element.offsetHeight : height;
4223 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
4224 if (shouldFallback) {
4225 width = offsetWidth;
4226 height = offsetHeight;
4227 }
4228 return {
4229 width,
4230 height,
4231 $: shouldFallback
4232 };
4233 }
4234 function unwrapElement(element) {
4235 return !isElement(element) ? element.contextElement : element;
4236 }
4237 function getScale(element) {
4238 const domElement = unwrapElement(element);
4239 if (!isHTMLElement(domElement)) {
4240 return createCoords(1);
4241 }
4242 const rect = domElement.getBoundingClientRect();
4243 const {
4244 width,
4245 height,
4246 $: $2
4247 } = getCssDimensions(domElement);
4248 let x2 = ($2 ? round(rect.width) : rect.width) / width;
4249 let y2 = ($2 ? round(rect.height) : rect.height) / height;
4250 if (!x2 || !Number.isFinite(x2)) {
4251 x2 = 1;
4252 }
4253 if (!y2 || !Number.isFinite(y2)) {
4254 y2 = 1;
4255 }
4256 return {
4257 x: x2,
4258 y: y2
4259 };
4260 }
4261 var noOffsets = /* @__PURE__ */ createCoords(0);
4262 function getVisualOffsets(element) {
4263 const win = getWindow(element);
4264 if (!isWebKit() || !win.visualViewport) {
4265 return noOffsets;
4266 }
4267 return {
4268 x: win.visualViewport.offsetLeft,
4269 y: win.visualViewport.offsetTop
4270 };
4271 }
4272 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
4273 if (isFixed === void 0) {
4274 isFixed = false;
4275 }
4276 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
4277 return false;
4278 }
4279 return isFixed;
4280 }
4281 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
4282 if (includeScale === void 0) {
4283 includeScale = false;
4284 }
4285 if (isFixedStrategy === void 0) {
4286 isFixedStrategy = false;
4287 }
4288 const clientRect = element.getBoundingClientRect();
4289 const domElement = unwrapElement(element);
4290 let scale = createCoords(1);
4291 if (includeScale) {
4292 if (offsetParent) {
4293 if (isElement(offsetParent)) {
4294 scale = getScale(offsetParent);
4295 }
4296 } else {
4297 scale = getScale(element);
4298 }
4299 }
4300 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
4301 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
4302 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
4303 let width = clientRect.width / scale.x;
4304 let height = clientRect.height / scale.y;
4305 if (domElement) {
4306 const win = getWindow(domElement);
4307 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
4308 let currentWin = win;
4309 let currentIFrame = getFrameElement(currentWin);
4310 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
4311 const iframeScale = getScale(currentIFrame);
4312 const iframeRect = currentIFrame.getBoundingClientRect();
4313 const css = getComputedStyle2(currentIFrame);
4314 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
4315 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
4316 x2 *= iframeScale.x;
4317 y2 *= iframeScale.y;
4318 width *= iframeScale.x;
4319 height *= iframeScale.y;
4320 x2 += left;
4321 y2 += top;
4322 currentWin = getWindow(currentIFrame);
4323 currentIFrame = getFrameElement(currentWin);
4324 }
4325 }
4326 return rectToClientRect({
4327 width,
4328 height,
4329 x: x2,
4330 y: y2
4331 });
4332 }
4333 function getWindowScrollBarX(element, rect) {
4334 const leftScroll = getNodeScroll(element).scrollLeft;
4335 if (!rect) {
4336 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
4337 }
4338 return rect.left + leftScroll;
4339 }
4340 function getHTMLOffset(documentElement, scroll) {
4341 const htmlRect = documentElement.getBoundingClientRect();
4342 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
4343 const y2 = htmlRect.top + scroll.scrollTop;
4344 return {
4345 x: x2,
4346 y: y2
4347 };
4348 }
4349 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
4350 let {
4351 elements,
4352 rect,
4353 offsetParent,
4354 strategy
4355 } = _ref;
4356 const isFixed = strategy === "fixed";
4357 const documentElement = getDocumentElement(offsetParent);
4358 const topLayer = elements ? isTopLayer(elements.floating) : false;
4359 if (offsetParent === documentElement || topLayer && isFixed) {
4360 return rect;
4361 }
4362 let scroll = {
4363 scrollLeft: 0,
4364 scrollTop: 0
4365 };
4366 let scale = createCoords(1);
4367 const offsets = createCoords(0);
4368 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4369 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4370 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4371 scroll = getNodeScroll(offsetParent);
4372 }
4373 if (isOffsetParentAnElement) {
4374 const offsetRect = getBoundingClientRect(offsetParent);
4375 scale = getScale(offsetParent);
4376 offsets.x = offsetRect.x + offsetParent.clientLeft;
4377 offsets.y = offsetRect.y + offsetParent.clientTop;
4378 }
4379 }
4380 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4381 return {
4382 width: rect.width * scale.x,
4383 height: rect.height * scale.y,
4384 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
4385 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
4386 };
4387 }
4388 function getClientRects(element) {
4389 return Array.from(element.getClientRects());
4390 }
4391 function getDocumentRect(element) {
4392 const html = getDocumentElement(element);
4393 const scroll = getNodeScroll(element);
4394 const body = element.ownerDocument.body;
4395 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
4396 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
4397 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
4398 const y2 = -scroll.scrollTop;
4399 if (getComputedStyle2(body).direction === "rtl") {
4400 x2 += max(html.clientWidth, body.clientWidth) - width;
4401 }
4402 return {
4403 width,
4404 height,
4405 x: x2,
4406 y: y2
4407 };
4408 }
4409 var SCROLLBAR_MAX = 25;
4410 function getViewportRect(element, strategy) {
4411 const win = getWindow(element);
4412 const html = getDocumentElement(element);
4413 const visualViewport = win.visualViewport;
4414 let width = html.clientWidth;
4415 let height = html.clientHeight;
4416 let x2 = 0;
4417 let y2 = 0;
4418 if (visualViewport) {
4419 width = visualViewport.width;
4420 height = visualViewport.height;
4421 const visualViewportBased = isWebKit();
4422 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
4423 x2 = visualViewport.offsetLeft;
4424 y2 = visualViewport.offsetTop;
4425 }
4426 }
4427 const windowScrollbarX = getWindowScrollBarX(html);
4428 if (windowScrollbarX <= 0) {
4429 const doc = html.ownerDocument;
4430 const body = doc.body;
4431 const bodyStyles = getComputedStyle(body);
4432 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
4433 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
4434 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
4435 width -= clippingStableScrollbarWidth;
4436 }
4437 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
4438 width += windowScrollbarX;
4439 }
4440 return {
4441 width,
4442 height,
4443 x: x2,
4444 y: y2
4445 };
4446 }
4447 function getInnerBoundingClientRect(element, strategy) {
4448 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
4449 const top = clientRect.top + element.clientTop;
4450 const left = clientRect.left + element.clientLeft;
4451 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
4452 const width = element.clientWidth * scale.x;
4453 const height = element.clientHeight * scale.y;
4454 const x2 = left * scale.x;
4455 const y2 = top * scale.y;
4456 return {
4457 width,
4458 height,
4459 x: x2,
4460 y: y2
4461 };
4462 }
4463 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
4464 let rect;
4465 if (clippingAncestor === "viewport") {
4466 rect = getViewportRect(element, strategy);
4467 } else if (clippingAncestor === "document") {
4468 rect = getDocumentRect(getDocumentElement(element));
4469 } else if (isElement(clippingAncestor)) {
4470 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
4471 } else {
4472 const visualOffsets = getVisualOffsets(element);
4473 rect = {
4474 x: clippingAncestor.x - visualOffsets.x,
4475 y: clippingAncestor.y - visualOffsets.y,
4476 width: clippingAncestor.width,
4477 height: clippingAncestor.height
4478 };
4479 }
4480 return rectToClientRect(rect);
4481 }
4482 function hasFixedPositionAncestor(element, stopNode) {
4483 const parentNode = getParentNode(element);
4484 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
4485 return false;
4486 }
4487 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
4488 }
4489 function getClippingElementAncestors(element, cache) {
4490 const cachedResult = cache.get(element);
4491 if (cachedResult) {
4492 return cachedResult;
4493 }
4494 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
4495 let currentContainingBlockComputedStyle = null;
4496 const elementIsFixed = getComputedStyle2(element).position === "fixed";
4497 let currentNode = elementIsFixed ? getParentNode(element) : element;
4498 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
4499 const computedStyle = getComputedStyle2(currentNode);
4500 const currentNodeIsContaining = isContainingBlock(currentNode);
4501 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
4502 currentContainingBlockComputedStyle = null;
4503 }
4504 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
4505 if (shouldDropCurrentNode) {
4506 result = result.filter((ancestor) => ancestor !== currentNode);
4507 } else {
4508 currentContainingBlockComputedStyle = computedStyle;
4509 }
4510 currentNode = getParentNode(currentNode);
4511 }
4512 cache.set(element, result);
4513 return result;
4514 }
4515 function getClippingRect(_ref) {
4516 let {
4517 element,
4518 boundary,
4519 rootBoundary,
4520 strategy
4521 } = _ref;
4522 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
4523 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
4524 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
4525 let top = firstRect.top;
4526 let right = firstRect.right;
4527 let bottom = firstRect.bottom;
4528 let left = firstRect.left;
4529 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
4530 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
4531 top = max(rect.top, top);
4532 right = min(rect.right, right);
4533 bottom = min(rect.bottom, bottom);
4534 left = max(rect.left, left);
4535 }
4536 return {
4537 width: right - left,
4538 height: bottom - top,
4539 x: left,
4540 y: top
4541 };
4542 }
4543 function getDimensions(element) {
4544 const {
4545 width,
4546 height
4547 } = getCssDimensions(element);
4548 return {
4549 width,
4550 height
4551 };
4552 }
4553 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
4554 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4555 const documentElement = getDocumentElement(offsetParent);
4556 const isFixed = strategy === "fixed";
4557 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
4558 let scroll = {
4559 scrollLeft: 0,
4560 scrollTop: 0
4561 };
4562 const offsets = createCoords(0);
4563 function setLeftRTLScrollbarOffset() {
4564 offsets.x = getWindowScrollBarX(documentElement);
4565 }
4566 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4567 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4568 scroll = getNodeScroll(offsetParent);
4569 }
4570 if (isOffsetParentAnElement) {
4571 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
4572 offsets.x = offsetRect.x + offsetParent.clientLeft;
4573 offsets.y = offsetRect.y + offsetParent.clientTop;
4574 } else if (documentElement) {
4575 setLeftRTLScrollbarOffset();
4576 }
4577 }
4578 if (isFixed && !isOffsetParentAnElement && documentElement) {
4579 setLeftRTLScrollbarOffset();
4580 }
4581 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4582 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
4583 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
4584 return {
4585 x: x2,
4586 y: y2,
4587 width: rect.width,
4588 height: rect.height
4589 };
4590 }
4591 function isStaticPositioned(element) {
4592 return getComputedStyle2(element).position === "static";
4593 }
4594 function getTrueOffsetParent(element, polyfill) {
4595 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
4596 return null;
4597 }
4598 if (polyfill) {
4599 return polyfill(element);
4600 }
4601 let rawOffsetParent = element.offsetParent;
4602 if (getDocumentElement(element) === rawOffsetParent) {
4603 rawOffsetParent = rawOffsetParent.ownerDocument.body;
4604 }
4605 return rawOffsetParent;
4606 }
4607 function getOffsetParent(element, polyfill) {
4608 const win = getWindow(element);
4609 if (isTopLayer(element)) {
4610 return win;
4611 }
4612 if (!isHTMLElement(element)) {
4613 let svgOffsetParent = getParentNode(element);
4614 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
4615 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
4616 return svgOffsetParent;
4617 }
4618 svgOffsetParent = getParentNode(svgOffsetParent);
4619 }
4620 return win;
4621 }
4622 let offsetParent = getTrueOffsetParent(element, polyfill);
4623 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
4624 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
4625 }
4626 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
4627 return win;
4628 }
4629 return offsetParent || getContainingBlock(element) || win;
4630 }
4631 var getElementRects = async function(data) {
4632 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
4633 const getDimensionsFn = this.getDimensions;
4634 const floatingDimensions = await getDimensionsFn(data.floating);
4635 return {
4636 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
4637 floating: {
4638 x: 0,
4639 y: 0,
4640 width: floatingDimensions.width,
4641 height: floatingDimensions.height
4642 }
4643 };
4644 };
4645 function isRTL(element) {
4646 return getComputedStyle2(element).direction === "rtl";
4647 }
4648 var platform2 = {
4649 convertOffsetParentRelativeRectToViewportRelativeRect,
4650 getDocumentElement,
4651 getClippingRect,
4652 getOffsetParent,
4653 getElementRects,
4654 getClientRects,
4655 getDimensions,
4656 getScale,
4657 isElement,
4658 isRTL
4659 };
4660 function rectsAreEqual(a2, b2) {
4661 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
4662 }
4663 function observeMove(element, onMove) {
4664 let io = null;
4665 let timeoutId;
4666 const root = getDocumentElement(element);
4667 function cleanup() {
4668 var _io;
4669 clearTimeout(timeoutId);
4670 (_io = io) == null || _io.disconnect();
4671 io = null;
4672 }
4673 function refresh(skip, threshold) {
4674 if (skip === void 0) {
4675 skip = false;
4676 }
4677 if (threshold === void 0) {
4678 threshold = 1;
4679 }
4680 cleanup();
4681 const elementRectForRootMargin = element.getBoundingClientRect();
4682 const {
4683 left,
4684 top,
4685 width,
4686 height
4687 } = elementRectForRootMargin;
4688 if (!skip) {
4689 onMove();
4690 }
4691 if (!width || !height) {
4692 return;
4693 }
4694 const insetTop = floor(top);
4695 const insetRight = floor(root.clientWidth - (left + width));
4696 const insetBottom = floor(root.clientHeight - (top + height));
4697 const insetLeft = floor(left);
4698 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
4699 const options = {
4700 rootMargin,
4701 threshold: max(0, min(1, threshold)) || 1
4702 };
4703 let isFirstUpdate = true;
4704 function handleObserve(entries) {
4705 const ratio = entries[0].intersectionRatio;
4706 if (ratio !== threshold) {
4707 if (!isFirstUpdate) {
4708 return refresh();
4709 }
4710 if (!ratio) {
4711 timeoutId = setTimeout(() => {
4712 refresh(false, 1e-7);
4713 }, 1e3);
4714 } else {
4715 refresh(false, ratio);
4716 }
4717 }
4718 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
4719 refresh();
4720 }
4721 isFirstUpdate = false;
4722 }
4723 try {
4724 io = new IntersectionObserver(handleObserve, {
4725 ...options,
4726 // Handle <iframe>s
4727 root: root.ownerDocument
4728 });
4729 } catch (_e) {
4730 io = new IntersectionObserver(handleObserve, options);
4731 }
4732 io.observe(element);
4733 }
4734 refresh(true);
4735 return cleanup;
4736 }
4737 function autoUpdate(reference, floating, update2, options) {
4738 if (options === void 0) {
4739 options = {};
4740 }
4741 const {
4742 ancestorScroll = true,
4743 ancestorResize = true,
4744 elementResize = typeof ResizeObserver === "function",
4745 layoutShift = typeof IntersectionObserver === "function",
4746 animationFrame = false
4747 } = options;
4748 const referenceEl = unwrapElement(reference);
4749 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
4750 ancestors.forEach((ancestor) => {
4751 ancestorScroll && ancestor.addEventListener("scroll", update2, {
4752 passive: true
4753 });
4754 ancestorResize && ancestor.addEventListener("resize", update2);
4755 });
4756 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
4757 let reobserveFrame = -1;
4758 let resizeObserver = null;
4759 if (elementResize) {
4760 resizeObserver = new ResizeObserver((_ref) => {
4761 let [firstEntry] = _ref;
4762 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
4763 resizeObserver.unobserve(floating);
4764 cancelAnimationFrame(reobserveFrame);
4765 reobserveFrame = requestAnimationFrame(() => {
4766 var _resizeObserver;
4767 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
4768 });
4769 }
4770 update2();
4771 });
4772 if (referenceEl && !animationFrame) {
4773 resizeObserver.observe(referenceEl);
4774 }
4775 if (floating) {
4776 resizeObserver.observe(floating);
4777 }
4778 }
4779 let frameId;
4780 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
4781 if (animationFrame) {
4782 frameLoop();
4783 }
4784 function frameLoop() {
4785 const nextRefRect = getBoundingClientRect(reference);
4786 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
4787 update2();
4788 }
4789 prevRefRect = nextRefRect;
4790 frameId = requestAnimationFrame(frameLoop);
4791 }
4792 update2();
4793 return () => {
4794 var _resizeObserver2;
4795 ancestors.forEach((ancestor) => {
4796 ancestorScroll && ancestor.removeEventListener("scroll", update2);
4797 ancestorResize && ancestor.removeEventListener("resize", update2);
4798 });
4799 cleanupIo == null || cleanupIo();
4800 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
4801 resizeObserver = null;
4802 if (animationFrame) {
4803 cancelAnimationFrame(frameId);
4804 }
4805 };
4806 }
4807 var offset2 = offset;
4808 var shift2 = shift;
4809 var flip2 = flip;
4810 var size2 = size;
4811 var hide2 = hide;
4812 var limitShift2 = limitShift;
4813 var computePosition2 = (reference, floating, options) => {
4814 const cache = /* @__PURE__ */ new Map();
4815 const mergedOptions = {
4816 platform: platform2,
4817 ...options
4818 };
4819 const platformWithCache = {
4820 ...mergedOptions.platform,
4821 _c: cache
4822 };
4823 return computePosition(reference, floating, {
4824 ...mergedOptions,
4825 platform: platformWithCache
4826 });
4827 };
4828
4829 // node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
4830 var React19 = __toESM(require_react(), 1);
4831 var import_react2 = __toESM(require_react(), 1);
4832 var ReactDOM3 = __toESM(require_react_dom(), 1);
4833 var isClient = typeof document !== "undefined";
4834 var noop2 = function noop3() {
4835 };
4836 var index = isClient ? import_react2.useLayoutEffect : noop2;
4837 function deepEqual(a2, b2) {
4838 if (a2 === b2) {
4839 return true;
4840 }
4841 if (typeof a2 !== typeof b2) {
4842 return false;
4843 }
4844 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
4845 return true;
4846 }
4847 let length;
4848 let i2;
4849 let keys;
4850 if (a2 && b2 && typeof a2 === "object") {
4851 if (Array.isArray(a2)) {
4852 length = a2.length;
4853 if (length !== b2.length) return false;
4854 for (i2 = length; i2-- !== 0; ) {
4855 if (!deepEqual(a2[i2], b2[i2])) {
4856 return false;
4857 }
4858 }
4859 return true;
4860 }
4861 keys = Object.keys(a2);
4862 length = keys.length;
4863 if (length !== Object.keys(b2).length) {
4864 return false;
4865 }
4866 for (i2 = length; i2-- !== 0; ) {
4867 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
4868 return false;
4869 }
4870 }
4871 for (i2 = length; i2-- !== 0; ) {
4872 const key = keys[i2];
4873 if (key === "_owner" && a2.$$typeof) {
4874 continue;
4875 }
4876 if (!deepEqual(a2[key], b2[key])) {
4877 return false;
4878 }
4879 }
4880 return true;
4881 }
4882 return a2 !== a2 && b2 !== b2;
4883 }
4884 function getDPR(element) {
4885 if (typeof window === "undefined") {
4886 return 1;
4887 }
4888 const win = element.ownerDocument.defaultView || window;
4889 return win.devicePixelRatio || 1;
4890 }
4891 function roundByDPR(element, value) {
4892 const dpr = getDPR(element);
4893 return Math.round(value * dpr) / dpr;
4894 }
4895 function useLatestRef(value) {
4896 const ref = React19.useRef(value);
4897 index(() => {
4898 ref.current = value;
4899 });
4900 return ref;
4901 }
4902 function useFloating(options) {
4903 if (options === void 0) {
4904 options = {};
4905 }
4906 const {
4907 placement = "bottom",
4908 strategy = "absolute",
4909 middleware = [],
4910 platform: platform3,
4911 elements: {
4912 reference: externalReference,
4913 floating: externalFloating
4914 } = {},
4915 transform = true,
4916 whileElementsMounted,
4917 open
4918 } = options;
4919 const [data, setData] = React19.useState({
4920 x: 0,
4921 y: 0,
4922 strategy,
4923 placement,
4924 middlewareData: {},
4925 isPositioned: false
4926 });
4927 const [latestMiddleware, setLatestMiddleware] = React19.useState(middleware);
4928 if (!deepEqual(latestMiddleware, middleware)) {
4929 setLatestMiddleware(middleware);
4930 }
4931 const [_reference, _setReference] = React19.useState(null);
4932 const [_floating, _setFloating] = React19.useState(null);
4933 const setReference = React19.useCallback((node) => {
4934 if (node !== referenceRef.current) {
4935 referenceRef.current = node;
4936 _setReference(node);
4937 }
4938 }, []);
4939 const setFloating = React19.useCallback((node) => {
4940 if (node !== floatingRef.current) {
4941 floatingRef.current = node;
4942 _setFloating(node);
4943 }
4944 }, []);
4945 const referenceEl = externalReference || _reference;
4946 const floatingEl = externalFloating || _floating;
4947 const referenceRef = React19.useRef(null);
4948 const floatingRef = React19.useRef(null);
4949 const dataRef = React19.useRef(data);
4950 const hasWhileElementsMounted = whileElementsMounted != null;
4951 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
4952 const platformRef = useLatestRef(platform3);
4953 const openRef = useLatestRef(open);
4954 const update2 = React19.useCallback(() => {
4955 if (!referenceRef.current || !floatingRef.current) {
4956 return;
4957 }
4958 const config = {
4959 placement,
4960 strategy,
4961 middleware: latestMiddleware
4962 };
4963 if (platformRef.current) {
4964 config.platform = platformRef.current;
4965 }
4966 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
4967 const fullData = {
4968 ...data2,
4969 // The floating element's position may be recomputed while it's closed
4970 // but still mounted (such as when transitioning out). To ensure
4971 // `isPositioned` will be `false` initially on the next open, avoid
4972 // setting it to `true` when `open === false` (must be specified).
4973 isPositioned: openRef.current !== false
4974 };
4975 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
4976 dataRef.current = fullData;
4977 ReactDOM3.flushSync(() => {
4978 setData(fullData);
4979 });
4980 }
4981 });
4982 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
4983 index(() => {
4984 if (open === false && dataRef.current.isPositioned) {
4985 dataRef.current.isPositioned = false;
4986 setData((data2) => ({
4987 ...data2,
4988 isPositioned: false
4989 }));
4990 }
4991 }, [open]);
4992 const isMountedRef = React19.useRef(false);
4993 index(() => {
4994 isMountedRef.current = true;
4995 return () => {
4996 isMountedRef.current = false;
4997 };
4998 }, []);
4999 index(() => {
5000 if (referenceEl) referenceRef.current = referenceEl;
5001 if (floatingEl) floatingRef.current = floatingEl;
5002 if (referenceEl && floatingEl) {
5003 if (whileElementsMountedRef.current) {
5004 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
5005 }
5006 update2();
5007 }
5008 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
5009 const refs = React19.useMemo(() => ({
5010 reference: referenceRef,
5011 floating: floatingRef,
5012 setReference,
5013 setFloating
5014 }), [setReference, setFloating]);
5015 const elements = React19.useMemo(() => ({
5016 reference: referenceEl,
5017 floating: floatingEl
5018 }), [referenceEl, floatingEl]);
5019 const floatingStyles = React19.useMemo(() => {
5020 const initialStyles = {
5021 position: strategy,
5022 left: 0,
5023 top: 0
5024 };
5025 if (!elements.floating) {
5026 return initialStyles;
5027 }
5028 const x2 = roundByDPR(elements.floating, data.x);
5029 const y2 = roundByDPR(elements.floating, data.y);
5030 if (transform) {
5031 return {
5032 ...initialStyles,
5033 transform: "translate(" + x2 + "px, " + y2 + "px)",
5034 ...getDPR(elements.floating) >= 1.5 && {
5035 willChange: "transform"
5036 }
5037 };
5038 }
5039 return {
5040 position: strategy,
5041 left: x2,
5042 top: y2
5043 };
5044 }, [strategy, transform, elements.floating, data.x, data.y]);
5045 return React19.useMemo(() => ({
5046 ...data,
5047 update: update2,
5048 refs,
5049 elements,
5050 floatingStyles
5051 }), [data, update2, refs, elements, floatingStyles]);
5052 }
5053 var offset3 = (options, deps) => {
5054 const result = offset2(options);
5055 return {
5056 name: result.name,
5057 fn: result.fn,
5058 options: [options, deps]
5059 };
5060 };
5061 var shift3 = (options, deps) => {
5062 const result = shift2(options);
5063 return {
5064 name: result.name,
5065 fn: result.fn,
5066 options: [options, deps]
5067 };
5068 };
5069 var limitShift3 = (options, deps) => {
5070 const result = limitShift2(options);
5071 return {
5072 fn: result.fn,
5073 options: [options, deps]
5074 };
5075 };
5076 var flip3 = (options, deps) => {
5077 const result = flip2(options);
5078 return {
5079 name: result.name,
5080 fn: result.fn,
5081 options: [options, deps]
5082 };
5083 };
5084 var size3 = (options, deps) => {
5085 const result = size2(options);
5086 return {
5087 name: result.name,
5088 fn: result.fn,
5089 options: [options, deps]
5090 };
5091 };
5092 var hide3 = (options, deps) => {
5093 const result = hide2(options);
5094 return {
5095 name: result.name,
5096 fn: result.fn,
5097 options: [options, deps]
5098 };
5099 };
5100
5101 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs
5102 var React24 = __toESM(require_react(), 1);
5103 var ReactDOM4 = __toESM(require_react_dom(), 1);
5104
5105 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs
5106 var React23 = __toESM(require_react(), 1);
5107
5108 // node_modules/@base-ui/utils/store/createSelector.mjs
5109 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
5110 if (other.length > 0) {
5111 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
5112 }
5113 let selector2;
5114 if (a2 && b2 && c2 && d2 && e2 && f2) {
5115 selector2 = (state, a1, a22, a3) => {
5116 const va = a2(state, a1, a22, a3);
5117 const vb = b2(state, a1, a22, a3);
5118 const vc = c2(state, a1, a22, a3);
5119 const vd = d2(state, a1, a22, a3);
5120 const ve = e2(state, a1, a22, a3);
5121 return f2(va, vb, vc, vd, ve, a1, a22, a3);
5122 };
5123 } else if (a2 && b2 && c2 && d2 && e2) {
5124 selector2 = (state, a1, a22, a3) => {
5125 const va = a2(state, a1, a22, a3);
5126 const vb = b2(state, a1, a22, a3);
5127 const vc = c2(state, a1, a22, a3);
5128 const vd = d2(state, a1, a22, a3);
5129 return e2(va, vb, vc, vd, a1, a22, a3);
5130 };
5131 } else if (a2 && b2 && c2 && d2) {
5132 selector2 = (state, a1, a22, a3) => {
5133 const va = a2(state, a1, a22, a3);
5134 const vb = b2(state, a1, a22, a3);
5135 const vc = c2(state, a1, a22, a3);
5136 return d2(va, vb, vc, a1, a22, a3);
5137 };
5138 } else if (a2 && b2 && c2) {
5139 selector2 = (state, a1, a22, a3) => {
5140 const va = a2(state, a1, a22, a3);
5141 const vb = b2(state, a1, a22, a3);
5142 return c2(va, vb, a1, a22, a3);
5143 };
5144 } else if (a2 && b2) {
5145 selector2 = (state, a1, a22, a3) => {
5146 const va = a2(state, a1, a22, a3);
5147 return b2(va, a1, a22, a3);
5148 };
5149 } else if (a2) {
5150 selector2 = a2;
5151 } else {
5152 throw (
5153 /* minify-error-disabled */
5154 new Error("Missing arguments")
5155 );
5156 }
5157 return selector2;
5158 };
5159
5160 // node_modules/@base-ui/utils/store/useStore.mjs
5161 var React21 = __toESM(require_react(), 1);
5162 var import_shim = __toESM(require_shim(), 1);
5163 var import_with_selector = __toESM(require_with_selector(), 1);
5164
5165 // node_modules/@base-ui/utils/fastHooks.mjs
5166 var React20 = __toESM(require_react(), 1);
5167 var hooks = [];
5168 var currentInstance = void 0;
5169 function getInstance() {
5170 return currentInstance;
5171 }
5172 function register(hook) {
5173 hooks.push(hook);
5174 }
5175 function fastComponent(fn) {
5176 const FastComponent = (props, forwardedRef) => {
5177 const instance = useRefWithInit(createInstance).current;
5178 let result;
5179 try {
5180 currentInstance = instance;
5181 for (const hook of hooks) {
5182 hook.before(instance);
5183 }
5184 result = fn(props, forwardedRef);
5185 for (const hook of hooks) {
5186 hook.after(instance);
5187 }
5188 instance.didInitialize = true;
5189 } finally {
5190 currentInstance = void 0;
5191 }
5192 return result;
5193 };
5194 FastComponent.displayName = fn.displayName || fn.name;
5195 return FastComponent;
5196 }
5197 function fastComponentRef(fn) {
5198 return /* @__PURE__ */ React20.forwardRef(fastComponent(fn));
5199 }
5200 function createInstance() {
5201 return {
5202 didInitialize: false
5203 };
5204 }
5205
5206 // node_modules/@base-ui/utils/store/useStore.mjs
5207 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
5208 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
5209 function useStore(store, selector2, a1, a2, a3) {
5210 return useStoreImplementation(store, selector2, a1, a2, a3);
5211 }
5212 function useStoreR19(store, selector2, a1, a2, a3) {
5213 const getSelection = React21.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
5214 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
5215 }
5216 register({
5217 before(instance) {
5218 instance.syncIndex = 0;
5219 if (!instance.didInitialize) {
5220 instance.syncTick = 1;
5221 instance.syncHooks = [];
5222 instance.didChangeStore = true;
5223 instance.getSnapshot = () => {
5224 let didChange2 = false;
5225 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
5226 const hook = instance.syncHooks[i2];
5227 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
5228 if (!Object.is(hook.value, value)) {
5229 didChange2 = true;
5230 hook.value = value;
5231 }
5232 }
5233 if (didChange2) {
5234 instance.syncTick += 1;
5235 }
5236 return instance.syncTick;
5237 };
5238 }
5239 },
5240 after(instance) {
5241 if (instance.syncHooks.length > 0) {
5242 if (instance.didChangeStore) {
5243 instance.didChangeStore = false;
5244 instance.subscribe = (onStoreChange) => {
5245 const stores = /* @__PURE__ */ new Set();
5246 for (const hook of instance.syncHooks) {
5247 stores.add(hook.store);
5248 }
5249 const unsubscribes = [];
5250 for (const store of stores) {
5251 unsubscribes.push(store.subscribe(onStoreChange));
5252 }
5253 return () => {
5254 for (const unsubscribe of unsubscribes) {
5255 unsubscribe();
5256 }
5257 };
5258 };
5259 }
5260 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
5261 }
5262 }
5263 });
5264 function useStoreFast(store, selector2, a1, a2, a3) {
5265 const instance = getInstance();
5266 if (!instance) {
5267 return useStoreR19(store, selector2, a1, a2, a3);
5268 }
5269 const index2 = instance.syncIndex;
5270 instance.syncIndex += 1;
5271 let hook;
5272 if (!instance.didInitialize) {
5273 hook = {
5274 store,
5275 selector: selector2,
5276 a1,
5277 a2,
5278 a3,
5279 value: selector2(store.getSnapshot(), a1, a2, a3)
5280 };
5281 instance.syncHooks.push(hook);
5282 } else {
5283 hook = instance.syncHooks[index2];
5284 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
5285 if (hook.store !== store) {
5286 instance.didChangeStore = true;
5287 }
5288 hook.store = store;
5289 hook.selector = selector2;
5290 hook.a1 = a1;
5291 hook.a2 = a2;
5292 hook.a3 = a3;
5293 hook.value = selector2(store.getSnapshot(), a1, a2, a3);
5294 }
5295 }
5296 return hook.value;
5297 }
5298 function useStoreLegacy(store, selector2, a1, a2, a3) {
5299 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
5300 }
5301
5302 // node_modules/@base-ui/utils/store/Store.mjs
5303 var Store = class {
5304 /**
5305 * The current state of the store.
5306 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
5307 * 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).
5308 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
5309 *
5310 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
5311 */
5312 // Internal state to handle recursive `setState()` calls
5313 constructor(state) {
5314 this.state = state;
5315 this.listeners = /* @__PURE__ */ new Set();
5316 this.updateTick = 0;
5317 }
5318 /**
5319 * Registers a listener that will be called whenever the store's state changes.
5320 *
5321 * @param fn The listener function to be called on state changes.
5322 * @returns A function to unsubscribe the listener.
5323 */
5324 subscribe = (fn) => {
5325 this.listeners.add(fn);
5326 return () => {
5327 this.listeners.delete(fn);
5328 };
5329 };
5330 /**
5331 * Returns the current state of the store.
5332 */
5333 getSnapshot = () => {
5334 return this.state;
5335 };
5336 /**
5337 * Updates the entire store's state and notifies all registered listeners.
5338 *
5339 * @param newState The new state to set for the store.
5340 */
5341 setState(newState) {
5342 if (this.state === newState) {
5343 return;
5344 }
5345 this.state = newState;
5346 this.updateTick += 1;
5347 const currentTick = this.updateTick;
5348 for (const listener of this.listeners) {
5349 if (currentTick !== this.updateTick) {
5350 return;
5351 }
5352 listener(newState);
5353 }
5354 }
5355 /**
5356 * Merges the provided changes into the current state and notifies listeners if there are changes.
5357 *
5358 * @param changes An object containing the changes to apply to the current state.
5359 */
5360 update(changes) {
5361 for (const key in changes) {
5362 if (!Object.is(this.state[key], changes[key])) {
5363 this.setState({
5364 ...this.state,
5365 ...changes
5366 });
5367 return;
5368 }
5369 }
5370 }
5371 /**
5372 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
5373 *
5374 * @param key The key in the store's state to update.
5375 * @param value The new value to set for the specified key.
5376 */
5377 set(key, value) {
5378 if (!Object.is(this.state[key], value)) {
5379 this.setState({
5380 ...this.state,
5381 [key]: value
5382 });
5383 }
5384 }
5385 /**
5386 * Gives the state a new reference and updates all registered listeners.
5387 */
5388 notifyAll() {
5389 const newState = {
5390 ...this.state
5391 };
5392 this.setState(newState);
5393 }
5394 use(selector2, a1, a2, a3) {
5395 return useStore(this, selector2, a1, a2, a3);
5396 }
5397 };
5398
5399 // node_modules/@base-ui/utils/store/ReactStore.mjs
5400 var React22 = __toESM(require_react(), 1);
5401 var ReactStore = class extends Store {
5402 /**
5403 * Creates a new ReactStore instance.
5404 *
5405 * @param state Initial state of the store.
5406 * @param context Non-reactive context values.
5407 * @param selectors Optional selectors for use with `useState`.
5408 */
5409 constructor(state, context = {}, selectors3) {
5410 super(state);
5411 this.context = context;
5412 this.selectors = selectors3;
5413 }
5414 /**
5415 * Non-reactive values such as refs, callbacks, etc.
5416 */
5417 /**
5418 * Synchronizes a single external value into the store.
5419 *
5420 * Note that the while the value in `state` is updated immediately, the value returned
5421 * by `useState` is updated before the next render (similarly to React's `useState`).
5422 */
5423 useSyncedValue(key, value) {
5424 React22.useDebugValue(key);
5425 const store = this;
5426 useIsoLayoutEffect(() => {
5427 if (store.state[key] !== value) {
5428 store.set(key, value);
5429 }
5430 }, [store, key, value]);
5431 }
5432 /**
5433 * Synchronizes a single external value into the store and
5434 * cleans it up (sets to `undefined`) on unmount.
5435 *
5436 * Note that the while the value in `state` is updated immediately, the value returned
5437 * by `useState` is updated before the next render (similarly to React's `useState`).
5438 */
5439 useSyncedValueWithCleanup(key, value) {
5440 const store = this;
5441 useIsoLayoutEffect(() => {
5442 if (store.state[key] !== value) {
5443 store.set(key, value);
5444 }
5445 return () => {
5446 store.set(key, void 0);
5447 };
5448 }, [store, key, value]);
5449 }
5450 /**
5451 * Synchronizes multiple external values into the store.
5452 *
5453 * Note that the while the values in `state` are updated immediately, the values returned
5454 * by `useState` are updated before the next render (similarly to React's `useState`).
5455 */
5456 useSyncedValues(statePart) {
5457 const store = this;
5458 if (true) {
5459 React22.useDebugValue(statePart, (p2) => Object.keys(p2));
5460 const keys = React22.useRef(Object.keys(statePart)).current;
5461 const nextKeys = Object.keys(statePart);
5462 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
5463 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
5464 }
5465 }
5466 const dependencies = Object.values(statePart);
5467 useIsoLayoutEffect(() => {
5468 store.update(statePart);
5469 }, [store, ...dependencies]);
5470 }
5471 /**
5472 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
5473 * is non-undefined, the store's state at `key` is updated to match `controlled`.
5474 */
5475 useControlledProp(key, controlled) {
5476 React22.useDebugValue(key);
5477 const store = this;
5478 const isControlled = controlled !== void 0;
5479 useIsoLayoutEffect(() => {
5480 if (isControlled && !Object.is(store.state[key], controlled)) {
5481 store.setState({
5482 ...store.state,
5483 [key]: controlled
5484 });
5485 }
5486 }, [store, key, controlled, isControlled]);
5487 if (true) {
5488 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
5489 if (!cache.has(key)) {
5490 cache.set(key, isControlled);
5491 }
5492 const previouslyControlled = cache.get(key);
5493 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
5494 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).`);
5495 }
5496 }
5497 }
5498 /** Gets the current value from the store using a selector with the provided key.
5499 *
5500 * @param key Key of the selector to use.
5501 */
5502 select(key, a1, a2, a3) {
5503 const selector2 = this.selectors[key];
5504 return selector2(this.state, a1, a2, a3);
5505 }
5506 /**
5507 * Returns a value from the store's state using a selector function.
5508 * Used to subscribe to specific parts of the state.
5509 * This methods causes a rerender whenever the selected state changes.
5510 *
5511 * @param key Key of the selector to use.
5512 */
5513 useState(key, a1, a2, a3) {
5514 React22.useDebugValue(key);
5515 return useStore(this, this.selectors[key], a1, a2, a3);
5516 }
5517 /**
5518 * Wraps a function with `useStableCallback` to ensure it has a stable reference
5519 * and assigns it to the context.
5520 *
5521 * @param key Key of the event callback. Must be a function in the context.
5522 * @param fn Function to assign.
5523 */
5524 useContextCallback(key, fn) {
5525 React22.useDebugValue(key);
5526 const stableFunction = useStableCallback(fn ?? NOOP);
5527 this.context[key] = stableFunction;
5528 }
5529 /**
5530 * Returns a stable setter function for a specific key in the store's state.
5531 * It's commonly used to pass as a ref callback to React elements.
5532 *
5533 * @param key Key of the state to set.
5534 */
5535 useStateSetter(key) {
5536 const ref = React22.useRef(void 0);
5537 if (ref.current === void 0) {
5538 ref.current = (value) => {
5539 this.set(key, value);
5540 };
5541 }
5542 return ref.current;
5543 }
5544 /**
5545 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
5546 *
5547 * @param key Key of the selector to observe.
5548 * @param listener Listener function called when the selector result changes.
5549 */
5550 observe(selector2, listener) {
5551 let selectFn;
5552 if (typeof selector2 === "function") {
5553 selectFn = selector2;
5554 } else {
5555 selectFn = this.selectors[selector2];
5556 }
5557 let prevValue = selectFn(this.state);
5558 listener(prevValue, prevValue, this);
5559 return this.subscribe((nextState) => {
5560 const nextValue = selectFn(nextState);
5561 if (!Object.is(prevValue, nextValue)) {
5562 const oldValue = prevValue;
5563 prevValue = nextValue;
5564 listener(nextValue, oldValue, this);
5565 }
5566 });
5567 }
5568 };
5569
5570 // node_modules/@base-ui/react/floating-ui-react/components/FloatingRootStore.mjs
5571 var selectors = {
5572 open: createSelector((state) => state.open),
5573 transitionStatus: createSelector((state) => state.transitionStatus),
5574 domReferenceElement: createSelector((state) => state.domReferenceElement),
5575 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
5576 floatingElement: createSelector((state) => state.floatingElement),
5577 floatingId: createSelector((state) => state.floatingId)
5578 };
5579 var FloatingRootStore = class extends ReactStore {
5580 constructor(options) {
5581 const {
5582 syncOnly,
5583 nested,
5584 onOpenChange,
5585 triggerElements,
5586 ...initialState
5587 } = options;
5588 super({
5589 ...initialState,
5590 positionReference: initialState.referenceElement,
5591 domReferenceElement: initialState.referenceElement
5592 }, {
5593 onOpenChange,
5594 dataRef: {
5595 current: {}
5596 },
5597 events: createEventEmitter(),
5598 nested,
5599 triggerElements
5600 }, selectors);
5601 this.syncOnly = syncOnly;
5602 }
5603 /**
5604 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
5605 */
5606 syncOpenEvent = (newOpen, event) => {
5607 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
5608 // click events to upgrade a hover-open.
5609 event != null && isClickLikeEvent(event)) {
5610 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
5611 }
5612 };
5613 /**
5614 * Runs the root-owned side effects for an open state change.
5615 */
5616 dispatchOpenChange = (newOpen, eventDetails) => {
5617 this.syncOpenEvent(newOpen, eventDetails.event);
5618 const details = {
5619 open: newOpen,
5620 reason: eventDetails.reason,
5621 nativeEvent: eventDetails.event,
5622 nested: this.context.nested,
5623 triggerElement: eventDetails.trigger
5624 };
5625 this.context.events.emit("openchange", details);
5626 };
5627 /**
5628 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
5629 *
5630 * @param newOpen The new open state.
5631 * @param eventDetails Details about the event that triggered the open state change.
5632 */
5633 setOpen = (newOpen, eventDetails) => {
5634 if (this.syncOnly) {
5635 this.context.onOpenChange?.(newOpen, eventDetails);
5636 return;
5637 }
5638 this.dispatchOpenChange(newOpen, eventDetails);
5639 this.context.onOpenChange?.(newOpen, eventDetails);
5640 };
5641 };
5642
5643 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs
5644 function useSyncedFloatingRootContext(options) {
5645 const {
5646 popupStore,
5647 treatPopupAsFloatingElement = false,
5648 floatingRootContext: floatingRootContextProp,
5649 floatingId,
5650 nested,
5651 onOpenChange
5652 } = options;
5653 const open = popupStore.useState("open");
5654 const referenceElement = popupStore.useState("activeTriggerElement");
5655 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
5656 const triggerElements = popupStore.context.triggerElements;
5657 const handleOpenChange = onOpenChange;
5658 const internalStoreRef = React23.useRef(null);
5659 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
5660 internalStoreRef.current = new FloatingRootStore({
5661 open,
5662 transitionStatus: void 0,
5663 referenceElement,
5664 floatingElement,
5665 triggerElements,
5666 onOpenChange: handleOpenChange,
5667 floatingId,
5668 syncOnly: true,
5669 nested
5670 });
5671 }
5672 const store = floatingRootContextProp ?? internalStoreRef.current;
5673 popupStore.useSyncedValue("floatingId", floatingId);
5674 useIsoLayoutEffect(() => {
5675 const valuesToSync = {
5676 open,
5677 floatingId,
5678 referenceElement,
5679 floatingElement
5680 };
5681 if (isElement(referenceElement)) {
5682 valuesToSync.domReferenceElement = referenceElement;
5683 }
5684 if (store.state.positionReference === store.state.referenceElement) {
5685 valuesToSync.positionReference = referenceElement;
5686 }
5687 store.update(valuesToSync);
5688 }, [open, floatingId, referenceElement, floatingElement, store]);
5689 store.context.onOpenChange = handleOpenChange;
5690 store.context.nested = nested;
5691 return store;
5692 }
5693
5694 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs
5695 var FOCUSABLE_POPUP_PROPS = {
5696 tabIndex: -1,
5697 [FOCUSABLE_ATTRIBUTE]: ""
5698 };
5699 function usePopupStore(externalStore, createStore2, treatPopupAsFloatingElement = false) {
5700 const floatingId = useId();
5701 const nested = useFloatingParentNodeId() != null;
5702 const internalStoreRef = React24.useRef(null);
5703 if (externalStore === void 0 && internalStoreRef.current === null) {
5704 internalStoreRef.current = createStore2(floatingId, nested);
5705 }
5706 const store = externalStore ?? internalStoreRef.current;
5707 useSyncedFloatingRootContext({
5708 popupStore: store,
5709 treatPopupAsFloatingElement,
5710 floatingRootContext: store.state.floatingRootContext,
5711 floatingId,
5712 nested,
5713 onOpenChange: store.setOpen
5714 });
5715 return {
5716 store,
5717 internalStore: internalStoreRef.current
5718 };
5719 }
5720 function useTriggerRegistration(id, store) {
5721 const registeredElementIdRef = React24.useRef(null);
5722 const registeredElementRef = React24.useRef(null);
5723 return React24.useCallback((element) => {
5724 if (id === void 0) {
5725 return;
5726 }
5727 let shouldSyncTriggerCount = false;
5728 if (registeredElementIdRef.current !== null) {
5729 const registeredId = registeredElementIdRef.current;
5730 const registeredElement = registeredElementRef.current;
5731 const currentElement = store.context.triggerElements.getById(registeredId);
5732 if (registeredElement && currentElement === registeredElement) {
5733 store.context.triggerElements.delete(registeredId);
5734 shouldSyncTriggerCount = true;
5735 }
5736 registeredElementIdRef.current = null;
5737 registeredElementRef.current = null;
5738 }
5739 if (element !== null) {
5740 registeredElementIdRef.current = id;
5741 registeredElementRef.current = element;
5742 store.context.triggerElements.add(id, element);
5743 shouldSyncTriggerCount = true;
5744 }
5745 if (shouldSyncTriggerCount) {
5746 const triggerCount = store.context.triggerElements.size;
5747 if (store.select("open") && store.state.triggerCount !== triggerCount) {
5748 store.set("triggerCount", triggerCount);
5749 }
5750 }
5751 }, [store, id]);
5752 }
5753 function setPopupOpenState(state, open, trigger, preventUnmountOnClose = false) {
5754 if (open) {
5755 state.preventUnmountingOnClose = false;
5756 } else if (preventUnmountOnClose) {
5757 state.preventUnmountingOnClose = true;
5758 }
5759 const triggerId = trigger?.id ?? null;
5760 if (triggerId || open) {
5761 state.activeTriggerId = triggerId;
5762 state.activeTriggerElement = trigger ?? null;
5763 }
5764 }
5765 function attachPreventUnmountOnClose(eventDetails) {
5766 let preventUnmountOnClose = false;
5767 eventDetails.preventUnmountOnClose = () => {
5768 preventUnmountOnClose = true;
5769 };
5770 return () => preventUnmountOnClose;
5771 }
5772 function applyPopupOpenChange(store, nextOpen, eventDetails, options = {}) {
5773 const reason = eventDetails.reason;
5774 const isHover = reason === reason_parts_exports.triggerHover;
5775 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
5776 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
5777 const shouldPreventUnmountOnClose = attachPreventUnmountOnClose(eventDetails);
5778 store.context.onOpenChange?.(nextOpen, eventDetails);
5779 if (eventDetails.isCanceled) {
5780 return;
5781 }
5782 options.onBeforeDispatch?.();
5783 store.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
5784 const changeState = () => {
5785 const updatedState = {
5786 ...options.extraState,
5787 open: nextOpen
5788 };
5789 if (isFocusOpen) {
5790 updatedState.instantType = "focus";
5791 } else if (isDismissClose) {
5792 updatedState.instantType = "dismiss";
5793 } else if (isHover) {
5794 updatedState.instantType = void 0;
5795 }
5796 setPopupOpenState(updatedState, nextOpen, eventDetails.trigger, shouldPreventUnmountOnClose());
5797 store.update(updatedState);
5798 };
5799 if (isHover) {
5800 ReactDOM4.flushSync(changeState);
5801 } else {
5802 changeState();
5803 }
5804 }
5805 function useInitialOpenSync(store, openProp, defaultOpen, defaultTriggerId) {
5806 useOnFirstRender(() => {
5807 if (openProp === void 0 && store.state.open === false && defaultOpen) {
5808 store.state = {
5809 ...store.state,
5810 open: true,
5811 activeTriggerId: defaultTriggerId,
5812 preventUnmountingOnClose: false
5813 };
5814 }
5815 });
5816 }
5817 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
5818 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
5819 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
5820 const registerTrigger = useStableCallback((element) => {
5821 baseRegisterTrigger(element);
5822 if (!element) {
5823 return;
5824 }
5825 const open = store.select("open");
5826 const activeTriggerId = store.select("activeTriggerId");
5827 if (activeTriggerId === triggerId) {
5828 store.update({
5829 activeTriggerElement: element,
5830 ...open ? stateUpdates : null
5831 });
5832 return;
5833 }
5834 if (activeTriggerId == null && open) {
5835 store.update({
5836 activeTriggerId: triggerId,
5837 activeTriggerElement: element,
5838 ...stateUpdates
5839 });
5840 }
5841 });
5842 useIsoLayoutEffect(() => {
5843 if (isMountedByThisTrigger) {
5844 store.update({
5845 activeTriggerElement: triggerElementRef.current,
5846 ...stateUpdates
5847 });
5848 }
5849 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
5850 return {
5851 registerTrigger,
5852 isMountedByThisTrigger
5853 };
5854 }
5855 function useImplicitActiveTrigger(store, options = {}) {
5856 const {
5857 closeOnActiveTriggerUnmount = false
5858 } = options;
5859 const open = store.useState("open");
5860 const reactiveTriggerCount = store.useState("triggerCount");
5861 useIsoLayoutEffect(() => {
5862 if (!open) {
5863 if (store.state.triggerCount !== 0) {
5864 store.set("triggerCount", 0);
5865 }
5866 return;
5867 }
5868 const triggerCount = store.context.triggerElements.size;
5869 const stateUpdates = {};
5870 if (store.state.triggerCount !== triggerCount) {
5871 stateUpdates.triggerCount = triggerCount;
5872 }
5873 const activeTriggerId = store.select("activeTriggerId");
5874 let lostActiveTriggerId = null;
5875 if (activeTriggerId) {
5876 const activeTriggerElement = store.context.triggerElements.getById(activeTriggerId);
5877 if (!activeTriggerElement) {
5878 lostActiveTriggerId = activeTriggerId;
5879 } else if (activeTriggerElement !== store.state.activeTriggerElement) {
5880 stateUpdates.activeTriggerElement = activeTriggerElement;
5881 }
5882 }
5883 if (!lostActiveTriggerId && !activeTriggerId && triggerCount === 1) {
5884 const iteratorResult = store.context.triggerElements.entries().next();
5885 if (!iteratorResult.done) {
5886 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
5887 stateUpdates.activeTriggerId = implicitTriggerId;
5888 stateUpdates.activeTriggerElement = implicitTriggerElement;
5889 }
5890 }
5891 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0 || stateUpdates.activeTriggerElement !== void 0) {
5892 store.update(stateUpdates);
5893 }
5894 if (lostActiveTriggerId) {
5895 if (closeOnActiveTriggerUnmount) {
5896 queueMicrotask(() => {
5897 if (store.select("open") && store.select("activeTriggerId") === lostActiveTriggerId && !store.context.triggerElements.getById(lostActiveTriggerId)) {
5898 const eventDetails = createChangeEventDetails(reason_parts_exports.none);
5899 store.setOpen(false, eventDetails);
5900 if (!eventDetails.isCanceled) {
5901 store.update({
5902 activeTriggerId: null,
5903 activeTriggerElement: null
5904 });
5905 }
5906 }
5907 });
5908 }
5909 }
5910 }, [open, store, reactiveTriggerCount, closeOnActiveTriggerUnmount]);
5911 }
5912 function useOpenStateTransitions(open, store, onUnmount) {
5913 const {
5914 mounted,
5915 setMounted,
5916 transitionStatus
5917 } = useTransitionStatus(open);
5918 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
5919 const syncedPreventUnmountingOnClose = open ? false : preventUnmountingOnClose;
5920 store.useSyncedValues({
5921 mounted,
5922 transitionStatus,
5923 preventUnmountingOnClose: syncedPreventUnmountingOnClose
5924 });
5925 const forceUnmount = useStableCallback(() => {
5926 setMounted(false);
5927 store.update({
5928 activeTriggerId: null,
5929 activeTriggerElement: null,
5930 mounted: false,
5931 preventUnmountingOnClose: false
5932 });
5933 onUnmount?.();
5934 store.context.onOpenChangeComplete?.(false);
5935 });
5936 useOpenChangeComplete({
5937 enabled: mounted && !open && !syncedPreventUnmountingOnClose,
5938 open,
5939 ref: store.context.popupRef,
5940 onComplete() {
5941 if (!open) {
5942 forceUnmount();
5943 }
5944 }
5945 });
5946 return {
5947 forceUnmount,
5948 transitionStatus
5949 };
5950 }
5951 function usePopupInteractionProps(store, statePart) {
5952 store.useSyncedValues(statePart);
5953 useIsoLayoutEffect(() => () => {
5954 store.update({
5955 activeTriggerProps: EMPTY_OBJECT,
5956 inactiveTriggerProps: EMPTY_OBJECT,
5957 popupProps: EMPTY_OBJECT
5958 });
5959 }, [store]);
5960 }
5961
5962 // node_modules/@base-ui/react/utils/popups/popupTriggerMap.mjs
5963 var PopupTriggerMap = class {
5964 constructor() {
5965 this.elementsSet = /* @__PURE__ */ new Set();
5966 this.idMap = /* @__PURE__ */ new Map();
5967 }
5968 /**
5969 * Adds a trigger element with the given ID.
5970 *
5971 * Note: The provided element is assumed to not be registered under multiple IDs.
5972 */
5973 add(id, element) {
5974 const existingElement = this.idMap.get(id);
5975 if (existingElement === element) {
5976 return;
5977 }
5978 if (existingElement !== void 0) {
5979 this.elementsSet.delete(existingElement);
5980 }
5981 this.elementsSet.add(element);
5982 this.idMap.set(id, element);
5983 if (true) {
5984 if (this.elementsSet.size !== this.idMap.size) {
5985 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
5986 }
5987 }
5988 }
5989 /**
5990 * Removes the trigger element with the given ID.
5991 */
5992 delete(id) {
5993 const element = this.idMap.get(id);
5994 if (element) {
5995 this.elementsSet.delete(element);
5996 this.idMap.delete(id);
5997 }
5998 }
5999 /**
6000 * Whether the given element is registered as a trigger.
6001 */
6002 hasElement(element) {
6003 return this.elementsSet.has(element);
6004 }
6005 /**
6006 * Whether there is a registered trigger element matching the given predicate.
6007 */
6008 hasMatchingElement(predicate) {
6009 for (const element of this.elementsSet) {
6010 if (predicate(element)) {
6011 return true;
6012 }
6013 }
6014 return false;
6015 }
6016 /**
6017 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
6018 */
6019 getById(id) {
6020 return this.idMap.get(id);
6021 }
6022 /**
6023 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
6024 */
6025 entries() {
6026 return this.idMap.entries();
6027 }
6028 /**
6029 * Returns an iterable of all registered trigger elements.
6030 */
6031 elements() {
6032 return this.elementsSet.values();
6033 }
6034 /**
6035 * Returns the number of registered trigger elements.
6036 */
6037 get size() {
6038 return this.idMap.size;
6039 }
6040 };
6041
6042 // node_modules/@base-ui/react/floating-ui-react/utils/getEmptyRootContext.mjs
6043 function getEmptyRootContext() {
6044 return new FloatingRootStore({
6045 open: false,
6046 transitionStatus: void 0,
6047 floatingElement: null,
6048 referenceElement: null,
6049 triggerElements: new PopupTriggerMap(),
6050 floatingId: void 0,
6051 syncOnly: false,
6052 nested: false,
6053 onOpenChange: void 0
6054 });
6055 }
6056
6057 // node_modules/@base-ui/react/utils/popups/store.mjs
6058 function createInitialPopupStoreState() {
6059 return {
6060 open: false,
6061 openProp: void 0,
6062 mounted: false,
6063 transitionStatus: void 0,
6064 floatingRootContext: getEmptyRootContext(),
6065 floatingId: void 0,
6066 triggerCount: 0,
6067 preventUnmountingOnClose: false,
6068 payload: void 0,
6069 activeTriggerId: null,
6070 activeTriggerElement: null,
6071 triggerIdProp: void 0,
6072 popupElement: null,
6073 positionerElement: null,
6074 activeTriggerProps: EMPTY_OBJECT,
6075 inactiveTriggerProps: EMPTY_OBJECT,
6076 popupProps: EMPTY_OBJECT
6077 };
6078 }
6079 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) {
6080 return new FloatingRootStore({
6081 open: false,
6082 transitionStatus: void 0,
6083 floatingElement: null,
6084 referenceElement: null,
6085 triggerElements,
6086 floatingId,
6087 syncOnly: true,
6088 nested,
6089 onOpenChange: void 0
6090 });
6091 }
6092 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
6093 var openSelector = createSelector((state) => state.openProp ?? state.open);
6094 var popupIdSelector = createSelector((state) => {
6095 const popupId = state.popupElement?.id ?? state.floatingId;
6096 return popupId || void 0;
6097 });
6098 function triggerOwnsOpenPopup(state, triggerId) {
6099 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
6100 }
6101 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
6102 if (triggerOwnsOpenPopup(state, triggerId)) {
6103 return true;
6104 }
6105 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
6106 }
6107 var popupStoreSelectors = {
6108 open: openSelector,
6109 mounted: createSelector((state) => state.mounted),
6110 transitionStatus: createSelector((state) => state.transitionStatus),
6111 floatingRootContext: createSelector((state) => state.floatingRootContext),
6112 triggerCount: createSelector((state) => state.triggerCount),
6113 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
6114 payload: createSelector((state) => state.payload),
6115 activeTriggerId: activeTriggerIdSelector,
6116 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
6117 popupId: popupIdSelector,
6118 /**
6119 * Whether the trigger with the given ID was used to open the popup.
6120 */
6121 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
6122 /**
6123 * Whether the popup is open and was activated by a trigger with the given ID.
6124 */
6125 isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)),
6126 /**
6127 * Whether the popup is mounted and was activated by a trigger with the given ID.
6128 */
6129 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
6130 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
6131 /**
6132 * Popup id for the trigger that currently owns the open popup.
6133 */
6134 triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0),
6135 popupProps: createSelector((state) => state.popupProps),
6136 popupElement: createSelector((state) => state.popupElement),
6137 positionerElement: createSelector((state) => state.positionerElement)
6138 };
6139
6140 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloatingRootContext.mjs
6141 function useFloatingRootContext(options) {
6142 const {
6143 open = false,
6144 onOpenChange,
6145 elements = {}
6146 } = options;
6147 const floatingId = useId();
6148 const nested = useFloatingParentNodeId() != null;
6149 if (true) {
6150 const optionDomReference = elements.reference;
6151 if (optionDomReference && !isElement(optionDomReference)) {
6152 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
6153 }
6154 }
6155 const store = useRefWithInit(() => new FloatingRootStore({
6156 open,
6157 transitionStatus: void 0,
6158 onOpenChange,
6159 referenceElement: elements.reference ?? null,
6160 floatingElement: elements.floating ?? null,
6161 triggerElements: new PopupTriggerMap(),
6162 floatingId,
6163 syncOnly: false,
6164 nested
6165 })).current;
6166 useIsoLayoutEffect(() => {
6167 const valuesToSync = {
6168 open,
6169 floatingId
6170 };
6171 if (elements.reference !== void 0) {
6172 valuesToSync.referenceElement = elements.reference;
6173 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
6174 }
6175 if (elements.floating !== void 0) {
6176 valuesToSync.floatingElement = elements.floating;
6177 }
6178 store.update(valuesToSync);
6179 }, [open, floatingId, elements.reference, elements.floating, store]);
6180 store.context.onOpenChange = onOpenChange;
6181 store.context.nested = nested;
6182 return store;
6183 }
6184
6185 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs
6186 function useFloating2(options = {}) {
6187 const {
6188 nodeId,
6189 externalTree
6190 } = options;
6191 const internalStore = useFloatingRootContext(options);
6192 const store = options.rootContext || internalStore;
6193 const referenceElement = store.useState("referenceElement");
6194 const floatingElement = store.useState("floatingElement");
6195 const domReferenceElement = store.useState("domReferenceElement");
6196 const open = store.useState("open");
6197 const floatingId = store.useState("floatingId");
6198 const [positionReference, setPositionReferenceRaw] = React25.useState(null);
6199 const [localDomReference, setLocalDomReference] = React25.useState(void 0);
6200 const [localFloatingElement, setLocalFloatingElement] = React25.useState(void 0);
6201 const domReferenceRef = React25.useRef(null);
6202 const tree = useFloatingTree(externalTree);
6203 const storeElements = React25.useMemo(() => ({
6204 reference: referenceElement,
6205 floating: floatingElement,
6206 domReference: domReferenceElement
6207 }), [referenceElement, floatingElement, domReferenceElement]);
6208 const position = useFloating({
6209 ...options,
6210 elements: {
6211 ...storeElements,
6212 ...positionReference && {
6213 reference: positionReference
6214 }
6215 }
6216 });
6217 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
6218 const syncedFloatingElement = localFloatingElement === void 0 ? store.state.floatingElement : localFloatingElement;
6219 store.useSyncedValue("referenceElement", localDomReference ?? null);
6220 store.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement);
6221 store.useSyncedValue("floatingElement", syncedFloatingElement);
6222 const setPositionReference = React25.useCallback((node) => {
6223 const computedPositionReference = isElement(node) ? {
6224 getBoundingClientRect: () => node.getBoundingClientRect(),
6225 getClientRects: () => node.getClientRects(),
6226 contextElement: node
6227 } : node;
6228 setPositionReferenceRaw(computedPositionReference);
6229 position.refs.setReference(computedPositionReference);
6230 }, [position.refs]);
6231 const setReference = React25.useCallback((node) => {
6232 if (isElement(node) || node === null) {
6233 domReferenceRef.current = node;
6234 setLocalDomReference(node);
6235 }
6236 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
6237 // `null` to support `positionReference` + an unstable `reference`
6238 // callback ref.
6239 node !== null && !isElement(node)) {
6240 position.refs.setReference(node);
6241 }
6242 }, [position.refs, setLocalDomReference]);
6243 const setFloating = React25.useCallback((node) => {
6244 setLocalFloatingElement(node);
6245 position.refs.setFloating(node);
6246 }, [position.refs]);
6247 const refs = React25.useMemo(() => ({
6248 ...position.refs,
6249 setReference,
6250 setFloating,
6251 setPositionReference,
6252 domReference: domReferenceRef
6253 }), [position.refs, setReference, setFloating, setPositionReference]);
6254 const elements = React25.useMemo(() => ({
6255 ...position.elements,
6256 domReference: domReferenceElement
6257 }), [position.elements, domReferenceElement]);
6258 const context = React25.useMemo(() => ({
6259 ...position,
6260 dataRef: store.context.dataRef,
6261 open,
6262 onOpenChange: store.setOpen,
6263 events: store.context.events,
6264 floatingId,
6265 refs,
6266 elements,
6267 nodeId,
6268 rootStore: store
6269 }), [position, refs, elements, nodeId, store, open, floatingId]);
6270 useIsoLayoutEffect(() => {
6271 if (domReferenceElement) {
6272 domReferenceRef.current = domReferenceElement;
6273 }
6274 }, [domReferenceElement]);
6275 useIsoLayoutEffect(() => {
6276 store.context.dataRef.current.floatingContext = context;
6277 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
6278 if (node) {
6279 node.context = context;
6280 }
6281 });
6282 return React25.useMemo(() => ({
6283 ...position,
6284 context,
6285 refs,
6286 elements,
6287 rootStore: store
6288 }), [position, refs, elements, context, store]);
6289 }
6290
6291 // node_modules/@base-ui/react/floating-ui-react/hooks/useFocus.mjs
6292 var React26 = __toESM(require_react(), 1);
6293 var isMacSafari = parts_exports.os.mac && parts_exports.engine.webkit;
6294 function useFocus(context, props = {}) {
6295 const {
6296 enabled = true,
6297 delay
6298 } = props;
6299 const store = "rootStore" in context ? context.rootStore : context;
6300 const {
6301 events,
6302 dataRef
6303 } = store.context;
6304 const blockFocusRef = React26.useRef(false);
6305 const blockedReferenceRef = React26.useRef(null);
6306 const keyboardModalityRef = React26.useRef(true);
6307 const timeout = useTimeout();
6308 React26.useEffect(() => {
6309 const domReference = store.select("domReferenceElement");
6310 if (!enabled) {
6311 return void 0;
6312 }
6313 const win = getWindow(domReference);
6314 function onBlur() {
6315 const currentDomReference = store.select("domReferenceElement");
6316 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
6317 blockFocusRef.current = true;
6318 }
6319 }
6320 function onKeyDown() {
6321 keyboardModalityRef.current = true;
6322 }
6323 function onPointerDown() {
6324 keyboardModalityRef.current = false;
6325 }
6326 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
6327 }, [store, enabled]);
6328 React26.useEffect(() => {
6329 if (!enabled) {
6330 return void 0;
6331 }
6332 function onOpenChangeLocal(details) {
6333 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
6334 const referenceElement = store.select("domReferenceElement");
6335 if (isElement(referenceElement)) {
6336 blockedReferenceRef.current = referenceElement;
6337 blockFocusRef.current = true;
6338 }
6339 }
6340 }
6341 events.on("openchange", onOpenChangeLocal);
6342 return () => {
6343 events.off("openchange", onOpenChangeLocal);
6344 };
6345 }, [events, enabled, store]);
6346 const reference = React26.useMemo(() => {
6347 function resetBlockedFocus() {
6348 blockFocusRef.current = false;
6349 blockedReferenceRef.current = null;
6350 }
6351 return {
6352 onMouseLeave() {
6353 resetBlockedFocus();
6354 },
6355 onFocus(event) {
6356 const focusTarget = event.currentTarget;
6357 if (blockFocusRef.current) {
6358 if (blockedReferenceRef.current === focusTarget) {
6359 return;
6360 }
6361 resetBlockedFocus();
6362 }
6363 const target = getTarget(event.nativeEvent);
6364 if (isElement(target)) {
6365 if (isMacSafari && !event.relatedTarget) {
6366 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
6367 return;
6368 }
6369 } else if (!matchesFocusVisible(target)) {
6370 return;
6371 }
6372 }
6373 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
6374 const {
6375 nativeEvent,
6376 currentTarget
6377 } = event;
6378 const delayValue = typeof delay === "function" ? delay() : delay;
6379 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
6380 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6381 return;
6382 }
6383 timeout.start(delayValue, () => {
6384 if (blockFocusRef.current) {
6385 return;
6386 }
6387 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6388 });
6389 },
6390 onBlur(event) {
6391 resetBlockedFocus();
6392 const relatedTarget = event.relatedTarget;
6393 const nativeEvent = event.nativeEvent;
6394 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
6395 timeout.start(0, () => {
6396 const domReference = store.select("domReferenceElement");
6397 const activeEl = activeElement(ownerDocument(domReference));
6398 if (!relatedTarget && activeEl === domReference) {
6399 return;
6400 }
6401 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
6402 return;
6403 }
6404 const nextFocusedElement = relatedTarget ?? activeEl;
6405 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
6406 return;
6407 }
6408 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
6409 });
6410 }
6411 };
6412 }, [dataRef, delay, store, timeout]);
6413 return React26.useMemo(() => enabled ? {
6414 reference,
6415 trigger: reference
6416 } : {}, [enabled, reference]);
6417 }
6418
6419 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs
6420 var React27 = __toESM(require_react(), 1);
6421
6422 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverInteractionSharedState.mjs
6423 var HoverInteraction = class _HoverInteraction {
6424 constructor() {
6425 this.pointerType = void 0;
6426 this.interactedInside = false;
6427 this.handler = void 0;
6428 this.blockMouseMove = true;
6429 this.performedPointerEventsMutation = false;
6430 this.pointerEventsScopeElement = null;
6431 this.pointerEventsReferenceElement = null;
6432 this.pointerEventsFloatingElement = null;
6433 this.restTimeoutPending = false;
6434 this.openChangeTimeout = new Timeout();
6435 this.restTimeout = new Timeout();
6436 this.handleCloseOptions = void 0;
6437 }
6438 static create() {
6439 return new _HoverInteraction();
6440 }
6441 dispose = () => {
6442 this.openChangeTimeout.clear();
6443 this.restTimeout.clear();
6444 };
6445 disposeEffect = () => {
6446 return this.dispose;
6447 };
6448 };
6449 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
6450 function clearSafePolygonPointerEventsMutation(instance) {
6451 if (!instance.performedPointerEventsMutation) {
6452 return;
6453 }
6454 const scopeElement = instance.pointerEventsScopeElement;
6455 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
6456 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
6457 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
6458 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
6459 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
6460 }
6461 instance.performedPointerEventsMutation = false;
6462 instance.pointerEventsScopeElement = null;
6463 instance.pointerEventsReferenceElement = null;
6464 instance.pointerEventsFloatingElement = null;
6465 }
6466 function applySafePolygonPointerEventsMutation(instance, options) {
6467 const {
6468 scopeElement,
6469 referenceElement,
6470 floatingElement
6471 } = options;
6472 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
6473 if (existingOwner && existingOwner !== instance) {
6474 clearSafePolygonPointerEventsMutation(existingOwner);
6475 }
6476 clearSafePolygonPointerEventsMutation(instance);
6477 instance.performedPointerEventsMutation = true;
6478 instance.pointerEventsScopeElement = scopeElement;
6479 instance.pointerEventsReferenceElement = referenceElement;
6480 instance.pointerEventsFloatingElement = floatingElement;
6481 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
6482 scopeElement.style.pointerEvents = "none";
6483 referenceElement.style.pointerEvents = "auto";
6484 floatingElement.style.pointerEvents = "auto";
6485 }
6486 function useHoverInteractionSharedState(store) {
6487 const data = store.context.dataRef.current;
6488 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current;
6489 if (!data.hoverInteractionState) {
6490 data.hoverInteractionState = instance;
6491 }
6492 useOnMount(data.hoverInteractionState.disposeEffect);
6493 return data.hoverInteractionState;
6494 }
6495
6496 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs
6497 function useHoverFloatingInteraction(context, parameters = {}) {
6498 const {
6499 enabled = true,
6500 closeDelay: closeDelayProp = 0,
6501 nodeId: nodeIdProp
6502 } = parameters;
6503 const store = "rootStore" in context ? context.rootStore : context;
6504 const open = store.useState("open");
6505 const floatingElement = store.useState("floatingElement");
6506 const domReferenceElement = store.useState("domReferenceElement");
6507 const {
6508 dataRef
6509 } = store.context;
6510 const tree = useFloatingTree();
6511 const parentId = useFloatingParentNodeId();
6512 const instance = useHoverInteractionSharedState(store);
6513 const childClosedTimeout = useTimeout();
6514 const isClickLikeOpenEvent2 = useStableCallback(() => {
6515 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6516 });
6517 const isHoverOpen = useStableCallback(() => {
6518 return isHoverOpenEvent(dataRef.current.openEvent?.type);
6519 });
6520 const clearPointerEvents = useStableCallback(() => {
6521 clearSafePolygonPointerEventsMutation(instance);
6522 });
6523 useIsoLayoutEffect(() => {
6524 if (!open) {
6525 instance.pointerType = void 0;
6526 instance.restTimeoutPending = false;
6527 instance.interactedInside = false;
6528 clearPointerEvents();
6529 }
6530 }, [open, instance, clearPointerEvents]);
6531 React27.useEffect(() => {
6532 return clearPointerEvents;
6533 }, [clearPointerEvents]);
6534 useIsoLayoutEffect(() => {
6535 if (!enabled) {
6536 return void 0;
6537 }
6538 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
6539 const ref = domReferenceElement;
6540 const floatingEl = floatingElement;
6541 const doc = ownerDocument(floatingElement);
6542 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
6543 if (parentFloating) {
6544 parentFloating.style.pointerEvents = "";
6545 }
6546 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
6547 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
6548 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
6549 applySafePolygonPointerEventsMutation(instance, {
6550 scopeElement,
6551 referenceElement: ref,
6552 floatingElement: floatingEl
6553 });
6554 return () => {
6555 clearPointerEvents();
6556 };
6557 }
6558 return void 0;
6559 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
6560 React27.useEffect(() => {
6561 if (!enabled) {
6562 return void 0;
6563 }
6564 function hasParentChildren() {
6565 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0);
6566 }
6567 function closeWithDelay(event) {
6568 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
6569 const close = () => {
6570 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6571 tree?.events.emit("floating.closed", event);
6572 };
6573 if (closeDelay) {
6574 instance.openChangeTimeout.start(closeDelay, close);
6575 } else {
6576 instance.openChangeTimeout.clear();
6577 close();
6578 }
6579 }
6580 function handleInteractInside(event) {
6581 const target = getTarget(event);
6582 if (!isInteractiveElement(target)) {
6583 instance.interactedInside = false;
6584 return;
6585 }
6586 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
6587 }
6588 function onFloatingMouseEnter() {
6589 instance.openChangeTimeout.clear();
6590 childClosedTimeout.clear();
6591 tree?.events.off("floating.closed", onNodeClosed);
6592 clearPointerEvents();
6593 }
6594 function onFloatingMouseLeave(event) {
6595 if (hasParentChildren() && tree) {
6596 tree.events.on("floating.closed", onNodeClosed);
6597 return;
6598 }
6599 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
6600 return;
6601 }
6602 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
6603 const relatedTarget = event.relatedTarget;
6604 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
6605 if (isMovingIntoDescendantFloating) {
6606 return;
6607 }
6608 if (instance.handler) {
6609 instance.handler(event);
6610 return;
6611 }
6612 clearPointerEvents();
6613 if (isHoverOpen() && !isClickLikeOpenEvent2()) {
6614 closeWithDelay(event);
6615 }
6616 }
6617 function onNodeClosed(event) {
6618 if (!tree || !parentId || hasParentChildren()) {
6619 return;
6620 }
6621 childClosedTimeout.start(0, () => {
6622 tree.events.off("floating.closed", onNodeClosed);
6623 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6624 tree.events.emit("floating.closed", event);
6625 });
6626 }
6627 const floating = floatingElement;
6628 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
6629 tree?.events.off("floating.closed", onNodeClosed);
6630 });
6631 }, [enabled, floatingElement, store, dataRef, closeDelayProp, nodeIdProp, isHoverOpen, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]);
6632 }
6633
6634 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverReferenceInteraction.mjs
6635 var React28 = __toESM(require_react(), 1);
6636 var ReactDOM5 = __toESM(require_react_dom(), 1);
6637 var EMPTY_REF = {
6638 current: null
6639 };
6640 function useHoverReferenceInteraction(context, props = {}) {
6641 const {
6642 enabled = true,
6643 delay = 0,
6644 handleClose = null,
6645 mouseOnly = false,
6646 restMs = 0,
6647 move = true,
6648 triggerElementRef = EMPTY_REF,
6649 externalTree,
6650 isActiveTrigger = true,
6651 getHandleCloseContext,
6652 isClosing,
6653 shouldOpen: shouldOpenProp
6654 } = props;
6655 const store = "rootStore" in context ? context.rootStore : context;
6656 const {
6657 dataRef,
6658 events
6659 } = store.context;
6660 const tree = useFloatingTree(externalTree);
6661 const instance = useHoverInteractionSharedState(store);
6662 const isHoverCloseActiveRef = React28.useRef(false);
6663 const handleCloseRef = useValueAsRef(handleClose);
6664 const delayRef = useValueAsRef(delay);
6665 const restMsRef = useValueAsRef(restMs);
6666 const enabledRef = useValueAsRef(enabled);
6667 const shouldOpenRef = useValueAsRef(shouldOpenProp);
6668 const isClosingRef = useValueAsRef(isClosing);
6669 const isClickLikeOpenEvent2 = useStableCallback(() => {
6670 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6671 });
6672 const checkShouldOpen = useStableCallback(() => {
6673 return shouldOpenRef.current?.() !== false;
6674 });
6675 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
6676 const allTriggers = store.context.triggerElements;
6677 if (allTriggers.hasElement(currentTarget)) {
6678 return !currentDomReference || !contains(currentDomReference, currentTarget);
6679 }
6680 if (!isElement(target)) {
6681 return false;
6682 }
6683 const targetElement = target;
6684 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
6685 });
6686 const cleanupMouseMoveHandler = useStableCallback(() => {
6687 if (!instance.handler) {
6688 return;
6689 }
6690 const doc = ownerDocument(store.select("domReferenceElement"));
6691 doc.removeEventListener("mousemove", instance.handler);
6692 instance.handler = void 0;
6693 });
6694 const clearPointerEvents = useStableCallback(() => {
6695 clearSafePolygonPointerEventsMutation(instance);
6696 });
6697 if (isActiveTrigger) {
6698 instance.handleCloseOptions = handleCloseRef.current?.__options;
6699 }
6700 React28.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
6701 React28.useEffect(() => {
6702 if (!enabled) {
6703 return void 0;
6704 }
6705 function onOpenChangeLocal(details) {
6706 if (!details.open) {
6707 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
6708 cleanupMouseMoveHandler();
6709 instance.openChangeTimeout.clear();
6710 instance.restTimeout.clear();
6711 instance.blockMouseMove = true;
6712 instance.restTimeoutPending = false;
6713 } else {
6714 isHoverCloseActiveRef.current = false;
6715 }
6716 }
6717 events.on("openchange", onOpenChangeLocal);
6718 return () => {
6719 events.off("openchange", onOpenChangeLocal);
6720 };
6721 }, [enabled, events, instance, cleanupMouseMoveHandler]);
6722 React28.useEffect(() => {
6723 if (!enabled) {
6724 return void 0;
6725 }
6726 function closeWithDelay(event, runElseBranch = true) {
6727 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
6728 if (closeDelay) {
6729 instance.openChangeTimeout.start(closeDelay, () => {
6730 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6731 tree?.events.emit("floating.closed", event);
6732 });
6733 } else if (runElseBranch) {
6734 instance.openChangeTimeout.clear();
6735 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6736 tree?.events.emit("floating.closed", event);
6737 }
6738 }
6739 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
6740 if (!isElement(trigger)) {
6741 return void 0;
6742 }
6743 function onMouseEnter(event) {
6744 instance.openChangeTimeout.clear();
6745 instance.blockMouseMove = false;
6746 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6747 return;
6748 }
6749 const restMsValue = getRestMs(restMsRef.current);
6750 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
6751 const eventTarget = getTarget(event);
6752 const currentTarget = event.currentTarget ?? null;
6753 const currentDomReference = store.select("domReferenceElement");
6754 let triggerNode = currentTarget;
6755 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
6756 for (const triggerElement of store.context.triggerElements.elements()) {
6757 if (contains(triggerElement, eventTarget)) {
6758 triggerNode = triggerElement;
6759 break;
6760 }
6761 }
6762 }
6763 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
6764 triggerNode = currentDomReference;
6765 }
6766 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
6767 const isOpen = store.select("open");
6768 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
6769 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
6770 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
6771 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
6772 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
6773 const shouldOpen = !isOpen || isOverInactive;
6774 if (shouldOpenImmediately) {
6775 if (checkShouldOpen()) {
6776 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6777 }
6778 return;
6779 }
6780 if (isRestOnlyDelay) {
6781 return;
6782 }
6783 if (openDelay) {
6784 instance.openChangeTimeout.start(openDelay, () => {
6785 if (shouldOpen && checkShouldOpen()) {
6786 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6787 }
6788 });
6789 } else if (shouldOpen) {
6790 if (checkShouldOpen()) {
6791 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6792 }
6793 }
6794 }
6795 function onMouseLeave(event) {
6796 if (isClickLikeOpenEvent2()) {
6797 clearPointerEvents();
6798 return;
6799 }
6800 cleanupMouseMoveHandler();
6801 const domReferenceElement = store.select("domReferenceElement");
6802 const doc = ownerDocument(domReferenceElement);
6803 instance.restTimeout.clear();
6804 instance.restTimeoutPending = false;
6805 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
6806 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
6807 return;
6808 }
6809 if (handleCloseRef.current && handleCloseContextBase) {
6810 if (!store.select("open")) {
6811 instance.openChangeTimeout.clear();
6812 }
6813 const currentTrigger = triggerElementRef.current;
6814 instance.handler = handleCloseRef.current({
6815 ...handleCloseContextBase,
6816 tree,
6817 x: event.clientX,
6818 y: event.clientY,
6819 onClose() {
6820 clearPointerEvents();
6821 cleanupMouseMoveHandler();
6822 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
6823 closeWithDelay(event, true);
6824 }
6825 }
6826 });
6827 doc.addEventListener("mousemove", instance.handler);
6828 instance.handler(event);
6829 return;
6830 }
6831 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
6832 if (shouldClose) {
6833 closeWithDelay(event);
6834 }
6835 }
6836 if (move) {
6837 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
6838 once: true
6839 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6840 }
6841 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6842 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]);
6843 return React28.useMemo(() => {
6844 if (!enabled) {
6845 return void 0;
6846 }
6847 function setPointerRef(event) {
6848 instance.pointerType = event.pointerType;
6849 }
6850 return {
6851 onPointerDown: setPointerRef,
6852 onPointerEnter: setPointerRef,
6853 onMouseMove(event) {
6854 const {
6855 nativeEvent
6856 } = event;
6857 const trigger = event.currentTarget;
6858 const currentDomReference = store.select("domReferenceElement");
6859 const currentOpen = store.select("open");
6860 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
6861 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6862 return;
6863 }
6864 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
6865 const floatingElement = store.select("floatingElement");
6866 if (floatingElement) {
6867 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
6868 applySafePolygonPointerEventsMutation(instance, {
6869 scopeElement,
6870 referenceElement: trigger,
6871 floatingElement
6872 });
6873 }
6874 }
6875 const restMsValue = getRestMs(restMsRef.current);
6876 if (currentOpen && !isOverInactive || restMsValue === 0) {
6877 return;
6878 }
6879 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
6880 return;
6881 }
6882 instance.restTimeout.clear();
6883 function handleMouseMove() {
6884 instance.restTimeoutPending = false;
6885 if (isClickLikeOpenEvent2()) {
6886 return;
6887 }
6888 const latestOpen = store.select("open");
6889 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
6890 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
6891 }
6892 }
6893 if (instance.pointerType === "touch") {
6894 ReactDOM5.flushSync(() => {
6895 handleMouseMove();
6896 });
6897 } else if (isOverInactive && currentOpen) {
6898 handleMouseMove();
6899 } else {
6900 instance.restTimeoutPending = true;
6901 instance.restTimeout.start(restMsValue, handleMouseMove);
6902 }
6903 }
6904 };
6905 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef, checkShouldOpen]);
6906 }
6907
6908 // node_modules/@base-ui/react/floating-ui-react/safePolygon.mjs
6909 var CURSOR_SPEED_THRESHOLD = 0.1;
6910 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
6911 var POLYGON_BUFFER = 0.5;
6912 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
6913 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
6914 }
6915 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
6916 let isInsideValue = false;
6917 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
6918 isInsideValue = !isInsideValue;
6919 }
6920 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
6921 isInsideValue = !isInsideValue;
6922 }
6923 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
6924 isInsideValue = !isInsideValue;
6925 }
6926 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
6927 isInsideValue = !isInsideValue;
6928 }
6929 return isInsideValue;
6930 }
6931 function isInsideRect(pointX, pointY, rect) {
6932 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
6933 }
6934 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
6935 const minX = Math.min(x1, x2);
6936 const maxX = Math.max(x1, x2);
6937 const minY = Math.min(y1, y2);
6938 const maxY = Math.max(y1, y2);
6939 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
6940 }
6941 function safePolygon(options = {}) {
6942 const {
6943 blockPointerEvents = false
6944 } = options;
6945 const timeout = new Timeout();
6946 const fn = ({
6947 x: x2,
6948 y: y2,
6949 placement,
6950 elements,
6951 onClose,
6952 nodeId,
6953 tree
6954 }) => {
6955 const side = placement?.split("-")[0];
6956 let hasLanded = false;
6957 let lastX = null;
6958 let lastY = null;
6959 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
6960 function isCursorMovingSlowly(nextX, nextY) {
6961 const currentTime = performance.now();
6962 const elapsedTime = currentTime - lastCursorTime;
6963 if (lastX === null || lastY === null || elapsedTime === 0) {
6964 lastX = nextX;
6965 lastY = nextY;
6966 lastCursorTime = currentTime;
6967 return false;
6968 }
6969 const deltaX = nextX - lastX;
6970 const deltaY = nextY - lastY;
6971 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
6972 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
6973 lastX = nextX;
6974 lastY = nextY;
6975 lastCursorTime = currentTime;
6976 return distanceSquared < thresholdSquared;
6977 }
6978 function close() {
6979 timeout.clear();
6980 onClose();
6981 }
6982 return function onMouseMove(event) {
6983 timeout.clear();
6984 const domReference = elements.domReference;
6985 const floating = elements.floating;
6986 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
6987 return void 0;
6988 }
6989 const {
6990 clientX,
6991 clientY
6992 } = event;
6993 const target = getTarget(event);
6994 const isLeave = event.type === "mouseleave";
6995 const isOverFloatingEl = contains(floating, target);
6996 const isOverReferenceEl = contains(domReference, target);
6997 if (isOverFloatingEl) {
6998 hasLanded = true;
6999 if (!isLeave) {
7000 return void 0;
7001 }
7002 }
7003 if (isOverReferenceEl) {
7004 hasLanded = false;
7005 if (!isLeave) {
7006 hasLanded = true;
7007 return void 0;
7008 }
7009 }
7010 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
7011 return void 0;
7012 }
7013 function hasOpenChildNode() {
7014 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
7015 }
7016 function closeIfNoOpenChild() {
7017 if (!hasOpenChildNode()) {
7018 close();
7019 }
7020 }
7021 if (hasOpenChildNode()) {
7022 return void 0;
7023 }
7024 const refRect = domReference.getBoundingClientRect();
7025 const rect = floating.getBoundingClientRect();
7026 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
7027 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
7028 const isFloatingWider = rect.width > refRect.width;
7029 const isFloatingTaller = rect.height > refRect.height;
7030 const left = (isFloatingWider ? refRect : rect).left;
7031 const right = (isFloatingWider ? refRect : rect).right;
7032 const top = (isFloatingTaller ? refRect : rect).top;
7033 const bottom = (isFloatingTaller ? refRect : rect).bottom;
7034 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) {
7035 closeIfNoOpenChild();
7036 return void 0;
7037 }
7038 let isInsideTroughRect = false;
7039 switch (side) {
7040 case "top":
7041 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
7042 break;
7043 case "bottom":
7044 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
7045 break;
7046 case "left":
7047 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
7048 break;
7049 case "right":
7050 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
7051 break;
7052 default:
7053 }
7054 if (isInsideTroughRect) {
7055 return void 0;
7056 }
7057 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
7058 closeIfNoOpenChild();
7059 return void 0;
7060 }
7061 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
7062 closeIfNoOpenChild();
7063 return void 0;
7064 }
7065 let isInsidePolygon = false;
7066 switch (side) {
7067 case "top": {
7068 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7069 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7070 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7071 const cursorPointY = y2 + POLYGON_BUFFER + 1;
7072 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
7073 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
7074 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7075 break;
7076 }
7077 case "bottom": {
7078 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7079 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7080 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7081 const cursorPointY = y2 - POLYGON_BUFFER;
7082 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
7083 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
7084 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7085 break;
7086 }
7087 case "left": {
7088 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7089 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7090 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7091 const cursorPointX = x2 + POLYGON_BUFFER + 1;
7092 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
7093 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
7094 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
7095 break;
7096 }
7097 case "right": {
7098 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7099 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7100 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7101 const cursorPointX = x2 - POLYGON_BUFFER;
7102 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
7103 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
7104 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
7105 break;
7106 }
7107 default:
7108 }
7109 if (!isInsidePolygon) {
7110 closeIfNoOpenChild();
7111 } else if (!hasLanded) {
7112 timeout.start(40, closeIfNoOpenChild);
7113 }
7114 return void 0;
7115 };
7116 };
7117 fn.__options = {
7118 ...options,
7119 blockPointerEvents
7120 };
7121 return fn;
7122 }
7123
7124 // node_modules/@base-ui/react/utils/popupStateMapping.mjs
7125 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
7126 CommonPopupDataAttributes2["open"] = "data-open";
7127 CommonPopupDataAttributes2["closed"] = "data-closed";
7128 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
7129 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
7130 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
7131 CommonPopupDataAttributes2["side"] = "data-side";
7132 CommonPopupDataAttributes2["align"] = "data-align";
7133 return CommonPopupDataAttributes2;
7134 })({});
7135 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
7136 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
7137 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
7138 return CommonTriggerDataAttributes2;
7139 })({});
7140 var TRIGGER_HOOK = {
7141 [CommonTriggerDataAttributes.popupOpen]: ""
7142 };
7143 var PRESSABLE_TRIGGER_HOOK = {
7144 [CommonTriggerDataAttributes.popupOpen]: "",
7145 [CommonTriggerDataAttributes.pressed]: ""
7146 };
7147 var POPUP_OPEN_HOOK = {
7148 [CommonPopupDataAttributes.open]: ""
7149 };
7150 var POPUP_CLOSED_HOOK = {
7151 [CommonPopupDataAttributes.closed]: ""
7152 };
7153 var ANCHOR_HIDDEN_HOOK = {
7154 [CommonPopupDataAttributes.anchorHidden]: ""
7155 };
7156 var triggerOpenStateMapping = {
7157 open(value) {
7158 if (value) {
7159 return TRIGGER_HOOK;
7160 }
7161 return null;
7162 }
7163 };
7164 var popupStateMapping = {
7165 open(value) {
7166 if (value) {
7167 return POPUP_OPEN_HOOK;
7168 }
7169 return POPUP_CLOSED_HOOK;
7170 },
7171 anchorHidden(value) {
7172 if (value) {
7173 return ANCHOR_HIDDEN_HOOK;
7174 }
7175 return null;
7176 }
7177 };
7178
7179 // node_modules/@base-ui/utils/inertValue.mjs
7180 function inertValue(value) {
7181 if (isReactVersionAtLeast(19)) {
7182 return value;
7183 }
7184 return value ? "true" : void 0;
7185 }
7186
7187 // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs
7188 var React29 = __toESM(require_react(), 1);
7189
7190 // node_modules/@base-ui/react/floating-ui-react/middleware/arrow.mjs
7191 var baseArrow = (options) => ({
7192 name: "arrow",
7193 options,
7194 async fn(state) {
7195 const {
7196 x: x2,
7197 y: y2,
7198 placement,
7199 rects,
7200 platform: platform3,
7201 elements,
7202 middlewareData
7203 } = state;
7204 const {
7205 element,
7206 padding = 0,
7207 offsetParent = "real"
7208 } = evaluate(options, state) || {};
7209 if (element == null) {
7210 return {};
7211 }
7212 const paddingObject = getPaddingObject(padding);
7213 const coords = {
7214 x: x2,
7215 y: y2
7216 };
7217 const axis = getAlignmentAxis(placement);
7218 const length = getAxisLength(axis);
7219 const arrowDimensions = await platform3.getDimensions(element);
7220 const isYAxis = axis === "y";
7221 const minProp = isYAxis ? "top" : "left";
7222 const maxProp = isYAxis ? "bottom" : "right";
7223 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
7224 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
7225 const startDiff = coords[axis] - rects.reference[axis];
7226 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
7227 let clientSize = elements.floating[clientProp] || rects.floating[length];
7228 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
7229 clientSize = elements.floating[clientProp] || rects.floating[length];
7230 }
7231 const centerToReference = endDiff / 2 - startDiff / 2;
7232 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
7233 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
7234 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
7235 const min2 = minPadding;
7236 const max2 = clientSize - arrowDimensions[length] - maxPadding;
7237 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
7238 const offset4 = clamp(min2, center, max2);
7239 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
7240 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
7241 return {
7242 [axis]: coords[axis] + alignmentOffset,
7243 data: {
7244 [axis]: offset4,
7245 centerOffset: center - offset4 - alignmentOffset,
7246 ...shouldAddOffset && {
7247 alignmentOffset
7248 }
7249 },
7250 reset: shouldAddOffset
7251 };
7252 }
7253 });
7254 var arrow4 = (options, deps) => ({
7255 ...baseArrow(options),
7256 options: [options, deps]
7257 });
7258
7259 // node_modules/@base-ui/react/utils/hideMiddleware.mjs
7260 var nativeHideFn = hide3().fn;
7261 var hide4 = {
7262 name: "hide",
7263 async fn(state) {
7264 const {
7265 width,
7266 height,
7267 x: x2,
7268 y: y2
7269 } = state.rects.reference;
7270 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
7271 const nativeHideResult = await nativeHideFn(state);
7272 return {
7273 data: {
7274 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
7275 }
7276 };
7277 }
7278 };
7279
7280 // node_modules/@base-ui/react/utils/adaptiveOriginMiddleware.mjs
7281 var DEFAULT_SIDES = {
7282 sideX: "left",
7283 sideY: "top"
7284 };
7285 var adaptiveOrigin = {
7286 name: "adaptiveOrigin",
7287 async fn(state) {
7288 const {
7289 x: rawX,
7290 y: rawY,
7291 rects: {
7292 floating: floatRect
7293 },
7294 elements: {
7295 floating
7296 },
7297 platform: platform3,
7298 strategy,
7299 placement
7300 } = state;
7301 const win = getWindow(floating);
7302 const styles = win.getComputedStyle(floating);
7303 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
7304 if (!hasTransition) {
7305 return {
7306 x: rawX,
7307 y: rawY,
7308 data: DEFAULT_SIDES
7309 };
7310 }
7311 const offsetParent = await platform3.getOffsetParent?.(floating);
7312 let offsetDimensions = {
7313 width: 0,
7314 height: 0
7315 };
7316 if (strategy === "fixed" && win?.visualViewport) {
7317 offsetDimensions = {
7318 width: win.visualViewport.width,
7319 height: win.visualViewport.height
7320 };
7321 } else if (offsetParent === win) {
7322 const doc = ownerDocument(floating);
7323 offsetDimensions = {
7324 width: doc.documentElement.clientWidth,
7325 height: doc.documentElement.clientHeight
7326 };
7327 } else if (await platform3.isElement?.(offsetParent)) {
7328 offsetDimensions = await platform3.getDimensions(offsetParent);
7329 }
7330 const currentSide = getSide(placement);
7331 let x2 = rawX;
7332 let y2 = rawY;
7333 if (currentSide === "left") {
7334 x2 = offsetDimensions.width - (rawX + floatRect.width);
7335 }
7336 if (currentSide === "top") {
7337 y2 = offsetDimensions.height - (rawY + floatRect.height);
7338 }
7339 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
7340 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
7341 return {
7342 x: x2,
7343 y: y2,
7344 data: {
7345 sideX,
7346 sideY
7347 }
7348 };
7349 }
7350 };
7351
7352 // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs
7353 function getLogicalSide(sideParam, renderedSide, isRtl) {
7354 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
7355 const logicalRight = isRtl ? "inline-start" : "inline-end";
7356 const logicalLeft = isRtl ? "inline-end" : "inline-start";
7357 return {
7358 top: "top",
7359 right: isLogicalSideParam ? logicalRight : "right",
7360 bottom: "bottom",
7361 left: isLogicalSideParam ? logicalLeft : "left"
7362 }[renderedSide];
7363 }
7364 function getOffsetData(state, sideParam, isRtl) {
7365 const {
7366 rects,
7367 placement
7368 } = state;
7369 const data = {
7370 side: getLogicalSide(sideParam, getSide(placement), isRtl),
7371 align: getAlignment(placement) || "center",
7372 anchor: {
7373 width: rects.reference.width,
7374 height: rects.reference.height
7375 },
7376 positioner: {
7377 width: rects.floating.width,
7378 height: rects.floating.height
7379 }
7380 };
7381 return data;
7382 }
7383 function useAnchorPositioning(params) {
7384 const {
7385 // Public parameters
7386 anchor,
7387 positionMethod = "absolute",
7388 side: sideParam = "bottom",
7389 sideOffset = 0,
7390 align = "center",
7391 alignOffset = 0,
7392 collisionBoundary,
7393 collisionPadding: collisionPaddingParam = 5,
7394 sticky = false,
7395 arrowPadding = 5,
7396 disableAnchorTracking = false,
7397 inline: inlineMiddleware,
7398 // Private parameters
7399 keepMounted = false,
7400 floatingRootContext,
7401 mounted,
7402 collisionAvoidance,
7403 shiftCrossAxis = false,
7404 nodeId,
7405 adaptiveOrigin: adaptiveOrigin2,
7406 lazyFlip = false,
7407 externalTree
7408 } = params;
7409 const [mountSide, setMountSide] = React29.useState(null);
7410 if (!mounted && mountSide !== null) {
7411 setMountSide(null);
7412 }
7413 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
7414 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
7415 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
7416 const anchorFn = typeof anchor === "function" ? anchor : void 0;
7417 const anchorFnCallback = useStableCallback(anchorFn);
7418 const anchorDep = anchorFn ? anchorFnCallback : anchor;
7419 const anchorValueRef = useValueAsRef(anchor);
7420 const mountedRef = useValueAsRef(mounted);
7421 const direction = useDirection();
7422 const isRtl = direction === "rtl";
7423 const side = mountSide || {
7424 top: "top",
7425 right: "right",
7426 bottom: "bottom",
7427 left: "left",
7428 "inline-end": isRtl ? "left" : "right",
7429 "inline-start": isRtl ? "right" : "left"
7430 }[sideParam];
7431 const placement = align === "center" ? side : `${side}-${align}`;
7432 let collisionPadding = collisionPaddingParam;
7433 const bias = 1;
7434 const biasTop = sideParam === "bottom" ? bias : 0;
7435 const biasBottom = sideParam === "top" ? bias : 0;
7436 const biasLeft = sideParam === "right" ? bias : 0;
7437 const biasRight = sideParam === "left" ? bias : 0;
7438 if (typeof collisionPadding === "number") {
7439 collisionPadding = {
7440 top: collisionPadding + biasTop,
7441 right: collisionPadding + biasRight,
7442 bottom: collisionPadding + biasBottom,
7443 left: collisionPadding + biasLeft
7444 };
7445 } else if (collisionPadding) {
7446 collisionPadding = {
7447 top: (collisionPadding.top || 0) + biasTop,
7448 right: (collisionPadding.right || 0) + biasRight,
7449 bottom: (collisionPadding.bottom || 0) + biasBottom,
7450 left: (collisionPadding.left || 0) + biasLeft
7451 };
7452 }
7453 const commonCollisionProps = {
7454 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
7455 padding: collisionPadding
7456 };
7457 const arrowRef = React29.useRef(null);
7458 const sideOffsetRef = useValueAsRef(sideOffset);
7459 const alignOffsetRef = useValueAsRef(alignOffset);
7460 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
7461 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
7462 const middleware = [];
7463 if (inlineMiddleware) {
7464 middleware.push(inlineMiddleware);
7465 }
7466 middleware.push(offset3((state) => {
7467 const data = getOffsetData(state, sideParam, isRtl);
7468 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
7469 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
7470 return {
7471 mainAxis: sideAxis,
7472 crossAxis: alignAxis,
7473 alignmentAxis: alignAxis
7474 };
7475 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
7476 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
7477 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
7478 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
7479 ...commonCollisionProps,
7480 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
7481 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
7482 padding: {
7483 top: collisionPadding.top + bias,
7484 right: collisionPadding.right + bias,
7485 bottom: collisionPadding.bottom + bias,
7486 left: collisionPadding.left + bias
7487 },
7488 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
7489 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
7490 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
7491 });
7492 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
7493 const html = ownerDocument(data.elements.floating).documentElement;
7494 return {
7495 ...commonCollisionProps,
7496 // Use the Layout Viewport to avoid shifting around when pinch-zooming
7497 // for context menus.
7498 rootBoundary: shiftCrossAxis ? {
7499 x: 0,
7500 y: 0,
7501 width: html.clientWidth,
7502 height: html.clientHeight
7503 } : void 0,
7504 mainAxis: collisionAvoidanceAlign !== "none",
7505 crossAxis: crossAxisShiftEnabled,
7506 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
7507 if (!arrowRef.current) {
7508 return {};
7509 }
7510 const {
7511 width,
7512 height
7513 } = arrowRef.current.getBoundingClientRect();
7514 const sideAxis = getSideAxis(getSide(limitData.placement));
7515 const arrowSize = sideAxis === "y" ? width : height;
7516 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
7517 return {
7518 offset: arrowSize / 2 + offsetAmount / 2
7519 };
7520 })
7521 };
7522 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
7523 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
7524 middleware.push(shiftMiddleware, flipMiddleware);
7525 } else {
7526 middleware.push(flipMiddleware, shiftMiddleware);
7527 }
7528 middleware.push(size3({
7529 ...commonCollisionProps,
7530 apply({
7531 elements: {
7532 floating
7533 },
7534 availableWidth,
7535 availableHeight,
7536 rects
7537 }) {
7538 if (!mountedRef.current) {
7539 return;
7540 }
7541 const floatingStyle = floating.style;
7542 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
7543 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
7544 const dpr = getWindow(floating).devicePixelRatio || 1;
7545 const {
7546 x: x3,
7547 y: y3,
7548 width,
7549 height
7550 } = rects.reference;
7551 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
7552 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
7553 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
7554 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
7555 }
7556 }), arrow4((state) => ({
7557 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
7558 // we'll create a fake element.
7559 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"),
7560 padding: arrowPadding,
7561 offsetParent: "floating"
7562 }), [arrowPadding]), {
7563 name: "transformOrigin",
7564 fn(state) {
7565 const {
7566 elements: elements2,
7567 middlewareData: middlewareData2,
7568 placement: renderedPlacement2,
7569 rects,
7570 y: y3
7571 } = state;
7572 const currentRenderedSide = getSide(renderedPlacement2);
7573 const currentRenderedAxis = getSideAxis(currentRenderedSide);
7574 const arrowEl = arrowRef.current;
7575 const arrowX = middlewareData2.arrow?.x || 0;
7576 const arrowY = middlewareData2.arrow?.y || 0;
7577 const arrowWidth = arrowEl?.clientWidth || 0;
7578 const arrowHeight = arrowEl?.clientHeight || 0;
7579 const transformX = arrowX + arrowWidth / 2;
7580 const transformY = arrowY + arrowHeight / 2;
7581 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
7582 const halfAnchorHeight = rects.reference.height / 2;
7583 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
7584 const isOverlappingAnchor = shiftY > sideOffsetValue;
7585 const adjacentTransformOrigin = {
7586 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
7587 bottom: `${transformX}px ${-sideOffsetValue}px`,
7588 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
7589 right: `${-sideOffsetValue}px ${transformY}px`
7590 }[currentRenderedSide];
7591 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
7592 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
7593 return {};
7594 }
7595 }, hide4, adaptiveOrigin2);
7596 useIsoLayoutEffect(() => {
7597 if (!mounted && floatingRootContext) {
7598 floatingRootContext.update({
7599 referenceElement: null,
7600 floatingElement: null,
7601 domReferenceElement: null,
7602 positionReference: null
7603 });
7604 }
7605 }, [mounted, floatingRootContext]);
7606 const autoUpdateOptions = React29.useMemo(() => ({
7607 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
7608 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
7609 }), [disableAnchorTracking]);
7610 const {
7611 refs,
7612 elements,
7613 x: x2,
7614 y: y2,
7615 middlewareData,
7616 update: update2,
7617 placement: renderedPlacement,
7618 context,
7619 isPositioned,
7620 floatingStyles: originalFloatingStyles
7621 } = useFloating2({
7622 rootContext: floatingRootContext,
7623 open: keepMounted ? mounted : void 0,
7624 placement,
7625 middleware,
7626 strategy: positionMethod,
7627 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
7628 nodeId,
7629 externalTree
7630 });
7631 const {
7632 sideX,
7633 sideY
7634 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
7635 const resolvedPosition = isPositioned ? positionMethod : "fixed";
7636 const floatingStyles = React29.useMemo(() => {
7637 const base = adaptiveOrigin2 ? {
7638 position: resolvedPosition,
7639 [sideX]: x2,
7640 [sideY]: y2
7641 } : {
7642 position: resolvedPosition,
7643 ...originalFloatingStyles
7644 };
7645 if (!isPositioned) {
7646 base.opacity = 0;
7647 }
7648 return base;
7649 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
7650 const registeredPositionReferenceRef = React29.useRef(null);
7651 useIsoLayoutEffect(() => {
7652 if (!mounted) {
7653 return;
7654 }
7655 const anchorValue = anchorValueRef.current;
7656 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
7657 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
7658 const finalAnchor = unwrappedElement || null;
7659 if (finalAnchor !== registeredPositionReferenceRef.current) {
7660 refs.setPositionReference(finalAnchor);
7661 registeredPositionReferenceRef.current = finalAnchor;
7662 }
7663 }, [mounted, refs, anchorDep, anchorValueRef]);
7664 React29.useEffect(() => {
7665 if (!mounted) {
7666 return;
7667 }
7668 const anchorValue = anchorValueRef.current;
7669 if (typeof anchorValue === "function") {
7670 return;
7671 }
7672 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
7673 refs.setPositionReference(anchorValue.current);
7674 registeredPositionReferenceRef.current = anchorValue.current;
7675 }
7676 }, [mounted, refs, anchorDep, anchorValueRef]);
7677 React29.useEffect(() => {
7678 if (keepMounted && mounted && elements.reference && elements.floating) {
7679 return autoUpdate(elements.reference, elements.floating, update2, autoUpdateOptions);
7680 }
7681 return void 0;
7682 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
7683 const renderedSide = getSide(renderedPlacement);
7684 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
7685 const renderedAlign = getAlignment(renderedPlacement) || "center";
7686 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
7687 useIsoLayoutEffect(() => {
7688 if (lazyFlip && mounted && isPositioned) {
7689 setMountSide(renderedSide);
7690 }
7691 }, [lazyFlip, mounted, isPositioned, renderedSide]);
7692 const arrowStyles = React29.useMemo(() => ({
7693 position: "absolute",
7694 top: middlewareData.arrow?.y,
7695 left: middlewareData.arrow?.x
7696 }), [middlewareData.arrow]);
7697 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
7698 return React29.useMemo(() => ({
7699 positionerStyles: floatingStyles,
7700 arrowStyles,
7701 arrowRef,
7702 arrowUncentered,
7703 side: logicalRenderedSide,
7704 align: renderedAlign,
7705 physicalSide: renderedSide,
7706 anchorHidden,
7707 refs,
7708 context,
7709 isPositioned,
7710 update: update2
7711 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
7712 }
7713 function isRef(param) {
7714 return param != null && "current" in param;
7715 }
7716
7717 // node_modules/@base-ui/react/utils/getDisabledMountTransitionStyles.mjs
7718 function getDisabledMountTransitionStyles(transitionStatus) {
7719 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
7720 }
7721
7722 // node_modules/@base-ui/react/utils/usePositioner.mjs
7723 function usePositioner(componentProps, state, {
7724 styles,
7725 transitionStatus,
7726 props,
7727 refs,
7728 hidden,
7729 inert = false
7730 }) {
7731 const style = {
7732 ...styles
7733 };
7734 if (inert) {
7735 style.pointerEvents = "none";
7736 }
7737 return useRenderElement("div", componentProps, {
7738 state,
7739 ref: refs,
7740 props: [{
7741 role: "presentation",
7742 hidden,
7743 style
7744 }, getDisabledMountTransitionStyles(transitionStatus), props],
7745 stateAttributesMapping: popupStateMapping
7746 });
7747 }
7748
7749 // node_modules/@base-ui/react/utils/usePopupViewport.mjs
7750 var React32 = __toESM(require_react(), 1);
7751 var ReactDOM6 = __toESM(require_react_dom(), 1);
7752
7753 // node_modules/@base-ui/utils/usePreviousValue.mjs
7754 var React30 = __toESM(require_react(), 1);
7755 function usePreviousValue(value) {
7756 const [state, setState] = React30.useState({
7757 current: value,
7758 previous: null
7759 });
7760 if (value !== state.current) {
7761 setState({
7762 current: value,
7763 previous: state.current
7764 });
7765 }
7766 return state.previous;
7767 }
7768
7769 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs
7770 var React31 = __toESM(require_react(), 1);
7771
7772 // node_modules/@base-ui/react/utils/getCssDimensions.mjs
7773 function getCssDimensions2(element) {
7774 const css = getComputedStyle2(element);
7775 let width = parseFloat(css.width) || 0;
7776 let height = parseFloat(css.height) || 0;
7777 const hasOffset = isHTMLElement(element);
7778 const offsetWidth = hasOffset ? element.offsetWidth : width;
7779 const offsetHeight = hasOffset ? element.offsetHeight : height;
7780 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
7781 if (shouldFallback) {
7782 width = offsetWidth;
7783 height = offsetHeight;
7784 }
7785 return {
7786 width,
7787 height
7788 };
7789 }
7790
7791 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs
7792 function usePopupAutoResize(parameters) {
7793 const {
7794 popupElement,
7795 positionerElement,
7796 content,
7797 mounted,
7798 onMeasureLayout: onMeasureLayoutParam,
7799 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
7800 side,
7801 direction
7802 } = parameters;
7803 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
7804 const animationFrame = useAnimationFrame();
7805 const committedDimensionsRef = React31.useRef(null);
7806 const isInitialRenderRef = React31.useRef(true);
7807 const restoreAnchoringStylesRef = React31.useRef(NOOP);
7808 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
7809 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
7810 const anchoringStyles = React31.useMemo(() => {
7811 let isOriginSide = side === "top";
7812 let isPhysicalLeft = side === "left";
7813 if (direction === "rtl") {
7814 isOriginSide = isOriginSide || side === "inline-end";
7815 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
7816 } else {
7817 isOriginSide = isOriginSide || side === "inline-start";
7818 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
7819 }
7820 return isOriginSide ? {
7821 position: "absolute",
7822 [side === "top" ? "bottom" : "top"]: "0",
7823 [isPhysicalLeft ? "right" : "left"]: "0"
7824 } : EMPTY_OBJECT;
7825 }, [side, direction]);
7826 useIsoLayoutEffect(() => {
7827 if (!mounted) {
7828 restoreAnchoringStylesRef.current = NOOP;
7829 isInitialRenderRef.current = true;
7830 committedDimensionsRef.current = null;
7831 return void 0;
7832 }
7833 if (!popupElement || !positionerElement) {
7834 return void 0;
7835 }
7836 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
7837 setPopupCssSize(popupElement, "auto");
7838 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
7839 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
7840 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
7841 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
7842 "--available-width": "max-content",
7843 "--available-height": "max-content"
7844 });
7845 function restoreMeasurementOverrides() {
7846 restorePopupPosition();
7847 restorePopupTransform();
7848 restorePositionerAvailableSize();
7849 }
7850 function restoreMeasurementOverridesIncludingScale() {
7851 restoreMeasurementOverrides();
7852 restorePopupScale();
7853 }
7854 onMeasureLayout?.();
7855 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
7856 setPositionerCssSize(positionerElement, "max-content");
7857 const dimensions = getCssDimensions2(popupElement);
7858 committedDimensionsRef.current = dimensions;
7859 setPositionerCssSize(positionerElement, dimensions);
7860 restoreMeasurementOverridesIncludingScale();
7861 onMeasureLayoutComplete?.(null, dimensions);
7862 isInitialRenderRef.current = false;
7863 return () => {
7864 restoreAnchoringStylesRef.current();
7865 restoreAnchoringStylesRef.current = NOOP;
7866 };
7867 }
7868 setPositionerCssSize(positionerElement, "max-content");
7869 const previousDimensions = committedDimensionsRef.current;
7870 const newDimensions = getCssDimensions2(popupElement);
7871 committedDimensionsRef.current = newDimensions;
7872 setPopupCssSize(popupElement, previousDimensions);
7873 restoreMeasurementOverridesIncludingScale();
7874 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
7875 setPositionerCssSize(positionerElement, newDimensions);
7876 const abortController = new AbortController();
7877 animationFrame.request(() => {
7878 setPopupCssSize(popupElement, newDimensions);
7879 runOnceAnimationsFinish(() => {
7880 popupElement.style.setProperty("--popup-width", "auto");
7881 popupElement.style.setProperty("--popup-height", "auto");
7882 }, abortController.signal);
7883 });
7884 return () => {
7885 abortController.abort();
7886 animationFrame.cancel();
7887 restoreAnchoringStylesRef.current();
7888 restoreAnchoringStylesRef.current = NOOP;
7889 };
7890 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
7891 }
7892 function overrideElementStyle(element, property, value) {
7893 const originalValue = element.style.getPropertyValue(property);
7894 element.style.setProperty(property, value);
7895 return () => {
7896 element.style.setProperty(property, originalValue);
7897 };
7898 }
7899 function applyElementStyles(element, styles) {
7900 const restorers = [];
7901 for (const [key, value] of Object.entries(styles)) {
7902 restorers.push(overrideElementStyle(element, key, value));
7903 }
7904 return restorers.length ? () => {
7905 restorers.forEach((restore) => restore());
7906 } : NOOP;
7907 }
7908 function setPopupCssSize(popupElement, size4) {
7909 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
7910 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
7911 popupElement.style.setProperty("--popup-width", width);
7912 popupElement.style.setProperty("--popup-height", height);
7913 }
7914 function setPositionerCssSize(positionerElement, size4) {
7915 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
7916 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
7917 positionerElement.style.setProperty("--positioner-width", width);
7918 positionerElement.style.setProperty("--positioner-height", height);
7919 }
7920
7921 // node_modules/@base-ui/react/utils/usePopupViewport.mjs
7922 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
7923 function usePopupViewport(parameters) {
7924 const {
7925 store,
7926 side,
7927 cssVars,
7928 children
7929 } = parameters;
7930 const direction = useDirection();
7931 const activeTrigger = store.useState("activeTriggerElement");
7932 const activeTriggerId = store.useState("activeTriggerId");
7933 const open = store.useState("open");
7934 const payload = store.useState("payload");
7935 const mounted = store.useState("mounted");
7936 const popupElement = store.useState("popupElement");
7937 const positionerElement = store.useState("positionerElement");
7938 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
7939 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
7940 const capturedNodeRef = React32.useRef(null);
7941 const [previousContentNode, setPreviousContentNode] = React32.useState(null);
7942 const [newTriggerOffset, setNewTriggerOffset] = React32.useState(null);
7943 const currentContainerRef = React32.useRef(null);
7944 const previousContainerRef = React32.useRef(null);
7945 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
7946 const cleanupFrame = useAnimationFrame();
7947 const [previousContentDimensions, setPreviousContentDimensions] = React32.useState(null);
7948 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React32.useState(false);
7949 useIsoLayoutEffect(() => {
7950 store.set("hasViewport", true);
7951 return () => {
7952 store.set("hasViewport", false);
7953 };
7954 }, [store]);
7955 const handleMeasureLayout = useStableCallback(() => {
7956 currentContainerRef.current?.style.setProperty("animation", "none");
7957 currentContainerRef.current?.style.setProperty("transition", "none");
7958 previousContainerRef.current?.style.setProperty("display", "none");
7959 });
7960 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
7961 currentContainerRef.current?.style.removeProperty("animation");
7962 currentContainerRef.current?.style.removeProperty("transition");
7963 previousContainerRef.current?.style.removeProperty("display");
7964 if (previousDimensions) {
7965 setPreviousContentDimensions(previousDimensions);
7966 }
7967 });
7968 const lastHandledTriggerRef = React32.useRef(null);
7969 useIsoLayoutEffect(() => {
7970 if (!open || !mounted) {
7971 lastHandledTriggerRef.current = null;
7972 }
7973 }, [open, mounted]);
7974 useIsoLayoutEffect(() => {
7975 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
7976 setPreviousContentNode(capturedNodeRef.current);
7977 setShowStartingStyleAttribute(true);
7978 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
7979 setNewTriggerOffset(offset4);
7980 cleanupFrame.request(() => {
7981 ReactDOM6.flushSync(() => {
7982 setShowStartingStyleAttribute(false);
7983 });
7984 onAnimationsFinished(() => {
7985 setPreviousContentNode(null);
7986 setPreviousContentDimensions(null);
7987 capturedNodeRef.current = null;
7988 });
7989 });
7990 lastHandledTriggerRef.current = activeTrigger;
7991 }
7992 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
7993 useIsoLayoutEffect(() => {
7994 const source = currentContainerRef.current;
7995 if (!source) {
7996 return;
7997 }
7998 const wrapper = ownerDocument(source).createElement("div");
7999 for (const child of Array.from(source.childNodes)) {
8000 wrapper.appendChild(child.cloneNode(true));
8001 }
8002 capturedNodeRef.current = wrapper;
8003 });
8004 const isTransitioning = previousContentNode != null;
8005 let childrenToRender;
8006 if (!isTransitioning) {
8007 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
8008 "data-current": true,
8009 ref: currentContainerRef,
8010 children
8011 }, currentContentKey);
8012 } else {
8013 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(React32.Fragment, {
8014 children: [/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
8015 "data-previous": true,
8016 inert: inertValue(true),
8017 ref: previousContainerRef,
8018 style: {
8019 ...previousContentDimensions ? {
8020 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
8021 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
8022 } : null,
8023 position: "absolute"
8024 },
8025 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
8026 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
8027 "data-current": true,
8028 ref: currentContainerRef,
8029 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
8030 children
8031 }, currentContentKey)]
8032 });
8033 }
8034 useIsoLayoutEffect(() => {
8035 const container = previousContainerRef.current;
8036 if (!container || !previousContentNode) {
8037 return;
8038 }
8039 container.replaceChildren(...Array.from(previousContentNode.childNodes));
8040 }, [previousContentNode]);
8041 usePopupAutoResize({
8042 popupElement,
8043 positionerElement,
8044 mounted,
8045 content: payload,
8046 onMeasureLayout: handleMeasureLayout,
8047 onMeasureLayoutComplete: handleMeasureLayoutComplete,
8048 side,
8049 direction
8050 });
8051 const state = {
8052 activationDirection: getActivationDirection(newTriggerOffset),
8053 transitioning: isTransitioning
8054 };
8055 return {
8056 children: childrenToRender,
8057 state
8058 };
8059 }
8060 function getActivationDirection(offset4) {
8061 if (!offset4) {
8062 return void 0;
8063 }
8064 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
8065 }
8066 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
8067 if (value > tolerance) {
8068 return positiveLabel;
8069 }
8070 if (value < -tolerance) {
8071 return negativeLabel;
8072 }
8073 return "";
8074 }
8075 function calculateRelativePosition(from, to) {
8076 const fromRect = from.getBoundingClientRect();
8077 const toRect = to.getBoundingClientRect();
8078 const fromCenter = {
8079 x: fromRect.left + fromRect.width / 2,
8080 y: fromRect.top + fromRect.height / 2
8081 };
8082 const toCenter = {
8083 x: toRect.left + toRect.width / 2,
8084 y: toRect.top + toRect.height / 2
8085 };
8086 return {
8087 horizontal: toCenter.x - fromCenter.x,
8088 vertical: toCenter.y - fromCenter.y
8089 };
8090 }
8091 function usePopupContentKey(activeTriggerId, payload) {
8092 const [contentKey, setContentKey] = React32.useState(0);
8093 const previousActiveTriggerIdRef = React32.useRef(activeTriggerId);
8094 const previousPayloadRef = React32.useRef(payload);
8095 const pendingPayloadUpdateRef = React32.useRef(false);
8096 useIsoLayoutEffect(() => {
8097 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
8098 const previousPayload = previousPayloadRef.current;
8099 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
8100 const payloadChanged = payload !== previousPayload;
8101 if (triggerIdChanged) {
8102 setContentKey((value) => value + 1);
8103 pendingPayloadUpdateRef.current = !payloadChanged;
8104 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
8105 setContentKey((value) => value + 1);
8106 pendingPayloadUpdateRef.current = false;
8107 }
8108 previousActiveTriggerIdRef.current = activeTriggerId;
8109 previousPayloadRef.current = payload;
8110 }, [activeTriggerId, payload]);
8111 return `${activeTriggerId ?? "current"}-${contentKey}`;
8112 }
8113
8114 // node_modules/@base-ui/react/utils/FloatingPortalLite.mjs
8115 var React33 = __toESM(require_react(), 1);
8116 var ReactDOM7 = __toESM(require_react_dom(), 1);
8117 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
8118 var FloatingPortalLite = /* @__PURE__ */ React33.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
8119 const {
8120 children,
8121 container,
8122 className,
8123 render: render4,
8124 style,
8125 ...elementProps
8126 } = componentProps;
8127 const {
8128 portalNode,
8129 portalSubtree
8130 } = useFloatingPortalNode({
8131 container,
8132 ref: forwardedRef,
8133 componentProps,
8134 elementProps
8135 });
8136 if (!portalSubtree && !portalNode) {
8137 return null;
8138 }
8139 return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React33.Fragment, {
8140 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM7.createPortal(children, portalNode)]
8141 });
8142 });
8143 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
8144
8145 // node_modules/@base-ui/react/tooltip/index.parts.mjs
8146 var index_parts_exports = {};
8147 __export(index_parts_exports, {
8148 Arrow: () => TooltipArrow,
8149 Handle: () => TooltipHandle,
8150 Popup: () => TooltipPopup,
8151 Portal: () => TooltipPortal,
8152 Positioner: () => TooltipPositioner,
8153 Provider: () => TooltipProvider,
8154 Root: () => TooltipRoot,
8155 Trigger: () => TooltipTrigger,
8156 Viewport: () => TooltipViewport,
8157 createHandle: () => createTooltipHandle
8158 });
8159
8160 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs
8161 var React36 = __toESM(require_react(), 1);
8162
8163 // node_modules/@base-ui/react/tooltip/root/TooltipRootContext.mjs
8164 var React34 = __toESM(require_react(), 1);
8165 var TooltipRootContext = /* @__PURE__ */ React34.createContext(void 0);
8166 if (true) TooltipRootContext.displayName = "TooltipRootContext";
8167 function useTooltipRootContext(optional) {
8168 const context = React34.useContext(TooltipRootContext);
8169 if (context === void 0 && !optional) {
8170 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
8171 }
8172 return context;
8173 }
8174
8175 // node_modules/@base-ui/react/tooltip/store/TooltipStore.mjs
8176 var React35 = __toESM(require_react(), 1);
8177 var selectors2 = {
8178 ...popupStoreSelectors,
8179 disabled: createSelector((state) => state.disabled),
8180 instantType: createSelector((state) => state.instantType),
8181 isInstantPhase: createSelector((state) => state.isInstantPhase),
8182 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
8183 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
8184 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
8185 closeOnClick: createSelector((state) => state.closeOnClick),
8186 closeDelay: createSelector((state) => state.closeDelay),
8187 hasViewport: createSelector((state) => state.hasViewport)
8188 };
8189 var TooltipStore = class _TooltipStore extends ReactStore {
8190 constructor(initialState, floatingId, nested = false) {
8191 const triggerElements = new PopupTriggerMap();
8192 const state = {
8193 ...createInitialState(),
8194 ...initialState
8195 };
8196 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
8197 super(state, {
8198 popupRef: /* @__PURE__ */ React35.createRef(),
8199 onOpenChange: void 0,
8200 onOpenChangeComplete: void 0,
8201 triggerElements
8202 }, selectors2);
8203 }
8204 setOpen = (nextOpen, eventDetails) => {
8205 applyPopupOpenChange(this, nextOpen, eventDetails, {
8206 extraState: {
8207 openChangeReason: eventDetails.reason
8208 }
8209 });
8210 };
8211 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change.
8212 cancelPendingOpen(event) {
8213 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event));
8214 }
8215 static useStore(externalStore, initialState) {
8216 const store = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store;
8217 return store;
8218 }
8219 };
8220 function createInitialState() {
8221 return {
8222 ...createInitialPopupStoreState(),
8223 disabled: false,
8224 instantType: void 0,
8225 isInstantPhase: false,
8226 trackCursorAxis: "none",
8227 disableHoverablePopup: false,
8228 openChangeReason: null,
8229 closeOnClick: true,
8230 closeDelay: 0,
8231 hasViewport: false
8232 };
8233 }
8234
8235 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs
8236 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
8237 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
8238 const {
8239 disabled: disabled2 = false,
8240 defaultOpen = false,
8241 open: openProp,
8242 disableHoverablePopup = false,
8243 trackCursorAxis = "none",
8244 actionsRef,
8245 onOpenChange,
8246 onOpenChangeComplete,
8247 handle,
8248 triggerId: triggerIdProp,
8249 defaultTriggerId: defaultTriggerIdProp = null,
8250 children
8251 } = props;
8252 const store = TooltipStore.useStore(handle?.store, {
8253 open: defaultOpen,
8254 openProp,
8255 activeTriggerId: defaultTriggerIdProp,
8256 triggerIdProp
8257 });
8258 useInitialOpenSync(store, openProp, defaultOpen, defaultTriggerIdProp);
8259 store.useControlledProp("openProp", openProp);
8260 store.useControlledProp("triggerIdProp", triggerIdProp);
8261 store.useContextCallback("onOpenChange", onOpenChange);
8262 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
8263 const openState = store.useState("open");
8264 const open = !disabled2 && openState;
8265 const activeTriggerId = store.useState("activeTriggerId");
8266 const mounted = store.useState("mounted");
8267 const payload = store.useState("payload");
8268 store.useSyncedValues({
8269 trackCursorAxis,
8270 disableHoverablePopup
8271 });
8272 store.useSyncedValue("disabled", disabled2);
8273 useImplicitActiveTrigger(store, {
8274 closeOnActiveTriggerUnmount: true
8275 });
8276 const {
8277 forceUnmount,
8278 transitionStatus
8279 } = useOpenStateTransitions(open, store);
8280 const isInstantPhase = store.useState("isInstantPhase");
8281 const instantType = store.useState("instantType");
8282 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
8283 const previousInstantTypeRef = React36.useRef(null);
8284 useIsoLayoutEffect(() => {
8285 if (openState && disabled2) {
8286 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
8287 }
8288 }, [openState, disabled2, store]);
8289 useIsoLayoutEffect(() => {
8290 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
8291 if (instantType !== "delay") {
8292 previousInstantTypeRef.current = instantType;
8293 }
8294 store.set("instantType", "delay");
8295 } else if (previousInstantTypeRef.current !== null) {
8296 store.set("instantType", previousInstantTypeRef.current);
8297 previousInstantTypeRef.current = null;
8298 }
8299 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
8300 useIsoLayoutEffect(() => {
8301 if (open) {
8302 if (activeTriggerId == null) {
8303 store.set("payload", void 0);
8304 }
8305 }
8306 }, [store, activeTriggerId, open]);
8307 const handleImperativeClose = React36.useCallback(() => {
8308 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
8309 }, [store]);
8310 React36.useImperativeHandle(actionsRef, () => ({
8311 unmount: forceUnmount,
8312 close: handleImperativeClose
8313 }), [forceUnmount, handleImperativeClose]);
8314 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none";
8315 return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(TooltipRootContext.Provider, {
8316 value: store,
8317 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TooltipInteractions, {
8318 store,
8319 disabled: disabled2,
8320 trackCursorAxis
8321 }), typeof children === "function" ? children({
8322 payload
8323 }) : children]
8324 });
8325 });
8326 if (true) TooltipRoot.displayName = "TooltipRoot";
8327 function TooltipInteractions({
8328 store,
8329 disabled: disabled2,
8330 trackCursorAxis
8331 }) {
8332 const floatingRootContext = store.useState("floatingRootContext");
8333 const dismiss = useDismiss(floatingRootContext, {
8334 enabled: !disabled2,
8335 referencePress: () => store.select("closeOnClick")
8336 });
8337 const clientPoint = useClientPoint(floatingRootContext, {
8338 enabled: !disabled2 && trackCursorAxis !== "none",
8339 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
8340 });
8341 const activeTriggerProps = React36.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]);
8342 const inactiveTriggerProps = React36.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]);
8343 const popupProps = React36.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]);
8344 usePopupInteractionProps(store, {
8345 activeTriggerProps,
8346 inactiveTriggerProps,
8347 popupProps
8348 });
8349 return null;
8350 }
8351
8352 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs
8353 var React38 = __toESM(require_react(), 1);
8354
8355 // node_modules/@base-ui/react/tooltip/provider/TooltipProviderContext.mjs
8356 var React37 = __toESM(require_react(), 1);
8357 var TooltipProviderContext = /* @__PURE__ */ React37.createContext(void 0);
8358 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
8359 function useTooltipProviderContext() {
8360 return React37.useContext(TooltipProviderContext);
8361 }
8362
8363 // node_modules/@base-ui/react/tooltip/trigger/TooltipTriggerDataAttributes.mjs
8364 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
8365 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
8366 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
8367 return TooltipTriggerDataAttributes2;
8368 })({});
8369
8370 // node_modules/@base-ui/react/tooltip/utils/constants.mjs
8371 var OPEN_DELAY = 600;
8372
8373 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs
8374 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger";
8375 function getTargetElement(event) {
8376 if ("composedPath" in event) {
8377 const path = event.composedPath();
8378 for (let i2 = 0; i2 < path.length; i2 += 1) {
8379 const element = path[i2];
8380 if (isElement(element)) {
8381 return element;
8382 }
8383 }
8384 }
8385 const target = event.target;
8386 if (isElement(target)) {
8387 return target;
8388 }
8389 return null;
8390 }
8391 function closestEnabledTooltipTrigger(element) {
8392 let current = element;
8393 while (current) {
8394 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) {
8395 return current;
8396 }
8397 const parentElement = current.parentElement;
8398 if (parentElement) {
8399 current = parentElement;
8400 continue;
8401 }
8402 const root = current.getRootNode();
8403 current = "host" in root && isElement(root.host) ? root.host : null;
8404 }
8405 return null;
8406 }
8407 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
8408 const {
8409 render: render4,
8410 className,
8411 style,
8412 handle,
8413 payload,
8414 disabled: disabledProp,
8415 delay,
8416 closeOnClick = true,
8417 closeDelay,
8418 id: idProp,
8419 ...elementProps
8420 } = componentProps;
8421 const rootContext = useTooltipRootContext(true);
8422 const store = handle?.store ?? rootContext;
8423 if (!store) {
8424 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));
8425 }
8426 const thisTriggerId = useBaseUiId(idProp);
8427 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
8428 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
8429 const floatingRootContext = store.useState("floatingRootContext");
8430 const triggerElementRef = React38.useRef(null);
8431 const delayWithDefault = delay ?? OPEN_DELAY;
8432 const closeDelayWithDefault = closeDelay ?? 0;
8433 const {
8434 registerTrigger,
8435 isMountedByThisTrigger
8436 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
8437 payload,
8438 closeOnClick,
8439 closeDelay: closeDelayWithDefault
8440 });
8441 const providerContext = useTooltipProviderContext();
8442 const {
8443 delayRef,
8444 isInstantPhase,
8445 hasProvider
8446 } = useDelayGroup(floatingRootContext, {
8447 open: isOpenedByThisTrigger
8448 });
8449 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext);
8450 store.useSyncedValue("isInstantPhase", isInstantPhase);
8451 const rootDisabled = store.useState("disabled");
8452 const disabled2 = disabledProp ?? rootDisabled;
8453 const disabledRef = useValueAsRef(disabled2);
8454 const trackCursorAxis = store.useState("trackCursorAxis");
8455 const disableHoverablePopup = store.useState("disableHoverablePopup");
8456 const isNestedTriggerHoveredRef = React38.useRef(false);
8457 const nestedTriggerOpenTimeout = useTimeout();
8458 const pointerTypeRef = React38.useRef(void 0);
8459 function getOpenDelay() {
8460 const providerDelay = providerContext?.delay;
8461 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
8462 let computedOpenDelay = delayWithDefault;
8463 if (hasProvider) {
8464 if (groupOpenValue !== 0) {
8465 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault;
8466 } else {
8467 computedOpenDelay = 0;
8468 }
8469 }
8470 return computedOpenDelay;
8471 }
8472 function isEnabledNestedTriggerTarget(target) {
8473 const triggerEl = triggerElementRef.current;
8474 if (!triggerEl || !target) {
8475 return false;
8476 }
8477 const nearestTrigger = closestEnabledTooltipTrigger(target);
8478 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger);
8479 }
8480 function detectNestedTriggerHover(target) {
8481 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target);
8482 isNestedTriggerHoveredRef.current = nestedTriggerHovered;
8483 if (nestedTriggerHovered) {
8484 hoverInteraction.openChangeTimeout.clear();
8485 hoverInteraction.restTimeout.clear();
8486 hoverInteraction.restTimeoutPending = false;
8487 nestedTriggerOpenTimeout.clear();
8488 }
8489 return nestedTriggerHovered;
8490 }
8491 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
8492 enabled: !disabled2,
8493 mouseOnly: true,
8494 move: false,
8495 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
8496 restMs: getOpenDelay,
8497 delay() {
8498 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
8499 let computedCloseDelay = closeDelayWithDefault;
8500 if (closeDelay == null && hasProvider) {
8501 computedCloseDelay = closeValue;
8502 }
8503 return {
8504 close: computedCloseDelay
8505 };
8506 },
8507 triggerElementRef,
8508 isActiveTrigger: isTriggerActive,
8509 isClosing: () => store.select("transitionStatus") === "ending",
8510 shouldOpen() {
8511 return !isNestedTriggerHoveredRef.current;
8512 }
8513 });
8514 const focusProps = useFocus(floatingRootContext, {
8515 enabled: !disabled2
8516 }).reference;
8517 const handleNestedTriggerHover = (event) => {
8518 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current;
8519 const target = getTargetElement(event);
8520 const nestedTriggerHovered = detectNestedTriggerHover(target);
8521 const triggerEl = triggerElementRef.current;
8522 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target);
8523 if (nestedTriggerHovered && store.select("open") && store.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) {
8524 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
8525 return;
8526 }
8527 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences.
8528 isMouseLikePointerType(pointerTypeRef.current)) {
8529 const open = () => {
8530 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store.select("open")) {
8531 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl));
8532 }
8533 };
8534 const openDelay = getOpenDelay();
8535 if (openDelay === 0) {
8536 nestedTriggerOpenTimeout.clear();
8537 open();
8538 } else {
8539 nestedTriggerOpenTimeout.start(openDelay, open);
8540 }
8541 }
8542 };
8543 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
8544 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none";
8545 const state = {
8546 open: isOpenedByThisTrigger
8547 };
8548 const element = useRenderElement("button", componentProps, {
8549 state,
8550 ref: [forwardedRef, registerTrigger, triggerElementRef],
8551 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, {
8552 onMouseOver(event) {
8553 handleNestedTriggerHover(event.nativeEvent);
8554 },
8555 onFocus(event) {
8556 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) {
8557 event.preventBaseUIHandler();
8558 }
8559 },
8560 onMouseLeave() {
8561 isNestedTriggerHoveredRef.current = false;
8562 nestedTriggerOpenTimeout.clear();
8563 pointerTypeRef.current = void 0;
8564 },
8565 onPointerEnter(event) {
8566 pointerTypeRef.current = event.pointerType;
8567 },
8568 onPointerDown(event) {
8569 pointerTypeRef.current = event.pointerType;
8570 store.set("closeOnClick", closeOnClick);
8571 if (closeOnClick && !store.select("open")) {
8572 store.cancelPendingOpen(event.nativeEvent);
8573 }
8574 },
8575 onClick(event) {
8576 if (closeOnClick && !store.select("open")) {
8577 store.cancelPendingOpen(event.nativeEvent);
8578 }
8579 },
8580 id: thisTriggerId,
8581 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0,
8582 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : ""
8583 }, elementProps],
8584 stateAttributesMapping: triggerOpenStateMapping
8585 });
8586 return element;
8587 });
8588 if (true) TooltipTrigger.displayName = "TooltipTrigger";
8589
8590 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs
8591 var React40 = __toESM(require_react(), 1);
8592
8593 // node_modules/@base-ui/react/tooltip/portal/TooltipPortalContext.mjs
8594 var React39 = __toESM(require_react(), 1);
8595 var TooltipPortalContext = /* @__PURE__ */ React39.createContext(void 0);
8596 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
8597 function useTooltipPortalContext() {
8598 const value = React39.useContext(TooltipPortalContext);
8599 if (value === void 0) {
8600 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
8601 }
8602 return value;
8603 }
8604
8605 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs
8606 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
8607 var TooltipPortal = /* @__PURE__ */ React40.forwardRef(function TooltipPortal2(props, forwardedRef) {
8608 const {
8609 keepMounted = false,
8610 ...portalProps
8611 } = props;
8612 const store = useTooltipRootContext();
8613 const mounted = store.useState("mounted");
8614 const shouldRender = mounted || keepMounted;
8615 if (!shouldRender) {
8616 return null;
8617 }
8618 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipPortalContext.Provider, {
8619 value: keepMounted,
8620 children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FloatingPortalLite, {
8621 ref: forwardedRef,
8622 ...portalProps
8623 })
8624 });
8625 });
8626 if (true) TooltipPortal.displayName = "TooltipPortal";
8627
8628 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs
8629 var React42 = __toESM(require_react(), 1);
8630
8631 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositionerContext.mjs
8632 var React41 = __toESM(require_react(), 1);
8633 var TooltipPositionerContext = /* @__PURE__ */ React41.createContext(void 0);
8634 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
8635 function useTooltipPositionerContext() {
8636 const context = React41.useContext(TooltipPositionerContext);
8637 if (context === void 0) {
8638 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
8639 }
8640 return context;
8641 }
8642
8643 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs
8644 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
8645 var TooltipPositioner = /* @__PURE__ */ React42.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
8646 const {
8647 render: render4,
8648 className,
8649 anchor,
8650 positionMethod = "absolute",
8651 side = "top",
8652 align = "center",
8653 sideOffset = 0,
8654 alignOffset = 0,
8655 collisionBoundary = "clipping-ancestors",
8656 collisionPadding = 5,
8657 arrowPadding = 5,
8658 sticky = false,
8659 disableAnchorTracking = false,
8660 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
8661 style,
8662 ...elementProps
8663 } = componentProps;
8664 const store = useTooltipRootContext();
8665 const keepMounted = useTooltipPortalContext();
8666 const open = store.useState("open");
8667 const mounted = store.useState("mounted");
8668 const trackCursorAxis = store.useState("trackCursorAxis");
8669 const disableHoverablePopup = store.useState("disableHoverablePopup");
8670 const floatingRootContext = store.useState("floatingRootContext");
8671 const instantType = store.useState("instantType");
8672 const transitionStatus = store.useState("transitionStatus");
8673 const hasViewport = store.useState("hasViewport");
8674 const positioning = useAnchorPositioning({
8675 anchor,
8676 positionMethod,
8677 floatingRootContext,
8678 mounted,
8679 side,
8680 sideOffset,
8681 align,
8682 alignOffset,
8683 collisionBoundary,
8684 collisionPadding,
8685 sticky,
8686 arrowPadding,
8687 disableAnchorTracking,
8688 keepMounted,
8689 collisionAvoidance,
8690 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
8691 });
8692 const state = React42.useMemo(() => ({
8693 open,
8694 side: positioning.side,
8695 align: positioning.align,
8696 anchorHidden: positioning.anchorHidden,
8697 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
8698 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
8699 const element = usePositioner(componentProps, state, {
8700 styles: positioning.positionerStyles,
8701 transitionStatus,
8702 props: elementProps,
8703 refs: [forwardedRef, store.useStateSetter("positionerElement")],
8704 hidden: !mounted,
8705 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
8706 });
8707 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPositionerContext.Provider, {
8708 value: positioning,
8709 children: element
8710 });
8711 });
8712 if (true) TooltipPositioner.displayName = "TooltipPositioner";
8713
8714 // node_modules/@base-ui/react/tooltip/popup/TooltipPopup.mjs
8715 var React43 = __toESM(require_react(), 1);
8716 var stateAttributesMapping = {
8717 ...popupStateMapping,
8718 ...transitionStatusMapping
8719 };
8720 var TooltipPopup = /* @__PURE__ */ React43.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
8721 const {
8722 render: render4,
8723 className,
8724 style,
8725 ...elementProps
8726 } = componentProps;
8727 const store = useTooltipRootContext();
8728 const {
8729 side,
8730 align
8731 } = useTooltipPositionerContext();
8732 const open = store.useState("open");
8733 const instantType = store.useState("instantType");
8734 const transitionStatus = store.useState("transitionStatus");
8735 const popupProps = store.useState("popupProps");
8736 const floatingContext = store.useState("floatingRootContext");
8737 const disabled2 = store.useState("disabled");
8738 const closeDelay = store.useState("closeDelay");
8739 useOpenChangeComplete({
8740 open,
8741 ref: store.context.popupRef,
8742 onComplete() {
8743 if (open) {
8744 store.context.onOpenChangeComplete?.(true);
8745 }
8746 }
8747 });
8748 useHoverFloatingInteraction(floatingContext, {
8749 enabled: !disabled2,
8750 closeDelay
8751 });
8752 const setPopupElement = store.useStateSetter("popupElement");
8753 const state = {
8754 open,
8755 side,
8756 align,
8757 instant: instantType,
8758 transitionStatus
8759 };
8760 const element = useRenderElement("div", componentProps, {
8761 state,
8762 ref: [forwardedRef, store.context.popupRef, setPopupElement],
8763 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
8764 stateAttributesMapping
8765 });
8766 return element;
8767 });
8768 if (true) TooltipPopup.displayName = "TooltipPopup";
8769
8770 // node_modules/@base-ui/react/tooltip/arrow/TooltipArrow.mjs
8771 var React44 = __toESM(require_react(), 1);
8772 var TooltipArrow = /* @__PURE__ */ React44.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
8773 const {
8774 render: render4,
8775 className,
8776 style,
8777 ...elementProps
8778 } = componentProps;
8779 const store = useTooltipRootContext();
8780 const {
8781 arrowRef,
8782 side,
8783 align,
8784 arrowUncentered,
8785 arrowStyles
8786 } = useTooltipPositionerContext();
8787 const open = store.useState("open");
8788 const instantType = store.useState("instantType");
8789 const state = {
8790 open,
8791 side,
8792 align,
8793 uncentered: arrowUncentered,
8794 instant: instantType
8795 };
8796 const element = useRenderElement("div", componentProps, {
8797 state,
8798 ref: [forwardedRef, arrowRef],
8799 props: [{
8800 style: arrowStyles,
8801 "aria-hidden": true
8802 }, elementProps],
8803 stateAttributesMapping: popupStateMapping
8804 });
8805 return element;
8806 });
8807 if (true) TooltipArrow.displayName = "TooltipArrow";
8808
8809 // node_modules/@base-ui/react/tooltip/provider/TooltipProvider.mjs
8810 var React45 = __toESM(require_react(), 1);
8811 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
8812 var TooltipProvider = function TooltipProvider2(props) {
8813 const {
8814 delay,
8815 closeDelay,
8816 timeout = 400
8817 } = props;
8818 const contextValue = React45.useMemo(() => ({
8819 delay,
8820 closeDelay
8821 }), [delay, closeDelay]);
8822 const delayValue = React45.useMemo(() => ({
8823 open: delay,
8824 close: closeDelay
8825 }), [delay, closeDelay]);
8826 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipProviderContext.Provider, {
8827 value: contextValue,
8828 children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FloatingDelayGroup, {
8829 delay: delayValue,
8830 timeoutMs: timeout,
8831 children: props.children
8832 })
8833 });
8834 };
8835 if (true) TooltipProvider.displayName = "TooltipProvider";
8836
8837 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs
8838 var React46 = __toESM(require_react(), 1);
8839
8840 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewportCssVars.mjs
8841 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
8842 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
8843 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
8844 return TooltipViewportCssVars2;
8845 })({});
8846
8847 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs
8848 var stateAttributesMapping2 = {
8849 activationDirection: (value) => value ? {
8850 "data-activation-direction": value
8851 } : null
8852 };
8853 var TooltipViewport = /* @__PURE__ */ React46.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
8854 const {
8855 render: render4,
8856 className,
8857 style,
8858 children,
8859 ...elementProps
8860 } = componentProps;
8861 const store = useTooltipRootContext();
8862 const positioner = useTooltipPositionerContext();
8863 const instantType = store.useState("instantType");
8864 const {
8865 children: childrenToRender,
8866 state: viewportState
8867 } = usePopupViewport({
8868 store,
8869 side: positioner.side,
8870 cssVars: TooltipViewportCssVars,
8871 children
8872 });
8873 const state = {
8874 activationDirection: viewportState.activationDirection,
8875 transitioning: viewportState.transitioning,
8876 instant: instantType
8877 };
8878 return useRenderElement("div", componentProps, {
8879 state,
8880 ref: forwardedRef,
8881 props: [elementProps, {
8882 children: childrenToRender
8883 }],
8884 stateAttributesMapping: stateAttributesMapping2
8885 });
8886 });
8887 if (true) TooltipViewport.displayName = "TooltipViewport";
8888
8889 // node_modules/@base-ui/react/tooltip/store/TooltipHandle.mjs
8890 var TooltipHandle = class {
8891 /**
8892 * Internal store holding the tooltip state.
8893 * @internal
8894 */
8895 constructor() {
8896 this.store = new TooltipStore();
8897 }
8898 /**
8899 * Opens the tooltip and associates it with the trigger with the given ID.
8900 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
8901 *
8902 * This method should only be called in an event handler or an effect (not during rendering).
8903 *
8904 * @param triggerId ID of the trigger to associate with the tooltip.
8905 */
8906 open(triggerId) {
8907 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
8908 if (triggerId && !triggerElement) {
8909 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
8910 }
8911 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
8912 }
8913 /**
8914 * Closes the tooltip.
8915 */
8916 close() {
8917 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
8918 }
8919 /**
8920 * Indicates whether the tooltip is currently open.
8921 */
8922 get isOpen() {
8923 return this.store.select("open");
8924 }
8925 };
8926 function createTooltipHandle() {
8927 return new TooltipHandle();
8928 }
8929
8930 // node_modules/@base-ui/react/use-render/useRender.mjs
8931 function useRender(params) {
8932 return useRenderElement(params.defaultTagName ?? "div", params, params);
8933 }
8934
8935 // packages/ui/build-module/text/text.mjs
8936 var import_element10 = __toESM(require_element(), 1);
8937 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
8938 function getRuntime() {
8939 const globalScope = globalThis;
8940 if (globalScope.__wpStyleRuntime) {
8941 return globalScope.__wpStyleRuntime;
8942 }
8943 globalScope.__wpStyleRuntime = {
8944 documents: /* @__PURE__ */ new Map(),
8945 styles: /* @__PURE__ */ new Map(),
8946 injectedStyles: /* @__PURE__ */ new WeakMap()
8947 };
8948 if (typeof document !== "undefined") {
8949 registerDocument(document);
8950 }
8951 return globalScope.__wpStyleRuntime;
8952 }
8953 function documentContainsStyleHash(targetDocument, hash) {
8954 if (!targetDocument.head) {
8955 return false;
8956 }
8957 for (const style of targetDocument.head.querySelectorAll(
8958 `style[${STYLE_HASH_ATTRIBUTE}]`
8959 )) {
8960 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
8961 return true;
8962 }
8963 }
8964 return false;
8965 }
8966 function injectStyle(targetDocument, hash, css) {
8967 if (!targetDocument.head) {
8968 return;
8969 }
8970 const runtime = getRuntime();
8971 let injectedStyles = runtime.injectedStyles.get(targetDocument);
8972 if (!injectedStyles) {
8973 injectedStyles = /* @__PURE__ */ new Set();
8974 runtime.injectedStyles.set(targetDocument, injectedStyles);
8975 }
8976 if (injectedStyles.has(hash)) {
8977 return;
8978 }
8979 if (documentContainsStyleHash(targetDocument, hash)) {
8980 injectedStyles.add(hash);
8981 return;
8982 }
8983 const style = targetDocument.createElement("style");
8984 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
8985 style.appendChild(targetDocument.createTextNode(css));
8986 targetDocument.head.appendChild(style);
8987 injectedStyles.add(hash);
8988 }
8989 function registerDocument(targetDocument) {
8990 const runtime = getRuntime();
8991 runtime.documents.set(
8992 targetDocument,
8993 (runtime.documents.get(targetDocument) ?? 0) + 1
8994 );
8995 for (const [hash, css] of runtime.styles) {
8996 injectStyle(targetDocument, hash, css);
8997 }
8998 return () => {
8999 const count = runtime.documents.get(targetDocument);
9000 if (count === void 0) {
9001 return;
9002 }
9003 if (count <= 1) {
9004 runtime.documents.delete(targetDocument);
9005 return;
9006 }
9007 runtime.documents.set(targetDocument, count - 1);
9008 };
9009 }
9010 function registerStyle(hash, css) {
9011 const runtime = getRuntime();
9012 runtime.styles.set(hash, css);
9013 for (const targetDocument of runtime.documents.keys()) {
9014 injectStyle(targetDocument, hash, css);
9015 }
9016 }
9017 if (typeof process === "undefined" || true) {
9018 registerStyle("a495f9d138", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer 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-emphasis,600);--_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-emphasis,600)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_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-emphasis,600);--_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-emphasis,600);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-emphasis,600);--_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-emphasis,600);--_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-emphasis,600);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-default,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-default,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,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-default,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-default,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,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)}}}');
9019 }
9020 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" };
9021 if (typeof process === "undefined" || true) {
9022 registerStyle("af6d9984a6", "._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,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-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,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-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 transparent)}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-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));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 transparent);transition:var(--_gcd-a-transition,none)}");
9023 }
9024 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" };
9025 var Text = (0, import_element10.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
9026 const element = useRender({
9027 render: render4,
9028 defaultTagName: "span",
9029 ref,
9030 props: mergeProps(props, {
9031 className: clsx_default(
9032 style_default.text,
9033 global_css_defense_default.heading,
9034 global_css_defense_default.p,
9035 style_default[variant],
9036 className
9037 )
9038 })
9039 });
9040 return element;
9041 });
9042
9043 // packages/ui/build-module/icon/icon.mjs
9044 var import_element11 = __toESM(require_element(), 1);
9045 var import_primitives = __toESM(require_primitives(), 1);
9046 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
9047 var Icon = (0, import_element11.forwardRef)(function Icon2({ icon, size: size4 = 24, ...restProps }, ref) {
9048 return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
9049 import_primitives.SVG,
9050 {
9051 ref,
9052 ...icon.props,
9053 ...restProps,
9054 width: size4,
9055 height: size4
9056 }
9057 );
9058 });
9059
9060 // packages/icons/build-module/library/arrow-down.mjs
9061 var import_primitives2 = __toESM(require_primitives(), 1);
9062 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
9063 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", fill: "currentColor", 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" }) });
9064
9065 // packages/icons/build-module/library/arrow-left.mjs
9066 var import_primitives3 = __toESM(require_primitives(), 1);
9067 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
9068 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", fill: "currentColor", 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" }) });
9069
9070 // packages/icons/build-module/library/arrow-right.mjs
9071 var import_primitives4 = __toESM(require_primitives(), 1);
9072 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
9073 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", fill: "currentColor", 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" }) });
9074
9075 // packages/icons/build-module/library/arrow-up.mjs
9076 var import_primitives5 = __toESM(require_primitives(), 1);
9077 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
9078 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", fill: "currentColor", 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" }) });
9079
9080 // packages/icons/build-module/library/block-table.mjs
9081 var import_primitives6 = __toESM(require_primitives(), 1);
9082 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
9083 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", fill: "currentColor", 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" }) });
9084
9085 // packages/icons/build-module/library/category.mjs
9086 var import_primitives7 = __toESM(require_primitives(), 1);
9087 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
9088 var category_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", 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" }) });
9089
9090 // packages/icons/build-module/library/check.mjs
9091 var import_primitives8 = __toESM(require_primitives(), 1);
9092 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
9093 var check_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", 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" }) });
9094
9095 // packages/icons/build-module/library/close-small.mjs
9096 var import_primitives9 = __toESM(require_primitives(), 1);
9097 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
9098 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", fill: "currentColor", 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" }) });
9099
9100 // packages/icons/build-module/library/cog.mjs
9101 var import_primitives10 = __toESM(require_primitives(), 1);
9102 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
9103 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", 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" }) });
9104
9105 // packages/icons/build-module/library/envelope.mjs
9106 var import_primitives11 = __toESM(require_primitives(), 1);
9107 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
9108 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", 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" }) });
9109
9110 // packages/icons/build-module/library/error.mjs
9111 var import_primitives12 = __toESM(require_primitives(), 1);
9112 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
9113 var error_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", 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" }) });
9114
9115 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
9116 var import_primitives13 = __toESM(require_primitives(), 1);
9117 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
9118 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", fill: "currentColor", 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" }) });
9119
9120 // packages/icons/build-module/library/format-list-bullets.mjs
9121 var import_primitives14 = __toESM(require_primitives(), 1);
9122 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
9123 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", fill: "currentColor", 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" }) });
9124
9125 // packages/icons/build-module/library/funnel.mjs
9126 var import_primitives15 = __toESM(require_primitives(), 1);
9127 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
9128 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives15.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
9129
9130 // packages/icons/build-module/library/globe.mjs
9131 var import_primitives16 = __toESM(require_primitives(), 1);
9132 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
9133 var globe_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", 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" }) });
9134
9135 // packages/icons/build-module/library/link.mjs
9136 var import_primitives17 = __toESM(require_primitives(), 1);
9137 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
9138 var link_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", 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" }) });
9139
9140 // packages/icons/build-module/library/mobile.mjs
9141 var import_primitives18 = __toESM(require_primitives(), 1);
9142 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
9143 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", 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" }) });
9144
9145 // packages/icons/build-module/library/more-vertical.mjs
9146 var import_primitives19 = __toESM(require_primitives(), 1);
9147 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
9148 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", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives19.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
9149
9150 // packages/icons/build-module/library/next.mjs
9151 var import_primitives20 = __toESM(require_primitives(), 1);
9152 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
9153 var next_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", 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" }) });
9154
9155 // packages/icons/build-module/library/post-list.mjs
9156 var import_primitives21 = __toESM(require_primitives(), 1);
9157 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
9158 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", fill: "currentColor", 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" }) });
9159
9160 // packages/icons/build-module/library/previous.mjs
9161 var import_primitives22 = __toESM(require_primitives(), 1);
9162 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
9163 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", 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" }) });
9164
9165 // packages/icons/build-module/library/scheduled.mjs
9166 var import_primitives23 = __toESM(require_primitives(), 1);
9167 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
9168 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", 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" }) });
9169
9170 // packages/icons/build-module/library/search.mjs
9171 var import_primitives24 = __toESM(require_primitives(), 1);
9172 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
9173 var search_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", 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" }) });
9174
9175 // packages/icons/build-module/library/seen.mjs
9176 var import_primitives25 = __toESM(require_primitives(), 1);
9177 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
9178 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", 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" }) });
9179
9180 // packages/icons/build-module/library/unseen.mjs
9181 var import_primitives26 = __toESM(require_primitives(), 1);
9182 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
9183 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", 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" }) });
9184
9185 // packages/icons/build-module/library/wordpress.mjs
9186 var import_primitives27 = __toESM(require_primitives(), 1);
9187 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
9188 var wordpress_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "-2 -2 24 24", fill: "currentColor", 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" }) });
9189
9190 // packages/ui/build-module/utils/render-slot-with-children.mjs
9191 var import_element12 = __toESM(require_element(), 1);
9192 function renderSlotWithChildren(slot, defaultSlot, children) {
9193 return (0, import_element12.cloneElement)(slot ?? defaultSlot, { children });
9194 }
9195
9196 // packages/ui/build-module/utils/theme-provider.mjs
9197 var theme = __toESM(require_theme(), 1);
9198
9199 // packages/ui/build-module/lock-unlock.mjs
9200 var import_private_apis = __toESM(require_private_apis(), 1);
9201 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
9202 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
9203 "@wordpress/ui"
9204 );
9205
9206 // packages/ui/build-module/utils/theme-provider.mjs
9207 function getThemeProvider() {
9208 const themePackage = theme;
9209 if (themePackage.ThemeProvider) {
9210 return themePackage.ThemeProvider;
9211 }
9212 if (!themePackage.privateApis) {
9213 throw new Error(
9214 "@wordpress/ui: @wordpress/theme must expose `ThemeProvider` or `privateApis.ThemeProvider`."
9215 );
9216 }
9217 return unlock(
9218 themePackage.privateApis
9219 ).ThemeProvider;
9220 }
9221 var ThemeProvider = getThemeProvider();
9222
9223 // packages/ui/build-module/stack/stack.mjs
9224 var import_element13 = __toESM(require_element(), 1);
9225 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
9226 function getRuntime2() {
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 registerDocument2(document);
9238 }
9239 return globalScope.__wpStyleRuntime;
9240 }
9241 function documentContainsStyleHash2(targetDocument, hash) {
9242 if (!targetDocument.head) {
9243 return false;
9244 }
9245 for (const style of targetDocument.head.querySelectorAll(
9246 `style[${STYLE_HASH_ATTRIBUTE2}]`
9247 )) {
9248 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
9249 return true;
9250 }
9251 }
9252 return false;
9253 }
9254 function injectStyle2(targetDocument, hash, css) {
9255 if (!targetDocument.head) {
9256 return;
9257 }
9258 const runtime = getRuntime2();
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 (documentContainsStyleHash2(targetDocument, hash)) {
9268 injectedStyles.add(hash);
9269 return;
9270 }
9271 const style = targetDocument.createElement("style");
9272 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
9273 style.appendChild(targetDocument.createTextNode(css));
9274 targetDocument.head.appendChild(style);
9275 injectedStyles.add(hash);
9276 }
9277 function registerDocument2(targetDocument) {
9278 const runtime = getRuntime2();
9279 runtime.documents.set(
9280 targetDocument,
9281 (runtime.documents.get(targetDocument) ?? 0) + 1
9282 );
9283 for (const [hash, css] of runtime.styles) {
9284 injectStyle2(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 registerStyle2(hash, css) {
9299 const runtime = getRuntime2();
9300 runtime.styles.set(hash, css);
9301 for (const targetDocument of runtime.documents.keys()) {
9302 injectStyle2(targetDocument, hash, css);
9303 }
9304 }
9305 if (typeof process === "undefined" || true) {
9306 registerStyle2("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}");
9307 }
9308 var style_default2 = { "stack": "_19ce0419607e1896__stack" };
9309 var gapTokens = {
9310 xs: "var(--wpds-dimension-gap-xs, 4px)",
9311 sm: "var(--wpds-dimension-gap-sm, 8px)",
9312 md: "var(--wpds-dimension-gap-md, 12px)",
9313 lg: "var(--wpds-dimension-gap-lg, 16px)",
9314 xl: "var(--wpds-dimension-gap-xl, 24px)",
9315 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
9316 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
9317 };
9318 var Stack = (0, import_element13.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
9319 const style = {
9320 gap: gap && gapTokens[gap],
9321 alignItems: align,
9322 justifyContent: justify,
9323 flexDirection: direction,
9324 flexWrap: wrap
9325 };
9326 const element = useRender({
9327 render: render4,
9328 ref,
9329 props: mergeProps(props, { style, className: style_default2.stack })
9330 });
9331 return element;
9332 });
9333
9334 // packages/ui/build-module/tooltip/index.mjs
9335 var tooltip_exports = {};
9336 __export(tooltip_exports, {
9337 Popup: () => Popup,
9338 Portal: () => Portal,
9339 Positioner: () => Positioner,
9340 Provider: () => Provider,
9341 Root: () => Root,
9342 Trigger: () => Trigger
9343 });
9344
9345 // packages/ui/build-module/tooltip/popup.mjs
9346 var import_element16 = __toESM(require_element(), 1);
9347
9348 // packages/ui/build-module/tooltip/portal.mjs
9349 var import_element14 = __toESM(require_element(), 1);
9350
9351 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
9352 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
9353 function getRuntime3() {
9354 const globalScope = globalThis;
9355 if (globalScope.__wpStyleRuntime) {
9356 return globalScope.__wpStyleRuntime;
9357 }
9358 globalScope.__wpStyleRuntime = {
9359 documents: /* @__PURE__ */ new Map(),
9360 styles: /* @__PURE__ */ new Map(),
9361 injectedStyles: /* @__PURE__ */ new WeakMap()
9362 };
9363 if (typeof document !== "undefined") {
9364 registerDocument3(document);
9365 }
9366 return globalScope.__wpStyleRuntime;
9367 }
9368 function documentContainsStyleHash3(targetDocument, hash) {
9369 if (!targetDocument.head) {
9370 return false;
9371 }
9372 for (const style of targetDocument.head.querySelectorAll(
9373 `style[${STYLE_HASH_ATTRIBUTE3}]`
9374 )) {
9375 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
9376 return true;
9377 }
9378 }
9379 return false;
9380 }
9381 function injectStyle3(targetDocument, hash, css) {
9382 if (!targetDocument.head) {
9383 return;
9384 }
9385 const runtime = getRuntime3();
9386 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9387 if (!injectedStyles) {
9388 injectedStyles = /* @__PURE__ */ new Set();
9389 runtime.injectedStyles.set(targetDocument, injectedStyles);
9390 }
9391 if (injectedStyles.has(hash)) {
9392 return;
9393 }
9394 if (documentContainsStyleHash3(targetDocument, hash)) {
9395 injectedStyles.add(hash);
9396 return;
9397 }
9398 const style = targetDocument.createElement("style");
9399 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
9400 style.appendChild(targetDocument.createTextNode(css));
9401 targetDocument.head.appendChild(style);
9402 injectedStyles.add(hash);
9403 }
9404 function registerDocument3(targetDocument) {
9405 const runtime = getRuntime3();
9406 runtime.documents.set(
9407 targetDocument,
9408 (runtime.documents.get(targetDocument) ?? 0) + 1
9409 );
9410 for (const [hash, css] of runtime.styles) {
9411 injectStyle3(targetDocument, hash, css);
9412 }
9413 return () => {
9414 const count = runtime.documents.get(targetDocument);
9415 if (count === void 0) {
9416 return;
9417 }
9418 if (count <= 1) {
9419 runtime.documents.delete(targetDocument);
9420 return;
9421 }
9422 runtime.documents.set(targetDocument, count - 1);
9423 };
9424 }
9425 function registerStyle3(hash, css) {
9426 const runtime = getRuntime3();
9427 runtime.styles.set(hash, css);
9428 for (const targetDocument of runtime.documents.keys()) {
9429 injectStyle3(targetDocument, hash, css);
9430 }
9431 }
9432 if (typeof process === "undefined" || true) {
9433 registerStyle3("be37f31c1e", "._11fc52b637ff8a7e__slot{inset:0;isolation:isolate;pointer-events:none;position:fixed;z-index:1000000003}@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._11fc52b637ff8a7e__slot>*{pointer-events:auto}}}");
9434 }
9435 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
9436 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
9437 function resolveOwnerDocument() {
9438 return typeof document === "undefined" ? null : document;
9439 }
9440 function isInWordPressEnvironment() {
9441 let topWp;
9442 try {
9443 topWp = window.top?.wp;
9444 } catch {
9445 }
9446 const wp = topWp ?? window.wp;
9447 return typeof wp?.components === "object" && wp.components !== null;
9448 }
9449 var cachedSlot = null;
9450 function ensureSlotIsAccessible(element) {
9451 element.setAttribute("aria-hidden", "false");
9452 return element;
9453 }
9454 function createSlot(ownerDocument2) {
9455 const element = ownerDocument2.createElement("div");
9456 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
9457 if (wp_compat_overlay_slot_default.slot) {
9458 element.classList.add(wp_compat_overlay_slot_default.slot);
9459 }
9460 ownerDocument2.body.appendChild(element);
9461 return element;
9462 }
9463 function getWpCompatOverlaySlot() {
9464 if (typeof window === "undefined") {
9465 return void 0;
9466 }
9467 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
9468 return void 0;
9469 }
9470 const ownerDocument2 = resolveOwnerDocument();
9471 if (!ownerDocument2 || !ownerDocument2.body) {
9472 return void 0;
9473 }
9474 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
9475 return ensureSlotIsAccessible(cachedSlot);
9476 }
9477 const existing = ownerDocument2.querySelector(
9478 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
9479 );
9480 if (existing instanceof HTMLDivElement) {
9481 cachedSlot = ensureSlotIsAccessible(existing);
9482 return cachedSlot;
9483 }
9484 if (cachedSlot?.isConnected) {
9485 cachedSlot.remove();
9486 }
9487 cachedSlot = ensureSlotIsAccessible(createSlot(ownerDocument2));
9488 return cachedSlot;
9489 }
9490
9491 // packages/ui/build-module/tooltip/portal.mjs
9492 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
9493 var Portal = (0, import_element14.forwardRef)(
9494 function TooltipPortal3({ container, ...restProps }, ref) {
9495 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
9496 index_parts_exports.Portal,
9497 {
9498 container: container ?? getWpCompatOverlaySlot(),
9499 ...restProps,
9500 ref
9501 }
9502 );
9503 }
9504 );
9505
9506 // packages/ui/build-module/tooltip/positioner.mjs
9507 var import_element15 = __toESM(require_element(), 1);
9508 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
9509 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
9510 function getRuntime4() {
9511 const globalScope = globalThis;
9512 if (globalScope.__wpStyleRuntime) {
9513 return globalScope.__wpStyleRuntime;
9514 }
9515 globalScope.__wpStyleRuntime = {
9516 documents: /* @__PURE__ */ new Map(),
9517 styles: /* @__PURE__ */ new Map(),
9518 injectedStyles: /* @__PURE__ */ new WeakMap()
9519 };
9520 if (typeof document !== "undefined") {
9521 registerDocument4(document);
9522 }
9523 return globalScope.__wpStyleRuntime;
9524 }
9525 function documentContainsStyleHash4(targetDocument, hash) {
9526 if (!targetDocument.head) {
9527 return false;
9528 }
9529 for (const style of targetDocument.head.querySelectorAll(
9530 `style[${STYLE_HASH_ATTRIBUTE4}]`
9531 )) {
9532 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
9533 return true;
9534 }
9535 }
9536 return false;
9537 }
9538 function injectStyle4(targetDocument, hash, css) {
9539 if (!targetDocument.head) {
9540 return;
9541 }
9542 const runtime = getRuntime4();
9543 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9544 if (!injectedStyles) {
9545 injectedStyles = /* @__PURE__ */ new Set();
9546 runtime.injectedStyles.set(targetDocument, injectedStyles);
9547 }
9548 if (injectedStyles.has(hash)) {
9549 return;
9550 }
9551 if (documentContainsStyleHash4(targetDocument, hash)) {
9552 injectedStyles.add(hash);
9553 return;
9554 }
9555 const style = targetDocument.createElement("style");
9556 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
9557 style.appendChild(targetDocument.createTextNode(css));
9558 targetDocument.head.appendChild(style);
9559 injectedStyles.add(hash);
9560 }
9561 function registerDocument4(targetDocument) {
9562 const runtime = getRuntime4();
9563 runtime.documents.set(
9564 targetDocument,
9565 (runtime.documents.get(targetDocument) ?? 0) + 1
9566 );
9567 for (const [hash, css] of runtime.styles) {
9568 injectStyle4(targetDocument, hash, css);
9569 }
9570 return () => {
9571 const count = runtime.documents.get(targetDocument);
9572 if (count === void 0) {
9573 return;
9574 }
9575 if (count <= 1) {
9576 runtime.documents.delete(targetDocument);
9577 return;
9578 }
9579 runtime.documents.set(targetDocument, count - 1);
9580 };
9581 }
9582 function registerStyle4(hash, css) {
9583 const runtime = getRuntime4();
9584 runtime.styles.set(hash, css);
9585 for (const targetDocument of runtime.documents.keys()) {
9586 injectStyle4(targetDocument, hash, css);
9587 }
9588 }
9589 if (typeof process === "undefined" || true) {
9590 registerStyle4("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
9591 }
9592 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
9593 if (typeof process === "undefined" || true) {
9594 registerStyle4("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);color:var(--wpds-color-foreground-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}}}}');
9595 }
9596 var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9597 var Positioner = (0, import_element15.forwardRef)(
9598 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
9599 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
9600 index_parts_exports.Positioner,
9601 {
9602 ref,
9603 align,
9604 side,
9605 sideOffset,
9606 ...props,
9607 className: clsx_default(
9608 resets_default["box-sizing"],
9609 style_default3.positioner,
9610 className
9611 )
9612 }
9613 );
9614 }
9615 );
9616
9617 // packages/ui/build-module/tooltip/popup.mjs
9618 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
9619 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
9620 function getRuntime5() {
9621 const globalScope = globalThis;
9622 if (globalScope.__wpStyleRuntime) {
9623 return globalScope.__wpStyleRuntime;
9624 }
9625 globalScope.__wpStyleRuntime = {
9626 documents: /* @__PURE__ */ new Map(),
9627 styles: /* @__PURE__ */ new Map(),
9628 injectedStyles: /* @__PURE__ */ new WeakMap()
9629 };
9630 if (typeof document !== "undefined") {
9631 registerDocument5(document);
9632 }
9633 return globalScope.__wpStyleRuntime;
9634 }
9635 function documentContainsStyleHash5(targetDocument, hash) {
9636 if (!targetDocument.head) {
9637 return false;
9638 }
9639 for (const style of targetDocument.head.querySelectorAll(
9640 `style[${STYLE_HASH_ATTRIBUTE5}]`
9641 )) {
9642 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
9643 return true;
9644 }
9645 }
9646 return false;
9647 }
9648 function injectStyle5(targetDocument, hash, css) {
9649 if (!targetDocument.head) {
9650 return;
9651 }
9652 const runtime = getRuntime5();
9653 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9654 if (!injectedStyles) {
9655 injectedStyles = /* @__PURE__ */ new Set();
9656 runtime.injectedStyles.set(targetDocument, injectedStyles);
9657 }
9658 if (injectedStyles.has(hash)) {
9659 return;
9660 }
9661 if (documentContainsStyleHash5(targetDocument, hash)) {
9662 injectedStyles.add(hash);
9663 return;
9664 }
9665 const style = targetDocument.createElement("style");
9666 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
9667 style.appendChild(targetDocument.createTextNode(css));
9668 targetDocument.head.appendChild(style);
9669 injectedStyles.add(hash);
9670 }
9671 function registerDocument5(targetDocument) {
9672 const runtime = getRuntime5();
9673 runtime.documents.set(
9674 targetDocument,
9675 (runtime.documents.get(targetDocument) ?? 0) + 1
9676 );
9677 for (const [hash, css] of runtime.styles) {
9678 injectStyle5(targetDocument, hash, css);
9679 }
9680 return () => {
9681 const count = runtime.documents.get(targetDocument);
9682 if (count === void 0) {
9683 return;
9684 }
9685 if (count <= 1) {
9686 runtime.documents.delete(targetDocument);
9687 return;
9688 }
9689 runtime.documents.set(targetDocument, count - 1);
9690 };
9691 }
9692 function registerStyle5(hash, css) {
9693 const runtime = getRuntime5();
9694 runtime.styles.set(hash, css);
9695 for (const targetDocument of runtime.documents.keys()) {
9696 injectStyle5(targetDocument, hash, css);
9697 }
9698 }
9699 if (typeof process === "undefined" || true) {
9700 registerStyle5("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);color:var(--wpds-color-foreground-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}}}}');
9701 }
9702 var style_default4 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9703 var POPUP_COLOR = { background: "#1e1e1e" };
9704 var Popup = (0, import_element16.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
9705 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
9706 index_parts_exports.Popup,
9707 {
9708 ref,
9709 className: clsx_default(style_default4.popup, className),
9710 ...props,
9711 children
9712 }
9713 ) });
9714 const positionedPopup = renderSlotWithChildren(
9715 positioner,
9716 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Positioner, {}),
9717 popupContent
9718 );
9719 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Portal, {}), positionedPopup);
9720 });
9721
9722 // packages/ui/build-module/tooltip/trigger.mjs
9723 var import_element17 = __toESM(require_element(), 1);
9724 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
9725 var Trigger = (0, import_element17.forwardRef)(
9726 function TooltipTrigger3(props, ref) {
9727 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(index_parts_exports.Trigger, { ref, ...props });
9728 }
9729 );
9730
9731 // packages/ui/build-module/tooltip/root.mjs
9732 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
9733 function Root(props) {
9734 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(index_parts_exports.Root, { ...props });
9735 }
9736
9737 // packages/ui/build-module/tooltip/provider.mjs
9738 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
9739 function Provider({ ...props }) {
9740 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(index_parts_exports.Provider, { ...props });
9741 }
9742
9743 // packages/ui/build-module/empty-state/index.mjs
9744 var empty_state_exports = {};
9745 __export(empty_state_exports, {
9746 Actions: () => Actions,
9747 Description: () => Description,
9748 Icon: () => Icon3,
9749 Root: () => Root2,
9750 Title: () => Title,
9751 Visual: () => Visual
9752 });
9753
9754 // packages/ui/build-module/empty-state/root.mjs
9755 var import_element18 = __toESM(require_element(), 1);
9756 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
9757 function getRuntime6() {
9758 const globalScope = globalThis;
9759 if (globalScope.__wpStyleRuntime) {
9760 return globalScope.__wpStyleRuntime;
9761 }
9762 globalScope.__wpStyleRuntime = {
9763 documents: /* @__PURE__ */ new Map(),
9764 styles: /* @__PURE__ */ new Map(),
9765 injectedStyles: /* @__PURE__ */ new WeakMap()
9766 };
9767 if (typeof document !== "undefined") {
9768 registerDocument6(document);
9769 }
9770 return globalScope.__wpStyleRuntime;
9771 }
9772 function documentContainsStyleHash6(targetDocument, hash) {
9773 if (!targetDocument.head) {
9774 return false;
9775 }
9776 for (const style of targetDocument.head.querySelectorAll(
9777 `style[${STYLE_HASH_ATTRIBUTE6}]`
9778 )) {
9779 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
9780 return true;
9781 }
9782 }
9783 return false;
9784 }
9785 function injectStyle6(targetDocument, hash, css) {
9786 if (!targetDocument.head) {
9787 return;
9788 }
9789 const runtime = getRuntime6();
9790 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9791 if (!injectedStyles) {
9792 injectedStyles = /* @__PURE__ */ new Set();
9793 runtime.injectedStyles.set(targetDocument, injectedStyles);
9794 }
9795 if (injectedStyles.has(hash)) {
9796 return;
9797 }
9798 if (documentContainsStyleHash6(targetDocument, hash)) {
9799 injectedStyles.add(hash);
9800 return;
9801 }
9802 const style = targetDocument.createElement("style");
9803 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
9804 style.appendChild(targetDocument.createTextNode(css));
9805 targetDocument.head.appendChild(style);
9806 injectedStyles.add(hash);
9807 }
9808 function registerDocument6(targetDocument) {
9809 const runtime = getRuntime6();
9810 runtime.documents.set(
9811 targetDocument,
9812 (runtime.documents.get(targetDocument) ?? 0) + 1
9813 );
9814 for (const [hash, css] of runtime.styles) {
9815 injectStyle6(targetDocument, hash, css);
9816 }
9817 return () => {
9818 const count = runtime.documents.get(targetDocument);
9819 if (count === void 0) {
9820 return;
9821 }
9822 if (count <= 1) {
9823 runtime.documents.delete(targetDocument);
9824 return;
9825 }
9826 runtime.documents.set(targetDocument, count - 1);
9827 };
9828 }
9829 function registerStyle6(hash, css) {
9830 const runtime = getRuntime6();
9831 runtime.styles.set(hash, css);
9832 for (const targetDocument of runtime.documents.keys()) {
9833 injectStyle6(targetDocument, hash, css);
9834 }
9835 }
9836 if (typeof process === "undefined" || true) {
9837 registerStyle6("7b60a246cc", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-foreground-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-foreground-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-background-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-foreground-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}}}}');
9838 }
9839 var style_default5 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9840 var Root2 = (0, import_element18.forwardRef)(
9841 function EmptyStateRoot({ render: render4, ...props }, ref) {
9842 const className = clsx_default(style_default5.root);
9843 const element = useRender({
9844 defaultTagName: "div",
9845 render: render4,
9846 ref,
9847 props: mergeProps({ className }, props)
9848 });
9849 return element;
9850 }
9851 );
9852
9853 // packages/ui/build-module/empty-state/visual.mjs
9854 var import_element19 = __toESM(require_element(), 1);
9855 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
9856 function getRuntime7() {
9857 const globalScope = globalThis;
9858 if (globalScope.__wpStyleRuntime) {
9859 return globalScope.__wpStyleRuntime;
9860 }
9861 globalScope.__wpStyleRuntime = {
9862 documents: /* @__PURE__ */ new Map(),
9863 styles: /* @__PURE__ */ new Map(),
9864 injectedStyles: /* @__PURE__ */ new WeakMap()
9865 };
9866 if (typeof document !== "undefined") {
9867 registerDocument7(document);
9868 }
9869 return globalScope.__wpStyleRuntime;
9870 }
9871 function documentContainsStyleHash7(targetDocument, hash) {
9872 if (!targetDocument.head) {
9873 return false;
9874 }
9875 for (const style of targetDocument.head.querySelectorAll(
9876 `style[${STYLE_HASH_ATTRIBUTE7}]`
9877 )) {
9878 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
9879 return true;
9880 }
9881 }
9882 return false;
9883 }
9884 function injectStyle7(targetDocument, hash, css) {
9885 if (!targetDocument.head) {
9886 return;
9887 }
9888 const runtime = getRuntime7();
9889 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9890 if (!injectedStyles) {
9891 injectedStyles = /* @__PURE__ */ new Set();
9892 runtime.injectedStyles.set(targetDocument, injectedStyles);
9893 }
9894 if (injectedStyles.has(hash)) {
9895 return;
9896 }
9897 if (documentContainsStyleHash7(targetDocument, hash)) {
9898 injectedStyles.add(hash);
9899 return;
9900 }
9901 const style = targetDocument.createElement("style");
9902 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
9903 style.appendChild(targetDocument.createTextNode(css));
9904 targetDocument.head.appendChild(style);
9905 injectedStyles.add(hash);
9906 }
9907 function registerDocument7(targetDocument) {
9908 const runtime = getRuntime7();
9909 runtime.documents.set(
9910 targetDocument,
9911 (runtime.documents.get(targetDocument) ?? 0) + 1
9912 );
9913 for (const [hash, css] of runtime.styles) {
9914 injectStyle7(targetDocument, hash, css);
9915 }
9916 return () => {
9917 const count = runtime.documents.get(targetDocument);
9918 if (count === void 0) {
9919 return;
9920 }
9921 if (count <= 1) {
9922 runtime.documents.delete(targetDocument);
9923 return;
9924 }
9925 runtime.documents.set(targetDocument, count - 1);
9926 };
9927 }
9928 function registerStyle7(hash, css) {
9929 const runtime = getRuntime7();
9930 runtime.styles.set(hash, css);
9931 for (const targetDocument of runtime.documents.keys()) {
9932 injectStyle7(targetDocument, hash, css);
9933 }
9934 }
9935 if (typeof process === "undefined" || true) {
9936 registerStyle7("7b60a246cc", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-foreground-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-foreground-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-background-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-foreground-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}}}}');
9937 }
9938 var style_default6 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9939 var Visual = (0, import_element19.forwardRef)(
9940 function EmptyStateVisual({ render: render4, ...props }, ref) {
9941 const className = clsx_default(style_default6.visual);
9942 const element = useRender({
9943 defaultTagName: "div",
9944 render: render4,
9945 ref,
9946 props: mergeProps({ className }, props)
9947 });
9948 return element;
9949 }
9950 );
9951
9952 // packages/ui/build-module/empty-state/icon.mjs
9953 var import_element20 = __toESM(require_element(), 1);
9954 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
9955 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
9956 function getRuntime8() {
9957 const globalScope = globalThis;
9958 if (globalScope.__wpStyleRuntime) {
9959 return globalScope.__wpStyleRuntime;
9960 }
9961 globalScope.__wpStyleRuntime = {
9962 documents: /* @__PURE__ */ new Map(),
9963 styles: /* @__PURE__ */ new Map(),
9964 injectedStyles: /* @__PURE__ */ new WeakMap()
9965 };
9966 if (typeof document !== "undefined") {
9967 registerDocument8(document);
9968 }
9969 return globalScope.__wpStyleRuntime;
9970 }
9971 function documentContainsStyleHash8(targetDocument, hash) {
9972 if (!targetDocument.head) {
9973 return false;
9974 }
9975 for (const style of targetDocument.head.querySelectorAll(
9976 `style[${STYLE_HASH_ATTRIBUTE8}]`
9977 )) {
9978 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
9979 return true;
9980 }
9981 }
9982 return false;
9983 }
9984 function injectStyle8(targetDocument, hash, css) {
9985 if (!targetDocument.head) {
9986 return;
9987 }
9988 const runtime = getRuntime8();
9989 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9990 if (!injectedStyles) {
9991 injectedStyles = /* @__PURE__ */ new Set();
9992 runtime.injectedStyles.set(targetDocument, injectedStyles);
9993 }
9994 if (injectedStyles.has(hash)) {
9995 return;
9996 }
9997 if (documentContainsStyleHash8(targetDocument, hash)) {
9998 injectedStyles.add(hash);
9999 return;
10000 }
10001 const style = targetDocument.createElement("style");
10002 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
10003 style.appendChild(targetDocument.createTextNode(css));
10004 targetDocument.head.appendChild(style);
10005 injectedStyles.add(hash);
10006 }
10007 function registerDocument8(targetDocument) {
10008 const runtime = getRuntime8();
10009 runtime.documents.set(
10010 targetDocument,
10011 (runtime.documents.get(targetDocument) ?? 0) + 1
10012 );
10013 for (const [hash, css] of runtime.styles) {
10014 injectStyle8(targetDocument, hash, css);
10015 }
10016 return () => {
10017 const count = runtime.documents.get(targetDocument);
10018 if (count === void 0) {
10019 return;
10020 }
10021 if (count <= 1) {
10022 runtime.documents.delete(targetDocument);
10023 return;
10024 }
10025 runtime.documents.set(targetDocument, count - 1);
10026 };
10027 }
10028 function registerStyle8(hash, css) {
10029 const runtime = getRuntime8();
10030 runtime.styles.set(hash, css);
10031 for (const targetDocument of runtime.documents.keys()) {
10032 injectStyle8(targetDocument, hash, css);
10033 }
10034 }
10035 if (typeof process === "undefined" || true) {
10036 registerStyle8("7b60a246cc", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-foreground-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-foreground-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-background-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-foreground-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}}}}');
10037 }
10038 var style_default7 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10039 var Icon3 = (0, import_element20.forwardRef)(
10040 function EmptyStateIcon({ icon, className, ...restProps }, ref) {
10041 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
10042 Visual,
10043 {
10044 ref,
10045 className: clsx_default(style_default7.icon, className),
10046 ...restProps,
10047 children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Icon, { icon })
10048 }
10049 );
10050 }
10051 );
10052
10053 // packages/ui/build-module/empty-state/title.mjs
10054 var import_element21 = __toESM(require_element(), 1);
10055 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
10056 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash";
10057 function getRuntime9() {
10058 const globalScope = globalThis;
10059 if (globalScope.__wpStyleRuntime) {
10060 return globalScope.__wpStyleRuntime;
10061 }
10062 globalScope.__wpStyleRuntime = {
10063 documents: /* @__PURE__ */ new Map(),
10064 styles: /* @__PURE__ */ new Map(),
10065 injectedStyles: /* @__PURE__ */ new WeakMap()
10066 };
10067 if (typeof document !== "undefined") {
10068 registerDocument9(document);
10069 }
10070 return globalScope.__wpStyleRuntime;
10071 }
10072 function documentContainsStyleHash9(targetDocument, hash) {
10073 if (!targetDocument.head) {
10074 return false;
10075 }
10076 for (const style of targetDocument.head.querySelectorAll(
10077 `style[${STYLE_HASH_ATTRIBUTE9}]`
10078 )) {
10079 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) {
10080 return true;
10081 }
10082 }
10083 return false;
10084 }
10085 function injectStyle9(targetDocument, hash, css) {
10086 if (!targetDocument.head) {
10087 return;
10088 }
10089 const runtime = getRuntime9();
10090 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10091 if (!injectedStyles) {
10092 injectedStyles = /* @__PURE__ */ new Set();
10093 runtime.injectedStyles.set(targetDocument, injectedStyles);
10094 }
10095 if (injectedStyles.has(hash)) {
10096 return;
10097 }
10098 if (documentContainsStyleHash9(targetDocument, hash)) {
10099 injectedStyles.add(hash);
10100 return;
10101 }
10102 const style = targetDocument.createElement("style");
10103 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash);
10104 style.appendChild(targetDocument.createTextNode(css));
10105 targetDocument.head.appendChild(style);
10106 injectedStyles.add(hash);
10107 }
10108 function registerDocument9(targetDocument) {
10109 const runtime = getRuntime9();
10110 runtime.documents.set(
10111 targetDocument,
10112 (runtime.documents.get(targetDocument) ?? 0) + 1
10113 );
10114 for (const [hash, css] of runtime.styles) {
10115 injectStyle9(targetDocument, hash, css);
10116 }
10117 return () => {
10118 const count = runtime.documents.get(targetDocument);
10119 if (count === void 0) {
10120 return;
10121 }
10122 if (count <= 1) {
10123 runtime.documents.delete(targetDocument);
10124 return;
10125 }
10126 runtime.documents.set(targetDocument, count - 1);
10127 };
10128 }
10129 function registerStyle9(hash, css) {
10130 const runtime = getRuntime9();
10131 runtime.styles.set(hash, css);
10132 for (const targetDocument of runtime.documents.keys()) {
10133 injectStyle9(targetDocument, hash, css);
10134 }
10135 }
10136 if (typeof process === "undefined" || true) {
10137 registerStyle9("7b60a246cc", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-foreground-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-foreground-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-background-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-foreground-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}}}}');
10138 }
10139 var style_default8 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10140 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h2", {});
10141 var Title = (0, import_element21.forwardRef)(
10142 function EmptyStateTitle({ render: render4 = DEFAULT_TAG, className, children, ...props }, ref) {
10143 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
10144 Text,
10145 {
10146 ref,
10147 variant: "heading-lg",
10148 render: render4,
10149 className: clsx_default(style_default8.title, className),
10150 ...props,
10151 children
10152 }
10153 );
10154 }
10155 );
10156
10157 // packages/ui/build-module/empty-state/description.mjs
10158 var import_element22 = __toESM(require_element(), 1);
10159 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
10160 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash";
10161 function getRuntime10() {
10162 const globalScope = globalThis;
10163 if (globalScope.__wpStyleRuntime) {
10164 return globalScope.__wpStyleRuntime;
10165 }
10166 globalScope.__wpStyleRuntime = {
10167 documents: /* @__PURE__ */ new Map(),
10168 styles: /* @__PURE__ */ new Map(),
10169 injectedStyles: /* @__PURE__ */ new WeakMap()
10170 };
10171 if (typeof document !== "undefined") {
10172 registerDocument10(document);
10173 }
10174 return globalScope.__wpStyleRuntime;
10175 }
10176 function documentContainsStyleHash10(targetDocument, hash) {
10177 if (!targetDocument.head) {
10178 return false;
10179 }
10180 for (const style of targetDocument.head.querySelectorAll(
10181 `style[${STYLE_HASH_ATTRIBUTE10}]`
10182 )) {
10183 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) {
10184 return true;
10185 }
10186 }
10187 return false;
10188 }
10189 function injectStyle10(targetDocument, hash, css) {
10190 if (!targetDocument.head) {
10191 return;
10192 }
10193 const runtime = getRuntime10();
10194 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10195 if (!injectedStyles) {
10196 injectedStyles = /* @__PURE__ */ new Set();
10197 runtime.injectedStyles.set(targetDocument, injectedStyles);
10198 }
10199 if (injectedStyles.has(hash)) {
10200 return;
10201 }
10202 if (documentContainsStyleHash10(targetDocument, hash)) {
10203 injectedStyles.add(hash);
10204 return;
10205 }
10206 const style = targetDocument.createElement("style");
10207 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash);
10208 style.appendChild(targetDocument.createTextNode(css));
10209 targetDocument.head.appendChild(style);
10210 injectedStyles.add(hash);
10211 }
10212 function registerDocument10(targetDocument) {
10213 const runtime = getRuntime10();
10214 runtime.documents.set(
10215 targetDocument,
10216 (runtime.documents.get(targetDocument) ?? 0) + 1
10217 );
10218 for (const [hash, css] of runtime.styles) {
10219 injectStyle10(targetDocument, hash, css);
10220 }
10221 return () => {
10222 const count = runtime.documents.get(targetDocument);
10223 if (count === void 0) {
10224 return;
10225 }
10226 if (count <= 1) {
10227 runtime.documents.delete(targetDocument);
10228 return;
10229 }
10230 runtime.documents.set(targetDocument, count - 1);
10231 };
10232 }
10233 function registerStyle10(hash, css) {
10234 const runtime = getRuntime10();
10235 runtime.styles.set(hash, css);
10236 for (const targetDocument of runtime.documents.keys()) {
10237 injectStyle10(targetDocument, hash, css);
10238 }
10239 }
10240 if (typeof process === "undefined" || true) {
10241 registerStyle10("7b60a246cc", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-foreground-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-foreground-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-background-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-foreground-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}}}}');
10242 }
10243 var style_default9 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10244 var DEFAULT_TAG2 = /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", {});
10245 var Description = (0, import_element22.forwardRef)(function EmptyStateDescription({ render: render4 = DEFAULT_TAG2, className, children, ...props }, ref) {
10246 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
10247 Text,
10248 {
10249 ref,
10250 variant: "body-md",
10251 render: render4,
10252 className: clsx_default(style_default9.description, className),
10253 ...props,
10254 children
10255 }
10256 );
10257 });
10258
10259 // packages/ui/build-module/empty-state/actions.mjs
10260 var import_element23 = __toESM(require_element(), 1);
10261 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash";
10262 function getRuntime11() {
10263 const globalScope = globalThis;
10264 if (globalScope.__wpStyleRuntime) {
10265 return globalScope.__wpStyleRuntime;
10266 }
10267 globalScope.__wpStyleRuntime = {
10268 documents: /* @__PURE__ */ new Map(),
10269 styles: /* @__PURE__ */ new Map(),
10270 injectedStyles: /* @__PURE__ */ new WeakMap()
10271 };
10272 if (typeof document !== "undefined") {
10273 registerDocument11(document);
10274 }
10275 return globalScope.__wpStyleRuntime;
10276 }
10277 function documentContainsStyleHash11(targetDocument, hash) {
10278 if (!targetDocument.head) {
10279 return false;
10280 }
10281 for (const style of targetDocument.head.querySelectorAll(
10282 `style[${STYLE_HASH_ATTRIBUTE11}]`
10283 )) {
10284 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) {
10285 return true;
10286 }
10287 }
10288 return false;
10289 }
10290 function injectStyle11(targetDocument, hash, css) {
10291 if (!targetDocument.head) {
10292 return;
10293 }
10294 const runtime = getRuntime11();
10295 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10296 if (!injectedStyles) {
10297 injectedStyles = /* @__PURE__ */ new Set();
10298 runtime.injectedStyles.set(targetDocument, injectedStyles);
10299 }
10300 if (injectedStyles.has(hash)) {
10301 return;
10302 }
10303 if (documentContainsStyleHash11(targetDocument, hash)) {
10304 injectedStyles.add(hash);
10305 return;
10306 }
10307 const style = targetDocument.createElement("style");
10308 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash);
10309 style.appendChild(targetDocument.createTextNode(css));
10310 targetDocument.head.appendChild(style);
10311 injectedStyles.add(hash);
10312 }
10313 function registerDocument11(targetDocument) {
10314 const runtime = getRuntime11();
10315 runtime.documents.set(
10316 targetDocument,
10317 (runtime.documents.get(targetDocument) ?? 0) + 1
10318 );
10319 for (const [hash, css] of runtime.styles) {
10320 injectStyle11(targetDocument, hash, css);
10321 }
10322 return () => {
10323 const count = runtime.documents.get(targetDocument);
10324 if (count === void 0) {
10325 return;
10326 }
10327 if (count <= 1) {
10328 runtime.documents.delete(targetDocument);
10329 return;
10330 }
10331 runtime.documents.set(targetDocument, count - 1);
10332 };
10333 }
10334 function registerStyle11(hash, css) {
10335 const runtime = getRuntime11();
10336 runtime.styles.set(hash, css);
10337 for (const targetDocument of runtime.documents.keys()) {
10338 injectStyle11(targetDocument, hash, css);
10339 }
10340 }
10341 if (typeof process === "undefined" || true) {
10342 registerStyle11("7b60a246cc", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-foreground-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-foreground-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-background-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-foreground-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}}}}');
10343 }
10344 var style_default10 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10345 var Actions = (0, import_element23.forwardRef)(
10346 function EmptyStateActions({ render: render4, ...props }, ref) {
10347 const className = clsx_default(style_default10.actions);
10348 const element = useRender({
10349 defaultTagName: "div",
10350 render: render4,
10351 ref,
10352 props: mergeProps({ className }, props)
10353 });
10354 return element;
10355 }
10356 );
10357
10358 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
10359 var import_element24 = __toESM(require_element(), 1);
10360 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash";
10361 function getRuntime12() {
10362 const globalScope = globalThis;
10363 if (globalScope.__wpStyleRuntime) {
10364 return globalScope.__wpStyleRuntime;
10365 }
10366 globalScope.__wpStyleRuntime = {
10367 documents: /* @__PURE__ */ new Map(),
10368 styles: /* @__PURE__ */ new Map(),
10369 injectedStyles: /* @__PURE__ */ new WeakMap()
10370 };
10371 if (typeof document !== "undefined") {
10372 registerDocument12(document);
10373 }
10374 return globalScope.__wpStyleRuntime;
10375 }
10376 function documentContainsStyleHash12(targetDocument, hash) {
10377 if (!targetDocument.head) {
10378 return false;
10379 }
10380 for (const style of targetDocument.head.querySelectorAll(
10381 `style[${STYLE_HASH_ATTRIBUTE12}]`
10382 )) {
10383 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) {
10384 return true;
10385 }
10386 }
10387 return false;
10388 }
10389 function injectStyle12(targetDocument, hash, css) {
10390 if (!targetDocument.head) {
10391 return;
10392 }
10393 const runtime = getRuntime12();
10394 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10395 if (!injectedStyles) {
10396 injectedStyles = /* @__PURE__ */ new Set();
10397 runtime.injectedStyles.set(targetDocument, injectedStyles);
10398 }
10399 if (injectedStyles.has(hash)) {
10400 return;
10401 }
10402 if (documentContainsStyleHash12(targetDocument, hash)) {
10403 injectedStyles.add(hash);
10404 return;
10405 }
10406 const style = targetDocument.createElement("style");
10407 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash);
10408 style.appendChild(targetDocument.createTextNode(css));
10409 targetDocument.head.appendChild(style);
10410 injectedStyles.add(hash);
10411 }
10412 function registerDocument12(targetDocument) {
10413 const runtime = getRuntime12();
10414 runtime.documents.set(
10415 targetDocument,
10416 (runtime.documents.get(targetDocument) ?? 0) + 1
10417 );
10418 for (const [hash, css] of runtime.styles) {
10419 injectStyle12(targetDocument, hash, css);
10420 }
10421 return () => {
10422 const count = runtime.documents.get(targetDocument);
10423 if (count === void 0) {
10424 return;
10425 }
10426 if (count <= 1) {
10427 runtime.documents.delete(targetDocument);
10428 return;
10429 }
10430 runtime.documents.set(targetDocument, count - 1);
10431 };
10432 }
10433 function registerStyle12(hash, css) {
10434 const runtime = getRuntime12();
10435 runtime.styles.set(hash, css);
10436 for (const targetDocument of runtime.documents.keys()) {
10437 injectStyle12(targetDocument, hash, css);
10438 }
10439 }
10440 if (typeof process === "undefined" || true) {
10441 registerStyle12("fa606a57ae", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer 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}}}");
10442 }
10443 var style_default11 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
10444 var VisuallyHidden = (0, import_element24.forwardRef)(
10445 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
10446 const element = useRender({
10447 render: render4,
10448 ref,
10449 props: mergeProps(
10450 { className: style_default11["visually-hidden"] },
10451 restProps,
10452 {
10453 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
10454 "data-visually-hidden": ""
10455 }
10456 )
10457 });
10458 return element;
10459 }
10460 );
10461
10462 // packages/ui/build-module/link/link.mjs
10463 var import_element25 = __toESM(require_element(), 1);
10464 var import_i18n = __toESM(require_i18n(), 1);
10465 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
10466 var STYLE_HASH_ATTRIBUTE13 = "data-wp-hash";
10467 function getRuntime13() {
10468 const globalScope = globalThis;
10469 if (globalScope.__wpStyleRuntime) {
10470 return globalScope.__wpStyleRuntime;
10471 }
10472 globalScope.__wpStyleRuntime = {
10473 documents: /* @__PURE__ */ new Map(),
10474 styles: /* @__PURE__ */ new Map(),
10475 injectedStyles: /* @__PURE__ */ new WeakMap()
10476 };
10477 if (typeof document !== "undefined") {
10478 registerDocument13(document);
10479 }
10480 return globalScope.__wpStyleRuntime;
10481 }
10482 function documentContainsStyleHash13(targetDocument, hash) {
10483 if (!targetDocument.head) {
10484 return false;
10485 }
10486 for (const style of targetDocument.head.querySelectorAll(
10487 `style[${STYLE_HASH_ATTRIBUTE13}]`
10488 )) {
10489 if (style.getAttribute(STYLE_HASH_ATTRIBUTE13) === hash) {
10490 return true;
10491 }
10492 }
10493 return false;
10494 }
10495 function injectStyle13(targetDocument, hash, css) {
10496 if (!targetDocument.head) {
10497 return;
10498 }
10499 const runtime = getRuntime13();
10500 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10501 if (!injectedStyles) {
10502 injectedStyles = /* @__PURE__ */ new Set();
10503 runtime.injectedStyles.set(targetDocument, injectedStyles);
10504 }
10505 if (injectedStyles.has(hash)) {
10506 return;
10507 }
10508 if (documentContainsStyleHash13(targetDocument, hash)) {
10509 injectedStyles.add(hash);
10510 return;
10511 }
10512 const style = targetDocument.createElement("style");
10513 style.setAttribute(STYLE_HASH_ATTRIBUTE13, hash);
10514 style.appendChild(targetDocument.createTextNode(css));
10515 targetDocument.head.appendChild(style);
10516 injectedStyles.add(hash);
10517 }
10518 function registerDocument13(targetDocument) {
10519 const runtime = getRuntime13();
10520 runtime.documents.set(
10521 targetDocument,
10522 (runtime.documents.get(targetDocument) ?? 0) + 1
10523 );
10524 for (const [hash, css] of runtime.styles) {
10525 injectStyle13(targetDocument, hash, css);
10526 }
10527 return () => {
10528 const count = runtime.documents.get(targetDocument);
10529 if (count === void 0) {
10530 return;
10531 }
10532 if (count <= 1) {
10533 runtime.documents.delete(targetDocument);
10534 return;
10535 }
10536 runtime.documents.set(targetDocument, count - 1);
10537 };
10538 }
10539 function registerStyle13(hash, css) {
10540 const runtime = getRuntime13();
10541 runtime.styles.set(hash, css);
10542 for (const targetDocument of runtime.documents.keys()) {
10543 injectStyle13(targetDocument, hash, css);
10544 }
10545 }
10546 if (typeof process === "undefined" || true) {
10547 registerStyle13("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
10548 }
10549 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10550 if (typeof process === "undefined" || true) {
10551 registerStyle13("5f8e7aa0bc", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._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,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,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,var(--wp-admin-theme-color,#3858e9));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}}}");
10552 }
10553 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" };
10554 if (typeof process === "undefined" || true) {
10555 registerStyle13("e8e6a9be37", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer 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-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9))}.c6055659b8e2cd2c__is-brand:active,.c6055659b8e2cd2c__is-brand:hover{--_gcd-a-color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000))}._92e0dfcaeee15b88__is-neutral,._92e0dfcaeee15b88__is-neutral:visited{--_gcd-a-color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);color:var(--wpds-color-foreground-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-foreground-interactive-neutral-active,#1e1e1e);color:var(--wpds-color-foreground-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-default,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"}}}');
10556 }
10557 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" };
10558 if (typeof process === "undefined" || true) {
10559 registerStyle13("af6d9984a6", "._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,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-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,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-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 transparent)}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-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));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 transparent);transition:var(--_gcd-a-transition,none)}");
10560 }
10561 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" };
10562 var Link = (0, import_element25.forwardRef)(function Link2({
10563 children,
10564 variant = "default",
10565 tone = "brand",
10566 openInNewTab = false,
10567 render: render4,
10568 className,
10569 ...props
10570 }, ref) {
10571 const element = useRender({
10572 render: render4,
10573 defaultTagName: "a",
10574 ref,
10575 props: mergeProps(props, {
10576 className: clsx_default(
10577 global_css_defense_default2.a,
10578 resets_default2["box-sizing"],
10579 focus_default["outset-ring--focus-except-active"],
10580 variant !== "unstyled" && style_default12.link,
10581 variant !== "unstyled" && style_default12[`is-${tone}`],
10582 variant === "unstyled" && style_default12["is-unstyled"],
10583 className
10584 ),
10585 target: openInNewTab ? "_blank" : void 0,
10586 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
10587 children,
10588 openInNewTab && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
10589 "span",
10590 {
10591 className: style_default12["link-icon"],
10592 role: "img",
10593 "aria-label": (
10594 /* translators: accessibility text appended to link text */
10595 (0, import_i18n.__)("(opens in a new tab)")
10596 )
10597 }
10598 )
10599 ] })
10600 })
10601 });
10602 return element;
10603 });
10604
10605 // packages/dataviews/build-module/dataviews/index.mjs
10606 var import_element85 = __toESM(require_element(), 1);
10607 var import_compose14 = __toESM(require_compose(), 1);
10608
10609 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10610 var import_element26 = __toESM(require_element(), 1);
10611
10612 // packages/dataviews/build-module/constants.mjs
10613 var import_i18n2 = __toESM(require_i18n(), 1);
10614 var OPERATOR_IS_ANY = "isAny";
10615 var OPERATOR_IS_NONE = "isNone";
10616 var OPERATOR_IS_ALL = "isAll";
10617 var OPERATOR_IS_NOT_ALL = "isNotAll";
10618 var OPERATOR_BETWEEN = "between";
10619 var OPERATOR_IN_THE_PAST = "inThePast";
10620 var OPERATOR_OVER = "over";
10621 var OPERATOR_IS = "is";
10622 var OPERATOR_IS_NOT = "isNot";
10623 var OPERATOR_LESS_THAN = "lessThan";
10624 var OPERATOR_GREATER_THAN = "greaterThan";
10625 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
10626 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
10627 var OPERATOR_BEFORE = "before";
10628 var OPERATOR_AFTER = "after";
10629 var OPERATOR_BEFORE_INC = "beforeInc";
10630 var OPERATOR_AFTER_INC = "afterInc";
10631 var OPERATOR_CONTAINS = "contains";
10632 var OPERATOR_NOT_CONTAINS = "notContains";
10633 var OPERATOR_STARTS_WITH = "startsWith";
10634 var OPERATOR_ON = "on";
10635 var OPERATOR_NOT_ON = "notOn";
10636 var SORTING_DIRECTIONS = ["asc", "desc"];
10637 var sortArrows = { asc: "\u2191", desc: "\u2193" };
10638 var sortValues = { asc: "ascending", desc: "descending" };
10639 var sortLabels = {
10640 asc: (0, import_i18n2.__)("Sort ascending"),
10641 desc: (0, import_i18n2.__)("Sort descending")
10642 };
10643 var sortIcons = {
10644 asc: arrow_up_default,
10645 desc: arrow_down_default
10646 };
10647 var LAYOUT_TABLE = "table";
10648 var LAYOUT_GRID = "grid";
10649 var LAYOUT_LIST = "list";
10650 var LAYOUT_ACTIVITY = "activity";
10651 var LAYOUT_PICKER_GRID = "pickerGrid";
10652 var LAYOUT_PICKER_TABLE = "pickerTable";
10653 var LAYOUT_PICKER_ACTIVITY = "pickerActivity";
10654
10655 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10656 var DataViewsContext = (0, import_element26.createContext)({
10657 view: { type: LAYOUT_TABLE },
10658 onChangeView: () => {
10659 },
10660 fields: [],
10661 data: [],
10662 paginationInfo: {
10663 totalItems: 0,
10664 totalPages: 0
10665 },
10666 selection: [],
10667 onChangeSelection: () => {
10668 },
10669 setOpenedFilter: () => {
10670 },
10671 openedFilter: null,
10672 getItemId: (item) => item.id,
10673 isItemClickable: () => true,
10674 renderItemLink: void 0,
10675 containerWidth: 0,
10676 containerRef: (0, import_element26.createRef)(),
10677 resizeObserverRef: () => {
10678 },
10679 defaultLayouts: { list: {}, grid: {}, table: {} },
10680 filters: [],
10681 isShowingFilter: false,
10682 setIsShowingFilter: () => {
10683 },
10684 hasInitiallyLoaded: false,
10685 config: {
10686 perPageSizes: []
10687 },
10688 intersectionObserver: null
10689 });
10690 DataViewsContext.displayName = "DataViewsContext";
10691 var dataviews_context_default = DataViewsContext;
10692
10693 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
10694 var import_i18n23 = __toESM(require_i18n(), 1);
10695
10696 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
10697 var import_i18n10 = __toESM(require_i18n(), 1);
10698 var import_components6 = __toESM(require_components(), 1);
10699 var import_element35 = __toESM(require_element(), 1);
10700 var import_keycodes2 = __toESM(require_keycodes(), 1);
10701
10702 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
10703 var import_components = __toESM(require_components(), 1);
10704 var import_i18n3 = __toESM(require_i18n(), 1);
10705 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
10706 var SELECTION_CHECKBOX_CLASS = "dataviews-selection-checkbox";
10707 function DataViewsSelectionCheckbox({
10708 selection,
10709 onChangeSelection,
10710 item,
10711 getItemId,
10712 titleField,
10713 disabled: disabled2,
10714 ...extraProps
10715 }) {
10716 const id = getItemId(item);
10717 const isInSelectionArray = selection.includes(id);
10718 const checked = !disabled2 && isInSelectionArray;
10719 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n3.__)("(no title)");
10720 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10721 import_components.CheckboxControl,
10722 {
10723 className: SELECTION_CHECKBOX_CLASS,
10724 "aria-label": selectionLabel,
10725 "aria-disabled": disabled2,
10726 checked,
10727 onChange: () => {
10728 if (disabled2) {
10729 return;
10730 }
10731 onChangeSelection(
10732 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
10733 );
10734 },
10735 ...extraProps
10736 }
10737 );
10738 }
10739
10740 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10741 var import_components2 = __toESM(require_components(), 1);
10742 var import_i18n4 = __toESM(require_i18n(), 1);
10743 var import_element27 = __toESM(require_element(), 1);
10744 var import_data = __toESM(require_data(), 1);
10745 var import_compose = __toESM(require_compose(), 1);
10746
10747 // packages/dataviews/build-module/lock-unlock.mjs
10748 var import_private_apis2 = __toESM(require_private_apis(), 1);
10749 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
10750 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
10751 "@wordpress/dataviews"
10752 );
10753
10754 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10755 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
10756 var { Menu, kebabCase } = unlock2(import_components2.privateApis);
10757 function ButtonTrigger({
10758 action,
10759 onClick,
10760 items,
10761 variant
10762 }) {
10763 const label = typeof action.label === "string" ? action.label : action.label(items);
10764 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10765 import_components2.Button,
10766 {
10767 disabled: !!action.disabled,
10768 accessibleWhenDisabled: true,
10769 size: "compact",
10770 variant,
10771 onClick,
10772 children: label
10773 }
10774 );
10775 }
10776 function MenuItemTrigger({
10777 action,
10778 onClick,
10779 items
10780 }) {
10781 const label = typeof action.label === "string" ? action.label : action.label(items);
10782 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.ItemLabel, { children: label }) });
10783 }
10784 function ActionModal({
10785 action,
10786 items,
10787 closeModal
10788 }) {
10789 const label = typeof action.label === "string" ? action.label : action.label(items);
10790 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
10791 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10792 import_components2.Modal,
10793 {
10794 title: modalHeader || label,
10795 __experimentalHideHeader: !!action.hideModalHeader,
10796 onRequestClose: closeModal,
10797 focusOnMount: action.modalFocusOnMount ?? true,
10798 size: action.modalSize || "medium",
10799 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
10800 action.id
10801 )}`,
10802 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(action.RenderModal, { items, closeModal })
10803 }
10804 );
10805 }
10806 function ActionsMenuGroup({
10807 actions,
10808 item,
10809 registry,
10810 setActiveModalAction
10811 }) {
10812 const { primaryActions, regularActions } = (0, import_element27.useMemo)(() => {
10813 return actions.reduce(
10814 (acc, action) => {
10815 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
10816 return acc;
10817 },
10818 {
10819 primaryActions: [],
10820 regularActions: []
10821 }
10822 );
10823 }, [actions]);
10824 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10825 MenuItemTrigger,
10826 {
10827 action,
10828 onClick: () => {
10829 if ("RenderModal" in action) {
10830 setActiveModalAction(action);
10831 return;
10832 }
10833 action.callback([item], { registry });
10834 },
10835 items: [item]
10836 },
10837 action.id
10838 ));
10839 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Menu.Group, { children: [
10840 renderActionGroup(primaryActions),
10841 renderActionGroup(regularActions)
10842 ] });
10843 }
10844 function ItemActions({
10845 item,
10846 actions,
10847 isCompact
10848 }) {
10849 const registry = (0, import_data.useRegistry)();
10850 const { primaryActions, eligibleActions } = (0, import_element27.useMemo)(() => {
10851 const _eligibleActions = actions.filter(
10852 (action) => !action.isEligible || action.isEligible(item)
10853 );
10854 const _primaryActions = _eligibleActions.filter(
10855 (action) => action.isPrimary
10856 );
10857 return {
10858 primaryActions: _primaryActions,
10859 eligibleActions: _eligibleActions
10860 };
10861 }, [actions, item]);
10862 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10863 if (isCompact) {
10864 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10865 CompactItemActions,
10866 {
10867 item,
10868 actions: eligibleActions,
10869 isSmall: true,
10870 registry
10871 }
10872 );
10873 }
10874 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
10875 Stack,
10876 {
10877 direction: "row",
10878 justify: "flex-end",
10879 className: "dataviews-item-actions",
10880 style: {
10881 flexShrink: 0,
10882 width: "auto"
10883 },
10884 children: [
10885 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10886 PrimaryActions,
10887 {
10888 item,
10889 actions: primaryActions,
10890 registry
10891 }
10892 ),
10893 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
10894 // there if there are any actions at all.
10895 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10896 CompactItemActions,
10897 {
10898 item,
10899 actions: eligibleActions,
10900 registry
10901 }
10902 )
10903 ]
10904 }
10905 );
10906 }
10907 function CompactItemActions({
10908 item,
10909 actions,
10910 isSmall,
10911 registry
10912 }) {
10913 const [activeModalAction, setActiveModalAction] = (0, import_element27.useState)(
10914 null
10915 );
10916 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
10917 /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Menu, { placement: "bottom-end", children: [
10918 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10919 Menu.TriggerButton,
10920 {
10921 render: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10922 import_components2.Button,
10923 {
10924 size: isSmall ? "small" : "compact",
10925 icon: more_vertical_default,
10926 label: (0, import_i18n4.__)("Actions"),
10927 accessibleWhenDisabled: true,
10928 disabled: !actions.length,
10929 className: "dataviews-all-actions-button"
10930 }
10931 )
10932 }
10933 ),
10934 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10935 ActionsMenuGroup,
10936 {
10937 actions,
10938 item,
10939 registry,
10940 setActiveModalAction
10941 }
10942 ) })
10943 ] }),
10944 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10945 ActionModal,
10946 {
10947 action: activeModalAction,
10948 items: [item],
10949 closeModal: () => setActiveModalAction(null)
10950 }
10951 )
10952 ] });
10953 }
10954 function PrimaryActions({
10955 item,
10956 actions,
10957 registry,
10958 buttonVariant
10959 }) {
10960 const [activeModalAction, setActiveModalAction] = (0, import_element27.useState)(null);
10961 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10962 if (isMobileViewport) {
10963 return null;
10964 }
10965 if (!Array.isArray(actions) || actions.length === 0) {
10966 return null;
10967 }
10968 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
10969 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10970 ButtonTrigger,
10971 {
10972 action,
10973 onClick: () => {
10974 if ("RenderModal" in action) {
10975 setActiveModalAction(action);
10976 return;
10977 }
10978 action.callback([item], { registry });
10979 },
10980 items: [item],
10981 variant: buttonVariant
10982 },
10983 action.id
10984 )),
10985 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10986 ActionModal,
10987 {
10988 action: activeModalAction,
10989 items: [item],
10990 closeModal: () => setActiveModalAction(null)
10991 }
10992 )
10993 ] });
10994 }
10995
10996 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10997 var import_components3 = __toESM(require_components(), 1);
10998 var import_i18n6 = __toESM(require_i18n(), 1);
10999 var import_element28 = __toESM(require_element(), 1);
11000 var import_data2 = __toESM(require_data(), 1);
11001 var import_compose2 = __toESM(require_compose(), 1);
11002
11003 // packages/dataviews/build-module/utils/get-footer-message.mjs
11004 var import_i18n5 = __toESM(require_i18n(), 1);
11005 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
11006 if (selectionCount > 0) {
11007 return (0, import_i18n5.sprintf)(
11008 /* translators: %d: number of items. */
11009 (0, import_i18n5._n)("%d Item selected", "%d Items selected", selectionCount),
11010 selectionCount
11011 );
11012 }
11013 if (onlyTotalCount || totalItems <= itemsCount) {
11014 return (0, import_i18n5.sprintf)(
11015 /* translators: %d: number of items. */
11016 (0, import_i18n5._n)("%d Item", "%d Items", totalItems),
11017 totalItems
11018 );
11019 }
11020 return (0, import_i18n5.sprintf)(
11021 /* translators: %1$d: number of items. %2$d: total number of items. */
11022 (0, import_i18n5._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
11023 itemsCount,
11024 totalItems
11025 );
11026 }
11027
11028 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
11029 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
11030 function ActionWithModal({
11031 action,
11032 items,
11033 ActionTriggerComponent
11034 }) {
11035 const [isModalOpen, setIsModalOpen] = (0, import_element28.useState)(false);
11036 const actionTriggerProps = {
11037 action,
11038 onClick: () => {
11039 setIsModalOpen(true);
11040 },
11041 items
11042 };
11043 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
11044 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
11045 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11046 ActionModal,
11047 {
11048 action,
11049 items,
11050 closeModal: () => setIsModalOpen(false)
11051 }
11052 )
11053 ] });
11054 }
11055 function hasAPossibleBulkAction(actions, item) {
11056 return actions.some(
11057 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
11058 );
11059 }
11060 function useHasAPossibleBulkAction(actions, item) {
11061 return (0, import_element28.useMemo)(
11062 () => hasAPossibleBulkAction(actions, item),
11063 [actions, item]
11064 );
11065 }
11066 function useSomeItemHasAPossibleBulkAction(actions, data) {
11067 return (0, import_element28.useMemo)(
11068 () => data.some((item) => hasAPossibleBulkAction(actions, item)),
11069 [actions, data]
11070 );
11071 }
11072 function BulkSelectionCheckbox({
11073 selection,
11074 onChangeSelection,
11075 data,
11076 actions,
11077 getItemId,
11078 disableSelectAll = false
11079 }) {
11080 const selectableItems = (0, import_element28.useMemo)(() => {
11081 return data.filter((item) => {
11082 return actions.some(
11083 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
11084 );
11085 });
11086 }, [data, actions]);
11087 const selectedItems = data.filter(
11088 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
11089 );
11090 const hasSelection = selection.length > 0;
11091 const areAllSelected = selectedItems.length === selectableItems.length;
11092 if (disableSelectAll) {
11093 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11094 import_components3.CheckboxControl,
11095 {
11096 className: "dataviews-view-table-selection-checkbox",
11097 checked: hasSelection,
11098 disabled: !hasSelection,
11099 onChange: () => {
11100 onChangeSelection([]);
11101 },
11102 "aria-label": (0, import_i18n6.__)("Deselect all")
11103 }
11104 );
11105 }
11106 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11107 import_components3.CheckboxControl,
11108 {
11109 className: "dataviews-view-table-selection-checkbox",
11110 checked: areAllSelected,
11111 indeterminate: !areAllSelected && !!selectedItems.length,
11112 onChange: () => {
11113 if (areAllSelected) {
11114 onChangeSelection([]);
11115 } else {
11116 onChangeSelection(
11117 selectableItems.map((item) => getItemId(item))
11118 );
11119 }
11120 },
11121 "aria-label": areAllSelected ? (0, import_i18n6.__)("Deselect all") : (0, import_i18n6.__)("Select all")
11122 }
11123 );
11124 }
11125 function ActionTrigger({
11126 action,
11127 onClick,
11128 isBusy,
11129 items
11130 }) {
11131 const label = typeof action.label === "string" ? action.label : action.label(items);
11132 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
11133 if (isMobile) {
11134 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11135 import_components3.Button,
11136 {
11137 disabled: isBusy,
11138 accessibleWhenDisabled: true,
11139 label,
11140 icon: action.icon,
11141 size: "compact",
11142 onClick,
11143 isBusy
11144 }
11145 );
11146 }
11147 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11148 import_components3.Button,
11149 {
11150 disabled: isBusy,
11151 accessibleWhenDisabled: true,
11152 size: "compact",
11153 onClick,
11154 isBusy,
11155 children: label
11156 }
11157 );
11158 }
11159 var EMPTY_ARRAY2 = [];
11160 function ActionButton({
11161 action,
11162 selectedItems,
11163 actionInProgress,
11164 setActionInProgress
11165 }) {
11166 const registry = (0, import_data2.useRegistry)();
11167 const selectedEligibleItems = (0, import_element28.useMemo)(() => {
11168 return selectedItems.filter((item) => {
11169 return !action.isEligible || action.isEligible(item);
11170 });
11171 }, [action, selectedItems]);
11172 if ("RenderModal" in action) {
11173 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11174 ActionWithModal,
11175 {
11176 action,
11177 items: selectedEligibleItems,
11178 ActionTriggerComponent: ActionTrigger
11179 },
11180 action.id
11181 );
11182 }
11183 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11184 ActionTrigger,
11185 {
11186 action,
11187 onClick: async () => {
11188 setActionInProgress(action.id);
11189 await action.callback(selectedItems, {
11190 registry
11191 });
11192 setActionInProgress(null);
11193 },
11194 items: selectedEligibleItems,
11195 isBusy: actionInProgress === action.id
11196 },
11197 action.id
11198 );
11199 }
11200 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
11201 const message2 = getFooterMessage(
11202 selection.length,
11203 data.length,
11204 paginationInfo.totalItems,
11205 isInfiniteScroll
11206 );
11207 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
11208 Stack,
11209 {
11210 direction: "row",
11211 className: "dataviews-bulk-actions-footer__container",
11212 gap: "md",
11213 align: "center",
11214 children: [
11215 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11216 BulkSelectionCheckbox,
11217 {
11218 selection,
11219 onChangeSelection,
11220 data,
11221 actions,
11222 getItemId,
11223 disableSelectAll: isInfiniteScroll
11224 }
11225 ),
11226 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
11227 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
11228 Stack,
11229 {
11230 direction: "row",
11231 className: "dataviews-bulk-actions-footer__action-buttons",
11232 gap: "xs",
11233 children: [
11234 actionsToShow.map((action) => {
11235 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11236 ActionButton,
11237 {
11238 action,
11239 selectedItems,
11240 actionInProgress,
11241 setActionInProgress
11242 },
11243 action.id
11244 );
11245 }),
11246 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11247 import_components3.Button,
11248 {
11249 icon: close_small_default,
11250 showTooltip: true,
11251 tooltipPosition: "top",
11252 size: "compact",
11253 label: (0, import_i18n6.__)("Cancel"),
11254 disabled: !!actionInProgress,
11255 accessibleWhenDisabled: false,
11256 onClick: () => {
11257 onChangeSelection(EMPTY_ARRAY2);
11258 }
11259 }
11260 )
11261 ]
11262 }
11263 )
11264 ]
11265 }
11266 );
11267 }
11268 function FooterContent({
11269 selection,
11270 actions,
11271 onChangeSelection,
11272 data,
11273 getItemId,
11274 isInfiniteScroll,
11275 paginationInfo
11276 }) {
11277 const [actionInProgress, setActionInProgress] = (0, import_element28.useState)(
11278 null
11279 );
11280 const footerContentRef = (0, import_element28.useRef)(void 0);
11281 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
11282 const bulkActions = (0, import_element28.useMemo)(
11283 () => actions.filter((action) => action.supportsBulk),
11284 [actions]
11285 );
11286 const selectableItems = (0, import_element28.useMemo)(() => {
11287 return data.filter((item) => {
11288 return bulkActions.some(
11289 (action) => !action.isEligible || action.isEligible(item)
11290 );
11291 });
11292 }, [data, bulkActions]);
11293 const selectedItems = (0, import_element28.useMemo)(() => {
11294 return data.filter(
11295 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
11296 );
11297 }, [selection, data, getItemId, selectableItems]);
11298 const actionsToShow = (0, import_element28.useMemo)(
11299 () => actions.filter((action) => {
11300 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
11301 (item) => !action.isEligible || action.isEligible(item)
11302 );
11303 }),
11304 [actions, selectedItems, isMobile]
11305 );
11306 if (!actionInProgress) {
11307 if (footerContentRef.current) {
11308 footerContentRef.current = void 0;
11309 }
11310 return renderFooterContent(
11311 data,
11312 actions,
11313 getItemId,
11314 isInfiniteScroll,
11315 selection,
11316 actionsToShow,
11317 selectedItems,
11318 actionInProgress,
11319 setActionInProgress,
11320 onChangeSelection,
11321 paginationInfo
11322 );
11323 } else if (!footerContentRef.current) {
11324 footerContentRef.current = renderFooterContent(
11325 data,
11326 actions,
11327 getItemId,
11328 isInfiniteScroll,
11329 selection,
11330 actionsToShow,
11331 selectedItems,
11332 actionInProgress,
11333 setActionInProgress,
11334 onChangeSelection,
11335 paginationInfo
11336 );
11337 }
11338 return footerContentRef.current;
11339 }
11340 function BulkActionsFooter() {
11341 const {
11342 data,
11343 selection,
11344 actions = EMPTY_ARRAY2,
11345 onChangeSelection,
11346 getItemId,
11347 paginationInfo,
11348 view
11349 } = (0, import_element28.useContext)(dataviews_context_default);
11350 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11351 FooterContent,
11352 {
11353 selection,
11354 onChangeSelection,
11355 data,
11356 actions,
11357 getItemId,
11358 isInfiniteScroll: !!view.infiniteScrollEnabled,
11359 paginationInfo
11360 }
11361 );
11362 }
11363
11364 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11365 var import_i18n7 = __toESM(require_i18n(), 1);
11366 var import_components4 = __toESM(require_components(), 1);
11367 var import_element29 = __toESM(require_element(), 1);
11368
11369 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
11370 function getHideableFields(view, fields) {
11371 const togglableFields = [
11372 view?.titleField,
11373 view?.mediaField,
11374 view?.descriptionField
11375 ].filter(Boolean);
11376 return fields.filter(
11377 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
11378 );
11379 }
11380
11381 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11382 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
11383 var { Menu: Menu2 } = unlock2(import_components4.privateApis);
11384 function WithMenuSeparators({ children }) {
11385 return import_element29.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_element29.Fragment, { children: [
11386 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Separator, {}),
11387 child
11388 ] }, i2));
11389 }
11390 var _HeaderMenu = (0, import_element29.forwardRef)(function HeaderMenu({
11391 fieldId,
11392 view,
11393 fields,
11394 onChangeView,
11395 onHide,
11396 setOpenedFilter,
11397 canMove = true,
11398 canInsertLeft = true,
11399 canInsertRight = true
11400 }, ref) {
11401 const visibleFieldIds = view.fields ?? [];
11402 const index2 = visibleFieldIds?.indexOf(fieldId);
11403 const isSorted = view.sort?.field === fieldId;
11404 let isHidable = false;
11405 let isSortable = false;
11406 let canAddFilter = false;
11407 let operators = [];
11408 const field = fields.find((f2) => f2.id === fieldId);
11409 const { setIsShowingFilter } = (0, import_element29.useContext)(dataviews_context_default);
11410 if (!field) {
11411 return null;
11412 }
11413 isHidable = field.enableHiding !== false;
11414 isSortable = field.enableSorting !== false;
11415 const header = field.header;
11416 operators = !!field.filterBy && field.filterBy?.operators || [];
11417 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
11418 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
11419 return header;
11420 }
11421 const hiddenFields = getHideableFields(view, fields).filter(
11422 (f2) => !visibleFieldIds.includes(f2.id)
11423 );
11424 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
11425 const isRtl = (0, import_i18n7.isRTL)();
11426 return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11427 /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
11428 Menu2.TriggerButton,
11429 {
11430 render: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11431 import_components4.Button,
11432 {
11433 size: "compact",
11434 className: "dataviews-view-table-header-button",
11435 ref,
11436 variant: "tertiary"
11437 }
11438 ),
11439 children: [
11440 header,
11441 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
11442 ]
11443 }
11444 ),
11445 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(WithMenuSeparators, { children: [
11446 isSortable && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
11447 (direction) => {
11448 const isChecked = view.sort && isSorted && view.sort.direction === direction;
11449 const value = `${fieldId}-${direction}`;
11450 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11451 Menu2.RadioItem,
11452 {
11453 name: "view-table-sorting",
11454 value,
11455 checked: isChecked,
11456 onChange: () => {
11457 onChangeView({
11458 ...view,
11459 sort: {
11460 field: fieldId,
11461 direction
11462 },
11463 showLevels: false
11464 });
11465 },
11466 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
11467 },
11468 value
11469 );
11470 }
11471 ) }),
11472 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11473 Menu2.Item,
11474 {
11475 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: funnel_default }),
11476 onClick: () => {
11477 setOpenedFilter(fieldId);
11478 setIsShowingFilter(true);
11479 onChangeView({
11480 ...view,
11481 page: 1,
11482 filters: [
11483 ...view.filters || [],
11484 {
11485 field: fieldId,
11486 value: void 0,
11487 operator: operators[0]
11488 }
11489 ]
11490 });
11491 },
11492 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Add filter") })
11493 }
11494 ) }),
11495 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2.Group, { children: [
11496 canMove && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11497 Menu2.Item,
11498 {
11499 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: arrow_left_default }),
11500 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
11501 onClick: () => {
11502 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
11503 const newFields = [
11504 ...visibleFieldIds
11505 ];
11506 newFields.splice(index2, 1);
11507 newFields.splice(
11508 targetIndex,
11509 0,
11510 fieldId
11511 );
11512 onChangeView({
11513 ...view,
11514 fields: newFields
11515 });
11516 },
11517 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move left") })
11518 }
11519 ),
11520 canMove && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11521 Menu2.Item,
11522 {
11523 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: arrow_right_default }),
11524 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
11525 onClick: () => {
11526 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
11527 const newFields = [
11528 ...visibleFieldIds
11529 ];
11530 newFields.splice(index2, 1);
11531 newFields.splice(
11532 targetIndex,
11533 0,
11534 fieldId
11535 );
11536 onChangeView({
11537 ...view,
11538 fields: newFields
11539 });
11540 },
11541 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move right") })
11542 }
11543 ),
11544 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11545 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert left") }) }),
11546 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11547 const insertIndex = isRtl ? index2 + 1 : index2;
11548 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11549 Menu2.Item,
11550 {
11551 onClick: () => {
11552 onChangeView({
11553 ...view,
11554 fields: [
11555 ...visibleFieldIds.slice(
11556 0,
11557 insertIndex
11558 ),
11559 hiddenField.id,
11560 ...visibleFieldIds.slice(
11561 insertIndex
11562 )
11563 ]
11564 });
11565 },
11566 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11567 },
11568 hiddenField.id
11569 );
11570 }) })
11571 ] }),
11572 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11573 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert right") }) }),
11574 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11575 const insertIndex = isRtl ? index2 : index2 + 1;
11576 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11577 Menu2.Item,
11578 {
11579 onClick: () => {
11580 onChangeView({
11581 ...view,
11582 fields: [
11583 ...visibleFieldIds.slice(
11584 0,
11585 insertIndex
11586 ),
11587 hiddenField.id,
11588 ...visibleFieldIds.slice(
11589 insertIndex
11590 )
11591 ]
11592 });
11593 },
11594 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11595 },
11596 hiddenField.id
11597 );
11598 }) })
11599 ] }),
11600 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11601 Menu2.Item,
11602 {
11603 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: unseen_default }),
11604 onClick: () => {
11605 onHide(field);
11606 onChangeView({
11607 ...view,
11608 fields: visibleFieldIds.filter(
11609 (id) => id !== fieldId
11610 )
11611 });
11612 },
11613 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Hide column") })
11614 }
11615 )
11616 ] })
11617 ] }) })
11618 ] });
11619 });
11620 var ColumnHeaderMenu = _HeaderMenu;
11621 var column_header_menu_default = ColumnHeaderMenu;
11622
11623 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
11624 var import_element30 = __toESM(require_element(), 1);
11625 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
11626 function getClickableItemProps({
11627 item,
11628 isItemClickable,
11629 onClickItem,
11630 className
11631 }) {
11632 if (!isItemClickable(item) || !onClickItem) {
11633 return { className };
11634 }
11635 return {
11636 className: className ? `${className} ${className}--clickable` : void 0,
11637 role: "button",
11638 tabIndex: 0,
11639 onClick: (event) => {
11640 event.stopPropagation();
11641 onClickItem(item);
11642 },
11643 onKeyDown: (event) => {
11644 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11645 event.stopPropagation();
11646 onClickItem(item);
11647 }
11648 }
11649 };
11650 }
11651 function ItemClickWrapper({
11652 item,
11653 isItemClickable,
11654 onClickItem,
11655 renderItemLink,
11656 className,
11657 children,
11658 ...extraProps
11659 }) {
11660 if (!isItemClickable(item)) {
11661 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className, ...extraProps, children });
11662 }
11663 if (renderItemLink) {
11664 const renderedElement = renderItemLink({
11665 item,
11666 className: `${className} ${className}--clickable`,
11667 ...extraProps,
11668 children
11669 });
11670 return (0, import_element30.cloneElement)(renderedElement, {
11671 onClick: (event) => {
11672 event.stopPropagation();
11673 if (renderedElement.props.onClick) {
11674 renderedElement.props.onClick(event);
11675 }
11676 },
11677 onKeyDown: (event) => {
11678 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11679 event.stopPropagation();
11680 if (renderedElement.props.onKeyDown) {
11681 renderedElement.props.onKeyDown(event);
11682 }
11683 }
11684 }
11685 });
11686 }
11687 const clickProps = getClickableItemProps({
11688 item,
11689 isItemClickable,
11690 onClickItem,
11691 className
11692 });
11693 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { ...clickProps, ...extraProps, children });
11694 }
11695
11696 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
11697 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
11698 function ColumnPrimary({
11699 item,
11700 level,
11701 titleField,
11702 mediaField,
11703 descriptionField,
11704 onClickItem,
11705 renderItemLink,
11706 isItemClickable
11707 }) {
11708 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
11709 mediaField && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11710 ItemClickWrapper,
11711 {
11712 item,
11713 isItemClickable,
11714 onClickItem,
11715 renderItemLink,
11716 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
11717 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
11718 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11719 mediaField.render,
11720 {
11721 item,
11722 field: mediaField,
11723 config: { sizes: "32px" }
11724 }
11725 )
11726 }
11727 ),
11728 /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
11729 Stack,
11730 {
11731 direction: "column",
11732 align: "flex-start",
11733 className: "dataviews-view-table__primary-column-content",
11734 children: [
11735 titleField && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
11736 ItemClickWrapper,
11737 {
11738 item,
11739 isItemClickable,
11740 onClickItem,
11741 renderItemLink,
11742 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
11743 children: [
11744 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("span", { className: "dataviews-view-table__level", children: [
11745 Array(level).fill("\u2014").join(" "),
11746 "\xA0"
11747 ] }),
11748 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(titleField.render, { item, field: titleField })
11749 ]
11750 }
11751 ),
11752 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11753 descriptionField.render,
11754 {
11755 item,
11756 field: descriptionField
11757 }
11758 )
11759 ]
11760 }
11761 )
11762 ] });
11763 }
11764 var column_primary_default = ColumnPrimary;
11765
11766 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
11767 var import_element31 = __toESM(require_element(), 1);
11768 var import_i18n8 = __toESM(require_i18n(), 1);
11769 var isScrolledToEnd = (element) => {
11770 if ((0, import_i18n8.isRTL)()) {
11771 const scrollLeft = Math.abs(element.scrollLeft);
11772 return scrollLeft <= 1;
11773 }
11774 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
11775 };
11776 function useScrollState({
11777 scrollContainerRef,
11778 enabledHorizontal = false
11779 }) {
11780 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element31.useState)(false);
11781 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element31.useState)(false);
11782 const handleScroll = (0, import_element31.useCallback)(() => {
11783 const scrollContainer = scrollContainerRef.current;
11784 if (!scrollContainer) {
11785 return;
11786 }
11787 if (enabledHorizontal) {
11788 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
11789 }
11790 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
11791 }, [scrollContainerRef, enabledHorizontal]);
11792 (0, import_element31.useEffect)(() => {
11793 if (typeof window === "undefined" || !scrollContainerRef.current) {
11794 return () => {
11795 };
11796 }
11797 const scrollContainer = scrollContainerRef.current;
11798 handleScroll();
11799 scrollContainer.addEventListener("scroll", handleScroll);
11800 window.addEventListener("resize", handleScroll);
11801 return () => {
11802 scrollContainer.removeEventListener("scroll", handleScroll);
11803 window.removeEventListener("resize", handleScroll);
11804 };
11805 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
11806 return { isHorizontalScrollEnd, isVerticallyScrolled };
11807 }
11808
11809 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
11810 function getDataByGroup(data, groupByField) {
11811 return data.reduce((groups, item) => {
11812 const groupName = groupByField.getValue({ item });
11813 if (!groups.has(groupName)) {
11814 groups.set(groupName, []);
11815 }
11816 groups.get(groupName)?.push(item);
11817 return groups;
11818 }, /* @__PURE__ */ new Map());
11819 }
11820
11821 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-selection-props.mjs
11822 var import_element32 = __toESM(require_element(), 1);
11823 var import_keycodes = __toESM(require_keycodes(), 1);
11824 function getRange(orderedIds, fromIndex, toIndex) {
11825 return orderedIds.slice(
11826 Math.min(fromIndex, toIndex),
11827 Math.max(fromIndex, toIndex) + 1
11828 );
11829 }
11830 function getRangeSelection({
11831 anchorId,
11832 targetId,
11833 lastTargetId,
11834 orderedIds,
11835 selection
11836 }) {
11837 const targetIndex = orderedIds.indexOf(targetId);
11838 if (targetIndex === -1) {
11839 return selection;
11840 }
11841 const anchorIndex = anchorId === null ? -1 : orderedIds.indexOf(anchorId);
11842 const hasAnchor = anchorIndex !== -1;
11843 const rangeStart = hasAnchor ? anchorIndex : targetIndex;
11844 const lastTargetIndex = hasAnchor && lastTargetId !== null ? orderedIds.indexOf(lastTargetId) : -1;
11845 const lastRange = lastTargetIndex === -1 ? [] : getRange(orderedIds, rangeStart, lastTargetIndex);
11846 const base = selection.filter((id) => !lastRange.includes(id));
11847 return [
11848 .../* @__PURE__ */ new Set([
11849 ...base,
11850 ...getRange(orderedIds, rangeStart, targetIndex)
11851 ])
11852 ];
11853 }
11854 function getClosestSelectedId({
11855 targetId,
11856 orderedIds,
11857 selection
11858 }) {
11859 const targetIndex = orderedIds.indexOf(targetId);
11860 if (targetIndex === -1) {
11861 return null;
11862 }
11863 const selectedIds = new Set(selection);
11864 let closestId = null;
11865 let closestDistance = Infinity;
11866 orderedIds.forEach((id, index2) => {
11867 if (!selectedIds.has(id)) {
11868 return;
11869 }
11870 const distance = Math.abs(index2 - targetIndex);
11871 if (distance < closestDistance) {
11872 closestDistance = distance;
11873 closestId = id;
11874 }
11875 });
11876 return closestId;
11877 }
11878 function useSelectionProps({
11879 data,
11880 actions,
11881 getItemId,
11882 selection,
11883 onChangeSelection
11884 }) {
11885 const gestureRef = (0, import_element32.useRef)(null);
11886 const isTouchDeviceRef = (0, import_element32.useRef)(false);
11887 (0, import_element32.useEffect)(() => {
11888 const markTouchDevice = () => {
11889 isTouchDeviceRef.current = true;
11890 };
11891 document.addEventListener("touchstart", markTouchDevice, {
11892 once: true
11893 });
11894 return () => document.removeEventListener("touchstart", markTouchDevice);
11895 }, []);
11896 const selectableIds = data.filter((item) => hasAPossibleBulkAction(actions, item)).map(getItemId);
11897 const selectableIdSet = new Set(selectableIds);
11898 const hasSelectableItems = selectableIds.length > 0;
11899 const getSelectionProps = (id) => {
11900 const isSelectable = selectableIdSet.has(id);
11901 return {
11902 onMouseDown: (event) => {
11903 if (event.button === 0 && event.shiftKey && hasSelectableItems) {
11904 event.preventDefault();
11905 }
11906 },
11907 onClickCapture: (event) => {
11908 if (!hasSelectableItems) {
11909 return;
11910 }
11911 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11912 const isSelectionCheckboxClick = event.target instanceof Element && !!event.target.closest(`.${SELECTION_CHECKBOX_CLASS}`);
11913 if (!isModifierKeyPressed && !event.shiftKey) {
11914 if (isSelectable && isSelectionCheckboxClick) {
11915 gestureRef.current = {
11916 anchorId: id,
11917 lastTargetId: null
11918 };
11919 }
11920 return;
11921 }
11922 if (isTouchDeviceRef.current || document.getSelection()?.type === "Range") {
11923 return;
11924 }
11925 event.stopPropagation();
11926 if (!isSelectionCheckboxClick) {
11927 event.preventDefault();
11928 }
11929 if (!isSelectable) {
11930 return;
11931 }
11932 if (event.shiftKey) {
11933 let gesture = gestureRef.current;
11934 if (!gesture || !selectableIdSet.has(gesture.anchorId)) {
11935 gesture = {
11936 anchorId: getClosestSelectedId({
11937 targetId: id,
11938 orderedIds: selectableIds,
11939 selection
11940 }) ?? id,
11941 lastTargetId: null
11942 };
11943 }
11944 onChangeSelection(
11945 getRangeSelection({
11946 anchorId: gesture.anchorId,
11947 targetId: id,
11948 lastTargetId: gesture.lastTargetId,
11949 orderedIds: selectableIds,
11950 selection
11951 })
11952 );
11953 gestureRef.current = {
11954 anchorId: gesture.anchorId,
11955 lastTargetId: id
11956 };
11957 } else {
11958 onChangeSelection(
11959 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
11960 );
11961 gestureRef.current = { anchorId: id, lastTargetId: null };
11962 }
11963 }
11964 };
11965 };
11966 return { getSelectionProps };
11967 }
11968
11969 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
11970 var import_components5 = __toESM(require_components(), 1);
11971 var import_i18n9 = __toESM(require_i18n(), 1);
11972 var import_element33 = __toESM(require_element(), 1);
11973 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
11974 function FieldItem({
11975 field,
11976 isVisible: isVisible2,
11977 onToggleVisibility
11978 }) {
11979 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: [
11980 /* @__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 }) }),
11981 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
11982 ] }) });
11983 }
11984 function isDefined(item) {
11985 return !!item;
11986 }
11987 function PropertiesSection({
11988 showLabel = true
11989 }) {
11990 const { view, fields, onChangeView } = (0, import_element33.useContext)(dataviews_context_default);
11991 const regularFields = getHideableFields(view, fields);
11992 if (!regularFields?.length) {
11993 return null;
11994 }
11995 const titleField = fields.find((f2) => f2.id === view.titleField);
11996 const previewField = fields.find((f2) => f2.id === view.mediaField);
11997 const descriptionField = fields.find(
11998 (f2) => f2.id === view.descriptionField
11999 );
12000 const lockedFields = [
12001 {
12002 field: titleField,
12003 isVisibleFlag: "showTitle"
12004 },
12005 {
12006 field: previewField,
12007 isVisibleFlag: "showMedia"
12008 },
12009 {
12010 field: descriptionField,
12011 isVisibleFlag: "showDescription"
12012 }
12013 ].filter(({ field }) => isDefined(field));
12014 const visibleFieldIds = view.fields ?? [];
12015 const visibleRegularFieldsCount = regularFields.filter(
12016 (f2) => visibleFieldIds.includes(f2.id)
12017 ).length;
12018 const visibleLockedFields = lockedFields.filter(
12019 ({ isVisibleFlag }) => (
12020 // @ts-expect-error
12021 view[isVisibleFlag] ?? true
12022 )
12023 );
12024 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
12025 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
12026 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
12027 showLabel && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n9.__)("Properties") }),
12028 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12029 Stack,
12030 {
12031 direction: "column",
12032 className: "dataviews-view-config__properties",
12033 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
12034 lockedFields.map(({ field, isVisibleFlag }) => {
12035 const isVisible2 = view[isVisibleFlag] ?? true;
12036 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
12037 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12038 FieldItem,
12039 {
12040 field: fieldToRender,
12041 isVisible: isVisible2,
12042 onToggleVisibility: () => {
12043 onChangeView({
12044 ...view,
12045 [isVisibleFlag]: !isVisible2
12046 });
12047 }
12048 },
12049 field.id
12050 );
12051 }),
12052 regularFields.map((field) => {
12053 const isVisible2 = visibleFieldIds.includes(field.id);
12054 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
12055 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12056 FieldItem,
12057 {
12058 field: fieldToRender,
12059 isVisible: isVisible2,
12060 onToggleVisibility: () => {
12061 onChangeView({
12062 ...view,
12063 fields: isVisible2 ? visibleFieldIds.filter(
12064 (fieldId) => fieldId !== field.id
12065 ) : [...visibleFieldIds, field.id]
12066 });
12067 }
12068 },
12069 field.id
12070 );
12071 })
12072 ] })
12073 }
12074 )
12075 ] });
12076 }
12077
12078 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
12079 var import_element34 = __toESM(require_element(), 1);
12080 function useDelayedLoading(isLoading, options = { delay: 400 }) {
12081 const [showLoader, setShowLoader] = (0, import_element34.useState)(false);
12082 (0, import_element34.useEffect)(() => {
12083 if (!isLoading) {
12084 return;
12085 }
12086 const timeout = setTimeout(() => {
12087 setShowLoader(true);
12088 }, options.delay);
12089 return () => {
12090 clearTimeout(timeout);
12091 setShowLoader(false);
12092 };
12093 }, [isLoading, options.delay]);
12094 return showLoader;
12095 }
12096
12097 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
12098 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
12099 function getEffectiveAlign(explicitAlign, fieldType) {
12100 if (explicitAlign) {
12101 return explicitAlign;
12102 }
12103 if (fieldType === "integer" || fieldType === "number") {
12104 return "end";
12105 }
12106 return void 0;
12107 }
12108 function TableColumnField({
12109 item,
12110 fields,
12111 column,
12112 align
12113 }) {
12114 const field = fields.find((f2) => f2.id === column);
12115 if (!field) {
12116 return null;
12117 }
12118 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
12119 "dataviews-view-table__cell-align-end": align === "end",
12120 "dataviews-view-table__cell-align-center": align === "center"
12121 });
12122 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(field.render, { item, field }) });
12123 }
12124 function TableRow({
12125 hasBulkActions,
12126 item,
12127 level,
12128 actions,
12129 fields,
12130 id,
12131 view,
12132 titleField,
12133 mediaField,
12134 descriptionField,
12135 selection,
12136 getItemId,
12137 isItemClickable,
12138 onClickItem,
12139 renderItemLink,
12140 onChangeSelection,
12141 onMouseDown,
12142 onClickCapture,
12143 isActionsColumnSticky,
12144 posinset
12145 }) {
12146 const { paginationInfo } = (0, import_element35.useContext)(dataviews_context_default);
12147 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
12148 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
12149 const {
12150 showTitle = true,
12151 showMedia = true,
12152 showDescription = true,
12153 infiniteScrollEnabled
12154 } = view;
12155 const columns = view.fields ?? [];
12156 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
12157 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
12158 "tr",
12159 {
12160 className: clsx_default("dataviews-view-table__row", {
12161 "is-selected": hasPossibleBulkAction && isSelected2,
12162 "has-bulk-actions": hasPossibleBulkAction
12163 }),
12164 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
12165 "aria-posinset": posinset,
12166 role: infiniteScrollEnabled ? "article" : void 0,
12167 onClickCapture,
12168 onMouseDown: (event) => {
12169 const isMetaClick = (0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey;
12170 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
12171 event.preventDefault();
12172 }
12173 onMouseDown(event);
12174 },
12175 children: [
12176 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)(
12177 DataViewsSelectionCheckbox,
12178 {
12179 item,
12180 selection,
12181 onChangeSelection,
12182 getItemId,
12183 titleField,
12184 disabled: !hasPossibleBulkAction
12185 }
12186 ) }) }),
12187 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12188 column_primary_default,
12189 {
12190 item,
12191 level,
12192 titleField: showTitle ? titleField : void 0,
12193 mediaField: showMedia ? mediaField : void 0,
12194 descriptionField: showDescription ? descriptionField : void 0,
12195 isItemClickable,
12196 onClickItem,
12197 renderItemLink
12198 }
12199 ) }),
12200 columns.map((column) => {
12201 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
12202 const field = fields.find((f2) => f2.id === column);
12203 const effectiveAlign = getEffectiveAlign(align, field?.type);
12204 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12205 "td",
12206 {
12207 style: {
12208 width,
12209 maxWidth,
12210 minWidth
12211 },
12212 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12213 TableColumnField,
12214 {
12215 fields,
12216 item,
12217 column,
12218 align: effectiveAlign
12219 }
12220 )
12221 },
12222 column
12223 );
12224 }),
12225 !!actions?.length && // Disable reason: we are not making the element interactive,
12226 // but preventing any click events from bubbling up to the
12227 // table row. This allows us to add a click handler to the row
12228 // itself (to toggle row selection) without erroneously
12229 // intercepting click events from ItemActions.
12230 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12231 "td",
12232 {
12233 className: clsx_default("dataviews-view-table__actions-column", {
12234 "dataviews-view-table__actions-column--sticky": true,
12235 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
12236 }),
12237 onClick: (e2) => e2.stopPropagation(),
12238 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ItemActions, { item, actions })
12239 }
12240 )
12241 ]
12242 }
12243 );
12244 }
12245 function ViewTable({
12246 actions,
12247 data,
12248 fields,
12249 getItemId,
12250 getItemLevel,
12251 isLoading = false,
12252 onChangeView,
12253 onChangeSelection,
12254 selection,
12255 setOpenedFilter,
12256 onClickItem,
12257 isItemClickable,
12258 renderItemLink,
12259 view,
12260 className,
12261 empty
12262 }) {
12263 const { containerRef } = (0, import_element35.useContext)(dataviews_context_default);
12264 const isDelayedLoading = useDelayedLoading(isLoading);
12265 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12266 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12267 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
12268 const { getSelectionProps } = useSelectionProps({
12269 data: orderedData,
12270 actions,
12271 getItemId,
12272 selection,
12273 onChangeSelection
12274 });
12275 const headerMenuRefs = (0, import_element35.useRef)(/* @__PURE__ */ new Map());
12276 const headerMenuToFocusRef = (0, import_element35.useRef)(void 0);
12277 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element35.useState)();
12278 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element35.useState)(null);
12279 (0, import_element35.useEffect)(() => {
12280 if (headerMenuToFocusRef.current) {
12281 headerMenuToFocusRef.current.focus();
12282 headerMenuToFocusRef.current = void 0;
12283 }
12284 });
12285 const tableNoticeId = (0, import_element35.useId)();
12286 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
12287 scrollContainerRef: containerRef,
12288 enabledHorizontal: !!actions?.length
12289 });
12290 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12291 if (nextHeaderMenuToFocus) {
12292 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
12293 setNextHeaderMenuToFocus(void 0);
12294 return;
12295 }
12296 const onHide = (field) => {
12297 const hidden = headerMenuRefs.current.get(field.id);
12298 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
12299 setNextHeaderMenuToFocus(fallback?.node);
12300 };
12301 const handleHeaderContextMenu = (event) => {
12302 event.preventDefault();
12303 event.stopPropagation();
12304 const virtualAnchor = {
12305 getBoundingClientRect: () => ({
12306 x: event.clientX,
12307 y: event.clientY,
12308 top: event.clientY,
12309 left: event.clientX,
12310 right: event.clientX,
12311 bottom: event.clientY,
12312 width: 0,
12313 height: 0,
12314 toJSON: () => ({})
12315 })
12316 };
12317 window.requestAnimationFrame(() => {
12318 setContextMenuAnchor(virtualAnchor);
12319 });
12320 };
12321 const hasData = !!data?.length;
12322 const titleField = fields.find((field) => field.id === view.titleField);
12323 const mediaField = fields.find((field) => field.id === view.mediaField);
12324 const descriptionField = fields.find(
12325 (field) => field.id === view.descriptionField
12326 );
12327 const { showTitle = true, showMedia = true, showDescription = true } = view;
12328 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
12329 const columns = view.fields ?? [];
12330 const headerMenuRef = (column, index2) => (node) => {
12331 if (node) {
12332 headerMenuRefs.current.set(column, {
12333 node,
12334 fallback: columns[index2 > 0 ? index2 - 1 : 1]
12335 });
12336 } else {
12337 headerMenuRefs.current.delete(column);
12338 }
12339 };
12340 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12341 const isRtl = (0, import_i18n10.isRTL)();
12342 if (!hasData) {
12343 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12344 "div",
12345 {
12346 className: clsx_default("dataviews-no-results", {
12347 "is-refreshing": isDelayedLoading
12348 }),
12349 id: tableNoticeId,
12350 children: empty
12351 }
12352 );
12353 }
12354 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
12355 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
12356 "table",
12357 {
12358 className: clsx_default("dataviews-view-table", className, {
12359 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12360 view.layout.density
12361 ),
12362 "has-bulk-actions": hasBulkActions,
12363 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12364 }),
12365 "aria-busy": isLoading,
12366 "aria-describedby": tableNoticeId,
12367 role: isInfiniteScroll ? "feed" : void 0,
12368 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
12369 children: [
12370 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("colgroup", { children: [
12371 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
12372 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
12373 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12374 "col",
12375 {
12376 className: clsx_default(
12377 `dataviews-view-table__col-${column}`,
12378 {
12379 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
12380 }
12381 )
12382 },
12383 `col-${column}`
12384 )),
12385 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-actions" })
12386 ] }),
12387 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12388 import_components6.Popover,
12389 {
12390 anchor: contextMenuAnchor,
12391 onClose: () => setContextMenuAnchor(null),
12392 placement: "bottom-start",
12393 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(PropertiesSection, { showLabel: false })
12394 }
12395 ),
12396 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12397 "thead",
12398 {
12399 className: clsx_default({
12400 "dataviews-view-table__thead--stuck": isVerticallyScrolled
12401 }),
12402 onContextMenu: handleHeaderContextMenu,
12403 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("tr", { className: "dataviews-view-table__row", children: [
12404 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12405 "th",
12406 {
12407 className: "dataviews-view-table__checkbox-column",
12408 scope: "col",
12409 onContextMenu: handleHeaderContextMenu,
12410 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12411 BulkSelectionCheckbox,
12412 {
12413 selection,
12414 onChangeSelection,
12415 data,
12416 actions,
12417 getItemId
12418 }
12419 )
12420 }
12421 ),
12422 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12423 column_header_menu_default,
12424 {
12425 ref: headerMenuRef(
12426 titleField.id,
12427 0
12428 ),
12429 fieldId: titleField.id,
12430 view,
12431 fields,
12432 onChangeView,
12433 onHide,
12434 setOpenedFilter,
12435 canMove: false,
12436 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
12437 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
12438 }
12439 ) }),
12440 columns.map((column, index2) => {
12441 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
12442 const field = fields.find(
12443 (f2) => f2.id === column
12444 );
12445 const effectiveAlign = getEffectiveAlign(
12446 align,
12447 field?.type
12448 );
12449 const canInsertOrMove = view.layout?.enableMoving ?? true;
12450 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12451 "th",
12452 {
12453 style: {
12454 width,
12455 maxWidth,
12456 minWidth,
12457 textAlign: effectiveAlign
12458 },
12459 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
12460 scope: "col",
12461 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12462 column_header_menu_default,
12463 {
12464 ref: headerMenuRef(column, index2),
12465 fieldId: column,
12466 view,
12467 fields,
12468 onChangeView,
12469 onHide,
12470 setOpenedFilter,
12471 canMove: canInsertOrMove,
12472 canInsertLeft: canInsertOrMove,
12473 canInsertRight: canInsertOrMove
12474 }
12475 )
12476 },
12477 column
12478 );
12479 }),
12480 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12481 "th",
12482 {
12483 className: clsx_default(
12484 "dataviews-view-table__actions-column",
12485 {
12486 "dataviews-view-table__actions-column--sticky": true,
12487 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
12488 }
12489 ),
12490 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n10.__)("Actions") })
12491 }
12492 )
12493 ] })
12494 }
12495 ),
12496 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
12497 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("tbody", { children: [
12498 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12499 "td",
12500 {
12501 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
12502 className: "dataviews-view-table__group-header-cell",
12503 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n10.sprintf)(
12504 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12505 (0, import_i18n10.__)("%1$s: %2$s"),
12506 groupField.label,
12507 groupName
12508 )
12509 }
12510 ) }),
12511 groupItems.map((item, index2) => {
12512 const id = getItemId(item) || index2.toString();
12513 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12514 TableRow,
12515 {
12516 item,
12517 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12518 hasBulkActions,
12519 actions,
12520 fields,
12521 id,
12522 view,
12523 titleField,
12524 mediaField,
12525 descriptionField,
12526 selection,
12527 getItemId,
12528 onChangeSelection,
12529 ...getSelectionProps(id),
12530 onClickItem,
12531 renderItemLink,
12532 isItemClickable,
12533 isActionsColumnSticky: !isHorizontalScrollEnd
12534 },
12535 getItemId(item)
12536 );
12537 })
12538 ] }, `group-${groupName}`)
12539 ) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("tbody", { children: hasData && data.map((item, index2) => {
12540 const id = getItemId(item) || index2.toString();
12541 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12542 TableRow,
12543 {
12544 item,
12545 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12546 hasBulkActions,
12547 actions,
12548 fields,
12549 id,
12550 view,
12551 titleField,
12552 mediaField,
12553 descriptionField,
12554 selection,
12555 getItemId,
12556 onChangeSelection,
12557 ...getSelectionProps(id),
12558 onClickItem,
12559 renderItemLink,
12560 isItemClickable,
12561 isActionsColumnSticky: !isHorizontalScrollEnd,
12562 posinset: isInfiniteScroll ? index2 + 1 : void 0
12563 },
12564 getItemId(item)
12565 );
12566 }) })
12567 ]
12568 }
12569 ),
12570 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, {}) }) })
12571 ] });
12572 }
12573 var table_default = ViewTable;
12574
12575 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12576 var import_components9 = __toESM(require_components(), 1);
12577 var import_i18n13 = __toESM(require_i18n(), 1);
12578
12579 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12580 var import_components8 = __toESM(require_components(), 1);
12581 var import_i18n12 = __toESM(require_i18n(), 1);
12582 var import_compose3 = __toESM(require_compose(), 1);
12583 var import_element39 = __toESM(require_element(), 1);
12584
12585 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
12586 var import_components7 = __toESM(require_components(), 1);
12587 var import_i18n11 = __toESM(require_i18n(), 1);
12588 var import_element36 = __toESM(require_element(), 1);
12589 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
12590 var imageSizes = [
12591 {
12592 value: 120,
12593 breakpoint: 1
12594 },
12595 {
12596 value: 170,
12597 breakpoint: 1
12598 },
12599 {
12600 value: 230,
12601 breakpoint: 1
12602 },
12603 {
12604 value: 290,
12605 breakpoint: 1112
12606 // at minimum image width, 4 images display at this container size
12607 },
12608 {
12609 value: 350,
12610 breakpoint: 1636
12611 // at minimum image width, 6 images display at this container size
12612 },
12613 {
12614 value: 430,
12615 breakpoint: 588
12616 // at minimum image width, 2 images display at this container size
12617 }
12618 ];
12619 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
12620 function useGridColumns() {
12621 const context = (0, import_element36.useContext)(dataviews_context_default);
12622 const view = context.view;
12623 return (0, import_element36.useMemo)(() => {
12624 const containerWidth = context.containerWidth;
12625 const gap = 32;
12626 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
12627 const columns = Math.floor(
12628 (containerWidth + gap) / (previewSize + gap)
12629 );
12630 return Math.max(1, columns);
12631 }, [context.containerWidth, view.layout?.previewSize]);
12632 }
12633
12634 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
12635 var import_element37 = __toESM(require_element(), 1);
12636 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
12637 var GridItems = (0, import_element37.forwardRef)(({ className, previewSize, ...props }, ref) => {
12638 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12639 "div",
12640 {
12641 ref,
12642 className: clsx_default("dataviews-view-grid-items", className),
12643 style: {
12644 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
12645 },
12646 ...props
12647 }
12648 );
12649 });
12650
12651 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
12652 var import_element38 = __toESM(require_element(), 1);
12653 function useIntersectionObserver(elementRef, posinset) {
12654 const { intersectionObserver } = (0, import_element38.useContext)(dataviews_context_default);
12655 (0, import_element38.useEffect)(() => {
12656 const element = elementRef.current;
12657 if (!element || posinset === void 0 || !intersectionObserver) {
12658 return;
12659 }
12660 intersectionObserver.observe(element);
12661 return () => {
12662 intersectionObserver.unobserve(element);
12663 };
12664 }, [elementRef, intersectionObserver, posinset]);
12665 }
12666 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
12667 const hasData = !!data?.length;
12668 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
12669 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
12670 }
12671
12672 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12673 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
12674 var { Badge: WCBadge } = unlock2(import_components8.privateApis);
12675 function chunk(array, size4) {
12676 const chunks = [];
12677 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
12678 chunks.push(array.slice(i2, i2 + size4));
12679 }
12680 return chunks;
12681 }
12682 var GridItem = (0, import_element39.forwardRef)(
12683 function GridItem2({
12684 view,
12685 selection,
12686 onChangeSelection,
12687 onClickItem,
12688 isItemClickable,
12689 renderItemLink,
12690 getItemId,
12691 item,
12692 actions,
12693 mediaField,
12694 titleField,
12695 descriptionField,
12696 regularFields,
12697 badgeFields,
12698 hasBulkActions,
12699 config,
12700 posinset,
12701 setsize,
12702 ...props
12703 }, forwardedRef) {
12704 const {
12705 showTitle = true,
12706 showMedia = true,
12707 showDescription = true
12708 } = view;
12709 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
12710 const id = getItemId(item);
12711 const elementRef = (0, import_element39.useRef)(null);
12712 const setRefs = (0, import_element39.useCallback)(
12713 (node) => {
12714 elementRef.current = node;
12715 if (typeof forwardedRef === "function") {
12716 forwardedRef(node);
12717 } else if (forwardedRef) {
12718 forwardedRef.current = node;
12719 }
12720 },
12721 [forwardedRef]
12722 );
12723 useIntersectionObserver(elementRef, posinset);
12724 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
12725 const isSelected2 = selection.includes(id);
12726 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
12727 const rendersMediaField = showMedia && mediaField?.render;
12728 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12729 mediaField.render,
12730 {
12731 item,
12732 field: mediaField,
12733 config
12734 }
12735 ) : mediaPlaceholder;
12736 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(titleField.render, { item, field: titleField }) : null;
12737 let mediaA11yProps;
12738 let titleA11yProps;
12739 if (isItemClickable(item) && onClickItem) {
12740 if (renderedTitleField) {
12741 mediaA11yProps = {
12742 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
12743 };
12744 titleA11yProps = {
12745 id: `dataviews-view-grid__title-field-${instanceId}`
12746 };
12747 } else {
12748 mediaA11yProps = {
12749 "aria-label": (0, import_i18n12.__)("Navigate to item")
12750 };
12751 }
12752 }
12753 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12754 Stack,
12755 {
12756 direction: "column",
12757 ...props,
12758 ref: setRefs,
12759 "aria-setsize": setsize,
12760 "aria-posinset": posinset,
12761 className: clsx_default(
12762 props.className,
12763 "dataviews-view-grid__row__gridcell",
12764 "dataviews-view-grid__card",
12765 {
12766 "is-selected": hasBulkAction && isSelected2
12767 }
12768 ),
12769 children: [
12770 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12771 ItemClickWrapper,
12772 {
12773 item,
12774 isItemClickable,
12775 onClickItem,
12776 renderItemLink,
12777 className: clsx_default("dataviews-view-grid__media", {
12778 "dataviews-view-grid__media--placeholder": !rendersMediaField
12779 }),
12780 ...mediaA11yProps,
12781 children: renderedMediaField
12782 }
12783 ),
12784 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12785 DataViewsSelectionCheckbox,
12786 {
12787 item,
12788 selection,
12789 onChangeSelection,
12790 getItemId,
12791 titleField,
12792 disabled: !hasBulkAction
12793 }
12794 ),
12795 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12796 ItemActions,
12797 {
12798 item,
12799 actions,
12800 isCompact: true
12801 }
12802 ) }),
12803 showTitle && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12804 ItemClickWrapper,
12805 {
12806 item,
12807 isItemClickable,
12808 onClickItem,
12809 renderItemLink,
12810 className: "dataviews-view-grid__title-field dataviews-title-field",
12811 ...titleA11yProps,
12812 title: titleField?.getValueFormatted({
12813 item,
12814 field: titleField
12815 }) || void 0,
12816 children: renderedTitleField
12817 }
12818 ) }),
12819 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(Stack, { direction: "column", gap: "xs", children: [
12820 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12821 descriptionField.render,
12822 {
12823 item,
12824 field: descriptionField
12825 }
12826 ),
12827 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12828 Stack,
12829 {
12830 direction: "row",
12831 className: "dataviews-view-grid__badge-fields",
12832 gap: "sm",
12833 wrap: "wrap",
12834 align: "top",
12835 justify: "flex-start",
12836 children: badgeFields.map((field) => {
12837 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12838 WCBadge,
12839 {
12840 className: "dataviews-view-grid__field-value",
12841 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12842 field.render,
12843 {
12844 item,
12845 field
12846 }
12847 )
12848 },
12849 field.id
12850 );
12851 })
12852 }
12853 ),
12854 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12855 Stack,
12856 {
12857 direction: "column",
12858 className: "dataviews-view-grid__fields",
12859 gap: "xs",
12860 children: regularFields.map((field) => {
12861 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12862 import_components8.Flex,
12863 {
12864 className: "dataviews-view-grid__field",
12865 gap: 1,
12866 justify: "flex-start",
12867 expanded: true,
12868 style: { height: "auto" },
12869 direction: "row",
12870 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
12871 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(tooltip_exports.Root, { children: [
12872 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12873 tooltip_exports.Trigger,
12874 {
12875 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
12876 }
12877 ),
12878 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(tooltip_exports.Popup, { children: field.label })
12879 ] }),
12880 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12881 import_components8.FlexItem,
12882 {
12883 className: "dataviews-view-grid__field-value",
12884 style: { maxHeight: "none" },
12885 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12886 field.render,
12887 {
12888 item,
12889 field
12890 }
12891 )
12892 }
12893 )
12894 ] })
12895 },
12896 field.id
12897 );
12898 })
12899 }
12900 )
12901 ] })
12902 ]
12903 }
12904 );
12905 }
12906 );
12907 function CompositeGrid({
12908 data,
12909 isInfiniteScroll,
12910 className,
12911 inert,
12912 isLoading,
12913 view,
12914 fields,
12915 selection,
12916 onChangeSelection,
12917 onClickItem,
12918 isItemClickable,
12919 renderItemLink,
12920 getItemId,
12921 actions,
12922 getSelectionProps
12923 }) {
12924 const { paginationInfo, resizeObserverRef } = (0, import_element39.useContext)(dataviews_context_default);
12925 const gridColumns = useGridColumns();
12926 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12927 const titleField = fields.find(
12928 (field) => field.id === view?.titleField
12929 );
12930 const mediaField = fields.find(
12931 (field) => field.id === view?.mediaField
12932 );
12933 const descriptionField = fields.find(
12934 (field) => field.id === view?.descriptionField
12935 );
12936 const otherFields = view.fields ?? [];
12937 const { regularFields, badgeFields } = otherFields.reduce(
12938 (accumulator, fieldId) => {
12939 const field = fields.find((f2) => f2.id === fieldId);
12940 if (!field) {
12941 return accumulator;
12942 }
12943 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
12944 accumulator[key].push(field);
12945 return accumulator;
12946 },
12947 { regularFields: [], badgeFields: [] }
12948 );
12949 const size4 = "900px";
12950 const totalRows = Math.ceil(data.length / gridColumns);
12951 const placeholdersNeeded = usePlaceholdersNeeded(
12952 data,
12953 isInfiniteScroll,
12954 gridColumns
12955 );
12956 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, {
12957 // Render infinite scroll layout (no rows, feed semantics)
12958 children: [
12959 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12960 import_components8.Composite,
12961 {
12962 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12963 GridItems,
12964 {
12965 className: clsx_default(
12966 "dataviews-view-grid-infinite-scroll",
12967 className,
12968 {
12969 [`has-${view.layout?.density}-density`]: view.layout?.density && [
12970 "compact",
12971 "comfortable"
12972 ].includes(view.layout.density)
12973 }
12974 ),
12975 previewSize: view.layout?.previewSize,
12976 "aria-busy": isLoading,
12977 ref: resizeObserverRef
12978 }
12979 ),
12980 role: "feed",
12981 focusWrap: true,
12982 inert,
12983 children: [
12984 Array.from({ length: placeholdersNeeded }).map(
12985 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12986 import_components8.Composite.Item,
12987 {
12988 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12989 Stack,
12990 {
12991 ...props,
12992 direction: "column",
12993 role: "article",
12994 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
12995 }
12996 ),
12997 "aria-hidden": true,
12998 tabIndex: -1
12999 },
13000 `placeholder-${index2}`
13001 )
13002 ),
13003 data.map((item) => {
13004 const itemId = getItemId(item);
13005 const selectionProps = getSelectionProps(itemId);
13006 const stablePosition = item.position;
13007 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13008 import_components8.Composite.Item,
13009 {
13010 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13011 GridItem,
13012 {
13013 ...props,
13014 id: itemId,
13015 role: "article",
13016 view,
13017 selection,
13018 onChangeSelection,
13019 onClickItem,
13020 isItemClickable,
13021 renderItemLink,
13022 getItemId,
13023 item,
13024 actions,
13025 onMouseDown: (event) => {
13026 props.onMouseDown?.(event);
13027 selectionProps.onMouseDown(
13028 event
13029 );
13030 },
13031 onClickCapture: (event) => {
13032 props.onClickCapture?.(event);
13033 selectionProps.onClickCapture(
13034 event
13035 );
13036 },
13037 mediaField,
13038 titleField,
13039 descriptionField,
13040 regularFields,
13041 badgeFields,
13042 hasBulkActions,
13043 posinset: stablePosition,
13044 setsize: paginationInfo.totalItems,
13045 config: {
13046 sizes: size4
13047 }
13048 }
13049 )
13050 },
13051 itemId
13052 );
13053 })
13054 ]
13055 }
13056 ),
13057 // Render standard grid layout (with rows, grid semantics)
13058 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13059 import_components8.Composite,
13060 {
13061 role: "grid",
13062 className: clsx_default("dataviews-view-grid", className, {
13063 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
13064 view.layout.density
13065 )
13066 }),
13067 focusWrap: true,
13068 "aria-busy": isLoading,
13069 "aria-rowcount": totalRows,
13070 ref: resizeObserverRef,
13071 inert,
13072 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13073 import_components8.Composite.Row,
13074 {
13075 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13076 "div",
13077 {
13078 role: "row",
13079 "aria-rowindex": i2 + 1,
13080 "aria-label": (0, import_i18n12.sprintf)(
13081 /* translators: %d: The row number in the grid */
13082 (0, import_i18n12.__)("Row %d"),
13083 i2 + 1
13084 ),
13085 className: "dataviews-view-grid__row",
13086 style: {
13087 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
13088 }
13089 }
13090 ),
13091 children: row.map((item) => {
13092 const itemId = getItemId(item);
13093 const selectionProps = getSelectionProps(itemId);
13094 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13095 import_components8.Composite.Item,
13096 {
13097 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13098 GridItem,
13099 {
13100 ...props,
13101 id: itemId,
13102 role: "gridcell",
13103 view,
13104 selection,
13105 onChangeSelection,
13106 onClickItem,
13107 isItemClickable,
13108 renderItemLink,
13109 getItemId,
13110 item,
13111 actions,
13112 onMouseDown: (event) => {
13113 props.onMouseDown?.(
13114 event
13115 );
13116 selectionProps.onMouseDown(
13117 event
13118 );
13119 },
13120 onClickCapture: (event) => {
13121 props.onClickCapture?.(
13122 event
13123 );
13124 selectionProps.onClickCapture(
13125 event
13126 );
13127 },
13128 mediaField,
13129 titleField,
13130 descriptionField,
13131 regularFields,
13132 badgeFields,
13133 hasBulkActions,
13134 config: {
13135 sizes: size4
13136 }
13137 }
13138 )
13139 },
13140 itemId
13141 );
13142 })
13143 },
13144 i2
13145 ))
13146 }
13147 )
13148 ]
13149 });
13150 }
13151
13152 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
13153 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
13154 function ViewGrid({
13155 actions,
13156 data,
13157 fields,
13158 getItemId,
13159 isLoading,
13160 onChangeSelection,
13161 onClickItem,
13162 isItemClickable,
13163 renderItemLink,
13164 selection,
13165 view,
13166 className,
13167 empty
13168 }) {
13169 const isDelayedLoading = useDelayedLoading(!!isLoading);
13170 const hasData = !!data?.length;
13171 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
13172 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
13173 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13174 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
13175 const { getSelectionProps } = useSelectionProps({
13176 data: orderedData,
13177 actions,
13178 getItemId,
13179 selection,
13180 onChangeSelection
13181 });
13182 if (!hasData) {
13183 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13184 "div",
13185 {
13186 className: clsx_default("dataviews-no-results", {
13187 "is-refreshing": isDelayedLoading
13188 }),
13189 children: empty
13190 }
13191 );
13192 }
13193 const gridProps = {
13194 className: clsx_default(className, {
13195 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13196 }),
13197 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
13198 isLoading,
13199 view,
13200 fields,
13201 selection,
13202 onChangeSelection,
13203 onClickItem,
13204 isItemClickable,
13205 renderItemLink,
13206 getItemId,
13207 actions,
13208 getSelectionProps
13209 };
13210 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, {
13211 // Render multiple groups.
13212 children: [
13213 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
13214 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13215 Stack,
13216 {
13217 direction: "column",
13218 gap: "sm",
13219 children: [
13220 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)(
13221 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13222 (0, import_i18n13.__)("%1$s: %2$s"),
13223 groupField.label,
13224 groupName
13225 ) }),
13226 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13227 CompositeGrid,
13228 {
13229 ...gridProps,
13230 data: groupItems,
13231 isInfiniteScroll: false
13232 }
13233 )
13234 ]
13235 },
13236 groupName
13237 )
13238 ) }),
13239 // Render a single grid with all data.
13240 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13241 CompositeGrid,
13242 {
13243 ...gridProps,
13244 data,
13245 isInfiniteScroll: !!isInfiniteScroll
13246 }
13247 ),
13248 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components9.Spinner, {}) })
13249 ]
13250 });
13251 }
13252 var grid_default = ViewGrid;
13253
13254 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
13255 var import_compose4 = __toESM(require_compose(), 1);
13256 var import_components10 = __toESM(require_components(), 1);
13257 var import_element40 = __toESM(require_element(), 1);
13258 var import_i18n14 = __toESM(require_i18n(), 1);
13259 var import_data3 = __toESM(require_data(), 1);
13260 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
13261 var { Menu: Menu3 } = unlock2(import_components10.privateApis);
13262 function generateItemWrapperCompositeId(idPrefix) {
13263 return `${idPrefix}-item-wrapper`;
13264 }
13265 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
13266 return `${idPrefix}-primary-action-${primaryActionId}`;
13267 }
13268 function generateDropdownTriggerCompositeId(idPrefix) {
13269 return `${idPrefix}-dropdown`;
13270 }
13271 function PrimaryActionGridCell({
13272 idPrefix,
13273 primaryAction,
13274 item
13275 }) {
13276 const registry = (0, import_data3.useRegistry)();
13277 const [isModalOpen, setIsModalOpen] = (0, import_element40.useState)(false);
13278 const compositeItemId = generatePrimaryActionCompositeId(
13279 idPrefix,
13280 primaryAction.id
13281 );
13282 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
13283 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13284 import_components10.Composite.Item,
13285 {
13286 id: compositeItemId,
13287 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13288 import_components10.Button,
13289 {
13290 disabled: !!primaryAction.disabled,
13291 accessibleWhenDisabled: true,
13292 text: label,
13293 size: "small",
13294 onClick: () => setIsModalOpen(true)
13295 }
13296 ),
13297 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13298 ActionModal,
13299 {
13300 action: primaryAction,
13301 items: [item],
13302 closeModal: () => setIsModalOpen(false)
13303 }
13304 )
13305 }
13306 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13307 import_components10.Composite.Item,
13308 {
13309 id: compositeItemId,
13310 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13311 import_components10.Button,
13312 {
13313 disabled: !!primaryAction.disabled,
13314 accessibleWhenDisabled: true,
13315 size: "small",
13316 onClick: () => {
13317 primaryAction.callback([item], { registry });
13318 },
13319 children: label
13320 }
13321 )
13322 }
13323 ) }, primaryAction.id);
13324 }
13325 function ListItem({
13326 view,
13327 actions,
13328 idPrefix,
13329 isSelected: isSelected2,
13330 item,
13331 titleField,
13332 mediaField,
13333 descriptionField,
13334 onSelect,
13335 otherFields,
13336 onDropdownTriggerKeyDown,
13337 posinset
13338 }) {
13339 const {
13340 showTitle = true,
13341 showMedia = true,
13342 showDescription = true,
13343 infiniteScrollEnabled
13344 } = view;
13345 const itemRef = (0, import_element40.useRef)(null);
13346 const labelId = `${idPrefix}-label`;
13347 const descriptionId = `${idPrefix}-description`;
13348 const registry = (0, import_data3.useRegistry)();
13349 const [isHovered, setIsHovered] = (0, import_element40.useState)(false);
13350 const [activeModalAction, setActiveModalAction] = (0, import_element40.useState)(
13351 null
13352 );
13353 const handleHover = ({ type }) => {
13354 const isHover = type === "mouseenter";
13355 setIsHovered(isHover);
13356 };
13357 const { paginationInfo } = (0, import_element40.useContext)(dataviews_context_default);
13358 (0, import_element40.useEffect)(() => {
13359 if (isSelected2) {
13360 itemRef.current?.scrollIntoView({
13361 behavior: "auto",
13362 block: "nearest",
13363 inline: "nearest"
13364 });
13365 }
13366 }, [isSelected2]);
13367 const { primaryAction, eligibleActions } = (0, import_element40.useMemo)(() => {
13368 const _eligibleActions = actions.filter(
13369 (action) => !action.isEligible || action.isEligible(item)
13370 );
13371 const _primaryActions = _eligibleActions.filter(
13372 (action) => action.isPrimary
13373 );
13374 return {
13375 primaryAction: _primaryActions[0],
13376 eligibleActions: _eligibleActions
13377 };
13378 }, [actions, item]);
13379 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
13380 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)(
13381 mediaField.render,
13382 {
13383 item,
13384 field: mediaField,
13385 config: { sizes: "52px" }
13386 }
13387 ) }) : null;
13388 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(titleField.render, { item, field: titleField }) : null;
13389 const renderDescription = showDescription && descriptionField?.render;
13390 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
13391 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13392 Stack,
13393 {
13394 direction: "row",
13395 gap: "md",
13396 className: "dataviews-view-list__item-actions",
13397 children: [
13398 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13399 PrimaryActionGridCell,
13400 {
13401 idPrefix,
13402 primaryAction,
13403 item
13404 }
13405 ),
13406 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { role: "gridcell", children: [
13407 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Menu3, { placement: "bottom-end", children: [
13408 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13409 Menu3.TriggerButton,
13410 {
13411 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13412 import_components10.Composite.Item,
13413 {
13414 id: generateDropdownTriggerCompositeId(
13415 idPrefix
13416 ),
13417 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13418 import_components10.Button,
13419 {
13420 size: "small",
13421 icon: more_vertical_default,
13422 label: (0, import_i18n14.__)("Actions"),
13423 accessibleWhenDisabled: true,
13424 disabled: !actions.length,
13425 onKeyDown: onDropdownTriggerKeyDown
13426 }
13427 )
13428 }
13429 )
13430 }
13431 ),
13432 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13433 ActionsMenuGroup,
13434 {
13435 actions: eligibleActions,
13436 item,
13437 registry,
13438 setActiveModalAction
13439 }
13440 ) })
13441 ] }),
13442 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13443 ActionModal,
13444 {
13445 action: activeModalAction,
13446 items: [item],
13447 closeModal: () => setActiveModalAction(null)
13448 }
13449 )
13450 ] })
13451 ]
13452 }
13453 );
13454 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13455 import_components10.Composite.Row,
13456 {
13457 ref: itemRef,
13458 render: (
13459 /* aria-posinset breaks Composite.Row if passed to it directly. */
13460 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13461 "div",
13462 {
13463 "aria-posinset": posinset,
13464 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
13465 }
13466 )
13467 ),
13468 role: infiniteScrollEnabled ? "article" : "row",
13469 className: clsx_default({
13470 "is-selected": isSelected2,
13471 "is-hovered": isHovered
13472 }),
13473 onMouseEnter: handleHover,
13474 onMouseLeave: handleHover,
13475 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13476 Stack,
13477 {
13478 direction: "row",
13479 className: "dataviews-view-list__item-wrapper",
13480 children: [
13481 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13482 import_components10.Composite.Item,
13483 {
13484 id: generateItemWrapperCompositeId(idPrefix),
13485 "aria-pressed": isSelected2,
13486 "aria-labelledby": labelId,
13487 "aria-describedby": descriptionId,
13488 className: "dataviews-view-list__item",
13489 onClick: () => onSelect(item)
13490 }
13491 ) }),
13492 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13493 Stack,
13494 {
13495 direction: "row",
13496 gap: "md",
13497 justify: "start",
13498 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
13499 style: { flex: 1, minWidth: 0 },
13500 children: [
13501 renderedMediaField,
13502 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13503 Stack,
13504 {
13505 direction: "column",
13506 gap: "xs",
13507 className: "dataviews-view-list__field-wrapper",
13508 children: [
13509 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Stack, { direction: "row", align: "center", children: [
13510 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13511 "div",
13512 {
13513 className: "dataviews-title-field dataviews-view-list__title-field",
13514 id: labelId,
13515 children: renderedTitleField
13516 }
13517 ),
13518 usedActions
13519 ] }),
13520 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13521 descriptionField.render,
13522 {
13523 item,
13524 field: descriptionField
13525 }
13526 ) }),
13527 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13528 "div",
13529 {
13530 className: "dataviews-view-list__fields",
13531 id: descriptionId,
13532 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13533 "div",
13534 {
13535 className: "dataviews-view-list__field",
13536 children: [
13537 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13538 VisuallyHidden,
13539 {
13540 className: "dataviews-view-list__field-label",
13541 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", {}),
13542 children: field.label
13543 }
13544 ),
13545 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13546 field.render,
13547 {
13548 item,
13549 field
13550 }
13551 ) })
13552 ]
13553 },
13554 field.id
13555 ))
13556 }
13557 )
13558 ]
13559 }
13560 )
13561 ]
13562 }
13563 )
13564 ]
13565 }
13566 )
13567 }
13568 );
13569 }
13570 function isDefined2(item) {
13571 return !!item;
13572 }
13573 function ViewList(props) {
13574 const {
13575 actions,
13576 data,
13577 fields,
13578 getItemId,
13579 isLoading,
13580 onChangeSelection,
13581 selection,
13582 view,
13583 className,
13584 empty
13585 } = props;
13586 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
13587 const isDelayedLoading = useDelayedLoading(!!isLoading);
13588 const { paginationInfo } = (0, import_element40.useContext)(dataviews_context_default);
13589 const selectedItem = data?.findLast(
13590 (item) => selection.includes(getItemId(item))
13591 );
13592 const titleField = fields.find((field) => field.id === view.titleField);
13593 const mediaField = fields.find((field) => field.id === view.mediaField);
13594 const descriptionField = fields.find(
13595 (field) => field.id === view.descriptionField
13596 );
13597 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
13598 const onSelect = (item) => onChangeSelection([getItemId(item)]);
13599 const generateCompositeItemIdPrefix = (0, import_element40.useCallback)(
13600 (item) => `${baseId}-${getItemId(item)}`,
13601 [baseId, getItemId]
13602 );
13603 const isActiveCompositeItem = (0, import_element40.useCallback)(
13604 (item, idToCheck) => {
13605 return idToCheck.startsWith(
13606 generateCompositeItemIdPrefix(item)
13607 );
13608 },
13609 [generateCompositeItemIdPrefix]
13610 );
13611 const [activeCompositeId, setActiveCompositeId] = (0, import_element40.useState)(void 0);
13612 const compositeRef = (0, import_element40.useRef)(null);
13613 (0, import_element40.useEffect)(() => {
13614 if (selectedItem) {
13615 setActiveCompositeId(
13616 generateItemWrapperCompositeId(
13617 generateCompositeItemIdPrefix(selectedItem)
13618 )
13619 );
13620 }
13621 }, [selectedItem, generateCompositeItemIdPrefix]);
13622 const activeItemIndex = data.findIndex(
13623 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
13624 );
13625 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
13626 const isActiveIdInList = activeItemIndex !== -1;
13627 const selectCompositeItem = (0, import_element40.useCallback)(
13628 (targetIndex, generateCompositeId) => {
13629 const clampedIndex = Math.min(
13630 data.length - 1,
13631 Math.max(0, targetIndex)
13632 );
13633 if (!data[clampedIndex]) {
13634 return;
13635 }
13636 const itemIdPrefix = generateCompositeItemIdPrefix(
13637 data[clampedIndex]
13638 );
13639 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
13640 setActiveCompositeId(targetCompositeItemId);
13641 if (compositeRef.current?.contains(
13642 compositeRef.current.ownerDocument.activeElement
13643 )) {
13644 document.getElementById(targetCompositeItemId)?.focus();
13645 }
13646 },
13647 [data, generateCompositeItemIdPrefix]
13648 );
13649 (0, import_element40.useEffect)(() => {
13650 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
13651 if (!isActiveIdInList && wasActiveIdInList) {
13652 selectCompositeItem(
13653 previousActiveItemIndex,
13654 generateItemWrapperCompositeId
13655 );
13656 }
13657 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
13658 const onDropdownTriggerKeyDown = (0, import_element40.useCallback)(
13659 (event) => {
13660 if (event.key === "ArrowDown") {
13661 event.preventDefault();
13662 selectCompositeItem(
13663 activeItemIndex + 1,
13664 generateDropdownTriggerCompositeId
13665 );
13666 }
13667 if (event.key === "ArrowUp") {
13668 event.preventDefault();
13669 selectCompositeItem(
13670 activeItemIndex - 1,
13671 generateDropdownTriggerCompositeId
13672 );
13673 }
13674 },
13675 [selectCompositeItem, activeItemIndex]
13676 );
13677 const hasData = !!data?.length;
13678 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13679 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13680 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13681 const hasMoreItems = isInfiniteScroll && (view.startPosition ?? 1) + (view.perPage ?? 0) < paginationInfo.totalItems;
13682 const listClassName = clsx_default("dataviews-view-list", className, {
13683 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(view.layout.density),
13684 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13685 });
13686 const compositeProps = {
13687 ref: compositeRef,
13688 id: baseId,
13689 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", {}),
13690 activeId: activeCompositeId,
13691 setActiveId: setActiveCompositeId,
13692 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0
13693 };
13694 if (!hasData) {
13695 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13696 "div",
13697 {
13698 className: clsx_default("dataviews-no-results", {
13699 "is-refreshing": isDelayedLoading
13700 }),
13701 children: empty
13702 }
13703 );
13704 }
13705 if (hasData && groupField && dataByGroup) {
13706 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13707 import_components10.Composite,
13708 {
13709 ...compositeProps,
13710 className: "dataviews-view-list__group",
13711 role: "grid",
13712 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Stack, { direction: "column", gap: "lg", className: listClassName, children: Array.from(dataByGroup.entries()).map(
13713 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Stack, { direction: "column", children: [
13714 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n14.sprintf)(
13715 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13716 (0, import_i18n14.__)("%1$s: %2$s"),
13717 groupField.label,
13718 groupName
13719 ) }),
13720 groupItems.map((item) => {
13721 const id = generateCompositeItemIdPrefix(item);
13722 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13723 ListItem,
13724 {
13725 view,
13726 idPrefix: id,
13727 actions,
13728 item,
13729 isSelected: item === selectedItem,
13730 onSelect,
13731 mediaField,
13732 titleField,
13733 descriptionField,
13734 otherFields,
13735 onDropdownTriggerKeyDown
13736 },
13737 id
13738 );
13739 })
13740 ] }, groupName)
13741 ) })
13742 }
13743 );
13744 }
13745 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [
13746 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13747 import_components10.Composite,
13748 {
13749 ...compositeProps,
13750 className: listClassName,
13751 role: view.infiniteScrollEnabled ? "feed" : "grid",
13752 children: data.map((item, index2) => {
13753 const id = generateCompositeItemIdPrefix(item);
13754 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13755 ListItem,
13756 {
13757 view,
13758 idPrefix: id,
13759 actions,
13760 item,
13761 isSelected: item === selectedItem,
13762 onSelect,
13763 mediaField,
13764 titleField,
13765 descriptionField,
13766 otherFields,
13767 onDropdownTriggerKeyDown,
13768 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13769 },
13770 id
13771 );
13772 })
13773 }
13774 ),
13775 (hasMoreItems || isInfiniteScroll && isLoading) && // Keep the spinner's height reserved while loading more so the
13776 // scroll position doesn't bounce. Hidden, and silent to a11y,
13777 // while idle.
13778 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13779 "p",
13780 {
13781 className: "dataviews-loading-more",
13782 "aria-hidden": !isLoading,
13783 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components10.Spinner, {})
13784 }
13785 )
13786 ] });
13787 }
13788
13789 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13790 var import_components11 = __toESM(require_components(), 1);
13791
13792 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
13793 var import_i18n15 = __toESM(require_i18n(), 1);
13794 var import_element41 = __toESM(require_element(), 1);
13795 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
13796 function ActivityGroup({
13797 groupName,
13798 groupData,
13799 groupField,
13800 showLabel = true,
13801 children
13802 }) {
13803 const groupHeader = showLabel ? (0, import_element41.createInterpolateElement)(
13804 // translators: %s: The label of the field e.g. "Status".
13805 (0, import_i18n15.sprintf)((0, import_i18n15.__)("%s: <groupName />"), groupField.label).trim(),
13806 {
13807 groupName: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13808 groupField.render,
13809 {
13810 item: groupData[0],
13811 field: groupField
13812 }
13813 )
13814 }
13815 ) : /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(groupField.render, { item: groupData[0], field: groupField });
13816 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
13817 Stack,
13818 {
13819 direction: "column",
13820 className: "dataviews-view-activity__group",
13821 children: [
13822 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
13823 children
13824 ]
13825 },
13826 groupName
13827 );
13828 }
13829
13830 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
13831 var import_element42 = __toESM(require_element(), 1);
13832 var import_data4 = __toESM(require_data(), 1);
13833 var import_compose5 = __toESM(require_compose(), 1);
13834 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
13835 function ActivityItem(props) {
13836 const {
13837 view,
13838 actions,
13839 item,
13840 titleField,
13841 mediaField,
13842 descriptionField,
13843 otherFields,
13844 posinset,
13845 onClickItem,
13846 renderItemLink,
13847 isItemClickable
13848 } = props;
13849 const {
13850 showTitle = true,
13851 showMedia = true,
13852 showDescription = true,
13853 infiniteScrollEnabled
13854 } = view;
13855 const itemRef = (0, import_element42.useRef)(null);
13856 const registry = (0, import_data4.useRegistry)();
13857 const { paginationInfo } = (0, import_element42.useContext)(dataviews_context_default);
13858 const { primaryActions, eligibleActions } = (0, import_element42.useMemo)(() => {
13859 const _eligibleActions = actions.filter(
13860 (action) => !action.isEligible || action.isEligible(item)
13861 );
13862 const _primaryActions = _eligibleActions.filter(
13863 (action) => action.isPrimary
13864 );
13865 return {
13866 primaryActions: _primaryActions,
13867 eligibleActions: _eligibleActions
13868 };
13869 }, [actions, item]);
13870 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
13871 const density = view.layout?.density ?? "balanced";
13872 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13873 mediaField.render,
13874 {
13875 item,
13876 field: mediaField,
13877 config: {
13878 sizes: density === "comfortable" ? "32px" : "24px"
13879 }
13880 }
13881 ) : null;
13882 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13883 "span",
13884 {
13885 className: "dataviews-view-activity__item-bullet",
13886 "aria-hidden": "true"
13887 }
13888 ) });
13889 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(titleField.render, { item, field: titleField }) : null;
13890 const verticalGap = (0, import_element42.useMemo)(() => {
13891 switch (density) {
13892 case "comfortable":
13893 return "md";
13894 default:
13895 return "sm";
13896 }
13897 }, [density]);
13898 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13899 "div",
13900 {
13901 ref: itemRef,
13902 role: infiniteScrollEnabled ? "article" : void 0,
13903 "aria-posinset": posinset,
13904 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
13905 className: clsx_default(
13906 "dataviews-view-activity__item",
13907 density === "compact" && "is-compact",
13908 density === "balanced" && "is-balanced",
13909 density === "comfortable" && "is-comfortable"
13910 ),
13911 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
13912 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13913 Stack,
13914 {
13915 direction: "column",
13916 gap: "xs",
13917 align: "center",
13918 className: "dataviews-view-activity__item-type",
13919 children: renderedMediaField
13920 }
13921 ),
13922 /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
13923 Stack,
13924 {
13925 direction: "column",
13926 gap: verticalGap,
13927 align: "flex-start",
13928 className: "dataviews-view-activity__item-content",
13929 children: [
13930 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13931 ItemClickWrapper,
13932 {
13933 item,
13934 isItemClickable,
13935 onClickItem,
13936 renderItemLink,
13937 className: "dataviews-view-activity__item-title",
13938 children: renderedTitleField
13939 }
13940 ),
13941 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13942 descriptionField.render,
13943 {
13944 item,
13945 field: descriptionField
13946 }
13947 ) }),
13948 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
13949 "div",
13950 {
13951 className: "dataviews-view-activity__item-field",
13952 children: [
13953 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13954 VisuallyHidden,
13955 {
13956 className: "dataviews-view-activity__item-field-label",
13957 render: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", {}),
13958 children: field.label
13959 }
13960 ),
13961 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13962 field.render,
13963 {
13964 item,
13965 field
13966 }
13967 ) })
13968 ]
13969 },
13970 field.id
13971 )) }),
13972 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13973 PrimaryActions,
13974 {
13975 item,
13976 actions: primaryActions,
13977 registry,
13978 buttonVariant: "secondary"
13979 }
13980 )
13981 ]
13982 }
13983 ),
13984 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13985 // there if there are any actions at all.
13986 isMobileViewport && // At the same time, only show the menu if there are actions to show.
13987 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13988 ItemActions,
13989 {
13990 item,
13991 actions: eligibleActions,
13992 isCompact: true
13993 }
13994 ) })
13995 ] })
13996 }
13997 );
13998 }
13999 var activity_item_default = ActivityItem;
14000
14001 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
14002 var import_react10 = __toESM(require_react(), 1);
14003 function isDefined3(item) {
14004 return !!item;
14005 }
14006 function ActivityItems(props) {
14007 const { data, fields, getItemId, view } = props;
14008 const titleField = fields.find((field) => field.id === view.titleField);
14009 const mediaField = fields.find((field) => field.id === view.mediaField);
14010 const descriptionField = fields.find(
14011 (field) => field.id === view.descriptionField
14012 );
14013 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
14014 return data.map((item, index2) => {
14015 return /* @__PURE__ */ (0, import_react10.createElement)(
14016 activity_item_default,
14017 {
14018 ...props,
14019 key: getItemId(item),
14020 item,
14021 mediaField,
14022 titleField,
14023 descriptionField,
14024 otherFields,
14025 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
14026 }
14027 );
14028 });
14029 }
14030
14031 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
14032 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
14033 function ViewActivity(props) {
14034 const { empty, data, fields, isLoading, view, className } = props;
14035 const isDelayedLoading = useDelayedLoading(!!isLoading);
14036 const hasData = !!data?.length;
14037 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
14038 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
14039 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14040 if (!hasData) {
14041 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
14042 "div",
14043 {
14044 className: clsx_default("dataviews-no-results", {
14045 "is-refreshing": isDelayedLoading
14046 }),
14047 children: empty
14048 }
14049 );
14050 }
14051 const isInert = !isInfiniteScroll && !!isLoading;
14052 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
14053 "is-refreshing": !isInfiniteScroll && isDelayedLoading
14054 });
14055 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
14056 if (hasData && groupField && dataByGroup) {
14057 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
14058 Stack,
14059 {
14060 direction: "column",
14061 gap: "sm",
14062 className: wrapperClassName,
14063 inert: isInert ? "true" : void 0,
14064 children: groupedEntries.map(
14065 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
14066 ActivityGroup,
14067 {
14068 groupName,
14069 groupData,
14070 groupField,
14071 showLabel: view.groupBy?.showLabel !== false,
14072 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
14073 ActivityItems,
14074 {
14075 ...props,
14076 data: groupData
14077 }
14078 )
14079 },
14080 groupName
14081 )
14082 )
14083 }
14084 );
14085 }
14086 return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
14087 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
14088 "div",
14089 {
14090 className: wrapperClassName,
14091 role: view.infiniteScrollEnabled ? "feed" : void 0,
14092 inert: isInert ? "true" : void 0,
14093 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(ActivityItems, { ...props })
14094 }
14095 ),
14096 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_components11.Spinner, {}) })
14097 ] });
14098 }
14099
14100 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
14101 var import_components14 = __toESM(require_components(), 1);
14102 var import_i18n18 = __toESM(require_i18n(), 1);
14103 var import_compose6 = __toESM(require_compose(), 1);
14104 var import_element45 = __toESM(require_element(), 1);
14105
14106 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
14107 var import_components13 = __toESM(require_components(), 1);
14108 var import_data5 = __toESM(require_data(), 1);
14109 var import_element44 = __toESM(require_element(), 1);
14110 var import_i18n17 = __toESM(require_i18n(), 1);
14111
14112 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
14113 var import_components12 = __toESM(require_components(), 1);
14114 var import_element43 = __toESM(require_element(), 1);
14115 var import_i18n16 = __toESM(require_i18n(), 1);
14116 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
14117 function hasPaginationControls(view, paginationInfo) {
14118 return !view.infiniteScrollEnabled && paginationInfo.totalItems > 0 && paginationInfo.totalPages > 1;
14119 }
14120 function DataViewsPagination() {
14121 const { view, onChangeView, paginationInfo } = (0, import_element43.useContext)(dataviews_context_default);
14122 if (!hasPaginationControls(view, paginationInfo)) {
14123 return null;
14124 }
14125 const { totalPages } = paginationInfo;
14126 const currentPage = view.page ?? 1;
14127 const pageSelectOptions = Array.from(Array(totalPages)).map(
14128 (_, i2) => {
14129 const page = i2 + 1;
14130 return {
14131 value: page.toString(),
14132 label: page.toString(),
14133 "aria-label": currentPage === page ? (0, import_i18n16.sprintf)(
14134 // translators: 1: current page number. 2: total number of pages.
14135 (0, import_i18n16.__)("Page %1$d of %2$d"),
14136 currentPage,
14137 totalPages
14138 ) : page.toString()
14139 };
14140 }
14141 );
14142 return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
14143 Stack,
14144 {
14145 direction: "row",
14146 className: "dataviews-pagination",
14147 justify: "end",
14148 align: "center",
14149 gap: "xl",
14150 children: [
14151 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
14152 Stack,
14153 {
14154 direction: "row",
14155 justify: "flex-start",
14156 align: "center",
14157 gap: "xs",
14158 className: "dataviews-pagination__page-select",
14159 children: (0, import_element43.createInterpolateElement)(
14160 (0, import_i18n16.sprintf)(
14161 // translators: 1: Current page number, 2: Total number of pages.
14162 (0, import_i18n16._x)("<div>Page</div>%1$s<div>of %2$d</div>", "paging"),
14163 "<CurrentPage />",
14164 totalPages
14165 ),
14166 {
14167 div: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { "aria-hidden": true }),
14168 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
14169 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
14170 import_components12.SelectControl,
14171 {
14172 "aria-label": (0, import_i18n16.__)("Current page"),
14173 value: currentPage.toString(),
14174 options: pageSelectOptions,
14175 onChange: (newValue) => {
14176 onChangeView({
14177 ...view,
14178 page: +newValue
14179 });
14180 },
14181 size: "small",
14182 variant: "minimal"
14183 }
14184 )
14185 }
14186 )
14187 }
14188 ),
14189 /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
14190 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
14191 import_components12.Button,
14192 {
14193 onClick: () => onChangeView({
14194 ...view,
14195 page: currentPage - 1
14196 }),
14197 disabled: currentPage === 1,
14198 accessibleWhenDisabled: true,
14199 label: (0, import_i18n16.__)("Previous page"),
14200 icon: (0, import_i18n16.isRTL)() ? next_default : previous_default,
14201 showTooltip: true,
14202 size: "compact",
14203 tooltipPosition: "top"
14204 }
14205 ),
14206 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
14207 import_components12.Button,
14208 {
14209 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
14210 disabled: currentPage >= totalPages,
14211 accessibleWhenDisabled: true,
14212 label: (0, import_i18n16.__)("Next page"),
14213 icon: (0, import_i18n16.isRTL)() ? previous_default : next_default,
14214 showTooltip: true,
14215 size: "compact",
14216 tooltipPosition: "top"
14217 }
14218 )
14219 ] })
14220 ]
14221 }
14222 );
14223 }
14224 var dataviews_pagination_default = (0, import_element43.memo)(DataViewsPagination);
14225
14226 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
14227 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
14228 function useIsMultiselectPicker(actions) {
14229 return (0, import_element44.useMemo)(() => {
14230 return !!actions?.length && actions?.every((action) => action.supportsBulk);
14231 }, [actions]);
14232 }
14233
14234 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
14235 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
14236 var { Badge: WCBadge2 } = unlock2(import_components14.privateApis);
14237 function GridItem3({
14238 view,
14239 multiselect,
14240 selection,
14241 onChangeSelection,
14242 getItemId,
14243 item,
14244 mediaField,
14245 titleField,
14246 descriptionField,
14247 regularFields,
14248 badgeFields,
14249 config,
14250 posinset,
14251 setsize
14252 }) {
14253 const { showTitle = true, showMedia = true, showDescription = true } = view;
14254 const id = getItemId(item);
14255 const elementRef = (0, import_element45.useRef)(null);
14256 const isSelected2 = selection.includes(id);
14257 useIntersectionObserver(elementRef, posinset);
14258 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14259 mediaField.render,
14260 {
14261 item,
14262 field: mediaField,
14263 config
14264 }
14265 ) : null;
14266 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(titleField.render, { item, field: titleField }) : null;
14267 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14268 import_components14.Composite.Item,
14269 {
14270 ref: elementRef,
14271 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n18.__)("(no title)") : void 0,
14272 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Stack, { direction: "column", children, ...props }),
14273 role: "option",
14274 "aria-posinset": posinset,
14275 "aria-setsize": setsize,
14276 className: clsx_default("dataviews-view-picker-grid__card", {
14277 "is-selected": isSelected2
14278 }),
14279 "aria-selected": isSelected2,
14280 onClick: () => {
14281 if (isSelected2) {
14282 onChangeSelection(
14283 selection.filter((itemId) => id !== itemId)
14284 );
14285 } else {
14286 const newSelection = multiselect ? [...selection, id] : [id];
14287 onChangeSelection(newSelection);
14288 }
14289 },
14290 children: [
14291 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
14292 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14293 DataViewsSelectionCheckbox,
14294 {
14295 item,
14296 selection,
14297 onChangeSelection,
14298 getItemId,
14299 titleField,
14300 disabled: false,
14301 "aria-hidden": true,
14302 tabIndex: -1
14303 }
14304 ),
14305 showTitle && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14306 Stack,
14307 {
14308 direction: "row",
14309 justify: "space-between",
14310 className: "dataviews-view-picker-grid__title-actions",
14311 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
14312 }
14313 ),
14314 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(Stack, { direction: "column", gap: "xs", children: [
14315 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14316 descriptionField.render,
14317 {
14318 item,
14319 field: descriptionField
14320 }
14321 ),
14322 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14323 Stack,
14324 {
14325 direction: "row",
14326 className: "dataviews-view-picker-grid__badge-fields",
14327 gap: "sm",
14328 wrap: "wrap",
14329 align: "top",
14330 justify: "flex-start",
14331 children: badgeFields.map((field) => {
14332 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14333 WCBadge2,
14334 {
14335 className: "dataviews-view-picker-grid__field-value",
14336 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14337 field.render,
14338 {
14339 item,
14340 field
14341 }
14342 )
14343 },
14344 field.id
14345 );
14346 })
14347 }
14348 ),
14349 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14350 Stack,
14351 {
14352 direction: "column",
14353 className: "dataviews-view-picker-grid__fields",
14354 gap: "xs",
14355 children: regularFields.map((field) => {
14356 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14357 import_components14.Flex,
14358 {
14359 className: "dataviews-view-picker-grid__field",
14360 gap: 1,
14361 justify: "flex-start",
14362 expanded: true,
14363 style: { height: "auto" },
14364 direction: "row",
14365 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
14366 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
14367 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14368 import_components14.FlexItem,
14369 {
14370 className: "dataviews-view-picker-grid__field-value",
14371 style: { maxHeight: "none" },
14372 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14373 field.render,
14374 {
14375 item,
14376 field
14377 }
14378 )
14379 }
14380 )
14381 ] })
14382 },
14383 field.id
14384 );
14385 })
14386 }
14387 )
14388 ] })
14389 ]
14390 },
14391 id
14392 );
14393 }
14394 function GridGroup({
14395 groupName,
14396 groupField,
14397 showLabel = true,
14398 children
14399 }) {
14400 const headerId = (0, import_compose6.useInstanceId)(
14401 GridGroup,
14402 "dataviews-view-picker-grid-group__header"
14403 );
14404 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14405 Stack,
14406 {
14407 direction: "column",
14408 gap: "sm",
14409 role: "group",
14410 "aria-labelledby": headerId,
14411 children: [
14412 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14413 "h3",
14414 {
14415 className: "dataviews-view-picker-grid-group__header",
14416 id: headerId,
14417 children: showLabel ? (0, import_i18n18.sprintf)(
14418 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14419 (0, import_i18n18.__)("%1$s: %2$s"),
14420 groupField.label,
14421 groupName
14422 ) : groupName
14423 }
14424 ),
14425 children
14426 ]
14427 },
14428 groupName
14429 );
14430 }
14431 function ViewPickerGrid({
14432 actions,
14433 data,
14434 fields,
14435 getItemId,
14436 isLoading,
14437 onChangeSelection,
14438 selection,
14439 view,
14440 className,
14441 empty
14442 }) {
14443 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element45.useContext)(dataviews_context_default);
14444 const titleField = fields.find(
14445 (field) => field.id === view?.titleField
14446 );
14447 const mediaField = fields.find(
14448 (field) => field.id === view?.mediaField
14449 );
14450 const descriptionField = fields.find(
14451 (field) => field.id === view?.descriptionField
14452 );
14453 const otherFields = view.fields ?? [];
14454 const { regularFields, badgeFields } = otherFields.reduce(
14455 (accumulator, fieldId) => {
14456 const field = fields.find((f2) => f2.id === fieldId);
14457 if (!field) {
14458 return accumulator;
14459 }
14460 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
14461 accumulator[key].push(field);
14462 return accumulator;
14463 },
14464 { regularFields: [], badgeFields: [] }
14465 );
14466 const hasData = !!data?.length;
14467 const usedPreviewSize = view.layout?.previewSize;
14468 const isMultiselect = useIsMultiselectPicker(actions);
14469 const size4 = "900px";
14470 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14471 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14472 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
14473 const currentPage = view?.page ?? 1;
14474 const perPage = view?.perPage ?? 0;
14475 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
14476 const gridColumns = useGridColumns();
14477 const placeholdersNeeded = usePlaceholdersNeeded(
14478 data,
14479 isInfiniteScroll,
14480 gridColumns
14481 );
14482 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, {
14483 // Render multiple groups.
14484 children: [
14485 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14486 import_components14.Composite,
14487 {
14488 virtualFocus: true,
14489 orientation: "horizontal",
14490 role: "listbox",
14491 "aria-multiselectable": isMultiselect,
14492 className: clsx_default(
14493 "dataviews-view-picker-grid",
14494 className,
14495 {
14496 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14497 view.layout.density
14498 )
14499 }
14500 ),
14501 "aria-label": itemListLabel,
14502 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14503 Stack,
14504 {
14505 direction: "column",
14506 gap: "lg",
14507 children,
14508 ...props
14509 }
14510 ),
14511 children: Array.from(dataByGroup.entries()).map(
14512 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14513 GridGroup,
14514 {
14515 groupName,
14516 groupField,
14517 showLabel: view.groupBy?.showLabel !== false,
14518 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14519 GridItems,
14520 {
14521 previewSize: usedPreviewSize,
14522 style: {
14523 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
14524 },
14525 "aria-busy": isLoading,
14526 ref: resizeObserverRef,
14527 children: groupItems.map((item) => {
14528 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
14529 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14530 GridItem3,
14531 {
14532 view,
14533 multiselect: isMultiselect,
14534 selection,
14535 onChangeSelection,
14536 getItemId,
14537 item,
14538 mediaField,
14539 titleField,
14540 descriptionField,
14541 regularFields,
14542 badgeFields,
14543 config: {
14544 sizes: size4
14545 },
14546 posinset: posInSet,
14547 setsize: setSize
14548 },
14549 getItemId(item)
14550 );
14551 })
14552 }
14553 )
14554 },
14555 groupName
14556 )
14557 )
14558 }
14559 ),
14560 // Render a single grid with all data.
14561 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14562 import_components14.Composite,
14563 {
14564 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14565 GridItems,
14566 {
14567 className: clsx_default(
14568 "dataviews-view-picker-grid",
14569 className,
14570 {
14571 [`has-${view.layout?.density}-density`]: view.layout?.density && [
14572 "compact",
14573 "comfortable"
14574 ].includes(view.layout.density)
14575 }
14576 ),
14577 previewSize: usedPreviewSize,
14578 "aria-busy": isLoading,
14579 ref: resizeObserverRef
14580 }
14581 ),
14582 virtualFocus: true,
14583 orientation: "horizontal",
14584 role: "listbox",
14585 "aria-multiselectable": isMultiselect,
14586 "aria-label": itemListLabel,
14587 children: [
14588 Array.from({ length: placeholdersNeeded }).map(
14589 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14590 import_components14.Composite.Item,
14591 {
14592 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14593 Stack,
14594 {
14595 direction: "column",
14596 children,
14597 ...props
14598 }
14599 ),
14600 role: "option",
14601 "aria-hidden": true,
14602 tabIndex: -1,
14603 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
14604 },
14605 `placeholder-${index2}`
14606 )
14607 ),
14608 data.map((item) => {
14609 const posinset = item.position;
14610 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14611 GridItem3,
14612 {
14613 view,
14614 multiselect: isMultiselect,
14615 selection,
14616 onChangeSelection,
14617 getItemId,
14618 item,
14619 mediaField,
14620 titleField,
14621 descriptionField,
14622 regularFields,
14623 badgeFields,
14624 config: {
14625 sizes: size4
14626 },
14627 posinset,
14628 setsize: setSize
14629 },
14630 getItemId(item)
14631 );
14632 })
14633 ]
14634 }
14635 ),
14636 // Render empty state.
14637 !hasData && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14638 "div",
14639 {
14640 className: clsx_default({
14641 "dataviews-loading": isLoading,
14642 "dataviews-no-results": !isLoading
14643 }),
14644 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.Spinner, {}) }) : empty
14645 }
14646 ),
14647 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.Spinner, {}) })
14648 ]
14649 });
14650 }
14651 var picker_grid_default = ViewPickerGrid;
14652
14653 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
14654 var import_i18n19 = __toESM(require_i18n(), 1);
14655 var import_components15 = __toESM(require_components(), 1);
14656 var import_element46 = __toESM(require_element(), 1);
14657 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
14658 function TableColumnField2({
14659 item,
14660 fields,
14661 column,
14662 align
14663 }) {
14664 const field = fields.find((f2) => f2.id === column);
14665 if (!field) {
14666 return null;
14667 }
14668 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
14669 "dataviews-view-table__cell-align-end": align === "end",
14670 "dataviews-view-table__cell-align-center": align === "center"
14671 });
14672 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(field.render, { item, field }) });
14673 }
14674 function TableRow2({
14675 item,
14676 fields,
14677 id,
14678 view,
14679 titleField,
14680 mediaField,
14681 descriptionField,
14682 selection,
14683 getItemId,
14684 onChangeSelection,
14685 multiselect,
14686 posinset
14687 }) {
14688 const { paginationInfo } = (0, import_element46.useContext)(dataviews_context_default);
14689 const isSelected2 = selection.includes(id);
14690 const [isHovered, setIsHovered] = (0, import_element46.useState)(false);
14691 const elementRef = (0, import_element46.useRef)(null);
14692 useIntersectionObserver(elementRef, posinset);
14693 const {
14694 showTitle = true,
14695 showMedia = true,
14696 showDescription = true,
14697 infiniteScrollEnabled
14698 } = view;
14699 const handleMouseEnter = () => {
14700 setIsHovered(true);
14701 };
14702 const handleMouseLeave = () => {
14703 setIsHovered(false);
14704 };
14705 const columns = view.fields ?? [];
14706 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14707 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14708 import_components15.Composite.Item,
14709 {
14710 ref: elementRef,
14711 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14712 "tr",
14713 {
14714 className: clsx_default("dataviews-view-table__row", {
14715 "is-selected": isSelected2,
14716 "is-hovered": isHovered
14717 }),
14718 onMouseEnter: handleMouseEnter,
14719 onMouseLeave: handleMouseLeave,
14720 children,
14721 ...props
14722 }
14723 ),
14724 "aria-selected": isSelected2,
14725 "aria-setsize": paginationInfo.totalItems || void 0,
14726 "aria-posinset": posinset,
14727 role: infiniteScrollEnabled ? "article" : "option",
14728 onMouseDown: (event) => {
14729 if (event.button !== 0) {
14730 return;
14731 }
14732 event.currentTarget.parentElement?.focus({
14733 preventScroll: true
14734 });
14735 },
14736 onClick: () => {
14737 if (isSelected2) {
14738 onChangeSelection(
14739 selection.filter((itemId) => id !== itemId)
14740 );
14741 } else {
14742 const newSelection = multiselect ? [...selection, id] : [id];
14743 onChangeSelection(newSelection);
14744 }
14745 },
14746 children: [
14747 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14748 "td",
14749 {
14750 className: "dataviews-view-table__checkbox-column",
14751 role: "presentation",
14752 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14753 DataViewsSelectionCheckbox,
14754 {
14755 item,
14756 selection,
14757 onChangeSelection,
14758 getItemId,
14759 titleField,
14760 disabled: false,
14761 "aria-hidden": true,
14762 tabIndex: -1
14763 }
14764 ) })
14765 }
14766 ),
14767 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14768 "td",
14769 {
14770 role: "presentation",
14771 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14772 column_primary_default,
14773 {
14774 item,
14775 titleField: showTitle ? titleField : void 0,
14776 mediaField: showMedia ? mediaField : void 0,
14777 descriptionField: showDescription ? descriptionField : void 0,
14778 isItemClickable: () => false
14779 }
14780 )
14781 }
14782 ),
14783 columns.map((column) => {
14784 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14785 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14786 "td",
14787 {
14788 style: {
14789 width,
14790 maxWidth,
14791 minWidth
14792 },
14793 role: "presentation",
14794 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14795 TableColumnField2,
14796 {
14797 fields,
14798 item,
14799 column,
14800 align
14801 }
14802 )
14803 },
14804 column
14805 );
14806 })
14807 ]
14808 },
14809 id
14810 );
14811 }
14812 function ViewPickerTable({
14813 actions,
14814 data,
14815 fields,
14816 getItemId,
14817 isLoading = false,
14818 onChangeView,
14819 onChangeSelection,
14820 selection,
14821 setOpenedFilter,
14822 view,
14823 className,
14824 empty
14825 }) {
14826 const headerMenuRefs = (0, import_element46.useRef)(/* @__PURE__ */ new Map());
14827 const headerMenuToFocusRef = (0, import_element46.useRef)(void 0);
14828 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element46.useState)();
14829 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
14830 (0, import_element46.useEffect)(() => {
14831 if (headerMenuToFocusRef.current) {
14832 headerMenuToFocusRef.current.focus();
14833 headerMenuToFocusRef.current = void 0;
14834 }
14835 });
14836 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14837 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14838 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14839 const tableNoticeId = (0, import_element46.useId)();
14840 if (nextHeaderMenuToFocus) {
14841 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
14842 setNextHeaderMenuToFocus(void 0);
14843 return;
14844 }
14845 const onHide = (field) => {
14846 const hidden = headerMenuRefs.current.get(field.id);
14847 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
14848 setNextHeaderMenuToFocus(fallback?.node);
14849 };
14850 const hasData = !!data?.length;
14851 const titleField = fields.find((field) => field.id === view.titleField);
14852 const mediaField = fields.find((field) => field.id === view.mediaField);
14853 const descriptionField = fields.find(
14854 (field) => field.id === view.descriptionField
14855 );
14856 const { showTitle = true, showMedia = true, showDescription = true } = view;
14857 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14858 const columns = view.fields ?? [];
14859 const headerMenuRef = (column, index2) => (node) => {
14860 if (node) {
14861 headerMenuRefs.current.set(column, {
14862 node,
14863 fallback: columns[index2 > 0 ? index2 - 1 : 1]
14864 });
14865 } else {
14866 headerMenuRefs.current.delete(column);
14867 }
14868 };
14869 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
14870 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14871 "table",
14872 {
14873 className: clsx_default(
14874 "dataviews-view-table",
14875 "dataviews-view-picker-table",
14876 className,
14877 {
14878 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14879 view.layout.density
14880 )
14881 }
14882 ),
14883 "aria-busy": isLoading,
14884 "aria-describedby": tableNoticeId,
14885 role: isInfiniteScroll ? "feed" : "listbox",
14886 children: [
14887 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14888 "tr",
14889 {
14890 className: "dataviews-view-table__row",
14891 role: "presentation",
14892 children: [
14893 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14894 BulkSelectionCheckbox,
14895 {
14896 selection,
14897 onChangeSelection,
14898 data,
14899 actions,
14900 getItemId,
14901 disableSelectAll: isInfiniteScroll
14902 }
14903 ) }),
14904 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14905 column_header_menu_default,
14906 {
14907 ref: headerMenuRef(
14908 titleField.id,
14909 0
14910 ),
14911 fieldId: titleField.id,
14912 view,
14913 fields,
14914 onChangeView,
14915 onHide,
14916 setOpenedFilter,
14917 canMove: false
14918 }
14919 ) }),
14920 columns.map((column, index2) => {
14921 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14922 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14923 "th",
14924 {
14925 style: {
14926 width,
14927 maxWidth,
14928 minWidth,
14929 textAlign: align
14930 },
14931 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14932 scope: "col",
14933 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14934 column_header_menu_default,
14935 {
14936 ref: headerMenuRef(column, index2),
14937 fieldId: column,
14938 view,
14939 fields,
14940 onChangeView,
14941 onHide,
14942 setOpenedFilter,
14943 canMove: view.layout?.enableMoving ?? true
14944 }
14945 )
14946 },
14947 column
14948 );
14949 })
14950 ]
14951 }
14952 ) }),
14953 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14954 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14955 import_components15.Composite,
14956 {
14957 virtualFocus: true,
14958 orientation: "vertical",
14959 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("tbody", { role: "group" }),
14960 children: [
14961 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14962 "tr",
14963 {
14964 className: "dataviews-view-table__group-header-row",
14965 role: "presentation",
14966 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14967 "td",
14968 {
14969 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
14970 className: "dataviews-view-table__group-header-cell",
14971 role: "presentation",
14972 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n19.sprintf)(
14973 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14974 (0, import_i18n19.__)("%1$s: %2$s"),
14975 groupField.label,
14976 groupName
14977 )
14978 }
14979 )
14980 }
14981 ),
14982 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14983 TableRow2,
14984 {
14985 item,
14986 fields,
14987 id: getItemId(item) || index2.toString(),
14988 view,
14989 titleField,
14990 mediaField,
14991 descriptionField,
14992 selection,
14993 getItemId,
14994 onChangeSelection,
14995 multiselect: isMultiselect
14996 },
14997 getItemId(item)
14998 ))
14999 ]
15000 },
15001 `group-${groupName}`
15002 )
15003 ) : /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
15004 import_components15.Composite,
15005 {
15006 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("tbody", { role: "presentation" }),
15007 virtualFocus: true,
15008 orientation: "vertical",
15009 children: hasData && data.map((item, index2) => {
15010 const itemId = getItemId(item);
15011 const posinset = item.position;
15012 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
15013 TableRow2,
15014 {
15015 item,
15016 fields,
15017 id: itemId || index2.toString(),
15018 view,
15019 titleField,
15020 mediaField,
15021 descriptionField,
15022 selection,
15023 getItemId,
15024 onChangeSelection,
15025 multiselect: isMultiselect,
15026 posinset
15027 },
15028 itemId
15029 );
15030 })
15031 }
15032 )
15033 ]
15034 }
15035 ),
15036 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
15037 "div",
15038 {
15039 className: clsx_default({
15040 "dataviews-loading": isLoading,
15041 "dataviews-no-results": !hasData && !isLoading
15042 }),
15043 id: tableNoticeId,
15044 children: [
15045 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components15.Spinner, {}) }) : empty),
15046 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components15.Spinner, {}) })
15047 ]
15048 }
15049 )
15050 ] });
15051 }
15052 var picker_table_default = ViewPickerTable;
15053
15054 // packages/dataviews/build-module/components/dataviews-layouts/picker-activity/index.mjs
15055 var import_components16 = __toESM(require_components(), 1);
15056 var import_element47 = __toESM(require_element(), 1);
15057 var import_compose7 = __toESM(require_compose(), 1);
15058 var import_i18n20 = __toESM(require_i18n(), 1);
15059 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
15060 function isDefined4(item) {
15061 return !!item;
15062 }
15063 function PickerActivityItem({
15064 view,
15065 multiselect,
15066 selection,
15067 onChangeSelection,
15068 getItemId,
15069 item,
15070 titleField,
15071 mediaField,
15072 descriptionField,
15073 otherFields,
15074 posinset,
15075 setsize
15076 }) {
15077 const elementRef = (0, import_element47.useRef)(null);
15078 useIntersectionObserver(elementRef, posinset);
15079 const { showTitle = true, showMedia = true, showDescription = true } = view;
15080 const id = getItemId(item);
15081 const isSelected2 = selection.includes(id);
15082 const density = view.layout?.density ?? "balanced";
15083 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15084 mediaField.render,
15085 {
15086 item,
15087 field: mediaField,
15088 config: {
15089 sizes: density === "comfortable" ? "32px" : "24px"
15090 }
15091 }
15092 ) : null;
15093 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15094 "span",
15095 {
15096 className: "dataviews-view-picker-activity__item-bullet",
15097 "aria-hidden": "true"
15098 }
15099 ) });
15100 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(titleField.render, { item, field: titleField }) : null;
15101 const renderedDescriptionField = showDescription && descriptionField?.render ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(descriptionField.render, { item, field: descriptionField }) : null;
15102 const verticalGap = (0, import_element47.useMemo)(() => {
15103 switch (density) {
15104 case "comfortable":
15105 return "md";
15106 default:
15107 return "sm";
15108 }
15109 }, [density]);
15110 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15111 import_components16.Composite.Item,
15112 {
15113 ref: elementRef,
15114 role: "option",
15115 "aria-label": titleField ? titleField.getValue({ item }) || void 0 : void 0,
15116 "aria-posinset": posinset,
15117 "aria-setsize": setsize,
15118 "aria-selected": isSelected2,
15119 className: clsx_default(
15120 "dataviews-view-picker-activity__item",
15121 density === "compact" && "is-compact",
15122 density === "balanced" && "is-balanced",
15123 density === "comfortable" && "is-comfortable",
15124 isSelected2 && "is-selected"
15125 ),
15126 onClick: () => {
15127 if (isSelected2) {
15128 onChangeSelection(
15129 selection.filter((itemId) => id !== itemId)
15130 );
15131 } else {
15132 const newSelection = multiselect ? [...selection, id] : [id];
15133 onChangeSelection(newSelection);
15134 }
15135 },
15136 render: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", {}),
15137 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
15138 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15139 Stack,
15140 {
15141 direction: "column",
15142 gap: "xs",
15143 align: "center",
15144 className: "dataviews-view-picker-activity__item-type",
15145 children: renderedMediaField
15146 }
15147 ),
15148 /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
15149 Stack,
15150 {
15151 direction: "column",
15152 gap: verticalGap,
15153 align: "flex-start",
15154 className: "dataviews-view-picker-activity__item-content",
15155 children: [
15156 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-title", children: renderedTitleField }),
15157 renderedDescriptionField && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-description", children: renderedDescriptionField }),
15158 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
15159 "div",
15160 {
15161 className: "dataviews-view-picker-activity__item-field",
15162 children: [
15163 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15164 VisuallyHidden,
15165 {
15166 render: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", {}),
15167 className: "dataviews-view-picker-activity__item-field-label",
15168 children: field.label
15169 }
15170 ),
15171 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { className: "dataviews-view-picker-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15172 field.render,
15173 {
15174 item,
15175 field
15176 }
15177 ) })
15178 ]
15179 },
15180 field.id
15181 )) })
15182 ]
15183 }
15184 )
15185 ] })
15186 }
15187 );
15188 }
15189 function PickerActivityGroup({
15190 groupName,
15191 groupField,
15192 showLabel = true,
15193 children
15194 }) {
15195 const headerId = (0, import_compose7.useInstanceId)(
15196 PickerActivityGroup,
15197 "dataviews-view-picker-activity-group__header"
15198 );
15199 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
15200 Stack,
15201 {
15202 direction: "column",
15203 role: "group",
15204 "aria-labelledby": headerId,
15205 className: "dataviews-view-picker-activity-group",
15206 children: [
15207 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15208 "h3",
15209 {
15210 className: "dataviews-view-picker-activity-group__header",
15211 id: headerId,
15212 children: showLabel ? (0, import_i18n20.sprintf)(
15213 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
15214 (0, import_i18n20.__)("%1$s: %2$s"),
15215 groupField.label,
15216 groupName
15217 ) : groupName
15218 }
15219 ),
15220 children
15221 ]
15222 }
15223 );
15224 }
15225 function ViewPickerActivity({
15226 data,
15227 fields,
15228 getItemId,
15229 isLoading,
15230 onChangeSelection,
15231 selection,
15232 view,
15233 actions,
15234 className,
15235 empty
15236 }) {
15237 const { itemListLabel, paginationInfo } = (0, import_element47.useContext)(dataviews_context_default);
15238 const isMultiselect = useIsMultiselectPicker(actions);
15239 const titleField = fields.find(
15240 (field) => field.id === view?.titleField
15241 );
15242 const mediaField = fields.find(
15243 (field) => field.id === view?.mediaField
15244 );
15245 const descriptionField = fields.find(
15246 (field) => field.id === view?.descriptionField
15247 );
15248 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined4);
15249 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
15250 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
15251 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
15252 const setsize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
15253 const hasData = !!data?.length;
15254 const isGrouped = !!(groupField && dataByGroup);
15255 const renderItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15256 PickerActivityItem,
15257 {
15258 view,
15259 multiselect: isMultiselect,
15260 selection,
15261 onChangeSelection,
15262 getItemId,
15263 item,
15264 titleField,
15265 mediaField,
15266 descriptionField,
15267 otherFields,
15268 posinset: item.position,
15269 setsize
15270 },
15271 getItemId(item)
15272 );
15273 if (!hasData) {
15274 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15275 "div",
15276 {
15277 className: clsx_default({
15278 "dataviews-loading": isLoading,
15279 "dataviews-no-results": !isLoading
15280 }),
15281 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components16.Spinner, {}) }) : empty
15282 }
15283 );
15284 }
15285 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(import_jsx_runtime68.Fragment, { children: [
15286 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15287 import_components16.Composite,
15288 {
15289 virtualFocus: true,
15290 orientation: "vertical",
15291 role: "listbox",
15292 "aria-multiselectable": isMultiselect,
15293 "aria-label": itemListLabel,
15294 "aria-busy": isLoading,
15295 render: isGrouped ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Stack, { direction: "column", gap: "sm" }) : void 0,
15296 className: clsx_default(
15297 "dataviews-view-picker-activity",
15298 className
15299 ),
15300 children: isGrouped && dataByGroup ? Array.from(dataByGroup.entries()).map(
15301 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15302 PickerActivityGroup,
15303 {
15304 groupName,
15305 groupField,
15306 showLabel: view.groupBy?.showLabel !== false,
15307 children: groupItems.map(renderItem)
15308 },
15309 groupName
15310 )
15311 ) : data.map(renderItem)
15312 }
15313 ),
15314 isLoading && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components16.Spinner, {}) })
15315 ] });
15316 }
15317
15318 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
15319 var import_components17 = __toESM(require_components(), 1);
15320 var import_i18n21 = __toESM(require_i18n(), 1);
15321 var import_element48 = __toESM(require_element(), 1);
15322 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
15323 function DensityPicker() {
15324 const context = (0, import_element48.useContext)(dataviews_context_default);
15325 const view = context.view;
15326 return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
15327 import_components17.__experimentalToggleGroupControl,
15328 {
15329 label: (0, import_i18n21.__)("Density"),
15330 value: view.layout?.density || "balanced",
15331 onChange: (value) => {
15332 context.onChangeView({
15333 ...view,
15334 layout: {
15335 ...view.layout,
15336 density: value
15337 }
15338 });
15339 },
15340 isBlock: true,
15341 children: [
15342 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15343 import_components17.__experimentalToggleGroupControlOption,
15344 {
15345 value: "comfortable",
15346 label: (0, import_i18n21._x)(
15347 "Comfortable",
15348 "Density option for DataView layout"
15349 )
15350 },
15351 "comfortable"
15352 ),
15353 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15354 import_components17.__experimentalToggleGroupControlOption,
15355 {
15356 value: "balanced",
15357 label: (0, import_i18n21._x)("Balanced", "Density option for DataView layout")
15358 },
15359 "balanced"
15360 ),
15361 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15362 import_components17.__experimentalToggleGroupControlOption,
15363 {
15364 value: "compact",
15365 label: (0, import_i18n21._x)("Compact", "Density option for DataView layout")
15366 },
15367 "compact"
15368 )
15369 ]
15370 }
15371 );
15372 }
15373
15374 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
15375 var import_components18 = __toESM(require_components(), 1);
15376 var import_i18n22 = __toESM(require_i18n(), 1);
15377 var import_element49 = __toESM(require_element(), 1);
15378 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
15379 var imageSizes2 = [
15380 {
15381 value: 120,
15382 breakpoint: 1
15383 },
15384 {
15385 value: 170,
15386 breakpoint: 1
15387 },
15388 {
15389 value: 230,
15390 breakpoint: 1
15391 },
15392 {
15393 value: 290,
15394 breakpoint: 1112
15395 // at minimum image width, 4 images display at this container size
15396 },
15397 {
15398 value: 350,
15399 breakpoint: 1636
15400 // at minimum image width, 6 images display at this container size
15401 },
15402 {
15403 value: 430,
15404 breakpoint: 588
15405 // at minimum image width, 2 images display at this container size
15406 }
15407 ];
15408 function PreviewSizePicker() {
15409 const context = (0, import_element49.useContext)(dataviews_context_default);
15410 const view = context.view;
15411 const breakValues = imageSizes2.filter((size4) => {
15412 return context.containerWidth >= size4.breakpoint;
15413 });
15414 const layoutPreviewSize = view.layout?.previewSize ?? 230;
15415 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
15416 const marks = breakValues.map((size4, index2) => {
15417 return {
15418 value: index2
15419 };
15420 });
15421 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
15422 import_components18.RangeControl,
15423 {
15424 showTooltip: false,
15425 label: (0, import_i18n22.__)("Preview size"),
15426 value: previewSizeToUse,
15427 min: 0,
15428 max: breakValues.length - 1,
15429 withInputField: false,
15430 onChange: (value = 0) => {
15431 context.onChangeView({
15432 ...view,
15433 layout: {
15434 ...view.layout,
15435 previewSize: breakValues[value].value
15436 }
15437 });
15438 },
15439 step: 1,
15440 marks
15441 }
15442 );
15443 }
15444
15445 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
15446 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
15447 function GridConfigOptions() {
15448 return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
15449 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(DensityPicker, {}),
15450 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(PreviewSizePicker, {})
15451 ] });
15452 }
15453
15454 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
15455 var VIEW_LAYOUTS = [
15456 {
15457 type: LAYOUT_TABLE,
15458 label: (0, import_i18n23.__)("Table"),
15459 component: table_default,
15460 icon: block_table_default,
15461 viewConfigOptions: DensityPicker
15462 },
15463 {
15464 type: LAYOUT_GRID,
15465 label: (0, import_i18n23.__)("Grid"),
15466 component: grid_default,
15467 icon: category_default,
15468 viewConfigOptions: GridConfigOptions
15469 },
15470 {
15471 type: LAYOUT_LIST,
15472 label: (0, import_i18n23.__)("List"),
15473 component: ViewList,
15474 icon: (0, import_i18n23.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
15475 viewConfigOptions: DensityPicker
15476 },
15477 {
15478 type: LAYOUT_ACTIVITY,
15479 label: (0, import_i18n23.__)("Activity"),
15480 component: ViewActivity,
15481 icon: scheduled_default,
15482 viewConfigOptions: DensityPicker
15483 },
15484 {
15485 type: LAYOUT_PICKER_GRID,
15486 label: (0, import_i18n23.__)("Grid"),
15487 component: picker_grid_default,
15488 icon: category_default,
15489 viewConfigOptions: GridConfigOptions,
15490 isPicker: true
15491 },
15492 {
15493 type: LAYOUT_PICKER_TABLE,
15494 label: (0, import_i18n23.__)("Table"),
15495 component: picker_table_default,
15496 icon: block_table_default,
15497 viewConfigOptions: DensityPicker,
15498 isPicker: true
15499 },
15500 {
15501 type: LAYOUT_PICKER_ACTIVITY,
15502 label: (0, import_i18n23.__)("Activity"),
15503 component: ViewPickerActivity,
15504 icon: scheduled_default,
15505 viewConfigOptions: DensityPicker,
15506 isPicker: true
15507 }
15508 ];
15509
15510 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
15511 var import_element57 = __toESM(require_element(), 1);
15512
15513 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
15514 var import_components21 = __toESM(require_components(), 1);
15515 var import_i18n26 = __toESM(require_i18n(), 1);
15516 var import_element54 = __toESM(require_element(), 1);
15517
15518 // node_modules/@ariakit/react-components/dist/focusable/focusable-context.js
15519 var import_react11 = __toESM(require_react(), 1);
15520 var FocusableContext = (0, import_react11.createContext)(true);
15521
15522 // node_modules/@ariakit/utils/dist/index.js
15523 function toArray(arg) {
15524 if (Array.isArray(arg)) return arg;
15525 return typeof arg !== "undefined" ? [arg] : [];
15526 }
15527 function flatten2DArray(array) {
15528 const flattened = [];
15529 for (const row of array) flattened.push(...row);
15530 return flattened;
15531 }
15532 function reverseArray(array) {
15533 return array.slice().reverse();
15534 }
15535 function noop4(..._) {
15536 }
15537 function hasOwnProperty(object, prop) {
15538 if (typeof Object.hasOwn === "function") return Object.hasOwn(object, prop);
15539 return Object.prototype.hasOwnProperty.call(object, prop);
15540 }
15541 function chain(...fns) {
15542 return (...args) => {
15543 for (const fn of fns) if (typeof fn === "function") fn(...args);
15544 };
15545 }
15546 function normalizeString(str) {
15547 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
15548 }
15549 function omit(object, keys) {
15550 const result = { ...object };
15551 for (const key of keys) if (hasOwnProperty(result, key)) delete result[key];
15552 return result;
15553 }
15554 function pick(object, paths) {
15555 const result = {};
15556 for (const key of paths) if (hasOwnProperty(object, key)) result[key] = object[key];
15557 return result;
15558 }
15559 function identity(value) {
15560 return value;
15561 }
15562 function afterPaint(cb = noop4) {
15563 let raf = requestAnimationFrame(() => {
15564 raf = requestAnimationFrame(cb);
15565 });
15566 return () => cancelAnimationFrame(raf);
15567 }
15568 function invariant(condition, message2) {
15569 if (condition) return;
15570 if (typeof message2 !== "string") throw new Error("Invariant failed");
15571 throw new Error(message2);
15572 }
15573 function getKeys(obj) {
15574 return Object.keys(obj);
15575 }
15576 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
15577 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
15578 if (result == null) return false;
15579 return !result;
15580 }
15581 function disabledFromProps(props) {
15582 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
15583 }
15584 function removeUndefinedValues(obj) {
15585 const result = {};
15586 for (const key in obj) if (obj[key] !== void 0) result[key] = obj[key];
15587 return result;
15588 }
15589 function defaultValue(...values) {
15590 for (const value of values) if (value !== void 0) return value;
15591 }
15592 var canUseDOM = checkIsBrowser();
15593 function checkIsBrowser() {
15594 return typeof window !== "undefined" && !!window.document?.createElement;
15595 }
15596 function getDocument(node) {
15597 if (!node) return document;
15598 if ("self" in node) return node.document;
15599 return node.ownerDocument || document;
15600 }
15601 function getActiveElement(node, activeDescendant = false) {
15602 const { activeElement: activeElement2 } = getDocument(node);
15603 if (!activeElement2?.nodeName) return null;
15604 if (isFrame(activeElement2) && activeElement2.contentDocument?.body) return getActiveElement(activeElement2.contentDocument.body, activeDescendant);
15605 if (activeDescendant) {
15606 const id = activeElement2.getAttribute("aria-activedescendant");
15607 if (id) {
15608 const element = getDocument(activeElement2).getElementById(id);
15609 if (element) return element;
15610 }
15611 }
15612 return activeElement2;
15613 }
15614 function contains2(parent, child) {
15615 return parent === child || parent.contains(child);
15616 }
15617 function isElement2(target) {
15618 return target?.nodeType === 1;
15619 }
15620 function isNode2(target) {
15621 return typeof target?.nodeType === "number";
15622 }
15623 function isFrame(element) {
15624 return element.tagName === "IFRAME";
15625 }
15626 function isButton(element) {
15627 const tagName = element.tagName.toLowerCase();
15628 if (tagName === "button") return true;
15629 if (tagName === "input" && element.type) return buttonInputTypes.indexOf(element.type) !== -1;
15630 return false;
15631 }
15632 var buttonInputTypes = [
15633 "button",
15634 "color",
15635 "file",
15636 "image",
15637 "reset",
15638 "submit"
15639 ];
15640 function isVisible(element) {
15641 if (typeof element.checkVisibility === "function") return element.checkVisibility();
15642 const htmlElement = element;
15643 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
15644 }
15645 function isTextField(element) {
15646 try {
15647 if (element.tagName === "TEXTAREA") return true;
15648 if (element.tagName !== "INPUT") return false;
15649 return element.selectionStart !== null;
15650 } catch (_error) {
15651 return false;
15652 }
15653 }
15654 function isTextbox(element) {
15655 return element.isContentEditable || isTextField(element);
15656 }
15657 function getTextboxValue(element) {
15658 if (isTextField(element)) return element.value;
15659 if (element.isContentEditable) {
15660 const range = getDocument(element).createRange();
15661 range.selectNodeContents(element);
15662 return range.toString();
15663 }
15664 return "";
15665 }
15666 function getTextboxSelection(element) {
15667 let start = 0;
15668 let end = 0;
15669 if (isTextField(element)) {
15670 start = element.selectionStart || 0;
15671 end = element.selectionEnd || 0;
15672 } else if (element.isContentEditable) {
15673 const selection = getDocument(element).getSelection();
15674 if (selection?.rangeCount && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
15675 const range = selection.getRangeAt(0);
15676 const nextRange = range.cloneRange();
15677 nextRange.selectNodeContents(element);
15678 nextRange.setEnd(range.startContainer, range.startOffset);
15679 start = nextRange.toString().length;
15680 nextRange.setEnd(range.endContainer, range.endOffset);
15681 end = nextRange.toString().length;
15682 }
15683 }
15684 return {
15685 start,
15686 end
15687 };
15688 }
15689 var allowedPopupRoles = [
15690 "dialog",
15691 "menu",
15692 "listbox",
15693 "tree",
15694 "grid"
15695 ];
15696 var itemRoleByPopupRole = {
15697 menu: "menuitem",
15698 listbox: "option",
15699 tree: "treeitem"
15700 };
15701 function getPopupRole(element, fallback) {
15702 const role = element?.getAttribute("role");
15703 if (role && allowedPopupRoles.indexOf(role) !== -1) return role;
15704 return fallback;
15705 }
15706 function getItemRoleByPopupRole(popupRole) {
15707 if (popupRole == null) return;
15708 if (!hasOwnProperty(itemRoleByPopupRole, popupRole)) return;
15709 return itemRoleByPopupRole[popupRole];
15710 }
15711 function getScrollingElement(element) {
15712 if (!element) return null;
15713 const isScrollableOverflow = (overflow) => {
15714 if (overflow === "auto") return true;
15715 if (overflow === "scroll") return true;
15716 return false;
15717 };
15718 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
15719 const { overflowY } = getComputedStyle(element);
15720 if (isScrollableOverflow(overflowY)) return element;
15721 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
15722 const { overflowX } = getComputedStyle(element);
15723 if (isScrollableOverflow(overflowX)) return element;
15724 }
15725 const doc = getDocument(element);
15726 return getScrollingElement(element.parentElement) || doc.scrollingElement || doc.body;
15727 }
15728 function setSelectionRange(element, ...args) {
15729 if (/text|search|password|tel|url/i.test(element.type)) element.setSelectionRange(...args);
15730 }
15731 function sortBasedOnDOMPosition(items, getElement) {
15732 const pairs = items.map((item, index2) => [index2, item]);
15733 let isOrderDifferent = false;
15734 pairs.sort(([indexA, a2], [indexB, b2]) => {
15735 const elementA = getElement(a2);
15736 const elementB = getElement(b2);
15737 if (elementA === elementB) return 0;
15738 if (!elementA || !elementB) return 0;
15739 if (isElementPreceding(elementA, elementB)) {
15740 if (indexA > indexB) isOrderDifferent = true;
15741 return -1;
15742 }
15743 if (indexA < indexB) isOrderDifferent = true;
15744 return 1;
15745 });
15746 if (isOrderDifferent) return pairs.map(([_, item]) => item);
15747 return items;
15748 }
15749 function isElementPreceding(a2, b2) {
15750 return Boolean(b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING);
15751 }
15752 function isTouchDevice() {
15753 return canUseDOM && !!navigator.maxTouchPoints;
15754 }
15755 function isApple() {
15756 if (!canUseDOM) return false;
15757 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
15758 }
15759 function isSafari() {
15760 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
15761 }
15762 function isFirefox() {
15763 return canUseDOM && /firefox\//i.test(navigator.userAgent);
15764 }
15765 function isPortalEvent(event) {
15766 const { currentTarget, target } = event;
15767 if (!currentTarget) return false;
15768 if (!isNode2(target)) return true;
15769 return !contains2(currentTarget, target);
15770 }
15771 function isSelfTarget(event) {
15772 return event.target === event.currentTarget;
15773 }
15774 function isActivatableNavigationTarget(element) {
15775 if (!isElement2(element)) return false;
15776 const target = element;
15777 const tagName = target.tagName.toLowerCase();
15778 if (tagName === "a") return true;
15779 if (tagName === "button" && target.type === "submit") return true;
15780 if (tagName === "input" && target.type === "submit") return true;
15781 return false;
15782 }
15783 function isOpeningInNewTab(event) {
15784 const isAppleDevice = isApple();
15785 if (isAppleDevice && !event.metaKey) return false;
15786 if (!isAppleDevice && !event.ctrlKey) return false;
15787 return isActivatableNavigationTarget(event.currentTarget);
15788 }
15789 function isDownloading(event) {
15790 if (!event.altKey) return false;
15791 return isActivatableNavigationTarget(event.currentTarget);
15792 }
15793 function fireBlurEvent(element, eventInit) {
15794 const event = new FocusEvent("blur", eventInit);
15795 const defaultAllowed = element.dispatchEvent(event);
15796 const bubbleInit = {
15797 ...eventInit,
15798 bubbles: true
15799 };
15800 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
15801 return defaultAllowed;
15802 }
15803 function fireKeyboardEvent(element, type, eventInit) {
15804 const event = new KeyboardEvent(type, eventInit);
15805 return element.dispatchEvent(event);
15806 }
15807 function fireClickEvent(element, eventInit) {
15808 const event = new MouseEvent("click", eventInit);
15809 return element.dispatchEvent(event);
15810 }
15811 function isFocusEventOutside(event, container) {
15812 const containerElement = container || event.currentTarget;
15813 const relatedTarget = event.relatedTarget;
15814 return !isNode2(relatedTarget) || !contains2(containerElement, relatedTarget);
15815 }
15816 function isInputEvent(event) {
15817 return event.type === "input";
15818 }
15819 function queueBeforeEvent(element, type, callback, timeout) {
15820 const createTimer = (callback2) => {
15821 if (timeout) {
15822 const timerId2 = setTimeout(callback2, timeout);
15823 return () => clearTimeout(timerId2);
15824 }
15825 const timerId = requestAnimationFrame(callback2);
15826 return () => cancelAnimationFrame(timerId);
15827 };
15828 const cancelTimer = createTimer(() => {
15829 element.removeEventListener(type, callSync, true);
15830 callback();
15831 });
15832 const callSync = () => {
15833 cancelTimer();
15834 callback();
15835 };
15836 element.addEventListener(type, callSync, {
15837 once: true,
15838 capture: true
15839 });
15840 return () => {
15841 cancelTimer();
15842 element.removeEventListener(type, callSync, true);
15843 };
15844 }
15845 function addGlobalEventListener(type, listener, options, scope = window) {
15846 const children = [];
15847 try {
15848 scope.document.addEventListener(type, listener, options);
15849 for (const frame of Array.from(scope.frames)) children.push(addGlobalEventListener(type, listener, options, frame));
15850 } catch {
15851 }
15852 const removeEventListener = () => {
15853 try {
15854 scope.document.removeEventListener(type, listener, options);
15855 } catch {
15856 }
15857 for (const remove of children) remove();
15858 };
15859 return removeEventListener;
15860 }
15861 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'])";
15862 function isFocusable(element) {
15863 if (!element.matches(selector)) return false;
15864 if (!isVisible(element)) return false;
15865 if (element.closest("[inert]")) return false;
15866 return true;
15867 }
15868 function hasFocus(element) {
15869 const activeElement2 = getActiveElement(element);
15870 if (!activeElement2) return false;
15871 if (activeElement2 === element) return true;
15872 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15873 if (!activeDescendant) return false;
15874 return activeDescendant === element.id;
15875 }
15876 function hasFocusWithin(element) {
15877 const activeElement2 = getActiveElement(element);
15878 if (!activeElement2) return false;
15879 if (contains2(element, activeElement2)) return true;
15880 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15881 if (!activeDescendant) return false;
15882 if (!("id" in element)) return false;
15883 if (activeDescendant === element.id) return true;
15884 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
15885 }
15886 function focusIntoView(element, options) {
15887 if (!("scrollIntoView" in element)) element.focus();
15888 else {
15889 element.focus({ preventScroll: true });
15890 element.scrollIntoView({
15891 block: "nearest",
15892 inline: "nearest",
15893 ...options
15894 });
15895 }
15896 }
15897 function createUndoCallback(callback) {
15898 return async () => {
15899 const redo = await callback?.();
15900 return createUndoCallback(async () => {
15901 await redo?.();
15902 return callback;
15903 });
15904 };
15905 }
15906 var UndoManager = createUndoManager();
15907 function createUndoManager({ limit = 100 } = {}) {
15908 const undoStack = [];
15909 let redoStack = [];
15910 let currentGroup = null;
15911 const canUndo = () => undoStack.length > 0;
15912 const canRedo = () => redoStack.length > 0;
15913 const undo = async () => {
15914 if (!canUndo()) return;
15915 currentGroup = null;
15916 redoStack.push(await undoStack.pop()?.());
15917 };
15918 const redo = async () => {
15919 if (!canRedo()) return;
15920 currentGroup = null;
15921 undoStack.push(await redoStack.pop()?.());
15922 };
15923 const execute = async (callback, group) => {
15924 if (!callback) return;
15925 const sameGroup = group === currentGroup;
15926 currentGroup = group ?? null;
15927 const nextIndex = sameGroup ? Math.max(0, undoStack.length - 1) : undoStack.length;
15928 const undoCallback = await callback();
15929 if (!undoCallback) return;
15930 redoStack = [];
15931 const currentUndo = undoStack[nextIndex];
15932 undoStack[nextIndex] = createUndoCallback(async () => {
15933 await undoCallback?.();
15934 const currentRedo = await currentUndo?.();
15935 return async () => {
15936 await currentRedo?.();
15937 await callback?.();
15938 };
15939 });
15940 while (undoStack.length > limit) undoStack.shift();
15941 };
15942 return {
15943 canUndo,
15944 canRedo,
15945 undo,
15946 redo,
15947 execute
15948 };
15949 }
15950
15951 // node_modules/@ariakit/react-utils/dist/index.js
15952 var React47 = __toESM(require_react(), 1);
15953 var import_react12 = __toESM(require_react(), 1);
15954 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
15955 function setRef(ref, value) {
15956 if (typeof ref === "function") {
15957 const cleanup = ref(value);
15958 if (typeof cleanup === "function") return cleanup;
15959 } else if (ref) ref.current = value;
15960 }
15961 function isValidElementWithRef(element) {
15962 if (!element) return false;
15963 if (!(0, import_react12.isValidElement)(element)) return false;
15964 if ("ref" in element.props) return true;
15965 if ("ref" in element) return true;
15966 return false;
15967 }
15968 function getRefProperty(element) {
15969 if (!isValidElementWithRef(element)) return null;
15970 return { ...element.props }.ref || element.ref;
15971 }
15972 function mergeProps2(base, overrides) {
15973 const props = { ...base };
15974 for (const key in overrides) {
15975 if (!hasOwnProperty(overrides, key)) continue;
15976 if (key === "className") {
15977 const prop = "className";
15978 const baseClass = base[prop];
15979 const overrideClass = overrides[prop];
15980 if (baseClass && overrideClass) props[prop] = `${baseClass} ${overrideClass}`;
15981 else props[prop] = overrideClass || baseClass;
15982 continue;
15983 }
15984 if (key === "style") {
15985 const prop = "style";
15986 props[prop] = base[prop] ? {
15987 ...base[prop],
15988 ...overrides[prop]
15989 } : overrides[prop];
15990 continue;
15991 }
15992 const overrideValue = overrides[key];
15993 if (key.startsWith("on")) {
15994 if (typeof overrideValue !== "function") continue;
15995 const baseValue = base[key];
15996 if (typeof baseValue === "function") {
15997 props[key] = (...args) => {
15998 overrideValue(...args);
15999 baseValue(...args);
16000 };
16001 continue;
16002 }
16003 }
16004 props[key] = overrideValue;
16005 }
16006 return props;
16007 }
16008 var _React = { ...React47 };
16009 var useReactId = _React.useId;
16010 var useReactDeferredValue = _React.useDeferredValue;
16011 var useReactInsertionEffect = _React.useInsertionEffect;
16012 var useSafeLayoutEffect = canUseDOM ? import_react12.useLayoutEffect : import_react12.useEffect;
16013 function useInitialValue(value) {
16014 const [initialValue] = (0, import_react12.useState)(value);
16015 return initialValue;
16016 }
16017 function useLiveRef(value) {
16018 const ref = (0, import_react12.useRef)(value);
16019 useSafeLayoutEffect(() => {
16020 ref.current = value;
16021 });
16022 return ref;
16023 }
16024 function useEvent(callback) {
16025 const ref = (0, import_react12.useRef)(() => {
16026 throw new Error("Cannot call an event handler while rendering.");
16027 });
16028 if (useReactInsertionEffect) useReactInsertionEffect(() => {
16029 ref.current = callback;
16030 });
16031 else ref.current = callback;
16032 return (0, import_react12.useCallback)((...args) => ref.current?.(...args), []);
16033 }
16034 function useTransactionState(callback) {
16035 const [state, setState] = (0, import_react12.useState)(null);
16036 useSafeLayoutEffect(() => {
16037 if (state == null) return;
16038 if (!callback) return;
16039 let prevState = null;
16040 callback((prev) => {
16041 prevState = prev;
16042 return state;
16043 });
16044 return () => {
16045 callback(prevState);
16046 };
16047 }, [state, callback]);
16048 return [state, setState];
16049 }
16050 function useMergeRefs(...refs) {
16051 return (0, import_react12.useMemo)(() => {
16052 if (!refs.some(Boolean)) return;
16053 return (value) => {
16054 const refEffects = [];
16055 for (const ref of refs) {
16056 if (!ref) continue;
16057 const cleanup = setRef(ref, value);
16058 refEffects.push({
16059 ref,
16060 cleanup: typeof cleanup === "function" ? cleanup : void 0
16061 });
16062 }
16063 if (!refEffects.some((effect) => effect.cleanup)) return;
16064 return () => {
16065 for (const { ref, cleanup } of refEffects) if (cleanup) cleanup();
16066 else setRef(ref, null);
16067 };
16068 };
16069 }, refs);
16070 }
16071 function useId4(defaultId) {
16072 if (useReactId) {
16073 const reactId = useReactId();
16074 if (defaultId) return defaultId;
16075 return reactId;
16076 }
16077 const [id, setId] = (0, import_react12.useState)(defaultId);
16078 useSafeLayoutEffect(() => {
16079 if (defaultId || id) return;
16080 setId(`id-${Math.random().toString(36).slice(2, 8)}`);
16081 }, [defaultId, id]);
16082 return defaultId || id;
16083 }
16084 function useTagName(refOrElement, type) {
16085 const stringOrUndefined = (type2) => {
16086 if (typeof type2 !== "string") return;
16087 return type2;
16088 };
16089 const [tagName, setTagName] = (0, import_react12.useState)(() => stringOrUndefined(type));
16090 useSafeLayoutEffect(() => {
16091 setTagName((refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement)?.tagName.toLowerCase() || stringOrUndefined(type));
16092 }, [refOrElement, type]);
16093 return tagName;
16094 }
16095 function useAttribute(refOrElement, attributeName, defaultValue2) {
16096 const initialValue = useInitialValue(defaultValue2);
16097 const [attribute, setAttribute] = (0, import_react12.useState)(initialValue);
16098 (0, import_react12.useEffect)(() => {
16099 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
16100 if (!element) return;
16101 const callback = () => {
16102 const value = element.getAttribute(attributeName);
16103 setAttribute(value == null ? initialValue : value);
16104 };
16105 const observer = new MutationObserver(callback);
16106 observer.observe(element, { attributeFilter: [attributeName] });
16107 callback();
16108 return () => observer.disconnect();
16109 }, [
16110 refOrElement,
16111 attributeName,
16112 initialValue
16113 ]);
16114 return attribute;
16115 }
16116 function useUpdateEffect(effect, deps) {
16117 const mounted = (0, import_react12.useRef)(false);
16118 (0, import_react12.useEffect)(() => {
16119 if (mounted.current) return effect();
16120 mounted.current = true;
16121 }, deps);
16122 (0, import_react12.useEffect)(() => () => {
16123 mounted.current = false;
16124 }, []);
16125 }
16126 function useUpdateLayoutEffect(effect, deps) {
16127 const mounted = (0, import_react12.useRef)(false);
16128 useSafeLayoutEffect(() => {
16129 if (mounted.current) return effect();
16130 mounted.current = true;
16131 }, deps);
16132 useSafeLayoutEffect(() => () => {
16133 mounted.current = false;
16134 }, []);
16135 }
16136 function useForceUpdate() {
16137 return (0, import_react12.useReducer)(() => [], []);
16138 }
16139 function useBooleanEvent(booleanOrCallback) {
16140 return useEvent(typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback);
16141 }
16142 function useWrapElement(props, callback, deps = []) {
16143 const wrapElement = (0, import_react12.useCallback)((element) => {
16144 if (props.wrapElement) element = props.wrapElement(element);
16145 return callback(element);
16146 }, [...deps, props.wrapElement]);
16147 return {
16148 ...props,
16149 wrapElement
16150 };
16151 }
16152 function useMetadataProps(props, key, value) {
16153 const parent = props.onLoadedMetadataCapture;
16154 const onLoadedMetadataCapture = (0, import_react12.useMemo)(() => {
16155 return Object.assign(() => {
16156 }, parent, ...value !== void 0 ? [{ [key]: value }] : []);
16157 }, [
16158 parent,
16159 key,
16160 value
16161 ]);
16162 return [parent?.[key], { onLoadedMetadataCapture }];
16163 }
16164 var hasInstalledGlobalEventListeners = false;
16165 function useIsMouseMoving() {
16166 (0, import_react12.useEffect)(() => {
16167 if (hasInstalledGlobalEventListeners) return;
16168 addGlobalEventListener("mousemove", setMouseMoving, true);
16169 addGlobalEventListener("mousedown", resetMouseMoving, true);
16170 addGlobalEventListener("mouseup", resetMouseMoving, true);
16171 addGlobalEventListener("keydown", resetMouseMoving, true);
16172 addGlobalEventListener("scroll", resetMouseMoving, true);
16173 hasInstalledGlobalEventListeners = true;
16174 }, []);
16175 return useEvent(() => mouseMoving);
16176 }
16177 var mouseMoving = false;
16178 var previousScreenX = 0;
16179 var previousScreenY = 0;
16180 function hasMouseMovement(event) {
16181 const movementX = event.movementX || event.screenX - previousScreenX;
16182 const movementY = event.movementY || event.screenY - previousScreenY;
16183 previousScreenX = event.screenX;
16184 previousScreenY = event.screenY;
16185 return movementX || movementY || false;
16186 }
16187 function setMouseMoving(event) {
16188 if (!hasMouseMovement(event)) return;
16189 mouseMoving = true;
16190 }
16191 function resetMouseMoving() {
16192 mouseMoving = false;
16193 }
16194 function forwardRef29(render4) {
16195 const Role = React47.forwardRef((props, ref) => render4({
16196 ...props,
16197 ref
16198 }));
16199 Role.displayName = render4.displayName || render4.name;
16200 return Role;
16201 }
16202 function memo3(Component, propsAreEqual) {
16203 return React47.memo(Component, propsAreEqual);
16204 }
16205 function createElement3(Type, props) {
16206 const { wrapElement, render: render4, ...rest } = props;
16207 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
16208 let element;
16209 if (React47.isValidElement(render4)) {
16210 const renderProps = {
16211 ...render4.props,
16212 ref: mergedRef
16213 };
16214 element = React47.cloneElement(render4, mergeProps2(rest, renderProps));
16215 } else if (render4) element = render4(rest);
16216 else element = /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Type, { ...rest });
16217 if (wrapElement) return wrapElement(element);
16218 return element;
16219 }
16220 function createHook(useProps) {
16221 const useRole = (props = {}) => {
16222 return useProps(props);
16223 };
16224 useRole.displayName = useProps.name;
16225 return useRole;
16226 }
16227 function createStoreContext(providers = [], scopedProviders = []) {
16228 const context = React47.createContext(void 0);
16229 const scopedContext = React47.createContext(void 0);
16230 const useContext38 = () => React47.useContext(context);
16231 const useScopedContext = (onlyScoped = false) => {
16232 const scoped = React47.useContext(scopedContext);
16233 const store = useContext38();
16234 if (onlyScoped) return scoped;
16235 return scoped || store;
16236 };
16237 const useProviderContext = () => {
16238 const scoped = React47.useContext(scopedContext);
16239 const store = useContext38();
16240 if (scoped && scoped === store) return;
16241 return store;
16242 };
16243 const ContextProvider = (props) => {
16244 return providers.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Provider2, {
16245 ...props,
16246 children
16247 }), /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(context.Provider, { ...props }));
16248 };
16249 const ScopedContextProvider = (props) => {
16250 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ContextProvider, {
16251 ...props,
16252 children: scopedProviders.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Provider2, {
16253 ...props,
16254 children
16255 }), /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(scopedContext.Provider, { ...props }))
16256 });
16257 };
16258 return {
16259 context,
16260 scopedContext,
16261 useContext: useContext38,
16262 useScopedContext,
16263 useProviderContext,
16264 ContextProvider,
16265 ScopedContextProvider
16266 };
16267 }
16268
16269 // node_modules/@ariakit/react-components/dist/focusable/focusable.js
16270 var import_react13 = __toESM(require_react(), 1);
16271 var TagName = "div";
16272 var accessibleWhenDisabledSymbol = /* @__PURE__ */ Symbol("accessibleWhenDisabled");
16273 var isSafariBrowser = isSafari();
16274 var alwaysFocusVisibleInputTypes = [
16275 "text",
16276 "search",
16277 "url",
16278 "tel",
16279 "email",
16280 "password",
16281 "number",
16282 "date",
16283 "month",
16284 "week",
16285 "time",
16286 "datetime",
16287 "datetime-local"
16288 ];
16289 function isAlwaysFocusVisible(element) {
16290 const { tagName, readOnly, type } = element;
16291 if (tagName === "TEXTAREA" && !readOnly) return true;
16292 if (tagName === "SELECT" && !readOnly) return true;
16293 if (tagName === "INPUT" && !readOnly) return alwaysFocusVisibleInputTypes.includes(type);
16294 if (element.isContentEditable) return true;
16295 if (element.getAttribute("role") === "combobox" && element.dataset.name) return true;
16296 return false;
16297 }
16298 function isNativeTabbable(tagName) {
16299 if (!tagName) return true;
16300 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
16301 }
16302 function supportsDisabledAttribute(tagName) {
16303 if (!tagName) return true;
16304 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
16305 }
16306 function isNativeSubmitControl(element) {
16307 if (element.tagName === "BUTTON") {
16308 const { type } = element;
16309 return type === "submit";
16310 }
16311 if (element.tagName === "INPUT") {
16312 const { type } = element;
16313 return type === "submit" || type === "image";
16314 }
16315 return false;
16316 }
16317 function getTabIndex2({ focusable: focusable2, trulyDisabled, nativeTabbable, supportsDisabled, safariTabIndex, tabIndexProp }) {
16318 if (!focusable2) return tabIndexProp;
16319 if (trulyDisabled) {
16320 if (nativeTabbable && !supportsDisabled) return -1;
16321 return;
16322 }
16323 if (nativeTabbable) {
16324 if (safariTabIndex && tabIndexProp == null) return 0;
16325 return tabIndexProp;
16326 }
16327 return tabIndexProp ?? 0;
16328 }
16329 function useDisableEvent(onEvent, disabled2) {
16330 return useEvent((event) => {
16331 onEvent?.(event);
16332 if (event.defaultPrevented) return;
16333 if (disabled2) {
16334 event.stopPropagation();
16335 event.preventDefault();
16336 }
16337 });
16338 }
16339 var hasInstalledGlobalEventListeners2 = false;
16340 var isKeyboardModality = true;
16341 function onGlobalMouseDown(event) {
16342 const target = event.target;
16343 if (isElement2(target) && !target.hasAttribute("data-focus-visible")) isKeyboardModality = false;
16344 }
16345 function onGlobalKeyDown(event) {
16346 if (event.metaKey) return;
16347 if (event.ctrlKey) return;
16348 if (event.altKey) return;
16349 isKeyboardModality = true;
16350 }
16351 var useFocusable = createHook(function useFocusable2({ focusable: focusable2 = true, accessibleWhenDisabled, autoFocus, onFocusVisible, ...props }) {
16352 const ref = (0, import_react13.useRef)(null);
16353 const [parentAccessibleWhenDisabled, metadataProps] = useMetadataProps(props, accessibleWhenDisabledSymbol, accessibleWhenDisabled);
16354 accessibleWhenDisabled ??= parentAccessibleWhenDisabled;
16355 (0, import_react13.useEffect)(() => {
16356 if (!focusable2) return;
16357 if (hasInstalledGlobalEventListeners2) return;
16358 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
16359 addGlobalEventListener("keydown", onGlobalKeyDown, true);
16360 hasInstalledGlobalEventListeners2 = true;
16361 }, [focusable2]);
16362 const disabled2 = focusable2 && disabledFromProps(props);
16363 const trulyDisabled = disabled2 && !accessibleWhenDisabled;
16364 const [focusVisible, setFocusVisible] = (0, import_react13.useState)(false);
16365 const focusVisibleRef = (0, import_react13.useRef)(false);
16366 const nativeSubmitObserverCleanupRef = (0, import_react13.useRef)(null);
16367 const cleanupFocusVisible = useEvent((element) => {
16368 nativeSubmitObserverCleanupRef.current?.();
16369 nativeSubmitObserverCleanupRef.current = null;
16370 focusVisibleRef.current = false;
16371 element?.removeAttribute("data-focus-visible");
16372 });
16373 (0, import_react13.useEffect)(() => {
16374 if (!focusable2) return;
16375 if (!trulyDisabled) return;
16376 cleanupFocusVisible(ref.current);
16377 if (focusVisible) setFocusVisible(false);
16378 }, [
16379 focusable2,
16380 trulyDisabled,
16381 focusVisible,
16382 cleanupFocusVisible
16383 ]);
16384 (0, import_react13.useEffect)(() => {
16385 if (!focusable2) return;
16386 if (!focusVisible) return;
16387 const element = ref.current;
16388 if (!element) return;
16389 if (typeof IntersectionObserver === "undefined") return;
16390 const observer = new IntersectionObserver(() => {
16391 if (!isFocusable(element)) {
16392 focusVisibleRef.current = false;
16393 setFocusVisible(false);
16394 }
16395 });
16396 observer.observe(element);
16397 return () => observer.disconnect();
16398 }, [focusable2, focusVisible]);
16399 (0, import_react13.useEffect)(() => {
16400 return () => nativeSubmitObserverCleanupRef.current?.();
16401 }, []);
16402 const onKeyPressCapture = useDisableEvent(props.onKeyPressCapture, disabled2);
16403 const onMouseDownCapture = useDisableEvent(props.onMouseDownCapture, disabled2);
16404 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
16405 const handleFocusVisible = (event, currentTarget) => {
16406 if (currentTarget) event.currentTarget = currentTarget;
16407 if (!focusable2) return;
16408 const element = event.currentTarget;
16409 if (!element) return;
16410 if (!hasFocus(element)) return;
16411 onFocusVisible?.(event);
16412 if (event.defaultPrevented) return;
16413 element.dataset.focusVisible = "true";
16414 focusVisibleRef.current = true;
16415 if (isNativeSubmitControl(element)) {
16416 nativeSubmitObserverCleanupRef.current?.();
16417 nativeSubmitObserverCleanupRef.current = null;
16418 if (typeof IntersectionObserver !== "undefined") {
16419 const observer = new IntersectionObserver(() => {
16420 if (isFocusable(element)) return;
16421 cleanupFocusVisible(element);
16422 });
16423 observer.observe(element);
16424 nativeSubmitObserverCleanupRef.current = () => observer.disconnect();
16425 }
16426 return;
16427 }
16428 setFocusVisible(true);
16429 };
16430 const onKeyDownCaptureProp = props.onKeyDownCapture;
16431 const onKeyDownCapture = useEvent((event) => {
16432 onKeyDownCaptureProp?.(event);
16433 if (event.defaultPrevented) return;
16434 if (!focusable2) return;
16435 if (focusVisible) return;
16436 if (focusVisibleRef.current) return;
16437 if (event.metaKey) return;
16438 if (event.altKey) return;
16439 if (event.ctrlKey) return;
16440 if (!isSelfTarget(event)) return;
16441 const element = event.currentTarget;
16442 const applyFocusVisible = () => handleFocusVisible(event, element);
16443 queueBeforeEvent(element, "focusout", applyFocusVisible);
16444 });
16445 const onFocusCaptureProp = props.onFocusCapture;
16446 const onFocusCapture = useEvent((event) => {
16447 onFocusCaptureProp?.(event);
16448 if (event.defaultPrevented) return;
16449 if (!focusable2) return;
16450 if (!isSelfTarget(event)) {
16451 setFocusVisible(false);
16452 return;
16453 }
16454 const element = event.currentTarget;
16455 const applyFocusVisible = () => handleFocusVisible(event, element);
16456 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) queueBeforeEvent(event.target, "focusout", applyFocusVisible);
16457 else setFocusVisible(false);
16458 });
16459 const onBlurProp = props.onBlur;
16460 const onBlur = useEvent((event) => {
16461 onBlurProp?.(event);
16462 if (!focusable2) return;
16463 if (!isFocusEventOutside(event)) return;
16464 cleanupFocusVisible(event.currentTarget);
16465 setFocusVisible(false);
16466 });
16467 const autoFocusOnShow = (0, import_react13.useContext)(FocusableContext);
16468 const autoFocusRef = useEvent((element) => {
16469 if (!focusable2) return;
16470 if (!autoFocus) return;
16471 if (!element) return;
16472 if (!autoFocusOnShow) return;
16473 queueMicrotask(() => {
16474 if (hasFocus(element)) return;
16475 if (!isFocusable(element)) return;
16476 element.focus();
16477 });
16478 });
16479 const tagName = useTagName(ref);
16480 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
16481 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
16482 const [safariTabIndex, setSafariTabIndex] = (0, import_react13.useState)(false);
16483 if (isSafariBrowser) (0, import_react13.useEffect)(() => {
16484 if (!focusable2) return;
16485 const element = ref.current;
16486 if (!element) return;
16487 const { type } = element;
16488 const isNativeCheckboxOrRadio = element.tagName === "INPUT" && (type === "checkbox" || type === "radio");
16489 setSafariTabIndex(isButton(element) || isNativeCheckboxOrRadio);
16490 }, [focusable2]);
16491 const styleProp = props.style;
16492 const style = (0, import_react13.useMemo)(() => {
16493 if (trulyDisabled) return {
16494 pointerEvents: "none",
16495 ...styleProp
16496 };
16497 return styleProp;
16498 }, [trulyDisabled, styleProp]);
16499 props = {
16500 "data-focus-visible": focusable2 && focusVisible || void 0,
16501 "data-autofocus": autoFocus || void 0,
16502 "aria-disabled": disabled2 || void 0,
16503 ...props,
16504 ...metadataProps,
16505 ref: useMergeRefs(ref, autoFocusRef, props.ref),
16506 style,
16507 tabIndex: getTabIndex2({
16508 focusable: focusable2,
16509 trulyDisabled,
16510 nativeTabbable,
16511 supportsDisabled,
16512 safariTabIndex,
16513 tabIndexProp: props.tabIndex
16514 }),
16515 disabled: supportsDisabled && trulyDisabled ? true : void 0,
16516 contentEditable: disabled2 ? void 0 : props.contentEditable,
16517 onKeyPressCapture,
16518 onClickCapture,
16519 onMouseDownCapture,
16520 onKeyDownCapture,
16521 onFocusCapture,
16522 onBlur
16523 };
16524 return removeUndefinedValues(props);
16525 });
16526 var Focusable = forwardRef29(function Focusable2(props) {
16527 return createElement3(TagName, useFocusable(props));
16528 });
16529
16530 // node_modules/@ariakit/react-components/dist/command/command.js
16531 var import_react14 = __toESM(require_react(), 1);
16532 var TagName2 = "button";
16533 function isNativeClick(event) {
16534 if (!event.isTrusted) return false;
16535 const element = event.currentTarget;
16536 if (event.key === "Enter") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
16537 if (event.key === " ") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
16538 return false;
16539 }
16540 var symbol = /* @__PURE__ */ Symbol("command");
16541 var useCommand = createHook(function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
16542 const ref = (0, import_react14.useRef)(null);
16543 const [isNativeButton, setIsNativeButton] = (0, import_react14.useState)(false);
16544 (0, import_react14.useEffect)(() => {
16545 if (!ref.current) return;
16546 setIsNativeButton(isButton(ref.current));
16547 }, []);
16548 const [active, setActive] = (0, import_react14.useState)(false);
16549 const activeRef = (0, import_react14.useRef)(false);
16550 const disabled2 = disabledFromProps(props);
16551 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
16552 useSafeLayoutEffect(() => {
16553 if (!disabled2) return;
16554 activeRef.current = false;
16555 setActive(false);
16556 }, [disabled2]);
16557 const onKeyDownProp = props.onKeyDown;
16558 const onKeyDown = useEvent((event) => {
16559 onKeyDownProp?.(event);
16560 const element = event.currentTarget;
16561 if (event.defaultPrevented) return;
16562 if (isDuplicate) return;
16563 if (disabled2) return;
16564 if (!isSelfTarget(event)) return;
16565 if (isTextField(element)) return;
16566 if (element.isContentEditable) return;
16567 const isEnter = clickOnEnter && event.key === "Enter";
16568 const isSpace = clickOnSpace && event.key === " ";
16569 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
16570 const shouldPreventSpace = event.key === " " && !clickOnSpace;
16571 if (shouldPreventEnter || shouldPreventSpace) {
16572 event.preventDefault();
16573 return;
16574 }
16575 if (isEnter || isSpace) {
16576 const nativeClick = isNativeClick(event);
16577 if (isEnter) {
16578 if (!nativeClick) {
16579 event.preventDefault();
16580 const { view, ...eventInit } = event;
16581 const click = () => fireClickEvent(element, eventInit);
16582 if (isFirefox()) queueBeforeEvent(element, "keyup", click);
16583 else queueMicrotask(click);
16584 }
16585 } else if (isSpace) {
16586 activeRef.current = true;
16587 if (!nativeClick) {
16588 event.preventDefault();
16589 setActive(true);
16590 }
16591 }
16592 }
16593 });
16594 const onKeyUpProp = props.onKeyUp;
16595 const onKeyUp = useEvent((event) => {
16596 onKeyUpProp?.(event);
16597 if (isDuplicate) return;
16598 const isSpace = clickOnSpace && event.key === " ";
16599 if (!activeRef.current || !isSpace) return;
16600 const nativeClick = isNativeClick(event);
16601 activeRef.current = false;
16602 if (!nativeClick) setActive(false);
16603 if (event.defaultPrevented) return;
16604 if (!isSelfTarget(event)) return;
16605 if (disabled2) return;
16606 if (event.metaKey) return;
16607 if (nativeClick) return;
16608 event.preventDefault();
16609 const element = event.currentTarget;
16610 const { view, ...eventInit } = event;
16611 queueMicrotask(() => fireClickEvent(element, eventInit));
16612 });
16613 const onBlurProp = props.onBlur;
16614 const onBlur = useEvent((event) => {
16615 onBlurProp?.(event);
16616 if (!activeRef.current) return;
16617 activeRef.current = false;
16618 setActive(false);
16619 });
16620 props = {
16621 "data-active": active || void 0,
16622 type: isNativeButton ? "button" : void 0,
16623 ...metadataProps,
16624 ...props,
16625 ref: useMergeRefs(ref, props.ref),
16626 onKeyDown,
16627 onKeyUp,
16628 onBlur
16629 };
16630 props = useFocusable(props);
16631 return props;
16632 });
16633 var Command = forwardRef29(function Command2(props) {
16634 return createElement3(TagName2, useCommand(props));
16635 });
16636
16637 // node_modules/@ariakit/react-components/dist/collection/collection-context.js
16638 var ctx = createStoreContext();
16639 var useCollectionContext = ctx.useContext;
16640 var useCollectionScopedContext = ctx.useScopedContext;
16641 var useCollectionProviderContext = ctx.useProviderContext;
16642 var CollectionContextProvider = ctx.ContextProvider;
16643 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
16644
16645 // node_modules/@ariakit/react-components/dist/collection/collection-item.js
16646 var import_react15 = __toESM(require_react(), 1);
16647 var TagName3 = "div";
16648 var useCollectionItem = createHook(function useCollectionItem2({ store, shouldRegisterItem = true, getItem = identity, element, ...props }) {
16649 const context = useCollectionContext();
16650 store = store || context;
16651 const id = useId4(props.id);
16652 const ref = (0, import_react15.useRef)(element);
16653 (0, import_react15.useEffect)(() => {
16654 const element2 = ref.current;
16655 if (!id) return;
16656 if (!element2) return;
16657 if (!shouldRegisterItem) return;
16658 const item = getItem({
16659 id,
16660 element: element2
16661 });
16662 return store?.renderItem(item);
16663 }, [
16664 id,
16665 shouldRegisterItem,
16666 getItem,
16667 store
16668 ]);
16669 props = {
16670 ...props,
16671 ref: useMergeRefs(ref, props.ref)
16672 };
16673 return removeUndefinedValues(props);
16674 });
16675 var CollectionItem = forwardRef29(function CollectionItem2(props) {
16676 return createElement3(TagName3, useCollectionItem(props));
16677 });
16678
16679 // node_modules/@ariakit/react-components/dist/composite/composite-context.js
16680 var import_react16 = __toESM(require_react(), 1);
16681 var ctx2 = createStoreContext([CollectionContextProvider], [CollectionScopedContextProvider]);
16682 var useCompositeContext = ctx2.useContext;
16683 var useCompositeScopedContext = ctx2.useScopedContext;
16684 var useCompositeProviderContext = ctx2.useProviderContext;
16685 var CompositeContextProvider = ctx2.ContextProvider;
16686 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
16687 var CompositeItemContext = (0, import_react16.createContext)(void 0);
16688 var CompositeRowContext = (0, import_react16.createContext)(void 0);
16689
16690 // node_modules/@ariakit/store/dist/index.js
16691 function getInternal(store, key) {
16692 const internals = store.__unstableInternals;
16693 invariant(internals, "Invalid store");
16694 return internals[key];
16695 }
16696 function hasUpdatedKey(keys, updatedKey) {
16697 if (!keys) return true;
16698 for (const currentKey of keys) if (updatedKey instanceof Set) {
16699 if (updatedKey.has(currentKey)) return true;
16700 } else if (currentKey === updatedKey) return true;
16701 return false;
16702 }
16703 function isSameValue(value, other) {
16704 return value === other || value !== value && other !== other;
16705 }
16706 function getCleanupPrevState(prevState, state, stateBeforeCleanup, updatedKey) {
16707 let cleanupPrevState;
16708 for (const key of getKeys(state)) {
16709 if (isSameValue(state[key], stateBeforeCleanup[key])) continue;
16710 if (updatedKey !== void 0 && hasUpdatedKey([key], updatedKey)) continue;
16711 cleanupPrevState ??= { ...prevState };
16712 cleanupPrevState[key] = state[key];
16713 }
16714 return cleanupPrevState;
16715 }
16716 var MAX_REPAIR_PASSES = 100;
16717 function addKeyedListener(map, keys, listener) {
16718 if (!keys) return;
16719 for (const key of keys) {
16720 let listeners = map.get(key);
16721 if (!listeners) {
16722 listeners = /* @__PURE__ */ new Set();
16723 map.set(key, listeners);
16724 }
16725 listeners.add(listener);
16726 }
16727 }
16728 function deleteKeyedListener(map, keys, listener) {
16729 if (!map) return;
16730 if (!keys) return;
16731 for (const key of keys) {
16732 const listeners = map.get(key);
16733 if (!listeners) continue;
16734 listeners.delete(listener);
16735 if (!listeners.size) map.delete(key);
16736 }
16737 }
16738 function getFastPathNotifiedListeners(frame) {
16739 const notifiedListeners = /* @__PURE__ */ new Set();
16740 const currentListener = frame.currentListener;
16741 if (!currentListener) return notifiedListeners;
16742 for (const listener of frame.keyedListeners) {
16743 notifiedListeners.add(listener);
16744 if (listener === currentListener) return notifiedListeners;
16745 }
16746 notifiedListeners.clear();
16747 notifiedListeners.add(currentListener);
16748 return notifiedListeners;
16749 }
16750 function preserveFastPathNotifiedListeners(frame) {
16751 frame.notifiedListeners ??= getFastPathNotifiedListeners(frame);
16752 }
16753 function hasFastPathPassedListener(frame, listener) {
16754 if (!frame.currentListener) return false;
16755 let foundCurrentKeyedListener = false;
16756 for (const currentListener of frame.keyedListeners) {
16757 if (currentListener === frame.currentListener) {
16758 foundCurrentKeyedListener = true;
16759 continue;
16760 }
16761 if (!foundCurrentKeyedListener) continue;
16762 if (currentListener === listener) return false;
16763 }
16764 let foundListener = false;
16765 for (const currentListener of frame.group.listeners) {
16766 if (currentListener === frame.currentListener) return foundListener;
16767 if (currentListener === listener) foundListener = true;
16768 }
16769 return false;
16770 }
16771 function preserveFastPathFrames(fastPathFrames, group, listener) {
16772 for (const frame of fastPathFrames) {
16773 if (frame.group !== group) continue;
16774 if (frame.recovering) continue;
16775 if (listener && !frame.keyedListeners.has(listener)) continue;
16776 preserveFastPathNotifiedListeners(frame);
16777 for (const currentListener of frame.group.listeners) {
16778 if (currentListener === frame.currentListener) break;
16779 if (!hasFastPathPassedListener(frame, currentListener)) continue;
16780 frame.notifiedListeners?.add(currentListener);
16781 }
16782 }
16783 }
16784 function preserveFastPathPassedListeners(fastPathFrames, group, listener) {
16785 for (const frame of fastPathFrames) {
16786 if (frame.group !== group) continue;
16787 if (frame.recovering) continue;
16788 if (!hasFastPathPassedListener(frame, listener)) continue;
16789 preserveFastPathNotifiedListeners(frame);
16790 frame.notifiedListeners?.add(listener);
16791 }
16792 }
16793 function preserveFastPathPassedKeyedListeners({ fastPathFrames, group, keys, listener }) {
16794 const wasRegistered = group.listeners.has(listener);
16795 for (const frame of fastPathFrames) {
16796 if (frame.group !== group) continue;
16797 if (frame.recovering) continue;
16798 if (!keys.includes(frame.updatedKey)) continue;
16799 if (hasFastPathPassedListener(frame, listener)) {
16800 preserveFastPathNotifiedListeners(frame);
16801 frame.notifiedListeners?.add(listener);
16802 } else if (wasRegistered) {
16803 preserveFastPathNotifiedListeners(frame);
16804 frame.recoverToLive = true;
16805 }
16806 }
16807 }
16808 function clearFastPathNotifiedListener(fastPathFrames, group, listener) {
16809 for (const frame of fastPathFrames) {
16810 if (frame.group !== group) continue;
16811 frame.notifiedListeners?.delete(listener);
16812 }
16813 }
16814 function addFastPathKeyedListener({ fastPathFrames, group, keys, listener }) {
16815 for (const frame of fastPathFrames) {
16816 if (frame.group !== group) continue;
16817 if (frame.recovering) continue;
16818 if (!keys.includes(frame.updatedKey)) continue;
16819 frame.keyedListeners.add(listener);
16820 }
16821 }
16822 function runPendingCleanup(group, listener) {
16823 if (!group.disposables.size) return;
16824 const cleanup = group.disposables.get(listener);
16825 if (!cleanup) return;
16826 group.disposables.delete(listener);
16827 cleanup();
16828 }
16829 function setListenerCleanup(group, listener, cleanup) {
16830 const currentCleanup = group.disposables.get(listener);
16831 if (!currentCleanup) {
16832 group.disposables.set(listener, cleanup);
16833 return;
16834 }
16835 group.disposables.set(listener, () => {
16836 currentCleanup();
16837 cleanup();
16838 });
16839 }
16840 function notifyStoreListener(group, listener, state, prevState, getState, updatedKey) {
16841 if (group.suspendCounts?.has(listener)) return;
16842 const { disposables } = group;
16843 const cleanup = disposables.size ? disposables.get(listener) : void 0;
16844 if (cleanup) {
16845 disposables.delete(listener);
16846 const stateBeforeCleanup = state;
16847 cleanup();
16848 state = getState?.() ?? state;
16849 if (state !== stateBeforeCleanup) prevState = getCleanupPrevState(prevState, state, stateBeforeCleanup, updatedKey) ?? prevState;
16850 }
16851 const result = listener(state, prevState);
16852 if (result) setListenerCleanup(group, listener, result);
16853 }
16854 function runLiveListeners({ group, getState, prevState, updatedKey, notifiedListeners }) {
16855 const allKeysListeners = group.allKeysListeners;
16856 for (const listener of group.listeners) {
16857 if (notifiedListeners?.has(listener)) continue;
16858 if (!allKeysListeners?.has(listener)) {
16859 if (!hasUpdatedKey(group.listenerKeys.get(listener), updatedKey)) continue;
16860 }
16861 notifiedListeners?.add(listener);
16862 notifyStoreListener(group, listener, getState(), prevState, getState, updatedKey);
16863 }
16864 }
16865 function createStore(initialState, ...stores) {
16866 let state = initialState;
16867 let prevStateBatch = state;
16868 let destroy = noop4;
16869 let batchPending = false;
16870 let inDispatch = false;
16871 let updatedKeys = /* @__PURE__ */ new Set();
16872 const instances = /* @__PURE__ */ new Set();
16873 const setups = /* @__PURE__ */ new Set();
16874 const syncListenerGroup = {
16875 listeners: /* @__PURE__ */ new Set(),
16876 disposables: /* @__PURE__ */ new Map(),
16877 listenerKeys: /* @__PURE__ */ new WeakMap()
16878 };
16879 const batchListenerGroup = {
16880 listeners: /* @__PURE__ */ new Set(),
16881 disposables: /* @__PURE__ */ new Map(),
16882 listenerKeys: /* @__PURE__ */ new WeakMap()
16883 };
16884 const storeSetup = (callback) => {
16885 setups.add(callback);
16886 return () => setups.delete(callback);
16887 };
16888 const storeInit = () => {
16889 const initializedInstances = instances.size;
16890 const instance = /* @__PURE__ */ Symbol();
16891 instances.add(instance);
16892 const maybeDestroy = () => {
16893 if (!instances.delete(instance)) return;
16894 if (instances.size) return;
16895 destroy();
16896 };
16897 if (initializedInstances) return maybeDestroy;
16898 const stateKeys = getKeys(state);
16899 const desyncs = [];
16900 for (const store of stores) {
16901 const storeState = store?.getState?.();
16902 if (!storeState) continue;
16903 const keys = stateKeys.filter((key) => hasOwnProperty(storeState, key));
16904 if (!keys.length) continue;
16905 if (stores.length === 1 || keys.length === stateKeys.length) {
16906 for (const key of keys) desyncs.push(sync(store, [key], (state2) => {
16907 setState(key, state2[key], true);
16908 }));
16909 continue;
16910 }
16911 desyncs.push(subscribe(store, keys, (state2, prevState) => {
16912 for (const key of keys) {
16913 if (state2[key] === prevState[key]) continue;
16914 setState(key, state2[key], true);
16915 }
16916 }));
16917 for (const key of keys) {
16918 const liveState = store?.getState?.();
16919 if (!liveState) continue;
16920 setState(key, liveState[key], true);
16921 }
16922 }
16923 const teardowns = [];
16924 for (const setup2 of setups) teardowns.push(setup2());
16925 const cleanups = stores.map(init);
16926 destroy = chain(...desyncs, ...teardowns, ...cleanups);
16927 return maybeDestroy;
16928 };
16929 const deleteListenerIndexes = (group, listener, keys) => {
16930 if (keys === void 0) return;
16931 if (keys) deleteKeyedListener(group.listenersByKey, keys, listener);
16932 else group.allKeysListeners?.delete(listener);
16933 };
16934 const fastPathFrames = [];
16935 const registerListener = (keys, listener, group = syncListenerGroup) => {
16936 const listenerKeysValue = keys ? [...keys] : null;
16937 const wasRegistered = group.listeners.has(listener);
16938 if (!wasRegistered) clearFastPathNotifiedListener(fastPathFrames, group, listener);
16939 if (!listenerKeysValue) {
16940 if (wasRegistered) preserveFastPathFrames(fastPathFrames, group);
16941 preserveFastPathPassedListeners(fastPathFrames, group, listener);
16942 } else preserveFastPathPassedKeyedListeners({
16943 fastPathFrames,
16944 group,
16945 keys: listenerKeysValue,
16946 listener
16947 });
16948 if (wasRegistered) {
16949 preserveFastPathFrames(fastPathFrames, group, listener);
16950 deleteListenerIndexes(group, listener, group.listenerKeys.get(listener));
16951 }
16952 group.listeners.add(listener);
16953 if (listenerKeysValue) {
16954 group.listenersByKey ??= /* @__PURE__ */ new Map();
16955 addKeyedListener(group.listenersByKey, listenerKeysValue, listener);
16956 addFastPathKeyedListener({
16957 fastPathFrames,
16958 group,
16959 keys: listenerKeysValue,
16960 listener
16961 });
16962 } else {
16963 group.allKeysListeners ??= /* @__PURE__ */ new Set();
16964 group.allKeysListeners.add(listener);
16965 }
16966 group.listenerKeys.set(listener, listenerKeysValue);
16967 return () => {
16968 const cleanup = group.disposables.get(listener);
16969 group.disposables.delete(listener);
16970 preserveFastPathFrames(fastPathFrames, group, listener);
16971 const currentKeys = group.listenerKeys.get(listener);
16972 deleteListenerIndexes(group, listener, listenerKeysValue);
16973 if (currentKeys !== listenerKeysValue) deleteListenerIndexes(group, listener, currentKeys);
16974 group.listenerKeys.delete(listener);
16975 group.listeners.delete(listener);
16976 cleanup?.();
16977 };
16978 };
16979 const storeSubscribe = (keys, listener) => registerListener(keys, listener);
16980 const runInitialListener = (group, listener, prevState) => {
16981 const shouldSuspend = group.listeners.has(listener);
16982 if (shouldSuspend) {
16983 group.suspendCounts ??= /* @__PURE__ */ new Map();
16984 const count = group.suspendCounts.get(listener) ?? 0;
16985 group.suspendCounts.set(listener, count + 1);
16986 }
16987 let cleanupPrevState;
16988 try {
16989 const stateBeforeCleanups = state;
16990 runPendingCleanup(group, listener);
16991 if (state !== stateBeforeCleanups) cleanupPrevState = getCleanupPrevState(prevState, state, stateBeforeCleanups);
16992 const cleanup = listener(state, cleanupPrevState ?? prevState);
16993 if (cleanup) setListenerCleanup(group, listener, cleanup);
16994 } finally {
16995 if (shouldSuspend) {
16996 const suspendCounts = group.suspendCounts;
16997 const count = suspendCounts?.get(listener);
16998 if (count && count > 1) suspendCounts?.set(listener, count - 1);
16999 else suspendCounts?.delete(listener);
17000 if (!suspendCounts?.size) delete group.suspendCounts;
17001 }
17002 }
17003 };
17004 const storeSync = (keys, listener) => {
17005 runInitialListener(syncListenerGroup, listener, state);
17006 return registerListener(keys, listener);
17007 };
17008 const storeBatch = (keys, listener) => {
17009 if (!batchListenerGroup.listeners.size && !inDispatch) prevStateBatch = state;
17010 runInitialListener(batchListenerGroup, listener, prevStateBatch);
17011 return registerListener(keys, listener, batchListenerGroup);
17012 };
17013 const storePick = (keys) => createStore(pick(state, keys), finalStore);
17014 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
17015 const getState = () => state;
17016 const runListeners = (group, prevState, updatedKey) => {
17017 if (!(updatedKey instanceof Set) && !group.allKeysListeners?.size) {
17018 const keyedListeners = group.listenersByKey?.get(updatedKey);
17019 if (!keyedListeners) return;
17020 const frame = {
17021 group,
17022 keyedListeners,
17023 updatedKey,
17024 currentListener: null
17025 };
17026 fastPathFrames.push(frame);
17027 try {
17028 for (const listener of keyedListeners) {
17029 if (frame.notifiedListeners?.has(listener)) continue;
17030 frame.currentListener = listener;
17031 frame.notifiedListeners?.add(listener);
17032 notifyStoreListener(group, listener, state, prevState, getState, updatedKey);
17033 if (!group.allKeysListeners?.size && !frame.recoverToLive) continue;
17034 const notifiedListeners = frame.notifiedListeners ?? getFastPathNotifiedListeners(frame);
17035 frame.notifiedListeners = notifiedListeners;
17036 frame.recovering = true;
17037 runLiveListeners({
17038 group,
17039 getState,
17040 prevState,
17041 updatedKey,
17042 notifiedListeners
17043 });
17044 return;
17045 }
17046 } finally {
17047 fastPathFrames.pop();
17048 }
17049 return;
17050 }
17051 runLiveListeners({
17052 group,
17053 getState,
17054 prevState,
17055 updatedKey
17056 });
17057 };
17058 const setState = (key, value, fromStores = false) => {
17059 if (!hasOwnProperty(state, key)) return;
17060 const currentValue = state[key];
17061 const nextValue = typeof value === "function" ? value(currentValue) : value;
17062 if (isSameValue(nextValue, currentValue)) return;
17063 const wasInDispatch = inDispatch;
17064 inDispatch = true;
17065 const prevState = state;
17066 const nextState = {
17067 ...state,
17068 [key]: nextValue
17069 };
17070 state = nextState;
17071 let superseded = false;
17072 try {
17073 if (!fromStores && stores.length) {
17074 for (const store of stores) {
17075 store?.setState?.(key, nextValue);
17076 if (isSameValue(state[key], nextValue)) continue;
17077 superseded = true;
17078 break;
17079 }
17080 if (superseded) {
17081 let pass = 0;
17082 for (; pass < MAX_REPAIR_PASSES; pass += 1) {
17083 let changed = false;
17084 for (const store of stores) {
17085 const previousValue = state[key];
17086 store?.setState?.(key, previousValue);
17087 if (!isSameValue(state[key], previousValue)) changed = true;
17088 }
17089 if (!changed) break;
17090 }
17091 if (pass === MAX_REPAIR_PASSES) console.warn("Parent stores did not converge after a superseded fan-out; a parent listener may be rewriting this key in a cycle.");
17092 }
17093 }
17094 if (!superseded) runListeners(syncListenerGroup, state === nextState ? prevState : {
17095 ...state,
17096 [key]: prevState[key]
17097 }, key);
17098 } finally {
17099 inDispatch = wasInDispatch;
17100 }
17101 if (!batchListenerGroup.listeners.size) {
17102 if (!inDispatch) prevStateBatch = state;
17103 return;
17104 }
17105 updatedKeys.add(key);
17106 if (batchPending) return;
17107 batchPending = true;
17108 queueMicrotask(() => {
17109 batchPending = false;
17110 const snapshot = state;
17111 const updatedKeysSnapshot = updatedKeys;
17112 updatedKeys = /* @__PURE__ */ new Set();
17113 const prevStateBatchBefore = prevStateBatch;
17114 runListeners(batchListenerGroup, prevStateBatchBefore, updatedKeysSnapshot);
17115 if (prevStateBatch === prevStateBatchBefore) prevStateBatch = snapshot;
17116 });
17117 };
17118 const finalStore = {
17119 getState,
17120 setState,
17121 __unstableInternals: {
17122 setup: storeSetup,
17123 init: storeInit,
17124 subscribe: storeSubscribe,
17125 sync: storeSync,
17126 batch: storeBatch,
17127 pick: storePick,
17128 omit: storeOmit
17129 }
17130 };
17131 return finalStore;
17132 }
17133 function setup(store, ...args) {
17134 if (!store) return;
17135 return getInternal(store, "setup")(...args);
17136 }
17137 function init(store, ...args) {
17138 if (!store) return;
17139 return getInternal(store, "init")(...args);
17140 }
17141 function subscribe(store, ...args) {
17142 if (!store) return;
17143 return getInternal(store, "subscribe")(...args);
17144 }
17145 function sync(store, ...args) {
17146 if (!store) return;
17147 return getInternal(store, "sync")(...args);
17148 }
17149 function batch(store, ...args) {
17150 if (!store) return;
17151 return getInternal(store, "batch")(...args);
17152 }
17153 function omit2(store, ...args) {
17154 if (!store) return;
17155 return getInternal(store, "omit")(...args);
17156 }
17157 function pick2(store, ...args) {
17158 if (!store) return;
17159 return getInternal(store, "pick")(...args);
17160 }
17161 function mergeStore(...stores) {
17162 const initialState = {};
17163 for (const store2 of stores) {
17164 const nextState = store2?.getState?.();
17165 if (nextState) Object.assign(initialState, nextState);
17166 }
17167 const store = createStore(initialState, ...stores);
17168 return Object.assign({}, ...stores, store);
17169 }
17170 function throwOnConflictingProps(props, store) {
17171 if (false) return;
17172 if (!store) return;
17173 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
17174 const stateKey = key.replace("default", "");
17175 return `${stateKey[0]?.toLowerCase() || ""}${stateKey.slice(1)}`;
17176 });
17177 if (!defaultKeys.length) return;
17178 const storeState = store.getState();
17179 if (!defaultKeys.filter((key) => hasOwnProperty(storeState, key)).length) return;
17180 throw new Error(`Passing a store prop in conjunction with a default state is not supported.
17181
17182 const store = useSelectStore();
17183 <SelectProvider store={store} defaultValue="Apple" />
17184 ^ ^
17185
17186 Instead, pass the default state to the topmost store:
17187
17188 const store = useSelectStore({ defaultValue: "Apple" });
17189 <SelectProvider store={store} />
17190
17191 See https://github.com/ariakit/ariakit/pull/2745 for more details.
17192
17193 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
17194 `);
17195 }
17196
17197 // node_modules/@ariakit/components/dist/collection/collection-store.js
17198 function getCommonParent(items) {
17199 const firstItem = items.find((item) => !!item.element);
17200 const lastElement = [...items].reverse().find((item) => !!item.element)?.element;
17201 let parentElement = firstItem?.element?.parentElement;
17202 if (!lastElement) return getDocument(parentElement).body;
17203 while (parentElement) {
17204 if (parentElement.contains(lastElement)) return parentElement;
17205 parentElement = parentElement.parentElement;
17206 }
17207 return getDocument(parentElement).body;
17208 }
17209 function getPrivateStore(store) {
17210 return store?.__unstablePrivateStore;
17211 }
17212 function createCollectionStore(props = {}) {
17213 throwOnConflictingProps(props, props.store);
17214 const syncState = props.store?.getState();
17215 const items = defaultValue(props.items, syncState?.items, props.defaultItems, []);
17216 const itemsMap = new Map(items.map((item) => [item.id, item]));
17217 const initialState = {
17218 items,
17219 renderedItems: defaultValue(syncState?.renderedItems, [])
17220 };
17221 const syncPrivateStore = getPrivateStore(props.store);
17222 const privateStore = createStore({
17223 items,
17224 renderedItems: initialState.renderedItems
17225 }, syncPrivateStore);
17226 const collection = createStore(initialState, props.store);
17227 const sortItems = (renderedItems) => {
17228 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
17229 privateStore.setState("renderedItems", sortedItems);
17230 collection.setState("renderedItems", sortedItems);
17231 };
17232 setup(collection, () => init(privateStore));
17233 setup(privateStore, () => {
17234 return batch(privateStore, ["items"], (state) => {
17235 collection.setState("items", state.items);
17236 });
17237 });
17238 setup(privateStore, () => {
17239 return batch(privateStore, ["renderedItems"], (state) => {
17240 let firstRun = true;
17241 let raf = requestAnimationFrame(() => {
17242 const { renderedItems } = collection.getState();
17243 if (state.renderedItems === renderedItems) return;
17244 sortItems(state.renderedItems);
17245 });
17246 if (typeof IntersectionObserver !== "function") return () => cancelAnimationFrame(raf);
17247 const ioCallback = () => {
17248 if (firstRun) {
17249 firstRun = false;
17250 return;
17251 }
17252 cancelAnimationFrame(raf);
17253 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
17254 };
17255 const root = getCommonParent(state.renderedItems);
17256 const observer = new IntersectionObserver(ioCallback, { root });
17257 for (const item of state.renderedItems) {
17258 if (!item.element) continue;
17259 observer.observe(item.element);
17260 }
17261 return () => {
17262 cancelAnimationFrame(raf);
17263 observer.disconnect();
17264 };
17265 });
17266 });
17267 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
17268 let prevItem;
17269 setItems((items2) => {
17270 const index2 = items2.findIndex(({ id }) => id === item.id);
17271 const nextItems = items2.slice();
17272 if (index2 !== -1) {
17273 prevItem = items2[index2];
17274 const nextItem = {
17275 ...prevItem,
17276 ...item
17277 };
17278 nextItems[index2] = nextItem;
17279 itemsMap.set(item.id, nextItem);
17280 } else {
17281 nextItems.push(item);
17282 itemsMap.set(item.id, item);
17283 }
17284 return nextItems;
17285 });
17286 const unmergeItem = () => {
17287 setItems((items2) => {
17288 if (!prevItem) {
17289 if (canDeleteFromMap) itemsMap.delete(item.id);
17290 return items2.filter(({ id }) => id !== item.id);
17291 }
17292 const index2 = items2.findIndex(({ id }) => id === item.id);
17293 if (index2 === -1) return items2;
17294 const nextItems = items2.slice();
17295 nextItems[index2] = prevItem;
17296 itemsMap.set(item.id, prevItem);
17297 return nextItems;
17298 });
17299 };
17300 return unmergeItem;
17301 };
17302 const registerItem = (item) => mergeItem(item, (getItems) => privateStore.setState("items", getItems), true);
17303 return {
17304 ...collection,
17305 registerItem,
17306 renderItem: (item) => chain(registerItem(item), mergeItem(item, (getItems) => privateStore.setState("renderedItems", getItems))),
17307 item: (id) => {
17308 if (!id) return null;
17309 let item = itemsMap.get(id);
17310 if (!item) {
17311 const { items: items2 } = privateStore.getState();
17312 item = items2.find((item2) => item2.id === id);
17313 if (item) itemsMap.set(id, item);
17314 }
17315 return item || null;
17316 },
17317 __unstablePrivateStore: privateStore
17318 };
17319 }
17320
17321 // node_modules/@ariakit/components/dist/composite/composite-store.js
17322 var NULL_ITEM = { id: null };
17323 function findFirstEnabledItem(items, excludeId) {
17324 return items.find((item) => {
17325 if (excludeId) return !item.disabled && item.id !== excludeId;
17326 return !item.disabled;
17327 });
17328 }
17329 function getEnabledItems(items, excludeId) {
17330 return items.filter((item) => {
17331 if (excludeId) return !item.disabled && item.id !== excludeId;
17332 return !item.disabled;
17333 });
17334 }
17335 function getItemsInRow(items, rowId) {
17336 return items.filter((item) => item.rowId === rowId);
17337 }
17338 function findEnabledItemId({ items, fromIndex, step, rowId, excludeId }) {
17339 for (let i2 = fromIndex; i2 >= 0 && i2 < items.length; i2 += step) {
17340 const item = items[i2];
17341 if (!item) continue;
17342 if (item.rowId !== rowId) continue;
17343 if (item.disabled) continue;
17344 if (excludeId != null && item.id === excludeId) continue;
17345 return item.id;
17346 }
17347 }
17348 function flipItems(items, activeId, shouldInsertNullItem = false) {
17349 const index2 = items.findIndex((item) => item.id === activeId);
17350 return [
17351 ...items.slice(index2 + 1),
17352 ...shouldInsertNullItem ? [NULL_ITEM] : [],
17353 ...items.slice(0, index2)
17354 ];
17355 }
17356 function groupItemsByRows(items) {
17357 const rows = [];
17358 for (const item of items) {
17359 const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId);
17360 if (row) row.push(item);
17361 else rows.push([item]);
17362 }
17363 return rows;
17364 }
17365 function getMaxRowLength(array) {
17366 let maxLength = 0;
17367 for (const { length } of array) if (length > maxLength) maxLength = length;
17368 return maxLength;
17369 }
17370 function createEmptyItem(rowId) {
17371 return {
17372 id: "__EMPTY_ITEM__",
17373 disabled: true,
17374 rowId
17375 };
17376 }
17377 function normalizeRows(rows, activeId, focusShift) {
17378 const maxLength = getMaxRowLength(rows);
17379 for (const row of rows) for (let i2 = 0; i2 < maxLength; i2 += 1) {
17380 const item = row[i2];
17381 if (!item || focusShift && item.disabled) {
17382 const previousItem = i2 === 0 && focusShift ? findFirstEnabledItem(row) : row[i2 - 1];
17383 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem?.rowId);
17384 }
17385 }
17386 return rows;
17387 }
17388 function verticalizeItems(items) {
17389 const rows = groupItemsByRows(items);
17390 const maxLength = getMaxRowLength(rows);
17391 const verticalized = [];
17392 for (let i2 = 0; i2 < maxLength; i2 += 1) for (const row of rows) {
17393 const item = row[i2];
17394 if (item) verticalized.push({
17395 ...item,
17396 rowId: item.rowId ? `${i2}` : void 0
17397 });
17398 }
17399 return verticalized;
17400 }
17401 function createCompositeStore(props = {}) {
17402 const syncState = props.store?.getState();
17403 const collection = createCollectionStore(props);
17404 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId);
17405 const composite = createStore({
17406 ...collection.getState(),
17407 id: defaultValue(props.id, syncState?.id) ?? `id-${Math.random().toString(36).slice(2, 8)}`,
17408 activeId,
17409 baseElement: defaultValue(syncState?.baseElement, null),
17410 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, activeId === null),
17411 moves: defaultValue(syncState?.moves, 0),
17412 orientation: defaultValue(props.orientation, syncState?.orientation, "both"),
17413 rtl: defaultValue(props.rtl, syncState?.rtl, false),
17414 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, false),
17415 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, false),
17416 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, false),
17417 focusShift: defaultValue(props.focusShift, syncState?.focusShift, false)
17418 }, collection, props.store);
17419 setup(composite, () => sync(composite, ["renderedItems", "activeId"], (state) => {
17420 composite.setState("activeId", (activeId2) => {
17421 if (activeId2 !== void 0) return activeId2;
17422 return findFirstEnabledItem(state.renderedItems)?.id;
17423 });
17424 }));
17425 const getNextId = (direction = "next", options = {}) => {
17426 const defaultState = composite.getState();
17427 const { skip = 0, activeId: activeId2 = defaultState.activeId, focusShift = defaultState.focusShift, focusLoop = defaultState.focusLoop, focusWrap = defaultState.focusWrap, includesBaseElement = defaultState.includesBaseElement, renderedItems = defaultState.renderedItems, rtl = defaultState.rtl } = options;
17428 const isVerticalDirection = direction === "up" || direction === "down";
17429 const isNextDirection = direction === "next" || direction === "down";
17430 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
17431 const canShift = focusShift && !skip;
17432 if (!skip && !focusWrap && !includesBaseElement && activeId2 != null) {
17433 if (!isVerticalDirection ? true : !canShift && !renderedItems.some((item) => item.rowId != null)) {
17434 const activeIndex2 = renderedItems.findIndex((item) => item.id === activeId2);
17435 const activeItem2 = renderedItems[activeIndex2];
17436 if (activeItem2) {
17437 const step = canReverse ? -1 : 1;
17438 const nextId = findEnabledItemId({
17439 items: renderedItems,
17440 fromIndex: activeIndex2 + step,
17441 step,
17442 rowId: activeItem2.rowId,
17443 excludeId: activeId2
17444 });
17445 if (nextId !== void 0) return nextId;
17446 if (!(focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical"))) return void 0;
17447 return findEnabledItemId({
17448 items: renderedItems,
17449 fromIndex: step === 1 ? 0 : renderedItems.length - 1,
17450 step,
17451 rowId: activeItem2.rowId,
17452 excludeId: activeId2
17453 });
17454 }
17455 }
17456 }
17457 let items = !isVerticalDirection ? renderedItems : flatten2DArray(normalizeRows(groupItemsByRows(renderedItems), activeId2, canShift));
17458 items = canReverse ? reverseArray(items) : items;
17459 items = isVerticalDirection ? verticalizeItems(items) : items;
17460 if (activeId2 == null) return findFirstEnabledItem(items)?.id;
17461 const activeItem = items.find((item) => item.id === activeId2);
17462 if (!activeItem) return findFirstEnabledItem(items)?.id;
17463 const isGrid2 = items.some((item) => item.rowId);
17464 const activeIndex = items.indexOf(activeItem);
17465 const nextItems = items.slice(activeIndex + 1);
17466 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
17467 if (skip) {
17468 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
17469 return (nextEnabledItemsInRow.slice(skip)[0] || nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1])?.id;
17470 }
17471 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
17472 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
17473 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
17474 if (canLoop) return findFirstEnabledItem(flipItems(canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId), activeId2, hasNullItem), activeId2)?.id;
17475 if (canWrap) {
17476 const nextItem2 = findFirstEnabledItem(hasNullItem ? nextItemsInRow : nextItems, activeId2);
17477 return hasNullItem ? nextItem2?.id || null : nextItem2?.id;
17478 }
17479 const nextItem = findFirstEnabledItem(nextItemsInRow, activeId2);
17480 if (!nextItem && hasNullItem) return null;
17481 return nextItem?.id;
17482 };
17483 const getNextIdFromOptions = (direction, options) => {
17484 if (typeof options === "number") return getNextId(direction, { skip: options });
17485 return getNextId(direction, options);
17486 };
17487 return {
17488 ...collection,
17489 ...composite,
17490 setBaseElement: (element) => composite.setState("baseElement", element),
17491 setActiveId: (id) => composite.setState("activeId", id),
17492 move: (id) => {
17493 if (id === void 0) return;
17494 composite.setState("activeId", id);
17495 composite.setState("moves", (moves) => moves + 1);
17496 },
17497 first: () => findFirstEnabledItem(composite.getState().renderedItems)?.id,
17498 last: () => findFirstEnabledItem(reverseArray(composite.getState().renderedItems))?.id,
17499 next: (options) => getNextIdFromOptions("next", options),
17500 previous: (options) => getNextIdFromOptions("previous", options),
17501 down: (options) => getNextIdFromOptions("down", options),
17502 up: (options) => getNextIdFromOptions("up", options)
17503 };
17504 }
17505
17506 // node_modules/@ariakit/react-components/dist/composite/utils.js
17507 var findFirstEnabledItem2 = findFirstEnabledItem;
17508 var groupItemsByRows2 = groupItemsByRows;
17509 function getEnabledItem(store, id) {
17510 if (!id) return null;
17511 return store.item(id) || null;
17512 }
17513 function selectTextField(element, collapseToEnd = false) {
17514 if (isTextField(element)) element.setSelectionRange(collapseToEnd ? element.value.length : 0, element.value.length);
17515 else if (element.isContentEditable) {
17516 const selection = getDocument(element).getSelection();
17517 selection?.selectAllChildren(element);
17518 if (collapseToEnd) selection?.collapseToEnd();
17519 }
17520 }
17521 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
17522 function focusSilently(element) {
17523 element[FOCUS_SILENTLY] = true;
17524 element.focus({ preventScroll: true });
17525 }
17526 function silentlyFocused(element) {
17527 const isSilentlyFocused = element[FOCUS_SILENTLY];
17528 delete element[FOCUS_SILENTLY];
17529 return isSilentlyFocused;
17530 }
17531 function isItem(store, element, exclude) {
17532 if (!element) return false;
17533 if (element === exclude) return false;
17534 const item = store.item(element.id);
17535 if (!item) return false;
17536 if (exclude && item.element === exclude) return false;
17537 return true;
17538 }
17539
17540 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
17541 var import_react17 = __toESM(require_react(), 1);
17542 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
17543
17544 // node_modules/@ariakit/react-store/dist/index.js
17545 var React48 = __toESM(require_react(), 1);
17546 var import_shim2 = __toESM(require_shim(), 1);
17547 var noopSubscribe = () => () => {
17548 };
17549 function useStoreState(store, keyOrSelector = identity) {
17550 const storeSubscribe = React48.useCallback((callback) => {
17551 if (!store) return noopSubscribe();
17552 return subscribe(store, null, callback);
17553 }, [store]);
17554 const getSnapshot = () => {
17555 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
17556 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
17557 const state = store?.getState();
17558 if (selector2) return selector2(state);
17559 if (!state) return;
17560 if (!key) return;
17561 if (!hasOwnProperty(state, key)) return;
17562 return state[key];
17563 };
17564 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
17565 }
17566 function useStoreStateObject(store, object) {
17567 const objRef = React48.useRef({});
17568 const storeSubscribe = React48.useCallback((callback) => {
17569 if (!store) return noopSubscribe();
17570 return subscribe(store, null, callback);
17571 }, [store]);
17572 const getSnapshot = () => {
17573 const state = store?.getState();
17574 let updated = false;
17575 const obj = objRef.current;
17576 for (const prop in object) {
17577 const keyOrSelector = object[prop];
17578 if (typeof keyOrSelector === "function") {
17579 const value = keyOrSelector(state);
17580 if (!Object.is(value, obj[prop])) {
17581 obj[prop] = value;
17582 updated = true;
17583 }
17584 }
17585 if (typeof keyOrSelector === "string") {
17586 if (!state) continue;
17587 if (!hasOwnProperty(state, keyOrSelector)) continue;
17588 const value = state[keyOrSelector];
17589 if (!Object.is(value, obj[prop])) {
17590 obj[prop] = value;
17591 updated = true;
17592 }
17593 }
17594 }
17595 if (updated) objRef.current = { ...obj };
17596 return objRef.current;
17597 };
17598 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
17599 }
17600 function useStoreProps(store, props, key, setKey) {
17601 const value = hasOwnProperty(props, key) ? props[key] : void 0;
17602 const propsRef = useLiveRef({
17603 value,
17604 setValue: setKey ? props[setKey] : void 0
17605 });
17606 useSafeLayoutEffect(() => {
17607 return sync(store, [key], (state, prev) => {
17608 const { value: value2, setValue } = propsRef.current;
17609 if (!setValue) return;
17610 if (state[key] === prev[key]) return;
17611 if (state[key] === value2) return;
17612 setValue(state[key]);
17613 });
17614 }, [store, key]);
17615 useSafeLayoutEffect(() => {
17616 if (value === void 0) return;
17617 store.setState(key, value);
17618 return batch(store, [key], () => {
17619 if (value === void 0) return;
17620 store.setState(key, value);
17621 });
17622 });
17623 }
17624 function useStore2(createStore2, props) {
17625 const [store, setStore] = React48.useState(() => createStore2(props));
17626 useSafeLayoutEffect(() => init(store), [store]);
17627 const useState37 = React48.useCallback((keyOrSelector) => useStoreState(store, keyOrSelector), [store]);
17628 return [React48.useMemo(() => ({
17629 ...store,
17630 useState: useState37
17631 }), [store, useState37]), useEvent(() => {
17632 setStore((store2) => createStore2({
17633 ...props,
17634 ...store2.getState()
17635 }));
17636 })];
17637 }
17638
17639 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
17640 var TagName4 = "button";
17641 function isEditableElement(element) {
17642 if (isTextbox(element)) return true;
17643 return element.tagName === "INPUT" && !isButton(element);
17644 }
17645 function getNextPageOffset(scrollingElement, pageUp = false) {
17646 const height = scrollingElement.clientHeight;
17647 const { top } = scrollingElement.getBoundingClientRect();
17648 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
17649 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
17650 if (scrollingElement.tagName === "HTML") return pageOffset + scrollingElement.scrollTop;
17651 return pageOffset;
17652 }
17653 function getItemOffset(itemElement, pageUp = false) {
17654 const { top } = itemElement.getBoundingClientRect();
17655 if (pageUp) return top + itemElement.clientHeight;
17656 return top;
17657 }
17658 function findNextPageItemId(element, store, next, pageUp = false) {
17659 if (!store) return;
17660 if (!next) return;
17661 const { renderedItems } = store.getState();
17662 const scrollingElement = getScrollingElement(element);
17663 if (!scrollingElement) return;
17664 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
17665 let id;
17666 let prevDifference;
17667 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
17668 const previousId = id;
17669 id = next(i2);
17670 if (!id) break;
17671 if (id === previousId) continue;
17672 const itemElement = getEnabledItem(store, id)?.element;
17673 if (!itemElement) continue;
17674 const difference = getItemOffset(itemElement, pageUp) - nextPageOffset;
17675 const absDifference = Math.abs(difference);
17676 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
17677 if (prevDifference !== void 0 && prevDifference < absDifference) id = previousId;
17678 break;
17679 }
17680 prevDifference = absDifference;
17681 }
17682 return id;
17683 }
17684 function targetIsAnotherItem(event, store) {
17685 if (isSelfTarget(event)) return false;
17686 return isItem(store, event.target);
17687 }
17688 var useCompositeItem = createHook(function useCompositeItem2({ store, rowId: rowIdProp, preventScrollOnKeyDown = false, moveOnKeyPress = true, tabbable: tabbable2 = false, getItem: getItemProp, "aria-setsize": ariaSetSizeProp, "aria-posinset": ariaPosInSetProp, ...props }) {
17689 const context = useCompositeScopedContext();
17690 store = store || context;
17691 const id = useId4(props.id);
17692 const ref = (0, import_react17.useRef)(null);
17693 const row = (0, import_react17.useContext)(CompositeRowContext);
17694 const trulyDisabled = disabledFromProps(props) && !props.accessibleWhenDisabled;
17695 const shouldRegisterItem = props.shouldRegisterItem;
17696 const getRowId = (state) => {
17697 if (rowIdProp) return rowIdProp;
17698 if (!state) return;
17699 if (!row?.baseElement) return;
17700 if (row.baseElement !== state.baseElement) return;
17701 return row.id;
17702 };
17703 const { rowId, baseElement, isActiveItem, ariaSetSize, ariaPosInSet, isTabbable } = useStoreStateObject(store, {
17704 rowId: getRowId,
17705 baseElement(state) {
17706 return state?.baseElement || void 0;
17707 },
17708 isActiveItem(state) {
17709 return !!state && state.activeId === id;
17710 },
17711 ariaSetSize(state) {
17712 if (ariaSetSizeProp != null) return ariaSetSizeProp;
17713 if (!state) return;
17714 if (!row?.ariaSetSize) return;
17715 if (row.baseElement !== state.baseElement) return;
17716 return row.ariaSetSize;
17717 },
17718 ariaPosInSet(state) {
17719 if (ariaPosInSetProp != null) return ariaPosInSetProp;
17720 if (!state) return;
17721 if (!row?.ariaPosInSet) return;
17722 if (row.baseElement !== state.baseElement) return;
17723 const rowId2 = getRowId(state);
17724 const itemsInRow = state.renderedItems.filter((item) => item.rowId === rowId2);
17725 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
17726 },
17727 isTabbable(state) {
17728 if (!state?.renderedItems.length) return true;
17729 if (state.virtualFocus) return false;
17730 if (tabbable2) return true;
17731 if (state.activeId === null) return false;
17732 const item = store?.item(state.activeId);
17733 if (item?.disabled) return true;
17734 if (!item?.element) return true;
17735 return state.activeId === id;
17736 }
17737 });
17738 const getItem = (0, import_react17.useCallback)((item) => {
17739 const nextItem = {
17740 ...item,
17741 id: id || item.id,
17742 rowId,
17743 disabled: trulyDisabled,
17744 children: item.element?.textContent
17745 };
17746 if (getItemProp) return getItemProp(nextItem);
17747 return nextItem;
17748 }, [
17749 id,
17750 rowId,
17751 trulyDisabled,
17752 getItemProp
17753 ]);
17754 const onFocusProp = props.onFocus;
17755 const hasFocusedComposite = (0, import_react17.useRef)(false);
17756 const cancelScheduledFocusRedirectRef = (0, import_react17.useRef)(null);
17757 const onFocus = useEvent((event) => {
17758 onFocusProp?.(event);
17759 if (event.defaultPrevented) return;
17760 if (isPortalEvent(event)) return;
17761 if (!id) return;
17762 if (!store) return;
17763 if (targetIsAnotherItem(event, store)) return;
17764 const { virtualFocus, baseElement: baseElement2 } = store.getState();
17765 store.setActiveId(id);
17766 if (isTextbox(event.currentTarget)) selectTextField(event.currentTarget);
17767 if (!virtualFocus) return;
17768 if (!isSelfTarget(event)) return;
17769 if (isEditableElement(event.currentTarget)) return;
17770 const redirectFocusToBaseElement = (currentTarget2, relatedTarget2, baseElement3) => {
17771 if (isSafari() && currentTarget2.hasAttribute("data-autofocus")) currentTarget2.scrollIntoView({
17772 block: "nearest",
17773 inline: "nearest"
17774 });
17775 hasFocusedComposite.current = true;
17776 if (relatedTarget2 === baseElement3 || isItem(store, relatedTarget2)) focusSilently(baseElement3);
17777 else baseElement3.focus();
17778 };
17779 if (baseElement2?.isConnected) {
17780 redirectFocusToBaseElement(event.currentTarget, event.relatedTarget, baseElement2);
17781 return;
17782 }
17783 if (shouldRegisterItem === false) return;
17784 const { currentTarget, relatedTarget } = event;
17785 const cancelScheduledFocusRedirect = () => {
17786 cancelScheduledFocusRedirectRef.current?.();
17787 cancelScheduledFocusRedirectRef.current = null;
17788 };
17789 cancelScheduledFocusRedirect();
17790 cancelScheduledFocusRedirectRef.current = subscribe(store, null, () => {
17791 if (getActiveElement(currentTarget) !== currentTarget) {
17792 cancelScheduledFocusRedirect();
17793 return;
17794 }
17795 const state = store.getState();
17796 const nextBaseElement = state.baseElement;
17797 if (!nextBaseElement?.isConnected) return;
17798 cancelScheduledFocusRedirect();
17799 if (!state.virtualFocus) return;
17800 redirectFocusToBaseElement(currentTarget, relatedTarget, nextBaseElement);
17801 });
17802 });
17803 const onBlurCaptureProp = props.onBlurCapture;
17804 const onBlurCapture = useEvent((event) => {
17805 onBlurCaptureProp?.(event);
17806 if (event.defaultPrevented) return;
17807 if (store?.getState()?.virtualFocus && hasFocusedComposite.current) {
17808 hasFocusedComposite.current = false;
17809 event.preventDefault();
17810 event.stopPropagation();
17811 }
17812 });
17813 const onKeyDownProp = props.onKeyDown;
17814 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
17815 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
17816 const onKeyDown = useEvent((event) => {
17817 onKeyDownProp?.(event);
17818 if (event.defaultPrevented) return;
17819 if (!isSelfTarget(event)) return;
17820 if (!store) return;
17821 const { currentTarget } = event;
17822 const state = store.getState();
17823 const isGrid2 = !!store.item(id)?.rowId;
17824 const isVertical = state.orientation !== "horizontal";
17825 const isHorizontal = state.orientation !== "vertical";
17826 const canHomeEnd = () => {
17827 if (isGrid2) return true;
17828 if (isHorizontal) return true;
17829 if (!state.baseElement) return true;
17830 if (!isTextField(state.baseElement)) return true;
17831 return false;
17832 };
17833 const action = {
17834 ArrowUp: (isGrid2 || isVertical) && store.up,
17835 ArrowRight: (isGrid2 || isHorizontal) && store.next,
17836 ArrowDown: (isGrid2 || isVertical) && store.down,
17837 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
17838 Home: () => {
17839 if (!canHomeEnd()) return;
17840 if (!isGrid2 || event.ctrlKey) return store?.first();
17841 return store?.previous(-1);
17842 },
17843 End: () => {
17844 if (!canHomeEnd()) return;
17845 if (!isGrid2 || event.ctrlKey) return store?.last();
17846 return store?.next(-1);
17847 },
17848 PageUp: () => {
17849 return findNextPageItemId(currentTarget, store, store?.up, true);
17850 },
17851 PageDown: () => {
17852 return findNextPageItemId(currentTarget, store, store?.down);
17853 }
17854 }[event.key];
17855 if (action) {
17856 if (isTextbox(currentTarget)) {
17857 const selection = getTextboxSelection(currentTarget);
17858 const isLeft = isHorizontal && event.key === "ArrowLeft";
17859 const isRight = isHorizontal && event.key === "ArrowRight";
17860 const isUp = isVertical && event.key === "ArrowUp";
17861 const isDown = isVertical && event.key === "ArrowDown";
17862 if (isRight || isDown) {
17863 const { length: valueLength } = getTextboxValue(currentTarget);
17864 if (selection.end !== valueLength) return;
17865 } else if ((isLeft || isUp) && selection.start !== 0) return;
17866 }
17867 const nextId = action();
17868 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
17869 if (!moveOnKeyPressProp(event)) return;
17870 event.preventDefault();
17871 store.move(nextId);
17872 }
17873 }
17874 });
17875 const providerValue = (0, import_react17.useMemo)(() => ({
17876 id,
17877 baseElement
17878 }), [id, baseElement]);
17879 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(CompositeItemContext.Provider, {
17880 value: providerValue,
17881 children: element
17882 }), [providerValue]);
17883 props = {
17884 "data-active-item": isActiveItem || void 0,
17885 ...props,
17886 id,
17887 ref: useMergeRefs(ref, props.ref),
17888 tabIndex: isTabbable ? props.tabIndex : -1,
17889 onFocus,
17890 onBlurCapture,
17891 onKeyDown
17892 };
17893 props = useCommand(props);
17894 props = useCollectionItem({
17895 store,
17896 ...props,
17897 getItem,
17898 shouldRegisterItem: id ? shouldRegisterItem : false
17899 });
17900 return removeUndefinedValues({
17901 ...props,
17902 "aria-setsize": ariaSetSize,
17903 "aria-posinset": ariaPosInSet
17904 });
17905 });
17906 var CompositeItem = memo3(forwardRef29(function CompositeItem2(props) {
17907 return createElement3(TagName4, useCompositeItem(props));
17908 }));
17909
17910 // node_modules/@ariakit/react-components/dist/composite/composite.js
17911 var import_react18 = __toESM(require_react(), 1);
17912 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
17913 var TagName5 = "div";
17914 function isGrid(items) {
17915 return items.some((item) => !!item.rowId);
17916 }
17917 function isPrintableKey(event) {
17918 const target = event.target;
17919 if (target && !isTextField(target)) return false;
17920 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
17921 }
17922 function isModifierKey(event) {
17923 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
17924 }
17925 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
17926 return useEvent((event) => {
17927 onKeyboardEvent?.(event);
17928 if (event.defaultPrevented) return;
17929 if (event.isPropagationStopped()) return;
17930 if (!isSelfTarget(event)) return;
17931 if (isModifierKey(event)) return;
17932 if (isPrintableKey(event)) return;
17933 const activeElement2 = getEnabledItem(store, store.getState().activeId)?.element;
17934 if (!activeElement2) return;
17935 const { view, ...eventInit } = event;
17936 if (activeElement2 !== previousElementRef?.current) activeElement2.focus();
17937 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) event.preventDefault();
17938 if (event.currentTarget.contains(activeElement2)) event.stopPropagation();
17939 });
17940 }
17941 function findFirstEnabledItemInTheLastRow(items) {
17942 return findFirstEnabledItem2(flatten2DArray(reverseArray(groupItemsByRows2(items))));
17943 }
17944 function withBaseScrollPreserved(store, callback) {
17945 const { virtualFocus, baseElement } = store.getState();
17946 if (!virtualFocus || !baseElement || !isTextField(baseElement)) {
17947 callback();
17948 return;
17949 }
17950 const savedScrollLeft = baseElement.scrollLeft;
17951 const savedScrollTop = baseElement.scrollTop;
17952 callback();
17953 baseElement.scrollLeft = savedScrollLeft;
17954 baseElement.scrollTop = savedScrollTop;
17955 }
17956 function useScheduleFocus(store) {
17957 const [scheduled, setScheduled] = (0, import_react18.useState)(false);
17958 const schedule = (0, import_react18.useCallback)(() => setScheduled(true), []);
17959 const activeItem = useStoreState(store, (state) => scheduled ? getEnabledItem(store, state.activeId) : null);
17960 (0, import_react18.useEffect)(() => {
17961 const activeElement2 = activeItem?.element;
17962 if (!scheduled) return;
17963 if (!activeElement2) return;
17964 setScheduled(false);
17965 withBaseScrollPreserved(store, () => {
17966 activeElement2.focus({ preventScroll: true });
17967 });
17968 }, [
17969 store,
17970 activeItem,
17971 scheduled
17972 ]);
17973 return schedule;
17974 }
17975 var CompositeFocusOnMove = memo3(function CompositeFocusOnMove2({ store, focusOnMove, previousElementRef }) {
17976 const moves = useStoreState(store, "moves");
17977 const baseElement = useStoreState(store, "baseElement");
17978 (0, import_react18.useEffect)(() => {
17979 if (!moves) return;
17980 if (!focusOnMove) return;
17981 const { activeId } = store.getState();
17982 const itemElement = getEnabledItem(store, activeId)?.element;
17983 if (!itemElement) return;
17984 withBaseScrollPreserved(store, () => focusIntoView(itemElement));
17985 }, [
17986 store,
17987 moves,
17988 focusOnMove
17989 ]);
17990 useSafeLayoutEffect(() => {
17991 if (!moves) return;
17992 if (!baseElement) return;
17993 const { activeId } = store.getState();
17994 if (!(activeId === null)) return;
17995 const previousElement = previousElementRef.current;
17996 previousElementRef.current = null;
17997 if (previousElement) fireBlurEvent(previousElement, { relatedTarget: baseElement });
17998 if (!hasFocus(baseElement)) baseElement.focus();
17999 }, [
18000 store,
18001 moves,
18002 baseElement
18003 ]);
18004 return null;
18005 });
18006 var useComposite = createHook(function useComposite2({ store, composite = true, focusOnMove = composite, moveOnKeyPress = true, ...props }) {
18007 const context = useCompositeProviderContext();
18008 store = store || context;
18009 invariant(store, "Composite must receive a `store` prop or be wrapped in a CompositeProvider component.");
18010 const ref = (0, import_react18.useRef)(null);
18011 const previousElementRef = (0, import_react18.useRef)(null);
18012 const scheduleFocus = useScheduleFocus(store);
18013 const [, setBaseElement] = useTransactionState(composite ? store.setBaseElement : null);
18014 const virtualFocus = useStoreState(store, "virtualFocus");
18015 const activeId = useStoreState(store, (state) => state.virtualFocus ? state.activeId : null);
18016 useSafeLayoutEffect(() => {
18017 if (!store) return;
18018 if (!composite) return;
18019 if (!virtualFocus) return;
18020 const previousElement = previousElementRef.current;
18021 previousElementRef.current = null;
18022 if (!previousElement) return;
18023 const relatedTarget = getEnabledItem(store, activeId)?.element || getActiveElement(previousElement);
18024 if (relatedTarget === previousElement) return;
18025 fireBlurEvent(previousElement, { relatedTarget });
18026 }, [
18027 store,
18028 activeId,
18029 virtualFocus,
18030 composite
18031 ]);
18032 const onKeyDownCapture = useKeyboardEventProxy(store, props.onKeyDownCapture, previousElementRef);
18033 const onKeyUpCapture = useKeyboardEventProxy(store, props.onKeyUpCapture, previousElementRef);
18034 const onFocusCaptureProp = props.onFocusCapture;
18035 const onFocusCapture = useEvent((event) => {
18036 onFocusCaptureProp?.(event);
18037 if (event.defaultPrevented) return;
18038 if (!store) return;
18039 const { virtualFocus: virtualFocus2 } = store.getState();
18040 if (!virtualFocus2) return;
18041 const previousActiveElement = event.relatedTarget;
18042 const isSilentlyFocused = silentlyFocused(event.currentTarget);
18043 if (isSelfTarget(event) && isSilentlyFocused) {
18044 event.stopPropagation();
18045 previousElementRef.current = previousActiveElement;
18046 }
18047 });
18048 const onFocusProp = props.onFocus;
18049 const onFocus = useEvent((event) => {
18050 onFocusProp?.(event);
18051 if (event.defaultPrevented) return;
18052 if (!composite) return;
18053 if (!store) return;
18054 const { relatedTarget } = event;
18055 const { virtualFocus: virtualFocus2 } = store.getState();
18056 if (virtualFocus2) {
18057 if (isSelfTarget(event) && !isItem(store, relatedTarget)) queueMicrotask(scheduleFocus);
18058 } else if (isSelfTarget(event)) store.setActiveId(null);
18059 });
18060 const onBlurCaptureProp = props.onBlurCapture;
18061 const onBlurCapture = useEvent((event) => {
18062 onBlurCaptureProp?.(event);
18063 if (event.defaultPrevented) return;
18064 if (!store) return;
18065 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
18066 if (!virtualFocus2) return;
18067 const activeElement2 = getEnabledItem(store, activeId2)?.element;
18068 const nextActiveElement = event.relatedTarget;
18069 const nextActiveElementIsItem = isItem(store, nextActiveElement);
18070 const previousElement = previousElementRef.current;
18071 previousElementRef.current = null;
18072 if (isSelfTarget(event) && nextActiveElementIsItem) {
18073 if (nextActiveElement === activeElement2) {
18074 if (previousElement && previousElement !== nextActiveElement) fireBlurEvent(previousElement, event);
18075 } else if (activeElement2) fireBlurEvent(activeElement2, event);
18076 else if (previousElement) fireBlurEvent(previousElement, event);
18077 event.stopPropagation();
18078 } else if (!isItem(store, event.target) && activeElement2) fireBlurEvent(activeElement2, event);
18079 });
18080 const onKeyDownProp = props.onKeyDown;
18081 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
18082 const onKeyDown = useEvent((event) => {
18083 onKeyDownProp?.(event);
18084 if (event.nativeEvent.isComposing) return;
18085 if (event.defaultPrevented) return;
18086 if (!store) return;
18087 if (!isSelfTarget(event)) return;
18088 const { orientation, renderedItems, activeId: activeId2, rtl } = store.getState();
18089 if (getEnabledItem(store, activeId2)?.element?.isConnected) return;
18090 const isVertical = orientation !== "horizontal";
18091 const isHorizontal = orientation !== "vertical";
18092 const grid = isGrid(renderedItems);
18093 if ((event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End") && isTextField(event.currentTarget)) return;
18094 const up = () => {
18095 if (grid) return findFirstEnabledItemInTheLastRow(renderedItems)?.id;
18096 return store?.last();
18097 };
18098 const action = {
18099 ArrowUp: (grid || isVertical) && up,
18100 ArrowRight: (grid || isHorizontal) && (rtl ? store.last : store.first),
18101 ArrowDown: (grid || isVertical) && store.first,
18102 ArrowLeft: (grid || isHorizontal) && (rtl ? store.first : store.last),
18103 Home: store.first,
18104 End: store.last,
18105 PageUp: store.first,
18106 PageDown: store.last
18107 }[event.key];
18108 if (action) {
18109 const id = action();
18110 if (id !== void 0) {
18111 if (!moveOnKeyPressProp(event)) return;
18112 event.preventDefault();
18113 store.move(id);
18114 }
18115 }
18116 });
18117 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(CompositeScopedContextProvider, {
18118 value: store,
18119 children: [element, composite && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(CompositeFocusOnMove, {
18120 store,
18121 focusOnMove,
18122 previousElementRef
18123 })]
18124 }), [
18125 store,
18126 composite,
18127 focusOnMove
18128 ]);
18129 props = {
18130 "aria-activedescendant": useStoreState(store, (state) => {
18131 if (!store) return;
18132 if (!composite) return;
18133 if (!state.virtualFocus) return;
18134 return getEnabledItem(store, state.activeId)?.id;
18135 }),
18136 ...props,
18137 ref: useMergeRefs(ref, setBaseElement, props.ref),
18138 onKeyDownCapture,
18139 onKeyUpCapture,
18140 onFocusCapture,
18141 onFocus,
18142 onBlurCapture,
18143 onKeyDown
18144 };
18145 props = useFocusable({
18146 focusable: useStoreState(store, (state) => composite && (state.virtualFocus || state.activeId === null)),
18147 ...props
18148 });
18149 return props;
18150 });
18151 var Composite6 = forwardRef29(function Composite7(props) {
18152 return createElement3(TagName5, useComposite(props));
18153 });
18154
18155 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-context.js
18156 var ctx3 = createStoreContext();
18157 var useDisclosureContext = ctx3.useContext;
18158 var useDisclosureScopedContext = ctx3.useScopedContext;
18159 var useDisclosureProviderContext = ctx3.useProviderContext;
18160 var DisclosureContextProvider = ctx3.ContextProvider;
18161 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
18162
18163 // node_modules/@ariakit/react-components/dist/dialog/dialog-context.js
18164 var import_react19 = __toESM(require_react(), 1);
18165 var ctx4 = createStoreContext([DisclosureContextProvider], [DisclosureScopedContextProvider]);
18166 var useDialogContext = ctx4.useContext;
18167 var useDialogScopedContext = ctx4.useScopedContext;
18168 var useDialogProviderContext = ctx4.useProviderContext;
18169 var DialogContextProvider = ctx4.ContextProvider;
18170 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
18171 var DialogHeadingContext = (0, import_react19.createContext)(void 0);
18172 var DialogDescriptionContext = (0, import_react19.createContext)(void 0);
18173
18174 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-content.js
18175 var import_react20 = __toESM(require_react(), 1);
18176 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
18177 var import_react_dom4 = __toESM(require_react_dom(), 1);
18178 var TagName6 = "div";
18179 function afterTimeout(timeoutMs, cb) {
18180 const timeoutId = setTimeout(cb, timeoutMs);
18181 return () => clearTimeout(timeoutId);
18182 }
18183 function parseCSSTime(time) {
18184 const value = time?.trim() || "0s";
18185 const multiplier = value.endsWith("ms") ? 1 : 1e3;
18186 const parsed = Number.parseFloat(value) * multiplier;
18187 return Number.isNaN(parsed) ? 0 : parsed;
18188 }
18189 function getEndTime(names, delays, durations) {
18190 const nameList = names.split(",");
18191 const delayList = delays.split(",");
18192 const durationList = durations.split(",");
18193 let endTime = 0;
18194 for (const [index2, name] of nameList.entries()) {
18195 if (name.trim() === "none") continue;
18196 const delay = parseCSSTime(delayList[index2 % delayList.length]);
18197 const duration = parseCSSTime(durationList[index2 % durationList.length]);
18198 endTime = Math.max(endTime, delay + duration);
18199 }
18200 return endTime;
18201 }
18202 function getElementEndTime(element) {
18203 const { transitionProperty, transitionDuration, transitionDelay, animationName, animationDuration, animationDelay } = getComputedStyle(element);
18204 return Math.max(getEndTime(transitionProperty, transitionDelay, transitionDuration), getEndTime(animationName, animationDelay, animationDuration));
18205 }
18206 function isHidden(mounted, hidden, alwaysVisible) {
18207 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
18208 }
18209 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, unstable_otherElementRef: otherElementRef, ...props }) {
18210 const context = useDisclosureProviderContext();
18211 store = store || context;
18212 invariant(store, "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component.");
18213 const ref = (0, import_react20.useRef)(null);
18214 const id = useId4(props.id);
18215 const [transition, setTransition] = (0, import_react20.useState)(null);
18216 const open = useStoreState(store, "open");
18217 const mounted = useStoreState(store, "mounted");
18218 const animated = useStoreState(store, "animated");
18219 const contentElement = useStoreState(store, "contentElement");
18220 const otherElement = useStoreState(store.disclosure, "contentElement");
18221 const hasClosedRef = (0, import_react20.useRef)(false);
18222 useSafeLayoutEffect(() => {
18223 if (!ref.current) return;
18224 store?.setContentElement(ref.current);
18225 }, [store]);
18226 useSafeLayoutEffect(() => {
18227 let previousAnimated;
18228 store?.setState("animated", (animated2) => {
18229 previousAnimated = animated2;
18230 return true;
18231 });
18232 return () => {
18233 if (previousAnimated === void 0) return;
18234 store?.setState("animated", previousAnimated);
18235 };
18236 }, [store]);
18237 useSafeLayoutEffect(() => {
18238 if (!animated) {
18239 if (!open) {
18240 hasClosedRef.current = true;
18241 setTransition(null);
18242 } else if (hasClosedRef.current) {
18243 hasClosedRef.current = false;
18244 setTransition("enter");
18245 }
18246 return;
18247 }
18248 if (!contentElement?.isConnected) {
18249 setTransition(null);
18250 return;
18251 }
18252 return afterPaint(() => {
18253 setTransition(open ? "enter" : mounted ? "leave" : null);
18254 });
18255 }, [
18256 animated,
18257 contentElement,
18258 open,
18259 mounted
18260 ]);
18261 useSafeLayoutEffect(() => {
18262 if (!store) return;
18263 if (!animated) return;
18264 if (!transition) return;
18265 if (!contentElement) return;
18266 const stopAnimation = () => store?.setState("animating", false);
18267 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
18268 if (transition === "leave" && open) return;
18269 if (transition === "enter" && !open) return;
18270 if (typeof animated === "number") return afterTimeout(animated, stopAnimationSync);
18271 const elements = [contentElement];
18272 if (otherElement) elements.push(otherElement);
18273 const relatedElement = otherElementRef?.current;
18274 if (relatedElement) elements.push(relatedElement);
18275 const timeout = Math.max(...elements.map(getElementEndTime));
18276 if (!timeout) {
18277 if (transition === "enter") store.setState("animated", false);
18278 stopAnimation();
18279 return;
18280 }
18281 return afterTimeout(Math.max(timeout - 1e3 / 60, 0), stopAnimationSync);
18282 }, [
18283 store,
18284 animated,
18285 contentElement,
18286 otherElement,
18287 otherElementRef,
18288 open,
18289 transition
18290 ]);
18291 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DialogScopedContextProvider, {
18292 value: store,
18293 children: element
18294 }), [store]);
18295 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
18296 const styleProp = props.style;
18297 const style = (0, import_react20.useMemo)(() => {
18298 if (hidden) return {
18299 ...styleProp,
18300 display: "none"
18301 };
18302 return styleProp;
18303 }, [hidden, styleProp]);
18304 props = {
18305 "data-open": open || void 0,
18306 "data-enter": transition === "enter" || void 0,
18307 "data-leave": transition === "leave" || void 0,
18308 hidden,
18309 ...props,
18310 id,
18311 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
18312 style
18313 };
18314 return removeUndefinedValues(props);
18315 });
18316 var DisclosureContentImpl = forwardRef29(function DisclosureContentImpl2(props) {
18317 return createElement3(TagName6, useDisclosureContent(props));
18318 });
18319 var DisclosureContent = forwardRef29(function DisclosureContent2({ unmountOnHide, ...props }) {
18320 const context = useDisclosureProviderContext();
18321 if (useStoreState(props.store || context, (state) => !unmountOnHide || state?.mounted) === false) return null;
18322 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DisclosureContentImpl, { ...props });
18323 });
18324
18325 // node_modules/@ariakit/components/dist/disclosure/disclosure-store.js
18326 function createDisclosureStore(props = {}) {
18327 const store = mergeStore(props.store, omit2(props.disclosure, ["contentElement", "disclosureElement"]));
18328 throwOnConflictingProps(props, store);
18329 const syncState = store?.getState();
18330 const open = defaultValue(props.open, syncState?.open, props.defaultOpen, false);
18331 const animated = defaultValue(props.animated, syncState?.animated, false);
18332 const disclosure = createStore({
18333 open,
18334 animated,
18335 animating: !!animated && open,
18336 mounted: open,
18337 contentElement: defaultValue(syncState?.contentElement, null),
18338 disclosureElement: defaultValue(syncState?.disclosureElement, null)
18339 }, store);
18340 setup(disclosure, () => sync(disclosure, ["animated", "animating"], (state) => {
18341 if (state.animated) return;
18342 disclosure.setState("animating", false);
18343 }));
18344 setup(disclosure, () => subscribe(disclosure, ["open"], () => {
18345 if (!disclosure.getState().animated) return;
18346 disclosure.setState("animating", true);
18347 }));
18348 setup(disclosure, () => sync(disclosure, ["open", "animating"], (state) => {
18349 disclosure.setState("mounted", state.open || state.animating);
18350 }));
18351 return {
18352 ...disclosure,
18353 disclosure: props.disclosure,
18354 setOpen: (value) => disclosure.setState("open", value),
18355 show: () => disclosure.setState("open", true),
18356 hide: () => disclosure.setState("open", false),
18357 toggle: () => disclosure.setState("open", (open2) => !open2),
18358 stopAnimation: () => disclosure.setState("animating", false),
18359 setContentElement: (value) => disclosure.setState("contentElement", value),
18360 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
18361 };
18362 }
18363
18364 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-store.js
18365 function useDisclosureStoreProps(store, update2, props) {
18366 useUpdateEffect(update2, [props.store, props.disclosure]);
18367 useStoreProps(store, props, "open", "setOpen");
18368 useStoreProps(store, props, "mounted", "setMounted");
18369 useStoreProps(store, props, "animated");
18370 return Object.assign(store, { disclosure: props.disclosure });
18371 }
18372
18373 // node_modules/@ariakit/react-components/dist/popover/popover-context.js
18374 var ctx5 = createStoreContext([DialogContextProvider], [DialogScopedContextProvider]);
18375 var usePopoverContext = ctx5.useContext;
18376 var usePopoverScopedContext = ctx5.useScopedContext;
18377 var usePopoverProviderContext = ctx5.useProviderContext;
18378 var PopoverContextProvider = ctx5.ContextProvider;
18379 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
18380
18381 // node_modules/@ariakit/react-components/dist/combobox/combobox-context.js
18382 var import_react21 = __toESM(require_react(), 1);
18383 var ComboboxListRoleContext = (0, import_react21.createContext)(void 0);
18384 var ctx6 = createStoreContext([PopoverContextProvider, CompositeContextProvider], [PopoverScopedContextProvider, CompositeScopedContextProvider]);
18385 var useComboboxContext = ctx6.useContext;
18386 var useComboboxScopedContext = ctx6.useScopedContext;
18387 var useComboboxProviderContext = ctx6.useProviderContext;
18388 var ComboboxContextProvider = ctx6.ContextProvider;
18389 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
18390 var ComboboxItemValueContext = (0, import_react21.createContext)(void 0);
18391 var ComboboxItemCheckedContext = (0, import_react21.createContext)(false);
18392
18393 // node_modules/@ariakit/react-components/dist/collection/collection-store.js
18394 function useCollectionStoreProps(store, update2, props) {
18395 useUpdateEffect(update2, [props.store]);
18396 useStoreProps(store, props, "items", "setItems");
18397 return store;
18398 }
18399
18400 // node_modules/@ariakit/react-components/dist/composite/composite-store.js
18401 function useCompositeStoreOptions(props) {
18402 return {
18403 id: useId4(props.id),
18404 ...props
18405 };
18406 }
18407 function useCompositeStoreProps(store, update2, props) {
18408 store = useCollectionStoreProps(store, update2, props);
18409 useStoreProps(store, props, "activeId", "setActiveId");
18410 useStoreProps(store, props, "includesBaseElement");
18411 useStoreProps(store, props, "virtualFocus");
18412 useStoreProps(store, props, "orientation");
18413 useStoreProps(store, props, "rtl");
18414 useStoreProps(store, props, "focusLoop");
18415 useStoreProps(store, props, "focusWrap");
18416 useStoreProps(store, props, "focusShift");
18417 return store;
18418 }
18419
18420 // node_modules/@ariakit/components/dist/dialog/dialog-store.js
18421 function createDialogStore(props = {}) {
18422 return createDisclosureStore(props);
18423 }
18424
18425 // node_modules/@ariakit/react-components/dist/dialog/dialog-store.js
18426 function useDialogStoreProps(store, update2, props) {
18427 return useDisclosureStoreProps(store, update2, props);
18428 }
18429
18430 // node_modules/@ariakit/components/dist/popover/popover-store.js
18431 function createPopoverStore({ popover: otherPopover, ...props } = {}) {
18432 const store = mergeStore(props.store, omit2(otherPopover, [
18433 "arrowElement",
18434 "anchorElement",
18435 "contentElement",
18436 "popoverElement",
18437 "disclosureElement"
18438 ]));
18439 throwOnConflictingProps(props, store);
18440 const syncState = store?.getState();
18441 const dialog = createDialogStore({
18442 ...props,
18443 store
18444 });
18445 const placement = defaultValue(props.placement, syncState?.placement, "bottom");
18446 const popover = createStore({
18447 ...dialog.getState(),
18448 placement,
18449 currentPlacement: placement,
18450 anchorElement: defaultValue(syncState?.anchorElement, null),
18451 popoverElement: defaultValue(syncState?.popoverElement, null),
18452 arrowElement: defaultValue(syncState?.arrowElement, null),
18453 rendered: /* @__PURE__ */ Symbol("rendered")
18454 }, dialog, store);
18455 return {
18456 ...dialog,
18457 ...popover,
18458 setAnchorElement: (element) => popover.setState("anchorElement", element),
18459 setPopoverElement: (element) => popover.setState("popoverElement", element),
18460 setArrowElement: (element) => popover.setState("arrowElement", element),
18461 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
18462 };
18463 }
18464
18465 // node_modules/@ariakit/react-components/dist/popover/popover-store.js
18466 function usePopoverStoreProps(store, update2, props) {
18467 useUpdateEffect(update2, [props.popover]);
18468 useStoreProps(store, props, "placement");
18469 return useDialogStoreProps(store, update2, props);
18470 }
18471
18472 // node_modules/@ariakit/react-components/dist/popover/popover-anchor.js
18473 var TagName7 = "div";
18474 var usePopoverAnchor = createHook(function usePopoverAnchor2({ store, ...props }) {
18475 const context = usePopoverProviderContext();
18476 store = store || context;
18477 props = {
18478 ...props,
18479 ref: useMergeRefs(store?.setAnchorElement, props.ref)
18480 };
18481 return props;
18482 });
18483 var PopoverAnchor = forwardRef29(function PopoverAnchor2(props) {
18484 return createElement3(TagName7, usePopoverAnchor(props));
18485 });
18486
18487 // node_modules/@ariakit/react-components/dist/composite/composite-hover.js
18488 var import_react22 = __toESM(require_react(), 1);
18489 var TagName8 = "div";
18490 function hoveringInside(event) {
18491 const nextElement = event.relatedTarget;
18492 if (!isElement2(nextElement)) return false;
18493 return contains2(event.currentTarget, nextElement);
18494 }
18495 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
18496 function movingToAnotherItem(event) {
18497 const { relatedTarget } = event;
18498 if (!isElement2(relatedTarget)) return false;
18499 let dest = relatedTarget;
18500 do {
18501 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
18502 dest = dest.parentElement;
18503 } while (dest);
18504 return false;
18505 }
18506 var useCompositeHover = createHook(function useCompositeHover2({ store, focusOnHover = true, blurOnHoverEnd = !!focusOnHover, ...props }) {
18507 const context = useCompositeScopedContext();
18508 store = store || context;
18509 invariant(store, "CompositeHover must be wrapped in a Composite component.");
18510 const isMouseMoving = useIsMouseMoving();
18511 const onMouseMoveProp = props.onMouseMove;
18512 const focusOnHoverProp = useBooleanEvent(focusOnHover);
18513 const onMouseMove = useEvent((event) => {
18514 onMouseMoveProp?.(event);
18515 if (event.defaultPrevented) return;
18516 if (!isMouseMoving()) return;
18517 if (!focusOnHoverProp(event)) return;
18518 if (!hasFocusWithin(event.currentTarget)) {
18519 const baseElement = store?.getState().baseElement;
18520 if (baseElement && !hasFocus(baseElement)) baseElement.focus();
18521 }
18522 store?.setActiveId(event.currentTarget.id);
18523 });
18524 const onMouseLeaveProp = props.onMouseLeave;
18525 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
18526 const onMouseLeave = useEvent((event) => {
18527 onMouseLeaveProp?.(event);
18528 if (event.defaultPrevented) return;
18529 if (!isMouseMoving()) return;
18530 if (hoveringInside(event)) return;
18531 if (movingToAnotherItem(event)) return;
18532 if (!focusOnHoverProp(event)) return;
18533 if (!blurOnHoverEndProp(event)) return;
18534 store?.setActiveId(null);
18535 store?.getState().baseElement?.focus();
18536 });
18537 const ref = (0, import_react22.useCallback)((element) => {
18538 if (!element) return;
18539 element[symbol2] = true;
18540 }, []);
18541 props = {
18542 ...props,
18543 ref: useMergeRefs(ref, props.ref),
18544 onMouseMove,
18545 onMouseLeave
18546 };
18547 return removeUndefinedValues(props);
18548 });
18549 var CompositeHover = memo3(forwardRef29(function CompositeHover2(props) {
18550 return createElement3(TagName8, useCompositeHover(props));
18551 }));
18552
18553 // node_modules/@ariakit/react-components/dist/combobox/combobox.js
18554 var import_react23 = __toESM(require_react(), 1);
18555 var TagName9 = "input";
18556 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
18557 if (!autoSelect) return false;
18558 return items.find((item) => !item.disabled && item.value)?.value === activeValue;
18559 }
18560 function hasCompletionString(value, activeValue) {
18561 if (!activeValue) return false;
18562 if (value == null) return false;
18563 const normalizedValue = normalizeString(value);
18564 const normalizedActiveValue = normalizeString(activeValue);
18565 if (normalizedValue.length !== value.length) return false;
18566 if (normalizedActiveValue.length !== activeValue.length) return false;
18567 return normalizedActiveValue.length > normalizedValue.length && normalizedActiveValue.toLowerCase().startsWith(normalizedValue.toLowerCase());
18568 }
18569 function isAriaAutoCompleteValue(value) {
18570 return value === "inline" || value === "list" || value === "both" || value === "none";
18571 }
18572 function getDefaultAutoSelectId(items) {
18573 return items.find((item) => {
18574 if (item.disabled) return false;
18575 return item.element?.getAttribute("role") !== "tab";
18576 })?.id;
18577 }
18578 var useCombobox = createHook(function useCombobox2({ store, focusable: focusable2 = true, autoSelect: autoSelectProp = false, getAutoSelectId, setValueOnChange, showMinLength = 0, showOnChange, showOnMouseDown, showOnClick = showOnMouseDown, showOnKeyDown, showOnKeyPress = showOnKeyDown, blurActiveItemOnClick, setValueOnClick = true, moveOnKeyPress = true, autoComplete = "list", ...props }) {
18579 const context = useComboboxProviderContext();
18580 store = store || context;
18581 invariant(store, "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component.");
18582 const ref = (0, import_react23.useRef)(null);
18583 const [valueUpdated, forceValueUpdate] = useForceUpdate();
18584 const canAutoSelectRef = (0, import_react23.useRef)(false);
18585 const composingRef = (0, import_react23.useRef)(false);
18586 const autoSelect = useStoreState(store, (state) => state.virtualFocus && autoSelectProp);
18587 const inline4 = autoComplete === "inline" || autoComplete === "both";
18588 const [canInline, setCanInline] = (0, import_react23.useState)(inline4);
18589 useUpdateLayoutEffect(() => {
18590 if (!inline4) return;
18591 setCanInline(true);
18592 }, [inline4]);
18593 const storeValue = useStoreState(store, "value");
18594 const prevSelectedValueRef = (0, import_react23.useRef)(void 0);
18595 (0, import_react23.useEffect)(() => {
18596 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
18597 prevSelectedValueRef.current = prev.selectedValue;
18598 });
18599 }, [store]);
18600 const inlineActiveValue = useStoreState(store, (state) => {
18601 if (!inline4) return;
18602 if (!canInline) return;
18603 if (state.activeValue && Array.isArray(state.selectedValue)) {
18604 if (state.selectedValue.includes(state.activeValue)) return;
18605 if (prevSelectedValueRef.current?.includes(state.activeValue)) return;
18606 }
18607 return state.activeValue;
18608 });
18609 const items = useStoreState(store, "renderedItems");
18610 const open = useStoreState(store, "open");
18611 const contentElement = useStoreState(store, "contentElement");
18612 const value = (0, import_react23.useMemo)(() => {
18613 if (!inline4) return storeValue;
18614 if (!canInline) return storeValue;
18615 if (isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) {
18616 if (hasCompletionString(storeValue, inlineActiveValue)) return storeValue + (inlineActiveValue?.slice(storeValue.length) || "");
18617 return storeValue;
18618 }
18619 return inlineActiveValue || storeValue;
18620 }, [
18621 inline4,
18622 canInline,
18623 items,
18624 inlineActiveValue,
18625 autoSelect,
18626 storeValue
18627 ]);
18628 (0, import_react23.useEffect)(() => {
18629 const element = ref.current;
18630 if (!element) return;
18631 const onCompositeItemMove = () => setCanInline(true);
18632 element.addEventListener("combobox-item-move", onCompositeItemMove);
18633 return () => {
18634 element.removeEventListener("combobox-item-move", onCompositeItemMove);
18635 };
18636 }, []);
18637 (0, import_react23.useEffect)(() => {
18638 if (!inline4) return;
18639 if (!canInline) return;
18640 if (!inlineActiveValue) return;
18641 if (!isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) return;
18642 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
18643 let cleanup = noop4;
18644 queueMicrotask(() => {
18645 const element = ref.current;
18646 if (!element) return;
18647 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
18648 const nextStart = storeValue.length;
18649 const nextEnd = inlineActiveValue.length;
18650 setSelectionRange(element, nextStart, nextEnd);
18651 cleanup = () => {
18652 if (!hasFocus(element)) return;
18653 const { start, end } = getTextboxSelection(element);
18654 if (start !== nextStart) return;
18655 if (end !== nextEnd) return;
18656 setSelectionRange(element, prevStart, prevEnd);
18657 };
18658 });
18659 return () => cleanup();
18660 }, [
18661 valueUpdated,
18662 inline4,
18663 canInline,
18664 inlineActiveValue,
18665 items,
18666 autoSelect,
18667 storeValue
18668 ]);
18669 const getAutoSelectIdProp = useEvent(getAutoSelectId);
18670 const autoSelectIdRef = (0, import_react23.useRef)(null);
18671 const autoSelectMovedRef = (0, import_react23.useRef)(void 0);
18672 const userScrolledRef = (0, import_react23.useRef)(false);
18673 const isAutoScrollingRef = (0, import_react23.useRef)(false);
18674 (0, import_react23.useEffect)(() => {
18675 if (!open) return;
18676 if (!contentElement) return;
18677 const scrollingElement = getScrollingElement(contentElement);
18678 if (!scrollingElement) return;
18679 const onUserScroll = () => {
18680 canAutoSelectRef.current = false;
18681 userScrolledRef.current = true;
18682 };
18683 const onScroll = () => {
18684 if (!isAutoScrollingRef.current) userScrolledRef.current = true;
18685 if (!store) return;
18686 if (!canAutoSelectRef.current) return;
18687 const { activeId } = store.getState();
18688 if (activeId === null) return;
18689 if (activeId === autoSelectIdRef.current) return;
18690 canAutoSelectRef.current = false;
18691 };
18692 const options = {
18693 passive: true,
18694 capture: true
18695 };
18696 scrollingElement.addEventListener("wheel", onUserScroll, options);
18697 scrollingElement.addEventListener("touchmove", onUserScroll, options);
18698 scrollingElement.addEventListener("scroll", onScroll, options);
18699 return () => {
18700 scrollingElement.removeEventListener("wheel", onUserScroll, true);
18701 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
18702 scrollingElement.removeEventListener("scroll", onScroll, true);
18703 };
18704 }, [
18705 open,
18706 contentElement,
18707 store
18708 ]);
18709 useSafeLayoutEffect(() => {
18710 userScrolledRef.current = false;
18711 if (!storeValue) return;
18712 if (composingRef.current) return;
18713 canAutoSelectRef.current = true;
18714 }, [storeValue]);
18715 useSafeLayoutEffect(() => {
18716 if (autoSelect !== "always" && open) return;
18717 canAutoSelectRef.current = open;
18718 }, [autoSelect, open]);
18719 useSafeLayoutEffect(() => {
18720 if (open) return;
18721 autoSelectMovedRef.current = void 0;
18722 }, [open]);
18723 const resetValueOnSelect = useStoreState(store, "resetValueOnSelect");
18724 useUpdateEffect(() => {
18725 const canAutoSelect = canAutoSelectRef.current;
18726 if (!store) return;
18727 if (!open) return;
18728 if (!canAutoSelect && (!resetValueOnSelect || userScrolledRef.current)) return;
18729 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
18730 if (baseElement && !hasFocus(baseElement)) return;
18731 if (contentElement2?.hasAttribute("data-placing")) {
18732 const observer = new MutationObserver(forceValueUpdate);
18733 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
18734 return () => observer.disconnect();
18735 }
18736 if (autoSelect && canAutoSelect) {
18737 const userAutoSelectId = getAutoSelectIdProp(items);
18738 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : getDefaultAutoSelectId(items) ?? store.first();
18739 autoSelectIdRef.current = autoSelectId;
18740 const nextActiveId = autoSelectId ?? null;
18741 const nextActiveValue = store.item(nextActiveId)?.value;
18742 const moved = autoSelectMovedRef.current;
18743 if (nextActiveId !== activeId || moved?.id !== nextActiveId || moved?.value !== nextActiveValue) {
18744 autoSelectMovedRef.current = {
18745 id: nextActiveId,
18746 value: nextActiveValue
18747 };
18748 store.move(nextActiveId);
18749 } else store.setState("activeValue", nextActiveValue);
18750 } else {
18751 const element = store.item(activeId || store.first())?.element;
18752 if (element && "scrollIntoView" in element) {
18753 isAutoScrollingRef.current = true;
18754 element.scrollIntoView({
18755 block: "nearest",
18756 inline: "nearest"
18757 });
18758 requestAnimationFrame(() => {
18759 isAutoScrollingRef.current = false;
18760 });
18761 }
18762 }
18763 }, [
18764 store,
18765 open,
18766 valueUpdated,
18767 storeValue,
18768 autoSelect,
18769 resetValueOnSelect,
18770 getAutoSelectIdProp,
18771 items
18772 ]);
18773 (0, import_react23.useEffect)(() => {
18774 if (!inline4) return;
18775 const combobox = ref.current;
18776 if (!combobox) return;
18777 const elements = [combobox, contentElement].filter((value2) => !!value2);
18778 const onBlur2 = (event) => {
18779 if (elements.every((el) => isFocusEventOutside(event, el))) store?.setValue(value);
18780 };
18781 for (const element of elements) element.addEventListener("focusout", onBlur2);
18782 return () => {
18783 for (const element of elements) element.removeEventListener("focusout", onBlur2);
18784 };
18785 }, [
18786 inline4,
18787 contentElement,
18788 store,
18789 value
18790 ]);
18791 const canShow = (event) => {
18792 return event.currentTarget.value.length >= showMinLength;
18793 };
18794 const onChangeProp = props.onChange;
18795 const showOnChangeProp = useBooleanEvent(showOnChange ?? canShow);
18796 const setValueOnChangeProp = useBooleanEvent(setValueOnChange ?? !store.tag);
18797 const onChange = useEvent((event) => {
18798 onChangeProp?.(event);
18799 if (event.defaultPrevented) return;
18800 if (!store) return;
18801 const currentTarget = event.currentTarget;
18802 const { value: value2, selectionStart, selectionEnd } = currentTarget;
18803 const nativeEvent = event.nativeEvent;
18804 canAutoSelectRef.current = true;
18805 if (isInputEvent(nativeEvent)) {
18806 if (nativeEvent.isComposing) {
18807 canAutoSelectRef.current = false;
18808 composingRef.current = true;
18809 }
18810 if (inline4) {
18811 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
18812 const caretAtEnd = selectionStart === value2.length;
18813 setCanInline(textInserted && caretAtEnd);
18814 }
18815 }
18816 if (setValueOnChangeProp(event)) {
18817 const isSameValue2 = value2 === store.getState().value;
18818 store.setValue(value2);
18819 queueMicrotask(() => {
18820 setSelectionRange(currentTarget, selectionStart, selectionEnd);
18821 });
18822 if (inline4 && autoSelect && isSameValue2) forceValueUpdate();
18823 }
18824 if (showOnChangeProp(event)) store.show();
18825 if (!autoSelect || !canAutoSelectRef.current) store.setActiveId(null);
18826 });
18827 const onCompositionEndProp = props.onCompositionEnd;
18828 const onCompositionEnd = useEvent((event) => {
18829 canAutoSelectRef.current = true;
18830 composingRef.current = false;
18831 onCompositionEndProp?.(event);
18832 if (event.defaultPrevented) return;
18833 if (!autoSelect) return;
18834 forceValueUpdate();
18835 });
18836 const onMouseDownProp = props.onMouseDown;
18837 const blurActiveItemOnClickProp = useBooleanEvent(blurActiveItemOnClick ?? (() => store.getState().includesBaseElement));
18838 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18839 const showOnClickProp = useBooleanEvent(showOnClick ?? canShow);
18840 const onMouseDown = useEvent((event) => {
18841 onMouseDownProp?.(event);
18842 if (event.defaultPrevented) return;
18843 if (event.button) return;
18844 if (event.ctrlKey) return;
18845 if (!store) return;
18846 if (blurActiveItemOnClickProp(event)) store.setActiveId(null);
18847 if (setValueOnClickProp(event)) store.setValue(value);
18848 if (showOnClickProp(event)) queueBeforeEvent(event.currentTarget, "mouseup", store.show);
18849 });
18850 const onKeyDownProp = props.onKeyDown;
18851 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress ?? canShow);
18852 const onKeyDown = useEvent((event) => {
18853 onKeyDownProp?.(event);
18854 if (!event.repeat) canAutoSelectRef.current = false;
18855 if (event.defaultPrevented) return;
18856 if (!store) return;
18857 const { open: open2 } = store.getState();
18858 if (open2 && event.key === "Enter") {
18859 event.preventDefault();
18860 return;
18861 }
18862 if (event.ctrlKey) return;
18863 if (event.altKey) return;
18864 if (event.shiftKey) return;
18865 if (event.metaKey) return;
18866 if (open2) return;
18867 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
18868 if (showOnKeyPressProp(event)) {
18869 event.preventDefault();
18870 store.show();
18871 }
18872 }
18873 });
18874 const onBlurProp = props.onBlur;
18875 const onBlur = useEvent((event) => {
18876 canAutoSelectRef.current = false;
18877 onBlurProp?.(event);
18878 });
18879 const id = useId4(props.id);
18880 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
18881 const isActiveItem = useStoreState(store, (state) => state.activeId === null);
18882 props = {
18883 role: "combobox",
18884 "aria-autocomplete": ariaAutoComplete,
18885 "aria-haspopup": getPopupRole(contentElement, "listbox"),
18886 "aria-expanded": open,
18887 "aria-controls": contentElement?.id,
18888 "data-active-item": isActiveItem || void 0,
18889 value,
18890 ...props,
18891 id,
18892 ref: useMergeRefs(ref, props.ref),
18893 onChange,
18894 onCompositionEnd,
18895 onMouseDown,
18896 onKeyDown,
18897 onBlur
18898 };
18899 props = useComposite({
18900 store,
18901 focusable: focusable2,
18902 ...props,
18903 moveOnKeyPress: (event) => {
18904 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
18905 if (inline4) setCanInline(true);
18906 return true;
18907 }
18908 });
18909 props = usePopoverAnchor({
18910 store,
18911 ...props
18912 });
18913 return {
18914 autoComplete: "off",
18915 ...props
18916 };
18917 });
18918 var Combobox = forwardRef29(function Combobox2(props) {
18919 return createElement3(TagName9, useCombobox(props));
18920 });
18921
18922 // node_modules/@ariakit/react-components/dist/combobox/combobox-item.js
18923 var import_react24 = __toESM(require_react(), 1);
18924 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
18925 var TagName10 = "div";
18926 function isSelected(storeValue, itemValue) {
18927 if (itemValue == null) return;
18928 if (storeValue == null) return false;
18929 if (Array.isArray(storeValue)) return storeValue.includes(itemValue);
18930 return storeValue === itemValue;
18931 }
18932 function getItemRole(popupRole) {
18933 return getItemRoleByPopupRole(popupRole) ?? "option";
18934 }
18935 var useComboboxItem = createHook(function useComboboxItem2({ store, value, hideOnClick, setValueOnClick, selectValueOnClick = true, resetValueOnSelect, focusOnHover = false, moveOnKeyPress = true, getItem: getItemProp, ...props }) {
18936 const context = useComboboxScopedContext();
18937 store = store || context;
18938 invariant(store, "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component.");
18939 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
18940 resetValueOnSelectState: "resetValueOnSelect",
18941 multiSelectable(state) {
18942 return Array.isArray(state.selectedValue);
18943 },
18944 selected(state) {
18945 return isSelected(state.selectedValue, value);
18946 }
18947 });
18948 const getItem = (0, import_react24.useCallback)((item) => {
18949 const nextItem = {
18950 ...item,
18951 value
18952 };
18953 if (getItemProp) return getItemProp(nextItem);
18954 return nextItem;
18955 }, [value, getItemProp]);
18956 setValueOnClick = setValueOnClick ?? !multiSelectable;
18957 hideOnClick = hideOnClick ?? (value != null && !multiSelectable);
18958 const onClickProp = props.onClick;
18959 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18960 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
18961 const resetValueOnSelectProp = useBooleanEvent(resetValueOnSelect ?? resetValueOnSelectState ?? multiSelectable);
18962 const hideOnClickProp = useBooleanEvent(hideOnClick);
18963 const onClick = useEvent((event) => {
18964 onClickProp?.(event);
18965 if (event.defaultPrevented) return;
18966 if (isDownloading(event)) return;
18967 if (isOpeningInNewTab(event)) return;
18968 if (value != null) {
18969 if (selectValueOnClickProp(event)) {
18970 if (resetValueOnSelectProp(event)) store?.resetValue();
18971 store?.setSelectedValue((prevValue) => {
18972 if (!Array.isArray(prevValue)) return value;
18973 if (prevValue.includes(value)) return prevValue.filter((v2) => v2 !== value);
18974 return [...prevValue, value];
18975 });
18976 }
18977 if (setValueOnClickProp(event)) store?.setValue(value);
18978 }
18979 if (hideOnClickProp(event)) store?.hide();
18980 });
18981 const onKeyDownProp = props.onKeyDown;
18982 const onKeyDown = useEvent((event) => {
18983 onKeyDownProp?.(event);
18984 if (event.defaultPrevented) return;
18985 const baseElement = store?.getState().baseElement;
18986 if (!baseElement) return;
18987 if (hasFocus(baseElement)) return;
18988 const printable = event.key.length === 1 && !event.ctrlKey && !event.metaKey;
18989 const paste = (!isApple() ? event.ctrlKey : event.metaKey) && event.key.toLowerCase() === "v";
18990 const deleteKey = event.key === "Backspace" || event.key === "Delete";
18991 if (printable || paste || deleteKey) {
18992 queueMicrotask(() => baseElement.focus());
18993 if (isTextField(baseElement)) store?.setValue(baseElement.value);
18994 }
18995 });
18996 if (multiSelectable && selected != null) props = {
18997 "aria-selected": selected,
18998 ...props
18999 };
19000 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ComboboxItemValueContext.Provider, {
19001 value,
19002 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ComboboxItemCheckedContext.Provider, {
19003 value: selected ?? false,
19004 children: element
19005 })
19006 }), [value, selected]);
19007 props = {
19008 role: getItemRole((0, import_react24.useContext)(ComboboxListRoleContext)),
19009 children: value,
19010 ...props,
19011 onClick,
19012 onKeyDown
19013 };
19014 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
19015 props = useCompositeItem({
19016 store,
19017 ...props,
19018 getItem,
19019 moveOnKeyPress: (event) => {
19020 if (!moveOnKeyPressProp(event)) return false;
19021 const moveEvent = new Event("combobox-item-move");
19022 store?.getState().baseElement?.dispatchEvent(moveEvent);
19023 return true;
19024 }
19025 });
19026 props = useCompositeHover({
19027 store,
19028 focusOnHover,
19029 ...props
19030 });
19031 return props;
19032 });
19033 var ComboboxItem = memo3(forwardRef29(function ComboboxItem2(props) {
19034 return createElement3(TagName10, useComboboxItem(props));
19035 }));
19036
19037 // node_modules/@ariakit/react-components/dist/combobox/combobox-item-value.js
19038 var import_react25 = __toESM(require_react(), 1);
19039 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
19040 var TagName11 = "span";
19041 function normalizeValue(value) {
19042 return normalizeString(value).toLowerCase();
19043 }
19044 function getOffsets(string, values) {
19045 const offsets = [];
19046 for (const value of values) {
19047 if (!value) continue;
19048 let pos = 0;
19049 const length = value.length;
19050 let index2 = string.indexOf(value, pos);
19051 while (index2 !== -1) {
19052 offsets.push([index2, length]);
19053 pos = index2 + 1;
19054 index2 = string.indexOf(value, pos);
19055 }
19056 }
19057 return offsets;
19058 }
19059 function mergeOverlappingOffsets(offsets) {
19060 offsets.sort(([a2], [b2]) => a2 - b2);
19061 const merged = [];
19062 for (const [offset4, length] of offsets) {
19063 const last = merged[merged.length - 1];
19064 if (last && offset4 < last[0] + last[1]) last[1] = Math.max(last[1], offset4 + length - last[0]);
19065 else merged.push([offset4, length]);
19066 }
19067 return merged;
19068 }
19069 function getNormalizedIndexes(itemValue) {
19070 const starts = [];
19071 const ends = [];
19072 let index2 = 0;
19073 for (const char of itemValue) {
19074 const normalizedLength = normalizeValue(char).length;
19075 for (let i2 = 0; i2 < normalizedLength; i2 += 1) {
19076 starts.push(i2 === 0 ? index2 : -1);
19077 ends.push(index2);
19078 }
19079 index2 += char.length;
19080 }
19081 starts.push(itemValue.length);
19082 ends.push(itemValue.length);
19083 let nextBoundary = itemValue.length;
19084 for (let i2 = starts.length - 1; i2 >= 0; i2 -= 1) {
19085 const start = starts[i2];
19086 if (start == null) continue;
19087 if (start === -1) starts[i2] = nextBoundary;
19088 else nextBoundary = start;
19089 }
19090 return {
19091 starts,
19092 ends
19093 };
19094 }
19095 function toOriginalOffsets(itemValue, normalizedOffsets) {
19096 if (!normalizedOffsets.length) return normalizedOffsets;
19097 const { starts, ends } = getNormalizedIndexes(itemValue);
19098 const offsets = [];
19099 for (const [normalizedOffset, normalizedLength] of normalizedOffsets) {
19100 const start = starts[normalizedOffset];
19101 const end = ends[normalizedOffset + normalizedLength];
19102 if (start == null || end == null) continue;
19103 if (end <= start) continue;
19104 offsets.push([start, end - start]);
19105 }
19106 return offsets;
19107 }
19108 function splitValue(itemValue, userValue) {
19109 if (!itemValue) return itemValue;
19110 if (!userValue) return itemValue;
19111 const userValues = toArray(userValue).map(normalizeValue);
19112 const parts = [];
19113 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("span", {
19114 "data-autocomplete-value": autocomplete ? "" : void 0,
19115 "data-user-value": autocomplete ? void 0 : "",
19116 children: value
19117 }, parts.length);
19118 const offsets = toOriginalOffsets(itemValue, mergeOverlappingOffsets(getOffsets(normalizeValue(itemValue), new Set(userValues))));
19119 const firstEntry = offsets[0];
19120 if (!firstEntry) {
19121 parts.push(span(itemValue, true));
19122 return parts;
19123 }
19124 const [firstOffset] = firstEntry;
19125 [itemValue.slice(0, firstOffset), ...offsets.flatMap(([offset4, length], i2) => {
19126 const value = itemValue.slice(offset4, offset4 + length);
19127 const nextOffset = offsets[i2 + 1]?.[0];
19128 return [value, itemValue.slice(offset4 + length, nextOffset)];
19129 })].forEach((value, i2) => {
19130 if (!value) return;
19131 parts.push(span(value, i2 % 2 === 0));
19132 });
19133 return parts;
19134 }
19135 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
19136 const context = useComboboxScopedContext();
19137 store = store || context;
19138 const itemContext = (0, import_react25.useContext)(ComboboxItemValueContext);
19139 const itemValue = value ?? itemContext;
19140 const inputValue = useStoreState(store, (state) => userValue ?? state?.value);
19141 props = {
19142 children: (0, import_react25.useMemo)(() => {
19143 if (!itemValue) return;
19144 if (!inputValue) return itemValue;
19145 return splitValue(itemValue, inputValue);
19146 }, [itemValue, inputValue]),
19147 ...props
19148 };
19149 return removeUndefinedValues(props);
19150 });
19151 var ComboboxItemValue = forwardRef29(function ComboboxItemValue2(props) {
19152 return createElement3(TagName11, useComboboxItemValue(props));
19153 });
19154
19155 // node_modules/@ariakit/react-components/dist/combobox/combobox-label.js
19156 var TagName12 = "label";
19157 var useComboboxLabel = createHook(function useComboboxLabel2({ store, ...props }) {
19158 const context = useComboboxProviderContext();
19159 store = store || context;
19160 invariant(store, "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component.");
19161 props = {
19162 htmlFor: useStoreState(store, (state) => state.baseElement?.id),
19163 ...props
19164 };
19165 return removeUndefinedValues(props);
19166 });
19167 var ComboboxLabel = memo3(forwardRef29(function ComboboxLabel2(props) {
19168 return createElement3(TagName12, useComboboxLabel(props));
19169 }));
19170
19171 // node_modules/@ariakit/react-components/dist/combobox/combobox-list.js
19172 var import_react26 = __toESM(require_react(), 1);
19173 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
19174 var TagName13 = "div";
19175 var useComboboxList = createHook(function useComboboxList2({ store, alwaysVisible, ...props }) {
19176 const scopedContext = useComboboxScopedContext(true);
19177 const context = useComboboxContext();
19178 store = store || context;
19179 const scopedContextSameStore = !!store && store === scopedContext;
19180 invariant(store, "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component.");
19181 const ref = (0, import_react26.useRef)(null);
19182 const id = useId4(props.id);
19183 const mounted = useStoreState(store, "mounted");
19184 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
19185 const style = hidden ? {
19186 ...props.style,
19187 display: "none"
19188 } : props.style;
19189 const multiSelectable = useStoreState(store, (state) => Array.isArray(state.selectedValue));
19190 const role = useAttribute(ref, "role", props.role);
19191 const ariaMultiSelectable = role === "listbox" || role === "tree" || role === "grid" ? multiSelectable || void 0 : void 0;
19192 const [hasListboxInside, setHasListboxInside] = (0, import_react26.useState)(false);
19193 const contentElement = useStoreState(store, "contentElement");
19194 useSafeLayoutEffect(() => {
19195 if (!mounted) return;
19196 const element = ref.current;
19197 if (!element) return;
19198 if (contentElement !== element) return;
19199 const callback = () => {
19200 setHasListboxInside(!!element.querySelector("[role='listbox']"));
19201 };
19202 const observer = new MutationObserver(callback);
19203 observer.observe(element, {
19204 subtree: true,
19205 childList: true,
19206 attributeFilter: ["role"]
19207 });
19208 callback();
19209 return () => observer.disconnect();
19210 }, [mounted, contentElement]);
19211 if (!hasListboxInside) props = {
19212 role: "listbox",
19213 "aria-multiselectable": ariaMultiSelectable,
19214 ...props
19215 };
19216 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ComboboxScopedContextProvider, {
19217 value: store,
19218 children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ComboboxListRoleContext.Provider, {
19219 value: role,
19220 children: element
19221 })
19222 }), [store, role]);
19223 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
19224 props = {
19225 hidden,
19226 ...props,
19227 id,
19228 ref: useMergeRefs(setContentElement, ref, props.ref),
19229 style
19230 };
19231 return removeUndefinedValues(props);
19232 });
19233 var ComboboxList = forwardRef29(function ComboboxList2(props) {
19234 return createElement3(TagName13, useComboboxList(props));
19235 });
19236
19237 // node_modules/@ariakit/react-components/dist/tag/tag-context.js
19238 var import_react27 = __toESM(require_react(), 1);
19239 var TagValueContext = (0, import_react27.createContext)(null);
19240 var TagRemoveIdContext = (0, import_react27.createContext)(null);
19241 var ctx7 = createStoreContext([CompositeContextProvider], [CompositeScopedContextProvider]);
19242 var useTagContext = ctx7.useContext;
19243 var useTagScopedContext = ctx7.useScopedContext;
19244 var useTagProviderContext = ctx7.useProviderContext;
19245 var TagContextProvider = ctx7.ContextProvider;
19246 var TagScopedContextProvider = ctx7.ScopedContextProvider;
19247
19248 // node_modules/@ariakit/components/dist/combobox/combobox-store.js
19249 var isTouchSafari = isSafari() && isTouchDevice();
19250 function createComboboxStore({ tag, ...props } = {}) {
19251 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
19252 throwOnConflictingProps(props, store);
19253 const tagState = tag?.getState();
19254 const syncState = store?.getState();
19255 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId, null);
19256 const composite = createCompositeStore({
19257 ...props,
19258 activeId,
19259 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, true),
19260 orientation: defaultValue(props.orientation, syncState?.orientation, "vertical"),
19261 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, true),
19262 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, true),
19263 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, true)
19264 });
19265 const popover = createPopoverStore({
19266 ...props,
19267 placement: defaultValue(props.placement, syncState?.placement, "bottom-start")
19268 });
19269 const value = defaultValue(props.value, syncState?.value, props.defaultValue, "");
19270 const selectedValue = defaultValue(props.selectedValue, syncState?.selectedValue, tagState?.values, props.defaultSelectedValue, "");
19271 const multiSelectable = Array.isArray(selectedValue);
19272 const initialState = {
19273 ...composite.getState(),
19274 ...popover.getState(),
19275 value,
19276 selectedValue,
19277 resetValueOnSelect: defaultValue(props.resetValueOnSelect, syncState?.resetValueOnSelect, multiSelectable),
19278 resetValueOnHide: defaultValue(props.resetValueOnHide, syncState?.resetValueOnHide, multiSelectable && !tag),
19279 activeValue: syncState?.activeValue
19280 };
19281 const combobox = createStore(initialState, composite, popover, store);
19282 if (isTouchSafari) setup(combobox, () => sync(combobox, ["virtualFocus"], () => {
19283 combobox.setState("virtualFocus", false);
19284 }));
19285 setup(combobox, () => {
19286 if (!tag) return;
19287 return chain(sync(combobox, ["selectedValue"], (state) => {
19288 if (!Array.isArray(state.selectedValue)) return;
19289 tag.setValues(state.selectedValue);
19290 }), sync(tag, ["values"], (state) => {
19291 combobox.setState("selectedValue", state.values);
19292 }));
19293 });
19294 setup(combobox, () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
19295 if (!state.resetValueOnHide) return;
19296 if (state.mounted) return;
19297 combobox.setState("value", value);
19298 }));
19299 setup(combobox, () => sync(combobox, ["open"], (state) => {
19300 if (state.open) return;
19301 combobox.setState("activeId", activeId);
19302 combobox.setState("moves", 0);
19303 }));
19304 setup(combobox, () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
19305 if (state.moves === prevState.moves) combobox.setState("activeValue", void 0);
19306 }));
19307 setup(combobox, () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
19308 if (state.moves === prev.moves) return;
19309 const { activeId: activeId2 } = combobox.getState();
19310 const activeItem = composite.item(activeId2);
19311 combobox.setState("activeValue", activeItem?.value);
19312 }));
19313 return {
19314 ...popover,
19315 ...composite,
19316 ...combobox,
19317 tag,
19318 setValue: (value2) => combobox.setState("value", value2),
19319 resetValue: () => combobox.setState("value", initialState.value),
19320 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
19321 };
19322 }
19323
19324 // node_modules/@ariakit/react-components/dist/combobox/combobox-store.js
19325 function useComboboxStoreOptions(props) {
19326 const tag = useTagContext();
19327 props = {
19328 ...props,
19329 tag: props.tag !== void 0 ? props.tag : tag
19330 };
19331 return useCompositeStoreOptions(props);
19332 }
19333 function useComboboxStoreProps(store, update2, props) {
19334 useUpdateEffect(update2, [props.tag]);
19335 useStoreProps(store, props, "value", "setValue");
19336 useStoreProps(store, props, "selectedValue", "setSelectedValue");
19337 useStoreProps(store, props, "resetValueOnHide");
19338 useStoreProps(store, props, "resetValueOnSelect");
19339 return Object.assign(useCompositeStoreProps(usePopoverStoreProps(store, update2, props), update2, props), { tag: props.tag });
19340 }
19341 function useComboboxStore(props = {}) {
19342 props = useComboboxStoreOptions(props);
19343 const [store, update2] = useStore2(createComboboxStore, props);
19344 return useComboboxStoreProps(store, update2, props);
19345 }
19346
19347 // node_modules/@ariakit/react-components/dist/combobox/combobox-provider.js
19348 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
19349 function ComboboxProvider(props = {}) {
19350 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(ComboboxContextProvider, {
19351 value: useComboboxStore(props),
19352 children: props.children
19353 });
19354 }
19355
19356 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
19357 var import_remove_accents = __toESM(require_remove_accents(), 1);
19358 var import_compose8 = __toESM(require_compose(), 1);
19359 var import_i18n24 = __toESM(require_i18n(), 1);
19360 var import_element51 = __toESM(require_element(), 1);
19361 var import_components19 = __toESM(require_components(), 1);
19362
19363 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
19364 var EMPTY_ARRAY3 = [];
19365 var getCurrentValue = (filterDefinition, currentFilter) => {
19366 if (filterDefinition.singleSelection) {
19367 return currentFilter?.value;
19368 }
19369 if (Array.isArray(currentFilter?.value)) {
19370 return currentFilter.value;
19371 }
19372 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
19373 return [currentFilter.value];
19374 }
19375 return EMPTY_ARRAY3;
19376 };
19377
19378 // packages/dataviews/build-module/hooks/use-elements.mjs
19379 var import_element50 = __toESM(require_element(), 1);
19380 var EMPTY_ARRAY4 = [];
19381 function useElements({
19382 elements,
19383 getElements
19384 }) {
19385 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
19386 const [records, setRecords] = (0, import_element50.useState)(staticElements);
19387 const [isLoading, setIsLoading] = (0, import_element50.useState)(false);
19388 (0, import_element50.useEffect)(() => {
19389 if (!getElements) {
19390 setRecords(staticElements);
19391 return;
19392 }
19393 let cancelled = false;
19394 setIsLoading(true);
19395 getElements().then((fetchedElements) => {
19396 if (!cancelled) {
19397 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
19398 setRecords(dynamicElements);
19399 }
19400 }).catch(() => {
19401 if (!cancelled) {
19402 setRecords(staticElements);
19403 }
19404 }).finally(() => {
19405 if (!cancelled) {
19406 setIsLoading(false);
19407 }
19408 });
19409 return () => {
19410 cancelled = true;
19411 };
19412 }, [getElements, staticElements]);
19413 return {
19414 elements: records,
19415 isLoading
19416 };
19417 }
19418
19419 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
19420 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
19421 function normalizeSearchInput(input = "") {
19422 return (0, import_remove_accents.default)(input.trim().toLowerCase());
19423 }
19424 var getNewValue = (filterDefinition, currentFilter, value) => {
19425 if (filterDefinition.singleSelection) {
19426 return value;
19427 }
19428 if (Array.isArray(currentFilter?.value)) {
19429 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
19430 }
19431 return [value];
19432 };
19433 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
19434 return `${prefix}-${filterElementValue}`;
19435 }
19436 var MultiSelectionOption = ({ selected }) => {
19437 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19438 "span",
19439 {
19440 className: clsx_default(
19441 "dataviews-filters__search-widget-listitem-multi-selection",
19442 { "is-selected": selected }
19443 ),
19444 children: selected && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Icon, { icon: check_default })
19445 }
19446 );
19447 };
19448 var SingleSelectionOption = ({ selected }) => {
19449 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19450 "span",
19451 {
19452 className: clsx_default(
19453 "dataviews-filters__search-widget-listitem-single-selection",
19454 { "is-selected": selected }
19455 )
19456 }
19457 );
19458 };
19459 function ListBox({ view, filter, onChangeView }) {
19460 const baseId = (0, import_compose8.useInstanceId)(ListBox, "dataviews-filter-list-box");
19461 const [activeCompositeId, setActiveCompositeId] = (0, import_element51.useState)(
19462 // When there are one or less operators, the first item is set as active
19463 // (by setting the initial `activeId` to `undefined`).
19464 // With 2 or more operators, the focus is moved on the operators control
19465 // (by setting the initial `activeId` to `null`), meaning that there won't
19466 // be an active item initially. Focus is then managed via the
19467 // `onFocusVisible` callback.
19468 filter.operators?.length === 1 ? void 0 : null
19469 );
19470 const currentFilter = view.filters?.find(
19471 (f2) => f2.field === filter.field
19472 );
19473 const currentValue = getCurrentValue(filter, currentFilter);
19474 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19475 import_components19.Composite,
19476 {
19477 virtualFocus: true,
19478 focusLoop: true,
19479 activeId: activeCompositeId,
19480 setActiveId: setActiveCompositeId,
19481 role: "listbox",
19482 className: "dataviews-filters__search-widget-listbox",
19483 "aria-label": (0, import_i18n24.sprintf)(
19484 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
19485 (0, import_i18n24.__)("List of: %1$s"),
19486 filter.name
19487 ),
19488 onFocusVisible: () => {
19489 if (!activeCompositeId && filter.elements.length) {
19490 setActiveCompositeId(
19491 generateFilterElementCompositeItemId(
19492 baseId,
19493 filter.elements[0].value
19494 )
19495 );
19496 }
19497 },
19498 render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Composite.Typeahead, {}),
19499 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19500 import_components19.Composite.Hover,
19501 {
19502 render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19503 import_components19.Composite.Item,
19504 {
19505 id: generateFilterElementCompositeItemId(
19506 baseId,
19507 element.value
19508 ),
19509 render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19510 "div",
19511 {
19512 "aria-label": element.label,
19513 role: "option",
19514 className: "dataviews-filters__search-widget-listitem"
19515 }
19516 ),
19517 onClick: () => {
19518 const newFilters = currentFilter ? [
19519 ...(view.filters ?? []).map(
19520 (_filter) => {
19521 if (_filter.field === filter.field) {
19522 return {
19523 ..._filter,
19524 operator: currentFilter.operator || filter.operators[0],
19525 value: getNewValue(
19526 filter,
19527 currentFilter,
19528 element.value
19529 )
19530 };
19531 }
19532 return _filter;
19533 }
19534 )
19535 ] : [
19536 ...view.filters ?? [],
19537 {
19538 field: filter.field,
19539 operator: filter.operators[0],
19540 value: getNewValue(
19541 filter,
19542 currentFilter,
19543 element.value
19544 )
19545 }
19546 ];
19547 onChangeView({
19548 ...view,
19549 page: 1,
19550 filters: newFilters
19551 });
19552 }
19553 }
19554 ),
19555 children: [
19556 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19557 SingleSelectionOption,
19558 {
19559 selected: currentValue === element.value
19560 }
19561 ),
19562 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19563 MultiSelectionOption,
19564 {
19565 selected: currentValue.includes(element.value)
19566 }
19567 ),
19568 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19569 "span",
19570 {
19571 className: "dataviews-filters__search-widget-listitem-value",
19572 title: element.label,
19573 children: element.label
19574 }
19575 )
19576 ]
19577 },
19578 element.value
19579 ))
19580 }
19581 );
19582 }
19583 function ComboboxList22({ view, filter, onChangeView }) {
19584 const [searchValue, setSearchValue] = (0, import_element51.useState)("");
19585 const deferredSearchValue = (0, import_element51.useDeferredValue)(searchValue);
19586 const currentFilter = view.filters?.find(
19587 (_filter) => _filter.field === filter.field
19588 );
19589 const currentValue = getCurrentValue(filter, currentFilter);
19590 const matches = (0, import_element51.useMemo)(() => {
19591 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
19592 return filter.elements.filter(
19593 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
19594 );
19595 }, [filter.elements, deferredSearchValue]);
19596 return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19597 ComboboxProvider,
19598 {
19599 selectedValue: currentValue,
19600 setSelectedValue: (value) => {
19601 const newFilters = currentFilter ? [
19602 ...(view.filters ?? []).map((_filter) => {
19603 if (_filter.field === filter.field) {
19604 return {
19605 ..._filter,
19606 operator: currentFilter.operator || filter.operators[0],
19607 value
19608 };
19609 }
19610 return _filter;
19611 })
19612 ] : [
19613 ...view.filters ?? [],
19614 {
19615 field: filter.field,
19616 operator: filter.operators[0],
19617 value
19618 }
19619 ];
19620 onChangeView({
19621 ...view,
19622 page: 1,
19623 filters: newFilters
19624 });
19625 },
19626 setValue: setSearchValue,
19627 children: [
19628 /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
19629 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(ComboboxLabel, {}), children: (0, import_i18n24.__)("Search items") }),
19630 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19631 Combobox,
19632 {
19633 autoSelect: "always",
19634 placeholder: (0, import_i18n24.__)("Search"),
19635 className: "dataviews-filters__search-widget-filter-combobox__input"
19636 }
19637 ),
19638 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Icon, { icon: search_default }) })
19639 ] }),
19640 /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19641 ComboboxList,
19642 {
19643 className: "dataviews-filters__search-widget-filter-combobox-list",
19644 alwaysVisible: true,
19645 children: [
19646 matches.map((element) => {
19647 return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19648 ComboboxItem,
19649 {
19650 resetValueOnSelect: false,
19651 value: element.value,
19652 className: "dataviews-filters__search-widget-listitem",
19653 hideOnClick: false,
19654 setValueOnClick: false,
19655 focusOnHover: true,
19656 children: [
19657 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19658 SingleSelectionOption,
19659 {
19660 selected: currentValue === element.value
19661 }
19662 ),
19663 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19664 MultiSelectionOption,
19665 {
19666 selected: currentValue.includes(
19667 element.value
19668 )
19669 }
19670 ),
19671 /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19672 "span",
19673 {
19674 className: "dataviews-filters__search-widget-listitem-value",
19675 title: element.label,
19676 children: [
19677 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19678 ComboboxItemValue,
19679 {
19680 className: "dataviews-filters__search-widget-filter-combobox-item-value",
19681 value: element.label
19682 }
19683 ),
19684 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
19685 ]
19686 }
19687 )
19688 ]
19689 },
19690 element.value
19691 );
19692 }),
19693 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("p", { children: (0, import_i18n24.__)("No results found") })
19694 ]
19695 }
19696 )
19697 ]
19698 }
19699 );
19700 }
19701 function SearchWidget(props) {
19702 const { elements, isLoading } = useElements({
19703 elements: props.filter.elements,
19704 getElements: props.filter.getElements
19705 });
19706 if (isLoading) {
19707 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Spinner, {}) });
19708 }
19709 if (elements.length === 0) {
19710 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n24.__)("No elements found") });
19711 }
19712 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
19713 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
19714 }
19715
19716 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
19717 var import_es6 = __toESM(require_es6(), 1);
19718 var import_compose9 = __toESM(require_compose(), 1);
19719 var import_element52 = __toESM(require_element(), 1);
19720 var import_components20 = __toESM(require_components(), 1);
19721 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
19722 function InputWidget({
19723 filter,
19724 view,
19725 onChangeView,
19726 fields
19727 }) {
19728 const currentFilter = view.filters?.find(
19729 (f2) => f2.field === filter.field
19730 );
19731 const currentValue = getCurrentValue(filter, currentFilter);
19732 const field = (0, import_element52.useMemo)(() => {
19733 const currentField = fields.find((f2) => f2.id === filter.field);
19734 if (currentField) {
19735 return {
19736 ...currentField,
19737 // Deactivate validation for filters.
19738 isValid: {},
19739 // Filter controls are always enabled.
19740 isDisabled: () => false,
19741 // Filter controls are always visible.
19742 isVisible: () => true,
19743 // Configure getValue/setValue as if Item was a plain object.
19744 getValue: ({ item }) => item[currentField.id],
19745 setValue: ({ value }) => ({
19746 [currentField.id]: value
19747 })
19748 };
19749 }
19750 return currentField;
19751 }, [fields, filter.field]);
19752 const data = (0, import_element52.useMemo)(() => {
19753 return (view.filters ?? []).reduce(
19754 (acc, activeFilter) => {
19755 acc[activeFilter.field] = activeFilter.value;
19756 return acc;
19757 },
19758 {}
19759 );
19760 }, [view.filters]);
19761 const handleChange = (0, import_compose9.useEvent)((updatedData) => {
19762 if (!field || !currentFilter) {
19763 return;
19764 }
19765 const nextValue = field.getValue({ item: updatedData });
19766 if ((0, import_es6.default)(nextValue, currentValue)) {
19767 return;
19768 }
19769 onChangeView({
19770 ...view,
19771 filters: (view.filters ?? []).map(
19772 (_filter) => _filter.field === filter.field ? {
19773 ..._filter,
19774 operator: currentFilter.operator || filter.operators[0],
19775 // Consider empty strings as undefined:
19776 //
19777 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
19778 // - empty string as value means "search empty string": returns only the records that have an empty string as value
19779 //
19780 // In practice, this means the filter will not be able to find an empty string as the value.
19781 value: nextValue === "" ? void 0 : nextValue
19782 } : _filter
19783 )
19784 });
19785 });
19786 if (!field || !field.Edit || !currentFilter) {
19787 return null;
19788 }
19789 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
19790 import_components20.Flex,
19791 {
19792 className: "dataviews-filters__user-input-widget",
19793 gap: 2.5,
19794 direction: "column",
19795 children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
19796 field.Edit,
19797 {
19798 hideLabelFromVision: true,
19799 data,
19800 field,
19801 operator: currentFilter.operator,
19802 onChange: handleChange
19803 }
19804 )
19805 }
19806 );
19807 }
19808
19809 // node_modules/date-fns/constants.js
19810 var daysInYear = 365.2425;
19811 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
19812 var minTime = -maxTime;
19813 var millisecondsInWeek = 6048e5;
19814 var millisecondsInDay = 864e5;
19815 var secondsInHour = 3600;
19816 var secondsInDay = secondsInHour * 24;
19817 var secondsInWeek = secondsInDay * 7;
19818 var secondsInYear = secondsInDay * daysInYear;
19819 var secondsInMonth = secondsInYear / 12;
19820 var secondsInQuarter = secondsInMonth * 3;
19821 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
19822
19823 // node_modules/date-fns/constructFrom.js
19824 function constructFrom(date, value) {
19825 if (typeof date === "function") return date(value);
19826 if (date && typeof date === "object" && constructFromSymbol in date)
19827 return date[constructFromSymbol](value);
19828 if (date instanceof Date) return new date.constructor(value);
19829 return new Date(value);
19830 }
19831
19832 // node_modules/date-fns/toDate.js
19833 function toDate(argument, context) {
19834 return constructFrom(context || argument, argument);
19835 }
19836
19837 // node_modules/date-fns/addDays.js
19838 function addDays(date, amount, options) {
19839 const _date = toDate(date, options?.in);
19840 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19841 if (!amount) return _date;
19842 _date.setDate(_date.getDate() + amount);
19843 return _date;
19844 }
19845
19846 // node_modules/date-fns/addMonths.js
19847 function addMonths(date, amount, options) {
19848 const _date = toDate(date, options?.in);
19849 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19850 if (!amount) {
19851 return _date;
19852 }
19853 const dayOfMonth = _date.getDate();
19854 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
19855 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
19856 const daysInMonth = endOfDesiredMonth.getDate();
19857 if (dayOfMonth >= daysInMonth) {
19858 return endOfDesiredMonth;
19859 } else {
19860 _date.setFullYear(
19861 endOfDesiredMonth.getFullYear(),
19862 endOfDesiredMonth.getMonth(),
19863 dayOfMonth
19864 );
19865 return _date;
19866 }
19867 }
19868
19869 // node_modules/date-fns/_lib/defaultOptions.js
19870 var defaultOptions = {};
19871 function getDefaultOptions() {
19872 return defaultOptions;
19873 }
19874
19875 // node_modules/date-fns/startOfWeek.js
19876 function startOfWeek(date, options) {
19877 const defaultOptions2 = getDefaultOptions();
19878 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
19879 const _date = toDate(date, options?.in);
19880 const day = _date.getDay();
19881 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
19882 _date.setDate(_date.getDate() - diff);
19883 _date.setHours(0, 0, 0, 0);
19884 return _date;
19885 }
19886
19887 // node_modules/date-fns/startOfISOWeek.js
19888 function startOfISOWeek(date, options) {
19889 return startOfWeek(date, { ...options, weekStartsOn: 1 });
19890 }
19891
19892 // node_modules/date-fns/getISOWeekYear.js
19893 function getISOWeekYear(date, options) {
19894 const _date = toDate(date, options?.in);
19895 const year = _date.getFullYear();
19896 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
19897 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
19898 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
19899 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
19900 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
19901 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
19902 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
19903 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
19904 if (_date.getTime() >= startOfNextYear.getTime()) {
19905 return year + 1;
19906 } else if (_date.getTime() >= startOfThisYear.getTime()) {
19907 return year;
19908 } else {
19909 return year - 1;
19910 }
19911 }
19912
19913 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
19914 function getTimezoneOffsetInMilliseconds(date) {
19915 const _date = toDate(date);
19916 const utcDate = new Date(
19917 Date.UTC(
19918 _date.getFullYear(),
19919 _date.getMonth(),
19920 _date.getDate(),
19921 _date.getHours(),
19922 _date.getMinutes(),
19923 _date.getSeconds(),
19924 _date.getMilliseconds()
19925 )
19926 );
19927 utcDate.setUTCFullYear(_date.getFullYear());
19928 return +date - +utcDate;
19929 }
19930
19931 // node_modules/date-fns/_lib/normalizeDates.js
19932 function normalizeDates(context, ...dates) {
19933 const normalize = constructFrom.bind(
19934 null,
19935 context || dates.find((date) => typeof date === "object")
19936 );
19937 return dates.map(normalize);
19938 }
19939
19940 // node_modules/date-fns/startOfDay.js
19941 function startOfDay(date, options) {
19942 const _date = toDate(date, options?.in);
19943 _date.setHours(0, 0, 0, 0);
19944 return _date;
19945 }
19946
19947 // node_modules/date-fns/differenceInCalendarDays.js
19948 function differenceInCalendarDays(laterDate, earlierDate, options) {
19949 const [laterDate_, earlierDate_] = normalizeDates(
19950 options?.in,
19951 laterDate,
19952 earlierDate
19953 );
19954 const laterStartOfDay = startOfDay(laterDate_);
19955 const earlierStartOfDay = startOfDay(earlierDate_);
19956 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
19957 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
19958 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
19959 }
19960
19961 // node_modules/date-fns/startOfISOWeekYear.js
19962 function startOfISOWeekYear(date, options) {
19963 const year = getISOWeekYear(date, options);
19964 const fourthOfJanuary = constructFrom(options?.in || date, 0);
19965 fourthOfJanuary.setFullYear(year, 0, 4);
19966 fourthOfJanuary.setHours(0, 0, 0, 0);
19967 return startOfISOWeek(fourthOfJanuary);
19968 }
19969
19970 // node_modules/date-fns/addWeeks.js
19971 function addWeeks(date, amount, options) {
19972 return addDays(date, amount * 7, options);
19973 }
19974
19975 // node_modules/date-fns/addYears.js
19976 function addYears(date, amount, options) {
19977 return addMonths(date, amount * 12, options);
19978 }
19979
19980 // node_modules/date-fns/isDate.js
19981 function isDate(value) {
19982 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
19983 }
19984
19985 // node_modules/date-fns/isValid.js
19986 function isValid(date) {
19987 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
19988 }
19989
19990 // node_modules/date-fns/startOfMonth.js
19991 function startOfMonth(date, options) {
19992 const _date = toDate(date, options?.in);
19993 _date.setDate(1);
19994 _date.setHours(0, 0, 0, 0);
19995 return _date;
19996 }
19997
19998 // node_modules/date-fns/startOfYear.js
19999 function startOfYear(date, options) {
20000 const date_ = toDate(date, options?.in);
20001 date_.setFullYear(date_.getFullYear(), 0, 1);
20002 date_.setHours(0, 0, 0, 0);
20003 return date_;
20004 }
20005
20006 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
20007 var formatDistanceLocale = {
20008 lessThanXSeconds: {
20009 one: "less than a second",
20010 other: "less than {{count}} seconds"
20011 },
20012 xSeconds: {
20013 one: "1 second",
20014 other: "{{count}} seconds"
20015 },
20016 halfAMinute: "half a minute",
20017 lessThanXMinutes: {
20018 one: "less than a minute",
20019 other: "less than {{count}} minutes"
20020 },
20021 xMinutes: {
20022 one: "1 minute",
20023 other: "{{count}} minutes"
20024 },
20025 aboutXHours: {
20026 one: "about 1 hour",
20027 other: "about {{count}} hours"
20028 },
20029 xHours: {
20030 one: "1 hour",
20031 other: "{{count}} hours"
20032 },
20033 xDays: {
20034 one: "1 day",
20035 other: "{{count}} days"
20036 },
20037 aboutXWeeks: {
20038 one: "about 1 week",
20039 other: "about {{count}} weeks"
20040 },
20041 xWeeks: {
20042 one: "1 week",
20043 other: "{{count}} weeks"
20044 },
20045 aboutXMonths: {
20046 one: "about 1 month",
20047 other: "about {{count}} months"
20048 },
20049 xMonths: {
20050 one: "1 month",
20051 other: "{{count}} months"
20052 },
20053 aboutXYears: {
20054 one: "about 1 year",
20055 other: "about {{count}} years"
20056 },
20057 xYears: {
20058 one: "1 year",
20059 other: "{{count}} years"
20060 },
20061 overXYears: {
20062 one: "over 1 year",
20063 other: "over {{count}} years"
20064 },
20065 almostXYears: {
20066 one: "almost 1 year",
20067 other: "almost {{count}} years"
20068 }
20069 };
20070 var formatDistance = (token, count, options) => {
20071 let result;
20072 const tokenValue = formatDistanceLocale[token];
20073 if (typeof tokenValue === "string") {
20074 result = tokenValue;
20075 } else if (count === 1) {
20076 result = tokenValue.one;
20077 } else {
20078 result = tokenValue.other.replace("{{count}}", count.toString());
20079 }
20080 if (options?.addSuffix) {
20081 if (options.comparison && options.comparison > 0) {
20082 return "in " + result;
20083 } else {
20084 return result + " ago";
20085 }
20086 }
20087 return result;
20088 };
20089
20090 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
20091 function buildFormatLongFn(args) {
20092 return (options = {}) => {
20093 const width = options.width ? String(options.width) : args.defaultWidth;
20094 const format6 = args.formats[width] || args.formats[args.defaultWidth];
20095 return format6;
20096 };
20097 }
20098
20099 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
20100 var dateFormats = {
20101 full: "EEEE, MMMM do, y",
20102 long: "MMMM do, y",
20103 medium: "MMM d, y",
20104 short: "MM/dd/yyyy"
20105 };
20106 var timeFormats = {
20107 full: "h:mm:ss a zzzz",
20108 long: "h:mm:ss a z",
20109 medium: "h:mm:ss a",
20110 short: "h:mm a"
20111 };
20112 var dateTimeFormats = {
20113 full: "{{date}} 'at' {{time}}",
20114 long: "{{date}} 'at' {{time}}",
20115 medium: "{{date}}, {{time}}",
20116 short: "{{date}}, {{time}}"
20117 };
20118 var formatLong = {
20119 date: buildFormatLongFn({
20120 formats: dateFormats,
20121 defaultWidth: "full"
20122 }),
20123 time: buildFormatLongFn({
20124 formats: timeFormats,
20125 defaultWidth: "full"
20126 }),
20127 dateTime: buildFormatLongFn({
20128 formats: dateTimeFormats,
20129 defaultWidth: "full"
20130 })
20131 };
20132
20133 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
20134 var formatRelativeLocale = {
20135 lastWeek: "'last' eeee 'at' p",
20136 yesterday: "'yesterday at' p",
20137 today: "'today at' p",
20138 tomorrow: "'tomorrow at' p",
20139 nextWeek: "eeee 'at' p",
20140 other: "P"
20141 };
20142 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
20143
20144 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
20145 function buildLocalizeFn(args) {
20146 return (value, options) => {
20147 const context = options?.context ? String(options.context) : "standalone";
20148 let valuesArray;
20149 if (context === "formatting" && args.formattingValues) {
20150 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
20151 const width = options?.width ? String(options.width) : defaultWidth;
20152 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
20153 } else {
20154 const defaultWidth = args.defaultWidth;
20155 const width = options?.width ? String(options.width) : args.defaultWidth;
20156 valuesArray = args.values[width] || args.values[defaultWidth];
20157 }
20158 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
20159 return valuesArray[index2];
20160 };
20161 }
20162
20163 // node_modules/date-fns/locale/en-US/_lib/localize.js
20164 var eraValues = {
20165 narrow: ["B", "A"],
20166 abbreviated: ["BC", "AD"],
20167 wide: ["Before Christ", "Anno Domini"]
20168 };
20169 var quarterValues = {
20170 narrow: ["1", "2", "3", "4"],
20171 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
20172 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
20173 };
20174 var monthValues = {
20175 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
20176 abbreviated: [
20177 "Jan",
20178 "Feb",
20179 "Mar",
20180 "Apr",
20181 "May",
20182 "Jun",
20183 "Jul",
20184 "Aug",
20185 "Sep",
20186 "Oct",
20187 "Nov",
20188 "Dec"
20189 ],
20190 wide: [
20191 "January",
20192 "February",
20193 "March",
20194 "April",
20195 "May",
20196 "June",
20197 "July",
20198 "August",
20199 "September",
20200 "October",
20201 "November",
20202 "December"
20203 ]
20204 };
20205 var dayValues = {
20206 narrow: ["S", "M", "T", "W", "T", "F", "S"],
20207 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
20208 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
20209 wide: [
20210 "Sunday",
20211 "Monday",
20212 "Tuesday",
20213 "Wednesday",
20214 "Thursday",
20215 "Friday",
20216 "Saturday"
20217 ]
20218 };
20219 var dayPeriodValues = {
20220 narrow: {
20221 am: "a",
20222 pm: "p",
20223 midnight: "mi",
20224 noon: "n",
20225 morning: "morning",
20226 afternoon: "afternoon",
20227 evening: "evening",
20228 night: "night"
20229 },
20230 abbreviated: {
20231 am: "AM",
20232 pm: "PM",
20233 midnight: "midnight",
20234 noon: "noon",
20235 morning: "morning",
20236 afternoon: "afternoon",
20237 evening: "evening",
20238 night: "night"
20239 },
20240 wide: {
20241 am: "a.m.",
20242 pm: "p.m.",
20243 midnight: "midnight",
20244 noon: "noon",
20245 morning: "morning",
20246 afternoon: "afternoon",
20247 evening: "evening",
20248 night: "night"
20249 }
20250 };
20251 var formattingDayPeriodValues = {
20252 narrow: {
20253 am: "a",
20254 pm: "p",
20255 midnight: "mi",
20256 noon: "n",
20257 morning: "in the morning",
20258 afternoon: "in the afternoon",
20259 evening: "in the evening",
20260 night: "at night"
20261 },
20262 abbreviated: {
20263 am: "AM",
20264 pm: "PM",
20265 midnight: "midnight",
20266 noon: "noon",
20267 morning: "in the morning",
20268 afternoon: "in the afternoon",
20269 evening: "in the evening",
20270 night: "at night"
20271 },
20272 wide: {
20273 am: "a.m.",
20274 pm: "p.m.",
20275 midnight: "midnight",
20276 noon: "noon",
20277 morning: "in the morning",
20278 afternoon: "in the afternoon",
20279 evening: "in the evening",
20280 night: "at night"
20281 }
20282 };
20283 var ordinalNumber = (dirtyNumber, _options) => {
20284 const number = Number(dirtyNumber);
20285 const rem100 = number % 100;
20286 if (rem100 > 20 || rem100 < 10) {
20287 switch (rem100 % 10) {
20288 case 1:
20289 return number + "st";
20290 case 2:
20291 return number + "nd";
20292 case 3:
20293 return number + "rd";
20294 }
20295 }
20296 return number + "th";
20297 };
20298 var localize = {
20299 ordinalNumber,
20300 era: buildLocalizeFn({
20301 values: eraValues,
20302 defaultWidth: "wide"
20303 }),
20304 quarter: buildLocalizeFn({
20305 values: quarterValues,
20306 defaultWidth: "wide",
20307 argumentCallback: (quarter) => quarter - 1
20308 }),
20309 month: buildLocalizeFn({
20310 values: monthValues,
20311 defaultWidth: "wide"
20312 }),
20313 day: buildLocalizeFn({
20314 values: dayValues,
20315 defaultWidth: "wide"
20316 }),
20317 dayPeriod: buildLocalizeFn({
20318 values: dayPeriodValues,
20319 defaultWidth: "wide",
20320 formattingValues: formattingDayPeriodValues,
20321 defaultFormattingWidth: "wide"
20322 })
20323 };
20324
20325 // node_modules/date-fns/locale/_lib/buildMatchFn.js
20326 function buildMatchFn(args) {
20327 return (string, options = {}) => {
20328 const width = options.width;
20329 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
20330 const matchResult = string.match(matchPattern);
20331 if (!matchResult) {
20332 return null;
20333 }
20334 const matchedString = matchResult[0];
20335 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
20336 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
20337 // [TODO] -- I challenge you to fix the type
20338 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
20339 );
20340 let value;
20341 value = args.valueCallback ? args.valueCallback(key) : key;
20342 value = options.valueCallback ? (
20343 // [TODO] -- I challenge you to fix the type
20344 options.valueCallback(value)
20345 ) : value;
20346 const rest = string.slice(matchedString.length);
20347 return { value, rest };
20348 };
20349 }
20350 function findKey(object, predicate) {
20351 for (const key in object) {
20352 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
20353 return key;
20354 }
20355 }
20356 return void 0;
20357 }
20358 function findIndex(array, predicate) {
20359 for (let key = 0; key < array.length; key++) {
20360 if (predicate(array[key])) {
20361 return key;
20362 }
20363 }
20364 return void 0;
20365 }
20366
20367 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
20368 function buildMatchPatternFn(args) {
20369 return (string, options = {}) => {
20370 const matchResult = string.match(args.matchPattern);
20371 if (!matchResult) return null;
20372 const matchedString = matchResult[0];
20373 const parseResult = string.match(args.parsePattern);
20374 if (!parseResult) return null;
20375 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
20376 value = options.valueCallback ? options.valueCallback(value) : value;
20377 const rest = string.slice(matchedString.length);
20378 return { value, rest };
20379 };
20380 }
20381
20382 // node_modules/date-fns/locale/en-US/_lib/match.js
20383 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
20384 var parseOrdinalNumberPattern = /\d+/i;
20385 var matchEraPatterns = {
20386 narrow: /^(b|a)/i,
20387 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
20388 wide: /^(before christ|before common era|anno domini|common era)/i
20389 };
20390 var parseEraPatterns = {
20391 any: [/^b/i, /^(a|c)/i]
20392 };
20393 var matchQuarterPatterns = {
20394 narrow: /^[1234]/i,
20395 abbreviated: /^q[1234]/i,
20396 wide: /^[1234](th|st|nd|rd)? quarter/i
20397 };
20398 var parseQuarterPatterns = {
20399 any: [/1/i, /2/i, /3/i, /4/i]
20400 };
20401 var matchMonthPatterns = {
20402 narrow: /^[jfmasond]/i,
20403 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
20404 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
20405 };
20406 var parseMonthPatterns = {
20407 narrow: [
20408 /^j/i,
20409 /^f/i,
20410 /^m/i,
20411 /^a/i,
20412 /^m/i,
20413 /^j/i,
20414 /^j/i,
20415 /^a/i,
20416 /^s/i,
20417 /^o/i,
20418 /^n/i,
20419 /^d/i
20420 ],
20421 any: [
20422 /^ja/i,
20423 /^f/i,
20424 /^mar/i,
20425 /^ap/i,
20426 /^may/i,
20427 /^jun/i,
20428 /^jul/i,
20429 /^au/i,
20430 /^s/i,
20431 /^o/i,
20432 /^n/i,
20433 /^d/i
20434 ]
20435 };
20436 var matchDayPatterns = {
20437 narrow: /^[smtwf]/i,
20438 short: /^(su|mo|tu|we|th|fr|sa)/i,
20439 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
20440 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
20441 };
20442 var parseDayPatterns = {
20443 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
20444 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
20445 };
20446 var matchDayPeriodPatterns = {
20447 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
20448 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
20449 };
20450 var parseDayPeriodPatterns = {
20451 any: {
20452 am: /^a/i,
20453 pm: /^p/i,
20454 midnight: /^mi/i,
20455 noon: /^no/i,
20456 morning: /morning/i,
20457 afternoon: /afternoon/i,
20458 evening: /evening/i,
20459 night: /night/i
20460 }
20461 };
20462 var match = {
20463 ordinalNumber: buildMatchPatternFn({
20464 matchPattern: matchOrdinalNumberPattern,
20465 parsePattern: parseOrdinalNumberPattern,
20466 valueCallback: (value) => parseInt(value, 10)
20467 }),
20468 era: buildMatchFn({
20469 matchPatterns: matchEraPatterns,
20470 defaultMatchWidth: "wide",
20471 parsePatterns: parseEraPatterns,
20472 defaultParseWidth: "any"
20473 }),
20474 quarter: buildMatchFn({
20475 matchPatterns: matchQuarterPatterns,
20476 defaultMatchWidth: "wide",
20477 parsePatterns: parseQuarterPatterns,
20478 defaultParseWidth: "any",
20479 valueCallback: (index2) => index2 + 1
20480 }),
20481 month: buildMatchFn({
20482 matchPatterns: matchMonthPatterns,
20483 defaultMatchWidth: "wide",
20484 parsePatterns: parseMonthPatterns,
20485 defaultParseWidth: "any"
20486 }),
20487 day: buildMatchFn({
20488 matchPatterns: matchDayPatterns,
20489 defaultMatchWidth: "wide",
20490 parsePatterns: parseDayPatterns,
20491 defaultParseWidth: "any"
20492 }),
20493 dayPeriod: buildMatchFn({
20494 matchPatterns: matchDayPeriodPatterns,
20495 defaultMatchWidth: "any",
20496 parsePatterns: parseDayPeriodPatterns,
20497 defaultParseWidth: "any"
20498 })
20499 };
20500
20501 // node_modules/date-fns/locale/en-US.js
20502 var enUS = {
20503 code: "en-US",
20504 formatDistance,
20505 formatLong,
20506 formatRelative,
20507 localize,
20508 match,
20509 options: {
20510 weekStartsOn: 0,
20511 firstWeekContainsDate: 1
20512 }
20513 };
20514
20515 // node_modules/date-fns/getDayOfYear.js
20516 function getDayOfYear(date, options) {
20517 const _date = toDate(date, options?.in);
20518 const diff = differenceInCalendarDays(_date, startOfYear(_date));
20519 const dayOfYear = diff + 1;
20520 return dayOfYear;
20521 }
20522
20523 // node_modules/date-fns/getISOWeek.js
20524 function getISOWeek(date, options) {
20525 const _date = toDate(date, options?.in);
20526 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
20527 return Math.round(diff / millisecondsInWeek) + 1;
20528 }
20529
20530 // node_modules/date-fns/getWeekYear.js
20531 function getWeekYear(date, options) {
20532 const _date = toDate(date, options?.in);
20533 const year = _date.getFullYear();
20534 const defaultOptions2 = getDefaultOptions();
20535 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20536 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
20537 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
20538 firstWeekOfNextYear.setHours(0, 0, 0, 0);
20539 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
20540 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
20541 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
20542 firstWeekOfThisYear.setHours(0, 0, 0, 0);
20543 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
20544 if (+_date >= +startOfNextYear) {
20545 return year + 1;
20546 } else if (+_date >= +startOfThisYear) {
20547 return year;
20548 } else {
20549 return year - 1;
20550 }
20551 }
20552
20553 // node_modules/date-fns/startOfWeekYear.js
20554 function startOfWeekYear(date, options) {
20555 const defaultOptions2 = getDefaultOptions();
20556 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20557 const year = getWeekYear(date, options);
20558 const firstWeek = constructFrom(options?.in || date, 0);
20559 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
20560 firstWeek.setHours(0, 0, 0, 0);
20561 const _date = startOfWeek(firstWeek, options);
20562 return _date;
20563 }
20564
20565 // node_modules/date-fns/getWeek.js
20566 function getWeek(date, options) {
20567 const _date = toDate(date, options?.in);
20568 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
20569 return Math.round(diff / millisecondsInWeek) + 1;
20570 }
20571
20572 // node_modules/date-fns/_lib/addLeadingZeros.js
20573 function addLeadingZeros(number, targetLength) {
20574 const sign = number < 0 ? "-" : "";
20575 const output = Math.abs(number).toString().padStart(targetLength, "0");
20576 return sign + output;
20577 }
20578
20579 // node_modules/date-fns/_lib/format/lightFormatters.js
20580 var lightFormatters = {
20581 // Year
20582 y(date, token) {
20583 const signedYear = date.getFullYear();
20584 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20585 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
20586 },
20587 // Month
20588 M(date, token) {
20589 const month = date.getMonth();
20590 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
20591 },
20592 // Day of the month
20593 d(date, token) {
20594 return addLeadingZeros(date.getDate(), token.length);
20595 },
20596 // AM or PM
20597 a(date, token) {
20598 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
20599 switch (token) {
20600 case "a":
20601 case "aa":
20602 return dayPeriodEnumValue.toUpperCase();
20603 case "aaa":
20604 return dayPeriodEnumValue;
20605 case "aaaaa":
20606 return dayPeriodEnumValue[0];
20607 case "aaaa":
20608 default:
20609 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
20610 }
20611 },
20612 // Hour [1-12]
20613 h(date, token) {
20614 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
20615 },
20616 // Hour [0-23]
20617 H(date, token) {
20618 return addLeadingZeros(date.getHours(), token.length);
20619 },
20620 // Minute
20621 m(date, token) {
20622 return addLeadingZeros(date.getMinutes(), token.length);
20623 },
20624 // Second
20625 s(date, token) {
20626 return addLeadingZeros(date.getSeconds(), token.length);
20627 },
20628 // Fraction of second
20629 S(date, token) {
20630 const numberOfDigits = token.length;
20631 const milliseconds = date.getMilliseconds();
20632 const fractionalSeconds = Math.trunc(
20633 milliseconds * Math.pow(10, numberOfDigits - 3)
20634 );
20635 return addLeadingZeros(fractionalSeconds, token.length);
20636 }
20637 };
20638
20639 // node_modules/date-fns/_lib/format/formatters.js
20640 var dayPeriodEnum = {
20641 am: "am",
20642 pm: "pm",
20643 midnight: "midnight",
20644 noon: "noon",
20645 morning: "morning",
20646 afternoon: "afternoon",
20647 evening: "evening",
20648 night: "night"
20649 };
20650 var formatters = {
20651 // Era
20652 G: function(date, token, localize2) {
20653 const era = date.getFullYear() > 0 ? 1 : 0;
20654 switch (token) {
20655 // AD, BC
20656 case "G":
20657 case "GG":
20658 case "GGG":
20659 return localize2.era(era, { width: "abbreviated" });
20660 // A, B
20661 case "GGGGG":
20662 return localize2.era(era, { width: "narrow" });
20663 // Anno Domini, Before Christ
20664 case "GGGG":
20665 default:
20666 return localize2.era(era, { width: "wide" });
20667 }
20668 },
20669 // Year
20670 y: function(date, token, localize2) {
20671 if (token === "yo") {
20672 const signedYear = date.getFullYear();
20673 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20674 return localize2.ordinalNumber(year, { unit: "year" });
20675 }
20676 return lightFormatters.y(date, token);
20677 },
20678 // Local week-numbering year
20679 Y: function(date, token, localize2, options) {
20680 const signedWeekYear = getWeekYear(date, options);
20681 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
20682 if (token === "YY") {
20683 const twoDigitYear = weekYear % 100;
20684 return addLeadingZeros(twoDigitYear, 2);
20685 }
20686 if (token === "Yo") {
20687 return localize2.ordinalNumber(weekYear, { unit: "year" });
20688 }
20689 return addLeadingZeros(weekYear, token.length);
20690 },
20691 // ISO week-numbering year
20692 R: function(date, token) {
20693 const isoWeekYear = getISOWeekYear(date);
20694 return addLeadingZeros(isoWeekYear, token.length);
20695 },
20696 // Extended year. This is a single number designating the year of this calendar system.
20697 // The main difference between `y` and `u` localizers are B.C. years:
20698 // | Year | `y` | `u` |
20699 // |------|-----|-----|
20700 // | AC 1 | 1 | 1 |
20701 // | BC 1 | 1 | 0 |
20702 // | BC 2 | 2 | -1 |
20703 // Also `yy` always returns the last two digits of a year,
20704 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
20705 u: function(date, token) {
20706 const year = date.getFullYear();
20707 return addLeadingZeros(year, token.length);
20708 },
20709 // Quarter
20710 Q: function(date, token, localize2) {
20711 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20712 switch (token) {
20713 // 1, 2, 3, 4
20714 case "Q":
20715 return String(quarter);
20716 // 01, 02, 03, 04
20717 case "QQ":
20718 return addLeadingZeros(quarter, 2);
20719 // 1st, 2nd, 3rd, 4th
20720 case "Qo":
20721 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20722 // Q1, Q2, Q3, Q4
20723 case "QQQ":
20724 return localize2.quarter(quarter, {
20725 width: "abbreviated",
20726 context: "formatting"
20727 });
20728 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20729 case "QQQQQ":
20730 return localize2.quarter(quarter, {
20731 width: "narrow",
20732 context: "formatting"
20733 });
20734 // 1st quarter, 2nd quarter, ...
20735 case "QQQQ":
20736 default:
20737 return localize2.quarter(quarter, {
20738 width: "wide",
20739 context: "formatting"
20740 });
20741 }
20742 },
20743 // Stand-alone quarter
20744 q: function(date, token, localize2) {
20745 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20746 switch (token) {
20747 // 1, 2, 3, 4
20748 case "q":
20749 return String(quarter);
20750 // 01, 02, 03, 04
20751 case "qq":
20752 return addLeadingZeros(quarter, 2);
20753 // 1st, 2nd, 3rd, 4th
20754 case "qo":
20755 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20756 // Q1, Q2, Q3, Q4
20757 case "qqq":
20758 return localize2.quarter(quarter, {
20759 width: "abbreviated",
20760 context: "standalone"
20761 });
20762 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20763 case "qqqqq":
20764 return localize2.quarter(quarter, {
20765 width: "narrow",
20766 context: "standalone"
20767 });
20768 // 1st quarter, 2nd quarter, ...
20769 case "qqqq":
20770 default:
20771 return localize2.quarter(quarter, {
20772 width: "wide",
20773 context: "standalone"
20774 });
20775 }
20776 },
20777 // Month
20778 M: function(date, token, localize2) {
20779 const month = date.getMonth();
20780 switch (token) {
20781 case "M":
20782 case "MM":
20783 return lightFormatters.M(date, token);
20784 // 1st, 2nd, ..., 12th
20785 case "Mo":
20786 return localize2.ordinalNumber(month + 1, { unit: "month" });
20787 // Jan, Feb, ..., Dec
20788 case "MMM":
20789 return localize2.month(month, {
20790 width: "abbreviated",
20791 context: "formatting"
20792 });
20793 // J, F, ..., D
20794 case "MMMMM":
20795 return localize2.month(month, {
20796 width: "narrow",
20797 context: "formatting"
20798 });
20799 // January, February, ..., December
20800 case "MMMM":
20801 default:
20802 return localize2.month(month, { width: "wide", context: "formatting" });
20803 }
20804 },
20805 // Stand-alone month
20806 L: function(date, token, localize2) {
20807 const month = date.getMonth();
20808 switch (token) {
20809 // 1, 2, ..., 12
20810 case "L":
20811 return String(month + 1);
20812 // 01, 02, ..., 12
20813 case "LL":
20814 return addLeadingZeros(month + 1, 2);
20815 // 1st, 2nd, ..., 12th
20816 case "Lo":
20817 return localize2.ordinalNumber(month + 1, { unit: "month" });
20818 // Jan, Feb, ..., Dec
20819 case "LLL":
20820 return localize2.month(month, {
20821 width: "abbreviated",
20822 context: "standalone"
20823 });
20824 // J, F, ..., D
20825 case "LLLLL":
20826 return localize2.month(month, {
20827 width: "narrow",
20828 context: "standalone"
20829 });
20830 // January, February, ..., December
20831 case "LLLL":
20832 default:
20833 return localize2.month(month, { width: "wide", context: "standalone" });
20834 }
20835 },
20836 // Local week of year
20837 w: function(date, token, localize2, options) {
20838 const week = getWeek(date, options);
20839 if (token === "wo") {
20840 return localize2.ordinalNumber(week, { unit: "week" });
20841 }
20842 return addLeadingZeros(week, token.length);
20843 },
20844 // ISO week of year
20845 I: function(date, token, localize2) {
20846 const isoWeek = getISOWeek(date);
20847 if (token === "Io") {
20848 return localize2.ordinalNumber(isoWeek, { unit: "week" });
20849 }
20850 return addLeadingZeros(isoWeek, token.length);
20851 },
20852 // Day of the month
20853 d: function(date, token, localize2) {
20854 if (token === "do") {
20855 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
20856 }
20857 return lightFormatters.d(date, token);
20858 },
20859 // Day of year
20860 D: function(date, token, localize2) {
20861 const dayOfYear = getDayOfYear(date);
20862 if (token === "Do") {
20863 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
20864 }
20865 return addLeadingZeros(dayOfYear, token.length);
20866 },
20867 // Day of week
20868 E: function(date, token, localize2) {
20869 const dayOfWeek = date.getDay();
20870 switch (token) {
20871 // Tue
20872 case "E":
20873 case "EE":
20874 case "EEE":
20875 return localize2.day(dayOfWeek, {
20876 width: "abbreviated",
20877 context: "formatting"
20878 });
20879 // T
20880 case "EEEEE":
20881 return localize2.day(dayOfWeek, {
20882 width: "narrow",
20883 context: "formatting"
20884 });
20885 // Tu
20886 case "EEEEEE":
20887 return localize2.day(dayOfWeek, {
20888 width: "short",
20889 context: "formatting"
20890 });
20891 // Tuesday
20892 case "EEEE":
20893 default:
20894 return localize2.day(dayOfWeek, {
20895 width: "wide",
20896 context: "formatting"
20897 });
20898 }
20899 },
20900 // Local day of week
20901 e: function(date, token, localize2, options) {
20902 const dayOfWeek = date.getDay();
20903 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20904 switch (token) {
20905 // Numerical value (Nth day of week with current locale or weekStartsOn)
20906 case "e":
20907 return String(localDayOfWeek);
20908 // Padded numerical value
20909 case "ee":
20910 return addLeadingZeros(localDayOfWeek, 2);
20911 // 1st, 2nd, ..., 7th
20912 case "eo":
20913 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20914 case "eee":
20915 return localize2.day(dayOfWeek, {
20916 width: "abbreviated",
20917 context: "formatting"
20918 });
20919 // T
20920 case "eeeee":
20921 return localize2.day(dayOfWeek, {
20922 width: "narrow",
20923 context: "formatting"
20924 });
20925 // Tu
20926 case "eeeeee":
20927 return localize2.day(dayOfWeek, {
20928 width: "short",
20929 context: "formatting"
20930 });
20931 // Tuesday
20932 case "eeee":
20933 default:
20934 return localize2.day(dayOfWeek, {
20935 width: "wide",
20936 context: "formatting"
20937 });
20938 }
20939 },
20940 // Stand-alone local day of week
20941 c: function(date, token, localize2, options) {
20942 const dayOfWeek = date.getDay();
20943 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20944 switch (token) {
20945 // Numerical value (same as in `e`)
20946 case "c":
20947 return String(localDayOfWeek);
20948 // Padded numerical value
20949 case "cc":
20950 return addLeadingZeros(localDayOfWeek, token.length);
20951 // 1st, 2nd, ..., 7th
20952 case "co":
20953 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20954 case "ccc":
20955 return localize2.day(dayOfWeek, {
20956 width: "abbreviated",
20957 context: "standalone"
20958 });
20959 // T
20960 case "ccccc":
20961 return localize2.day(dayOfWeek, {
20962 width: "narrow",
20963 context: "standalone"
20964 });
20965 // Tu
20966 case "cccccc":
20967 return localize2.day(dayOfWeek, {
20968 width: "short",
20969 context: "standalone"
20970 });
20971 // Tuesday
20972 case "cccc":
20973 default:
20974 return localize2.day(dayOfWeek, {
20975 width: "wide",
20976 context: "standalone"
20977 });
20978 }
20979 },
20980 // ISO day of week
20981 i: function(date, token, localize2) {
20982 const dayOfWeek = date.getDay();
20983 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
20984 switch (token) {
20985 // 2
20986 case "i":
20987 return String(isoDayOfWeek);
20988 // 02
20989 case "ii":
20990 return addLeadingZeros(isoDayOfWeek, token.length);
20991 // 2nd
20992 case "io":
20993 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
20994 // Tue
20995 case "iii":
20996 return localize2.day(dayOfWeek, {
20997 width: "abbreviated",
20998 context: "formatting"
20999 });
21000 // T
21001 case "iiiii":
21002 return localize2.day(dayOfWeek, {
21003 width: "narrow",
21004 context: "formatting"
21005 });
21006 // Tu
21007 case "iiiiii":
21008 return localize2.day(dayOfWeek, {
21009 width: "short",
21010 context: "formatting"
21011 });
21012 // Tuesday
21013 case "iiii":
21014 default:
21015 return localize2.day(dayOfWeek, {
21016 width: "wide",
21017 context: "formatting"
21018 });
21019 }
21020 },
21021 // AM or PM
21022 a: function(date, token, localize2) {
21023 const hours = date.getHours();
21024 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
21025 switch (token) {
21026 case "a":
21027 case "aa":
21028 return localize2.dayPeriod(dayPeriodEnumValue, {
21029 width: "abbreviated",
21030 context: "formatting"
21031 });
21032 case "aaa":
21033 return localize2.dayPeriod(dayPeriodEnumValue, {
21034 width: "abbreviated",
21035 context: "formatting"
21036 }).toLowerCase();
21037 case "aaaaa":
21038 return localize2.dayPeriod(dayPeriodEnumValue, {
21039 width: "narrow",
21040 context: "formatting"
21041 });
21042 case "aaaa":
21043 default:
21044 return localize2.dayPeriod(dayPeriodEnumValue, {
21045 width: "wide",
21046 context: "formatting"
21047 });
21048 }
21049 },
21050 // AM, PM, midnight, noon
21051 b: function(date, token, localize2) {
21052 const hours = date.getHours();
21053 let dayPeriodEnumValue;
21054 if (hours === 12) {
21055 dayPeriodEnumValue = dayPeriodEnum.noon;
21056 } else if (hours === 0) {
21057 dayPeriodEnumValue = dayPeriodEnum.midnight;
21058 } else {
21059 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
21060 }
21061 switch (token) {
21062 case "b":
21063 case "bb":
21064 return localize2.dayPeriod(dayPeriodEnumValue, {
21065 width: "abbreviated",
21066 context: "formatting"
21067 });
21068 case "bbb":
21069 return localize2.dayPeriod(dayPeriodEnumValue, {
21070 width: "abbreviated",
21071 context: "formatting"
21072 }).toLowerCase();
21073 case "bbbbb":
21074 return localize2.dayPeriod(dayPeriodEnumValue, {
21075 width: "narrow",
21076 context: "formatting"
21077 });
21078 case "bbbb":
21079 default:
21080 return localize2.dayPeriod(dayPeriodEnumValue, {
21081 width: "wide",
21082 context: "formatting"
21083 });
21084 }
21085 },
21086 // in the morning, in the afternoon, in the evening, at night
21087 B: function(date, token, localize2) {
21088 const hours = date.getHours();
21089 let dayPeriodEnumValue;
21090 if (hours >= 17) {
21091 dayPeriodEnumValue = dayPeriodEnum.evening;
21092 } else if (hours >= 12) {
21093 dayPeriodEnumValue = dayPeriodEnum.afternoon;
21094 } else if (hours >= 4) {
21095 dayPeriodEnumValue = dayPeriodEnum.morning;
21096 } else {
21097 dayPeriodEnumValue = dayPeriodEnum.night;
21098 }
21099 switch (token) {
21100 case "B":
21101 case "BB":
21102 case "BBB":
21103 return localize2.dayPeriod(dayPeriodEnumValue, {
21104 width: "abbreviated",
21105 context: "formatting"
21106 });
21107 case "BBBBB":
21108 return localize2.dayPeriod(dayPeriodEnumValue, {
21109 width: "narrow",
21110 context: "formatting"
21111 });
21112 case "BBBB":
21113 default:
21114 return localize2.dayPeriod(dayPeriodEnumValue, {
21115 width: "wide",
21116 context: "formatting"
21117 });
21118 }
21119 },
21120 // Hour [1-12]
21121 h: function(date, token, localize2) {
21122 if (token === "ho") {
21123 let hours = date.getHours() % 12;
21124 if (hours === 0) hours = 12;
21125 return localize2.ordinalNumber(hours, { unit: "hour" });
21126 }
21127 return lightFormatters.h(date, token);
21128 },
21129 // Hour [0-23]
21130 H: function(date, token, localize2) {
21131 if (token === "Ho") {
21132 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
21133 }
21134 return lightFormatters.H(date, token);
21135 },
21136 // Hour [0-11]
21137 K: function(date, token, localize2) {
21138 const hours = date.getHours() % 12;
21139 if (token === "Ko") {
21140 return localize2.ordinalNumber(hours, { unit: "hour" });
21141 }
21142 return addLeadingZeros(hours, token.length);
21143 },
21144 // Hour [1-24]
21145 k: function(date, token, localize2) {
21146 let hours = date.getHours();
21147 if (hours === 0) hours = 24;
21148 if (token === "ko") {
21149 return localize2.ordinalNumber(hours, { unit: "hour" });
21150 }
21151 return addLeadingZeros(hours, token.length);
21152 },
21153 // Minute
21154 m: function(date, token, localize2) {
21155 if (token === "mo") {
21156 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
21157 }
21158 return lightFormatters.m(date, token);
21159 },
21160 // Second
21161 s: function(date, token, localize2) {
21162 if (token === "so") {
21163 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
21164 }
21165 return lightFormatters.s(date, token);
21166 },
21167 // Fraction of second
21168 S: function(date, token) {
21169 return lightFormatters.S(date, token);
21170 },
21171 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
21172 X: function(date, token, _localize) {
21173 const timezoneOffset = date.getTimezoneOffset();
21174 if (timezoneOffset === 0) {
21175 return "Z";
21176 }
21177 switch (token) {
21178 // Hours and optional minutes
21179 case "X":
21180 return formatTimezoneWithOptionalMinutes(timezoneOffset);
21181 // Hours, minutes and optional seconds without `:` delimiter
21182 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21183 // so this token always has the same output as `XX`
21184 case "XXXX":
21185 case "XX":
21186 return formatTimezone(timezoneOffset);
21187 // Hours, minutes and optional seconds with `:` delimiter
21188 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21189 // so this token always has the same output as `XXX`
21190 case "XXXXX":
21191 case "XXX":
21192 // Hours and minutes with `:` delimiter
21193 default:
21194 return formatTimezone(timezoneOffset, ":");
21195 }
21196 },
21197 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
21198 x: function(date, token, _localize) {
21199 const timezoneOffset = date.getTimezoneOffset();
21200 switch (token) {
21201 // Hours and optional minutes
21202 case "x":
21203 return formatTimezoneWithOptionalMinutes(timezoneOffset);
21204 // Hours, minutes and optional seconds without `:` delimiter
21205 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21206 // so this token always has the same output as `xx`
21207 case "xxxx":
21208 case "xx":
21209 return formatTimezone(timezoneOffset);
21210 // Hours, minutes and optional seconds with `:` delimiter
21211 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21212 // so this token always has the same output as `xxx`
21213 case "xxxxx":
21214 case "xxx":
21215 // Hours and minutes with `:` delimiter
21216 default:
21217 return formatTimezone(timezoneOffset, ":");
21218 }
21219 },
21220 // Timezone (GMT)
21221 O: function(date, token, _localize) {
21222 const timezoneOffset = date.getTimezoneOffset();
21223 switch (token) {
21224 // Short
21225 case "O":
21226 case "OO":
21227 case "OOO":
21228 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
21229 // Long
21230 case "OOOO":
21231 default:
21232 return "GMT" + formatTimezone(timezoneOffset, ":");
21233 }
21234 },
21235 // Timezone (specific non-location)
21236 z: function(date, token, _localize) {
21237 const timezoneOffset = date.getTimezoneOffset();
21238 switch (token) {
21239 // Short
21240 case "z":
21241 case "zz":
21242 case "zzz":
21243 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
21244 // Long
21245 case "zzzz":
21246 default:
21247 return "GMT" + formatTimezone(timezoneOffset, ":");
21248 }
21249 },
21250 // Seconds timestamp
21251 t: function(date, token, _localize) {
21252 const timestamp = Math.trunc(+date / 1e3);
21253 return addLeadingZeros(timestamp, token.length);
21254 },
21255 // Milliseconds timestamp
21256 T: function(date, token, _localize) {
21257 return addLeadingZeros(+date, token.length);
21258 }
21259 };
21260 function formatTimezoneShort(offset4, delimiter = "") {
21261 const sign = offset4 > 0 ? "-" : "+";
21262 const absOffset = Math.abs(offset4);
21263 const hours = Math.trunc(absOffset / 60);
21264 const minutes = absOffset % 60;
21265 if (minutes === 0) {
21266 return sign + String(hours);
21267 }
21268 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
21269 }
21270 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
21271 if (offset4 % 60 === 0) {
21272 const sign = offset4 > 0 ? "-" : "+";
21273 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
21274 }
21275 return formatTimezone(offset4, delimiter);
21276 }
21277 function formatTimezone(offset4, delimiter = "") {
21278 const sign = offset4 > 0 ? "-" : "+";
21279 const absOffset = Math.abs(offset4);
21280 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
21281 const minutes = addLeadingZeros(absOffset % 60, 2);
21282 return sign + hours + delimiter + minutes;
21283 }
21284
21285 // node_modules/date-fns/_lib/format/longFormatters.js
21286 var dateLongFormatter = (pattern, formatLong2) => {
21287 switch (pattern) {
21288 case "P":
21289 return formatLong2.date({ width: "short" });
21290 case "PP":
21291 return formatLong2.date({ width: "medium" });
21292 case "PPP":
21293 return formatLong2.date({ width: "long" });
21294 case "PPPP":
21295 default:
21296 return formatLong2.date({ width: "full" });
21297 }
21298 };
21299 var timeLongFormatter = (pattern, formatLong2) => {
21300 switch (pattern) {
21301 case "p":
21302 return formatLong2.time({ width: "short" });
21303 case "pp":
21304 return formatLong2.time({ width: "medium" });
21305 case "ppp":
21306 return formatLong2.time({ width: "long" });
21307 case "pppp":
21308 default:
21309 return formatLong2.time({ width: "full" });
21310 }
21311 };
21312 var dateTimeLongFormatter = (pattern, formatLong2) => {
21313 const matchResult = pattern.match(/(P+)(p+)?/) || [];
21314 const datePattern = matchResult[1];
21315 const timePattern = matchResult[2];
21316 if (!timePattern) {
21317 return dateLongFormatter(pattern, formatLong2);
21318 }
21319 let dateTimeFormat;
21320 switch (datePattern) {
21321 case "P":
21322 dateTimeFormat = formatLong2.dateTime({ width: "short" });
21323 break;
21324 case "PP":
21325 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
21326 break;
21327 case "PPP":
21328 dateTimeFormat = formatLong2.dateTime({ width: "long" });
21329 break;
21330 case "PPPP":
21331 default:
21332 dateTimeFormat = formatLong2.dateTime({ width: "full" });
21333 break;
21334 }
21335 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
21336 };
21337 var longFormatters = {
21338 p: timeLongFormatter,
21339 P: dateTimeLongFormatter
21340 };
21341
21342 // node_modules/date-fns/_lib/protectedTokens.js
21343 var dayOfYearTokenRE = /^D+$/;
21344 var weekYearTokenRE = /^Y+$/;
21345 var throwTokens = ["D", "DD", "YY", "YYYY"];
21346 function isProtectedDayOfYearToken(token) {
21347 return dayOfYearTokenRE.test(token);
21348 }
21349 function isProtectedWeekYearToken(token) {
21350 return weekYearTokenRE.test(token);
21351 }
21352 function warnOrThrowProtectedError(token, format6, input) {
21353 const _message = message(token, format6, input);
21354 console.warn(_message);
21355 if (throwTokens.includes(token)) throw new RangeError(_message);
21356 }
21357 function message(token, format6, input) {
21358 const subject = token[0] === "Y" ? "years" : "days of the month";
21359 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`;
21360 }
21361
21362 // node_modules/date-fns/format.js
21363 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
21364 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
21365 var escapedStringRegExp = /^'([^]*?)'?$/;
21366 var doubleQuoteRegExp = /''/g;
21367 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
21368 function format(date, formatStr, options) {
21369 const defaultOptions2 = getDefaultOptions();
21370 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
21371 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
21372 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
21373 const originalDate = toDate(date, options?.in);
21374 if (!isValid(originalDate)) {
21375 throw new RangeError("Invalid time value");
21376 }
21377 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
21378 const firstCharacter = substring[0];
21379 if (firstCharacter === "p" || firstCharacter === "P") {
21380 const longFormatter = longFormatters[firstCharacter];
21381 return longFormatter(substring, locale.formatLong);
21382 }
21383 return substring;
21384 }).join("").match(formattingTokensRegExp).map((substring) => {
21385 if (substring === "''") {
21386 return { isToken: false, value: "'" };
21387 }
21388 const firstCharacter = substring[0];
21389 if (firstCharacter === "'") {
21390 return { isToken: false, value: cleanEscapedString(substring) };
21391 }
21392 if (formatters[firstCharacter]) {
21393 return { isToken: true, value: substring };
21394 }
21395 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
21396 throw new RangeError(
21397 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
21398 );
21399 }
21400 return { isToken: false, value: substring };
21401 });
21402 if (locale.localize.preprocessor) {
21403 parts = locale.localize.preprocessor(originalDate, parts);
21404 }
21405 const formatterOptions = {
21406 firstWeekContainsDate,
21407 weekStartsOn,
21408 locale
21409 };
21410 return parts.map((part) => {
21411 if (!part.isToken) return part.value;
21412 const token = part.value;
21413 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
21414 warnOrThrowProtectedError(token, formatStr, String(date));
21415 }
21416 const formatter = formatters[token[0]];
21417 return formatter(originalDate, token, locale.localize, formatterOptions);
21418 }).join("");
21419 }
21420 function cleanEscapedString(input) {
21421 const matched = input.match(escapedStringRegExp);
21422 if (!matched) {
21423 return input;
21424 }
21425 return matched[1].replace(doubleQuoteRegExp, "'");
21426 }
21427
21428 // node_modules/date-fns/subDays.js
21429 function subDays(date, amount, options) {
21430 return addDays(date, -amount, options);
21431 }
21432
21433 // node_modules/date-fns/subMonths.js
21434 function subMonths(date, amount, options) {
21435 return addMonths(date, -amount, options);
21436 }
21437
21438 // node_modules/date-fns/subWeeks.js
21439 function subWeeks(date, amount, options) {
21440 return addWeeks(date, -amount, options);
21441 }
21442
21443 // node_modules/date-fns/subYears.js
21444 function subYears(date, amount, options) {
21445 return addYears(date, -amount, options);
21446 }
21447
21448 // packages/dataviews/build-module/utils/operators.mjs
21449 var import_i18n25 = __toESM(require_i18n(), 1);
21450 var import_element53 = __toESM(require_element(), 1);
21451 var import_date = __toESM(require_date(), 1);
21452 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
21453 var filterTextWrappers = {
21454 Name: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
21455 Value: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
21456 };
21457 function getRelativeDate(value, unit) {
21458 switch (unit) {
21459 case "days":
21460 return subDays(/* @__PURE__ */ new Date(), value);
21461 case "weeks":
21462 return subWeeks(/* @__PURE__ */ new Date(), value);
21463 case "months":
21464 return subMonths(/* @__PURE__ */ new Date(), value);
21465 case "years":
21466 return subYears(/* @__PURE__ */ new Date(), value);
21467 default:
21468 return /* @__PURE__ */ new Date();
21469 }
21470 }
21471 var isNoneOperatorDefinition = {
21472 /* translators: DataViews operator name */
21473 label: (0, import_i18n25.__)("Is none of"),
21474 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21475 (0, import_i18n25.sprintf)(
21476 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
21477 (0, import_i18n25.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
21478 filter.name,
21479 activeElements.map((element) => element.label).join(", ")
21480 ),
21481 filterTextWrappers
21482 ),
21483 filter: ((item, field, filterValue) => {
21484 if (!filterValue?.length) {
21485 return true;
21486 }
21487 const fieldValue = field.getValue({ item });
21488 if (Array.isArray(fieldValue)) {
21489 return !filterValue.some(
21490 (fv) => fieldValue.includes(fv)
21491 );
21492 } else if (typeof fieldValue === "string") {
21493 return !filterValue.includes(fieldValue);
21494 }
21495 return false;
21496 }),
21497 selection: "multi"
21498 };
21499 var OPERATORS = [
21500 {
21501 name: OPERATOR_IS_ANY,
21502 /* translators: DataViews operator name */
21503 label: (0, import_i18n25.__)("Includes"),
21504 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21505 (0, import_i18n25.sprintf)(
21506 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
21507 (0, import_i18n25.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
21508 filter.name,
21509 activeElements.map((element) => element.label).join(", ")
21510 ),
21511 filterTextWrappers
21512 ),
21513 filter(item, field, filterValue) {
21514 if (!filterValue?.length) {
21515 return true;
21516 }
21517 const fieldValue = field.getValue({ item });
21518 if (Array.isArray(fieldValue)) {
21519 return filterValue.some(
21520 (fv) => fieldValue.includes(fv)
21521 );
21522 } else if (typeof fieldValue === "string") {
21523 return filterValue.includes(fieldValue);
21524 }
21525 return false;
21526 },
21527 selection: "multi"
21528 },
21529 {
21530 name: OPERATOR_IS_NONE,
21531 ...isNoneOperatorDefinition
21532 },
21533 {
21534 name: OPERATOR_IS_ALL,
21535 /* translators: DataViews operator name */
21536 label: (0, import_i18n25.__)("Includes all"),
21537 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21538 (0, import_i18n25.sprintf)(
21539 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
21540 (0, import_i18n25.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
21541 filter.name,
21542 activeElements.map((element) => element.label).join(", ")
21543 ),
21544 filterTextWrappers
21545 ),
21546 filter(item, field, filterValue) {
21547 if (!filterValue?.length) {
21548 return true;
21549 }
21550 return filterValue.every((value) => {
21551 return field.getValue({ item })?.includes(value);
21552 });
21553 },
21554 selection: "multi"
21555 },
21556 {
21557 name: OPERATOR_IS_NOT_ALL,
21558 ...isNoneOperatorDefinition
21559 },
21560 {
21561 name: OPERATOR_BETWEEN,
21562 /* translators: DataViews operator name */
21563 label: (0, import_i18n25.__)("Between (inc)"),
21564 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21565 (0, import_i18n25.sprintf)(
21566 /* 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". */
21567 (0, import_i18n25.__)(
21568 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
21569 ),
21570 filter.name,
21571 activeElements[0].label[0],
21572 activeElements[0].label[1]
21573 ),
21574 filterTextWrappers
21575 ),
21576 filter(item, field, filterValue) {
21577 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
21578 return true;
21579 }
21580 const fieldValue = field.getValue({ item });
21581 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
21582 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
21583 }
21584 return false;
21585 },
21586 selection: "custom"
21587 },
21588 {
21589 name: OPERATOR_IN_THE_PAST,
21590 /* translators: DataViews operator name */
21591 label: (0, import_i18n25.__)("In the past"),
21592 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21593 (0, import_i18n25.sprintf)(
21594 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
21595 (0, import_i18n25.__)(
21596 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
21597 ),
21598 filter.name,
21599 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21600 ),
21601 filterTextWrappers
21602 ),
21603 filter(item, field, filterValue) {
21604 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21605 return true;
21606 }
21607 const targetDate = getRelativeDate(
21608 filterValue.value,
21609 filterValue.unit
21610 );
21611 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21612 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
21613 },
21614 selection: "custom"
21615 },
21616 {
21617 name: OPERATOR_OVER,
21618 /* translators: DataViews operator name */
21619 label: (0, import_i18n25.__)("Over"),
21620 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21621 (0, import_i18n25.sprintf)(
21622 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
21623 (0, import_i18n25.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
21624 filter.name,
21625 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21626 ),
21627 filterTextWrappers
21628 ),
21629 filter(item, field, filterValue) {
21630 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21631 return true;
21632 }
21633 const targetDate = getRelativeDate(
21634 filterValue.value,
21635 filterValue.unit
21636 );
21637 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21638 return fieldValue < targetDate;
21639 },
21640 selection: "custom"
21641 },
21642 {
21643 name: OPERATOR_IS,
21644 /* translators: DataViews operator name */
21645 label: (0, import_i18n25.__)("Is"),
21646 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21647 (0, import_i18n25.sprintf)(
21648 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
21649 (0, import_i18n25.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21650 filter.name,
21651 activeElements[0].label
21652 ),
21653 filterTextWrappers
21654 ),
21655 filter(item, field, filterValue) {
21656 return filterValue === field.getValue({ item }) || filterValue === void 0;
21657 },
21658 selection: "single"
21659 },
21660 {
21661 name: OPERATOR_IS_NOT,
21662 /* translators: DataViews operator name */
21663 label: (0, import_i18n25.__)("Is not"),
21664 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21665 (0, import_i18n25.sprintf)(
21666 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
21667 (0, import_i18n25.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21668 filter.name,
21669 activeElements[0].label
21670 ),
21671 filterTextWrappers
21672 ),
21673 filter(item, field, filterValue) {
21674 return filterValue !== field.getValue({ item });
21675 },
21676 selection: "single"
21677 },
21678 {
21679 name: OPERATOR_LESS_THAN,
21680 /* translators: DataViews operator name */
21681 label: (0, import_i18n25.__)("Less than"),
21682 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21683 (0, import_i18n25.sprintf)(
21684 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
21685 (0, import_i18n25.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
21686 filter.name,
21687 activeElements[0].label
21688 ),
21689 filterTextWrappers
21690 ),
21691 filter(item, field, filterValue) {
21692 if (filterValue === void 0) {
21693 return true;
21694 }
21695 const fieldValue = field.getValue({ item });
21696 return fieldValue < filterValue;
21697 },
21698 selection: "single"
21699 },
21700 {
21701 name: OPERATOR_GREATER_THAN,
21702 /* translators: DataViews operator name */
21703 label: (0, import_i18n25.__)("Greater than"),
21704 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21705 (0, import_i18n25.sprintf)(
21706 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
21707 (0, import_i18n25.__)(
21708 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
21709 ),
21710 filter.name,
21711 activeElements[0].label
21712 ),
21713 filterTextWrappers
21714 ),
21715 filter(item, field, filterValue) {
21716 if (filterValue === void 0) {
21717 return true;
21718 }
21719 const fieldValue = field.getValue({ item });
21720 return fieldValue > filterValue;
21721 },
21722 selection: "single"
21723 },
21724 {
21725 name: OPERATOR_LESS_THAN_OR_EQUAL,
21726 /* translators: DataViews operator name */
21727 label: (0, import_i18n25.__)("Less than or equal"),
21728 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21729 (0, import_i18n25.sprintf)(
21730 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
21731 (0, import_i18n25.__)(
21732 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
21733 ),
21734 filter.name,
21735 activeElements[0].label
21736 ),
21737 filterTextWrappers
21738 ),
21739 filter(item, field, filterValue) {
21740 if (filterValue === void 0) {
21741 return true;
21742 }
21743 const fieldValue = field.getValue({ item });
21744 return fieldValue <= filterValue;
21745 },
21746 selection: "single"
21747 },
21748 {
21749 name: OPERATOR_GREATER_THAN_OR_EQUAL,
21750 /* translators: DataViews operator name */
21751 label: (0, import_i18n25.__)("Greater than or equal"),
21752 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21753 (0, import_i18n25.sprintf)(
21754 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
21755 (0, import_i18n25.__)(
21756 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
21757 ),
21758 filter.name,
21759 activeElements[0].label
21760 ),
21761 filterTextWrappers
21762 ),
21763 filter(item, field, filterValue) {
21764 if (filterValue === void 0) {
21765 return true;
21766 }
21767 const fieldValue = field.getValue({ item });
21768 return fieldValue >= filterValue;
21769 },
21770 selection: "single"
21771 },
21772 {
21773 name: OPERATOR_BEFORE,
21774 /* translators: DataViews operator name */
21775 label: (0, import_i18n25.__)("Before"),
21776 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21777 (0, import_i18n25.sprintf)(
21778 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
21779 (0, import_i18n25.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
21780 filter.name,
21781 activeElements[0].label
21782 ),
21783 filterTextWrappers
21784 ),
21785 filter(item, field, filterValue) {
21786 if (filterValue === void 0) {
21787 return true;
21788 }
21789 const filterDate = (0, import_date.getDate)(filterValue);
21790 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21791 return fieldDate < filterDate;
21792 },
21793 selection: "single"
21794 },
21795 {
21796 name: OPERATOR_AFTER,
21797 /* translators: DataViews operator name */
21798 label: (0, import_i18n25.__)("After"),
21799 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21800 (0, import_i18n25.sprintf)(
21801 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
21802 (0, import_i18n25.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
21803 filter.name,
21804 activeElements[0].label
21805 ),
21806 filterTextWrappers
21807 ),
21808 filter(item, field, filterValue) {
21809 if (filterValue === void 0) {
21810 return true;
21811 }
21812 const filterDate = (0, import_date.getDate)(filterValue);
21813 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21814 return fieldDate > filterDate;
21815 },
21816 selection: "single"
21817 },
21818 {
21819 name: OPERATOR_BEFORE_INC,
21820 /* translators: DataViews operator name */
21821 label: (0, import_i18n25.__)("Before (inc)"),
21822 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21823 (0, import_i18n25.sprintf)(
21824 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
21825 (0, import_i18n25.__)(
21826 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
21827 ),
21828 filter.name,
21829 activeElements[0].label
21830 ),
21831 filterTextWrappers
21832 ),
21833 filter(item, field, filterValue) {
21834 if (filterValue === void 0) {
21835 return true;
21836 }
21837 const filterDate = (0, import_date.getDate)(filterValue);
21838 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21839 return fieldDate <= filterDate;
21840 },
21841 selection: "single"
21842 },
21843 {
21844 name: OPERATOR_AFTER_INC,
21845 /* translators: DataViews operator name */
21846 label: (0, import_i18n25.__)("After (inc)"),
21847 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21848 (0, import_i18n25.sprintf)(
21849 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
21850 (0, import_i18n25.__)(
21851 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
21852 ),
21853 filter.name,
21854 activeElements[0].label
21855 ),
21856 filterTextWrappers
21857 ),
21858 filter(item, field, filterValue) {
21859 if (filterValue === void 0) {
21860 return true;
21861 }
21862 const filterDate = (0, import_date.getDate)(filterValue);
21863 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21864 return fieldDate >= filterDate;
21865 },
21866 selection: "single"
21867 },
21868 {
21869 name: OPERATOR_CONTAINS,
21870 /* translators: DataViews operator name */
21871 label: (0, import_i18n25.__)("Contains"),
21872 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21873 (0, import_i18n25.sprintf)(
21874 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
21875 (0, import_i18n25.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
21876 filter.name,
21877 activeElements[0].label
21878 ),
21879 filterTextWrappers
21880 ),
21881 filter(item, field, filterValue) {
21882 if (filterValue === void 0) {
21883 return true;
21884 }
21885 const fieldValue = field.getValue({ item });
21886 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21887 },
21888 selection: "single"
21889 },
21890 {
21891 name: OPERATOR_NOT_CONTAINS,
21892 /* translators: DataViews operator name */
21893 label: (0, import_i18n25.__)("Doesn't contain"),
21894 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21895 (0, import_i18n25.sprintf)(
21896 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
21897 (0, import_i18n25.__)(
21898 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
21899 ),
21900 filter.name,
21901 activeElements[0].label
21902 ),
21903 filterTextWrappers
21904 ),
21905 filter(item, field, filterValue) {
21906 if (filterValue === void 0) {
21907 return true;
21908 }
21909 const fieldValue = field.getValue({ item });
21910 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21911 },
21912 selection: "single"
21913 },
21914 {
21915 name: OPERATOR_STARTS_WITH,
21916 /* translators: DataViews operator name */
21917 label: (0, import_i18n25.__)("Starts with"),
21918 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21919 (0, import_i18n25.sprintf)(
21920 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
21921 (0, import_i18n25.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
21922 filter.name,
21923 activeElements[0].label
21924 ),
21925 filterTextWrappers
21926 ),
21927 filter(item, field, filterValue) {
21928 if (filterValue === void 0) {
21929 return true;
21930 }
21931 const fieldValue = field.getValue({ item });
21932 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
21933 },
21934 selection: "single"
21935 },
21936 {
21937 name: OPERATOR_ON,
21938 /* translators: DataViews operator name */
21939 label: (0, import_i18n25.__)("On"),
21940 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21941 (0, import_i18n25.sprintf)(
21942 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
21943 (0, import_i18n25.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21944 filter.name,
21945 activeElements[0].label
21946 ),
21947 filterTextWrappers
21948 ),
21949 filter(item, field, filterValue) {
21950 if (filterValue === void 0) {
21951 return true;
21952 }
21953 const filterDate = (0, import_date.getDate)(filterValue);
21954 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21955 return filterDate.getTime() === fieldDate.getTime();
21956 },
21957 selection: "single"
21958 },
21959 {
21960 name: OPERATOR_NOT_ON,
21961 /* translators: DataViews operator name */
21962 label: (0, import_i18n25.__)("Not on"),
21963 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21964 (0, import_i18n25.sprintf)(
21965 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
21966 (0, import_i18n25.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21967 filter.name,
21968 activeElements[0].label
21969 ),
21970 filterTextWrappers
21971 ),
21972 filter(item, field, filterValue) {
21973 if (filterValue === void 0) {
21974 return true;
21975 }
21976 const filterDate = (0, import_date.getDate)(filterValue);
21977 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21978 return filterDate.getTime() !== fieldDate.getTime();
21979 },
21980 selection: "single"
21981 }
21982 ];
21983 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
21984 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
21985 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
21986 (op) => op.name === name
21987 );
21988 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
21989
21990 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
21991 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
21992 var ENTER = "Enter";
21993 var SPACE = " ";
21994 var FilterText = ({
21995 activeElements,
21996 filterInView,
21997 filter
21998 }) => {
21999 if (activeElements === void 0 || activeElements.length === 0) {
22000 return filter.name;
22001 }
22002 const operator = getOperatorByName(filterInView?.operator);
22003 if (operator !== void 0) {
22004 return operator.filterText(filter, activeElements);
22005 }
22006 return (0, import_i18n26.sprintf)(
22007 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
22008 (0, import_i18n26.__)("Unknown status for %1$s"),
22009 filter.name
22010 );
22011 };
22012 function OperatorSelector({
22013 filter,
22014 view,
22015 onChangeView
22016 }) {
22017 const operatorOptions = filter.operators?.map((operator) => ({
22018 value: operator,
22019 label: getOperatorByName(operator)?.label || operator
22020 }));
22021 const currentFilter = view.filters?.find(
22022 (_filter) => _filter.field === filter.field
22023 );
22024 const value = currentFilter?.operator || filter.operators[0];
22025 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
22026 Stack,
22027 {
22028 direction: "row",
22029 gap: "sm",
22030 justify: "flex-start",
22031 className: "dataviews-filters__summary-operators-container",
22032 align: "center",
22033 children: [
22034 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components21.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
22035 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22036 import_components21.SelectControl,
22037 {
22038 className: "dataviews-filters__summary-operators-filter-select",
22039 label: (0, import_i18n26.__)("Conditions"),
22040 value,
22041 options: operatorOptions,
22042 onChange: (newValue) => {
22043 const newOperator = newValue;
22044 const currentOperator = currentFilter?.operator;
22045 const newFilters = currentFilter ? [
22046 ...(view.filters ?? []).map(
22047 (_filter) => {
22048 if (_filter.field === filter.field) {
22049 const currentOpSelectionModel = getOperatorByName(
22050 currentOperator
22051 )?.selection;
22052 const newOpSelectionModel = getOperatorByName(
22053 newOperator
22054 )?.selection;
22055 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
22056 currentOpSelectionModel,
22057 newOpSelectionModel
22058 ].includes("custom");
22059 return {
22060 ..._filter,
22061 value: shouldResetValue ? void 0 : _filter.value,
22062 operator: newOperator
22063 };
22064 }
22065 return _filter;
22066 }
22067 )
22068 ] : [
22069 ...view.filters ?? [],
22070 {
22071 field: filter.field,
22072 operator: newOperator,
22073 value: void 0
22074 }
22075 ];
22076 onChangeView({
22077 ...view,
22078 page: 1,
22079 filters: newFilters
22080 });
22081 },
22082 size: "small",
22083 variant: "minimal",
22084 hideLabelFromVision: true
22085 }
22086 )
22087 ]
22088 }
22089 );
22090 }
22091 function Filter({
22092 addFilterRef,
22093 openedFilter,
22094 fields,
22095 ...commonProps
22096 }) {
22097 const toggleRef = (0, import_element54.useRef)(null);
22098 const { filter, view, onChangeView } = commonProps;
22099 const filterInView = view.filters?.find(
22100 (f2) => f2.field === filter.field
22101 );
22102 let activeElements = [];
22103 const field = (0, import_element54.useMemo)(() => {
22104 const currentField = fields.find((f2) => f2.id === filter.field);
22105 if (currentField) {
22106 return {
22107 ...currentField,
22108 // Configure getValue as if Item was a plain object.
22109 // See related input-widget.tsx
22110 getValue: ({ item }) => item[currentField.id]
22111 };
22112 }
22113 return currentField;
22114 }, [fields, filter.field]);
22115 const { elements } = useElements({
22116 elements: filter.elements,
22117 getElements: filter.getElements
22118 });
22119 if (elements.length > 0) {
22120 activeElements = elements.filter((element) => {
22121 if (filter.singleSelection) {
22122 return element.value === filterInView?.value;
22123 }
22124 return filterInView?.value?.includes(element.value);
22125 });
22126 } else if (Array.isArray(filterInView?.value)) {
22127 const label = filterInView.value.map((v2) => {
22128 const formattedValue = field?.getValueFormatted({
22129 item: { [field.id]: v2 },
22130 field
22131 });
22132 return formattedValue || String(v2);
22133 });
22134 activeElements = [
22135 {
22136 value: filterInView.value,
22137 // @ts-ignore
22138 label
22139 }
22140 ];
22141 } else if (typeof filterInView?.value === "object") {
22142 activeElements = [
22143 { value: filterInView.value, label: filterInView.value }
22144 ];
22145 } else if (filterInView?.value !== void 0) {
22146 const label = field !== void 0 ? field.getValueFormatted({
22147 item: { [field.id]: filterInView.value },
22148 field
22149 }) : String(filterInView.value);
22150 activeElements = [
22151 {
22152 value: filterInView.value,
22153 label
22154 }
22155 ];
22156 }
22157 const isPrimary = filter.isPrimary;
22158 const isLocked = filterInView?.isLocked;
22159 const hasValues = !isLocked && filterInView?.value !== void 0;
22160 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
22161 const resetOrRemoveLabel = isPrimary ? (0, import_i18n26.__)("Reset") : (0, import_i18n26.__)("Remove");
22162 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22163 import_components21.Dropdown,
22164 {
22165 defaultOpen: openedFilter === filter.field,
22166 contentClassName: "dataviews-filters__summary-popover",
22167 popoverProps: { placement: "bottom-start", role: "dialog" },
22168 onClose: () => {
22169 toggleRef.current?.focus();
22170 },
22171 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
22172 /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(tooltip_exports.Root, { children: [
22173 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22174 tooltip_exports.Trigger,
22175 {
22176 render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22177 "div",
22178 {
22179 className: clsx_default(
22180 "dataviews-filters__summary-chip",
22181 {
22182 "has-reset": canResetOrRemove,
22183 "has-values": hasValues,
22184 "is-not-clickable": isLocked
22185 }
22186 ),
22187 role: "button",
22188 tabIndex: isLocked ? -1 : 0,
22189 onClick: () => {
22190 if (!isLocked) {
22191 onToggle();
22192 }
22193 },
22194 onKeyDown: (event) => {
22195 if (!isLocked && [ENTER, SPACE].includes(
22196 event.key
22197 )) {
22198 onToggle();
22199 event.preventDefault();
22200 }
22201 },
22202 "aria-disabled": isLocked,
22203 "aria-pressed": isOpen,
22204 "aria-expanded": isOpen,
22205 ref: toggleRef,
22206 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22207 FilterText,
22208 {
22209 activeElements,
22210 filterInView,
22211 filter
22212 }
22213 )
22214 }
22215 )
22216 }
22217 ),
22218 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(tooltip_exports.Popup, { children: (0, import_i18n26.sprintf)(
22219 /* translators: 1: Filter name. */
22220 (0, import_i18n26.__)("Filter by: %1$s"),
22221 filter.name.toLowerCase()
22222 ) })
22223 ] }),
22224 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(tooltip_exports.Root, { children: [
22225 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22226 tooltip_exports.Trigger,
22227 {
22228 render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22229 "button",
22230 {
22231 className: clsx_default(
22232 "dataviews-filters__summary-chip-remove",
22233 { "has-values": hasValues }
22234 ),
22235 "aria-label": resetOrRemoveLabel,
22236 onClick: () => {
22237 onChangeView({
22238 ...view,
22239 page: 1,
22240 filters: view.filters?.filter(
22241 (_filter) => _filter.field !== filter.field
22242 )
22243 });
22244 if (!isPrimary) {
22245 addFilterRef.current?.focus();
22246 } else {
22247 toggleRef.current?.focus();
22248 }
22249 },
22250 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components21.Icon, { icon: close_small_default })
22251 }
22252 )
22253 }
22254 ),
22255 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
22256 ] })
22257 ] }),
22258 renderContent: () => {
22259 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
22260 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(OperatorSelector, { ...commonProps }),
22261 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22262 SearchWidget,
22263 {
22264 ...commonProps,
22265 filter: {
22266 ...commonProps.filter,
22267 elements
22268 }
22269 }
22270 ) : /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(InputWidget, { ...commonProps, fields })
22271 ] });
22272 }
22273 }
22274 );
22275 }
22276
22277 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
22278 var import_components22 = __toESM(require_components(), 1);
22279 var import_i18n27 = __toESM(require_i18n(), 1);
22280 var import_element55 = __toESM(require_element(), 1);
22281 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
22282 var { Menu: Menu4 } = unlock2(import_components22.privateApis);
22283 function AddFilterMenu({
22284 filters,
22285 view,
22286 onChangeView,
22287 setOpenedFilter,
22288 triggerProps
22289 }) {
22290 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
22291 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(Menu4, { children: [
22292 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu4.TriggerButton, { ...triggerProps }),
22293 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
22294 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22295 Menu4.Item,
22296 {
22297 onClick: () => {
22298 setOpenedFilter(filter.field);
22299 onChangeView({
22300 ...view,
22301 page: 1,
22302 filters: [
22303 ...view.filters || [],
22304 {
22305 field: filter.field,
22306 value: void 0,
22307 operator: filter.operators[0]
22308 }
22309 ]
22310 });
22311 },
22312 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu4.ItemLabel, { children: filter.name })
22313 },
22314 filter.field
22315 );
22316 }) })
22317 ] });
22318 }
22319 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
22320 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
22321 return null;
22322 }
22323 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
22324 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22325 AddFilterMenu,
22326 {
22327 triggerProps: {
22328 render: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22329 import_components22.Button,
22330 {
22331 accessibleWhenDisabled: true,
22332 size: "compact",
22333 className: "dataviews-filters-button",
22334 variant: "tertiary",
22335 disabled: !inactiveFilters.length,
22336 ref
22337 }
22338 ),
22339 children: (0, import_i18n27.__)("Add filter")
22340 },
22341 ...{ filters, view, onChangeView, setOpenedFilter }
22342 }
22343 );
22344 }
22345 var add_filter_default = (0, import_element55.forwardRef)(AddFilter);
22346
22347 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
22348 var import_components23 = __toESM(require_components(), 1);
22349 var import_i18n28 = __toESM(require_i18n(), 1);
22350 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
22351 function ResetFilter({
22352 filters,
22353 view,
22354 onChangeView
22355 }) {
22356 const isPrimary = (field) => filters.some(
22357 (_filter) => _filter.field === field && _filter.isPrimary
22358 );
22359 const isDisabled = !view.search && !view.filters?.some(
22360 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
22361 );
22362 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
22363 import_components23.Button,
22364 {
22365 disabled: isDisabled,
22366 accessibleWhenDisabled: true,
22367 size: "compact",
22368 variant: "tertiary",
22369 className: "dataviews-filters__reset-button",
22370 onClick: () => {
22371 onChangeView({
22372 ...view,
22373 page: 1,
22374 search: "",
22375 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
22376 });
22377 },
22378 children: (0, import_i18n28.__)("Reset")
22379 }
22380 );
22381 }
22382
22383 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
22384 var import_element56 = __toESM(require_element(), 1);
22385 function useFilters(fields, view) {
22386 return (0, import_element56.useMemo)(() => {
22387 const filters = [];
22388 fields.forEach((field) => {
22389 if (field.filterBy === false || !field.hasElements && !field.Edit) {
22390 return;
22391 }
22392 const operators = field.filterBy.operators;
22393 const isPrimary = !!field.filterBy?.isPrimary;
22394 const isLocked = view.filters?.some(
22395 (f2) => f2.field === field.id && !!f2.isLocked
22396 ) ?? false;
22397 filters.push({
22398 field: field.id,
22399 name: field.label,
22400 elements: field.elements,
22401 getElements: field.getElements,
22402 hasElements: field.hasElements,
22403 singleSelection: operators.some(
22404 (op) => isSingleSelectionOperator(op)
22405 ),
22406 operators,
22407 isVisible: isLocked || isPrimary || !!view.filters?.some(
22408 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
22409 ),
22410 isPrimary,
22411 isLocked
22412 });
22413 });
22414 filters.sort((a2, b2) => {
22415 if (a2.isLocked && !b2.isLocked) {
22416 return -1;
22417 }
22418 if (!a2.isLocked && b2.isLocked) {
22419 return 1;
22420 }
22421 if (a2.isPrimary && !b2.isPrimary) {
22422 return -1;
22423 }
22424 if (!a2.isPrimary && b2.isPrimary) {
22425 return 1;
22426 }
22427 return a2.name.localeCompare(b2.name);
22428 });
22429 return filters;
22430 }, [fields, view]);
22431 }
22432 var use_filters_default = useFilters;
22433
22434 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
22435 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
22436 function Filters({ className }) {
22437 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element57.useContext)(dataviews_context_default);
22438 const addFilterRef = (0, import_element57.useRef)(null);
22439 const filters = use_filters_default(fields, view);
22440 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22441 add_filter_default,
22442 {
22443 filters,
22444 view,
22445 onChangeView,
22446 ref: addFilterRef,
22447 setOpenedFilter
22448 },
22449 "add-filter"
22450 );
22451 const visibleFilters = filters.filter((filter) => filter.isVisible);
22452 if (visibleFilters.length === 0) {
22453 return null;
22454 }
22455 const filterComponents = [
22456 ...visibleFilters.map((filter) => {
22457 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22458 Filter,
22459 {
22460 filter,
22461 view,
22462 fields,
22463 onChangeView,
22464 addFilterRef,
22465 openedFilter
22466 },
22467 filter.field
22468 );
22469 }),
22470 addFilter
22471 ];
22472 filterComponents.push(
22473 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22474 ResetFilter,
22475 {
22476 filters,
22477 view,
22478 onChangeView
22479 },
22480 "reset-filters"
22481 )
22482 );
22483 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22484 Stack,
22485 {
22486 direction: "row",
22487 justify: "flex-start",
22488 gap: "sm",
22489 style: { width: "fit-content" },
22490 wrap: "wrap",
22491 className,
22492 children: filterComponents
22493 }
22494 );
22495 }
22496 var filters_default = (0, import_element57.memo)(Filters);
22497
22498 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
22499 var import_element58 = __toESM(require_element(), 1);
22500 var import_components24 = __toESM(require_components(), 1);
22501 var import_i18n29 = __toESM(require_i18n(), 1);
22502 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
22503 function FiltersToggle() {
22504 const {
22505 filters,
22506 view,
22507 onChangeView,
22508 setOpenedFilter,
22509 isShowingFilter,
22510 setIsShowingFilter
22511 } = (0, import_element58.useContext)(dataviews_context_default);
22512 const buttonRef = (0, import_element58.useRef)(null);
22513 const onChangeViewWithFilterVisibility = (0, import_element58.useCallback)(
22514 (_view) => {
22515 onChangeView(_view);
22516 setIsShowingFilter(true);
22517 },
22518 [onChangeView, setIsShowingFilter]
22519 );
22520 if (filters.length === 0) {
22521 return null;
22522 }
22523 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
22524 const addFilterButtonProps = {
22525 label: (0, import_i18n29.__)("Add filter"),
22526 "aria-expanded": false,
22527 isPressed: false
22528 };
22529 const toggleFiltersButtonProps = {
22530 label: (0, import_i18n29._x)("Filter", "verb"),
22531 "aria-expanded": isShowingFilter,
22532 isPressed: isShowingFilter,
22533 onClick: () => {
22534 if (!isShowingFilter) {
22535 setOpenedFilter(null);
22536 }
22537 setIsShowingFilter(!isShowingFilter);
22538 }
22539 };
22540 const hasPrimaryOrLockedFilters = filters.some(
22541 (filter) => filter.isPrimary || filter.isLocked
22542 );
22543 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22544 import_components24.Button,
22545 {
22546 ref: buttonRef,
22547 className: "dataviews-filters__visibility-toggle",
22548 size: "compact",
22549 icon: funnel_default,
22550 disabled: hasPrimaryOrLockedFilters,
22551 accessibleWhenDisabled: true,
22552 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
22553 }
22554 );
22555 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22556 AddFilterMenu,
22557 {
22558 filters,
22559 view,
22560 onChangeView: onChangeViewWithFilterVisibility,
22561 setOpenedFilter,
22562 triggerProps: { render: buttonComponent }
22563 }
22564 ) : /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22565 FilterVisibilityToggle,
22566 {
22567 buttonRef,
22568 filtersCount: view.filters?.length,
22569 children: buttonComponent
22570 }
22571 ) });
22572 }
22573 function FilterVisibilityToggle({
22574 buttonRef,
22575 filtersCount,
22576 children
22577 }) {
22578 (0, import_element58.useEffect)(
22579 () => () => {
22580 buttonRef.current?.focus();
22581 },
22582 [buttonRef]
22583 );
22584 return /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(import_jsx_runtime87.Fragment, { children: [
22585 children,
22586 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
22587 ] });
22588 }
22589 var toggle_default = FiltersToggle;
22590
22591 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
22592 var import_element59 = __toESM(require_element(), 1);
22593 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
22594 function FiltersToggled(props) {
22595 const { isShowingFilter } = (0, import_element59.useContext)(dataviews_context_default);
22596 if (!isShowingFilter) {
22597 return null;
22598 }
22599 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(filters_default, { ...props });
22600 }
22601 var filters_toggled_default = FiltersToggled;
22602
22603 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
22604 var import_element60 = __toESM(require_element(), 1);
22605 var import_components25 = __toESM(require_components(), 1);
22606 var import_i18n30 = __toESM(require_i18n(), 1);
22607 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
22608 function DataViewsLayout({ className }) {
22609 const {
22610 actions = [],
22611 data,
22612 fields,
22613 getItemId,
22614 getItemLevel,
22615 hasInitiallyLoaded,
22616 isLoading,
22617 view,
22618 onChangeView,
22619 selection,
22620 onChangeSelection,
22621 setOpenedFilter,
22622 onClickItem,
22623 isItemClickable,
22624 renderItemLink,
22625 defaultLayouts,
22626 containerRef,
22627 empty = /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("p", { children: (0, import_i18n30.__)("No results") })
22628 } = (0, import_element60.useContext)(dataviews_context_default);
22629 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
22630 delay: 200
22631 });
22632 if (!hasInitiallyLoaded) {
22633 if (!isDelayedInitialLoading) {
22634 return null;
22635 }
22636 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components25.Spinner, {}) }) });
22637 }
22638 const ViewComponent = VIEW_LAYOUTS.find(
22639 (v2) => v2.type === view.type && defaultLayouts[v2.type]
22640 )?.component;
22641 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22642 ViewComponent,
22643 {
22644 className,
22645 actions,
22646 data,
22647 fields,
22648 getItemId,
22649 getItemLevel,
22650 isLoading,
22651 onChangeView,
22652 onChangeSelection,
22653 selection,
22654 setOpenedFilter,
22655 onClickItem,
22656 renderItemLink,
22657 isItemClickable,
22658 view,
22659 empty
22660 }
22661 ) });
22662 }
22663
22664 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
22665 var import_element61 = __toESM(require_element(), 1);
22666 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
22667 var EMPTY_ARRAY5 = [];
22668 function DataViewsFooter() {
22669 const {
22670 view,
22671 paginationInfo: { totalItems = 0, totalPages },
22672 data,
22673 actions = EMPTY_ARRAY5,
22674 isLoading,
22675 hasInitiallyLoaded
22676 } = (0, import_element61.useContext)(dataviews_context_default);
22677 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
22678 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
22679 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
22680 const hasPagination = hasPaginationControls(view, {
22681 totalItems,
22682 totalPages
22683 });
22684 if (!totalItems || !hasBulkActions && !hasPagination) {
22685 return null;
22686 }
22687 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22688 "div",
22689 {
22690 className: "dataviews-footer",
22691 inert: isRefreshing ? "true" : void 0,
22692 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(
22693 Stack,
22694 {
22695 direction: "row",
22696 justify: "end",
22697 align: "center",
22698 className: clsx_default("dataviews-footer__content", {
22699 "is-refreshing": isDelayedRefreshing
22700 }),
22701 gap: "sm",
22702 children: [
22703 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(BulkActionsFooter, {}),
22704 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(dataviews_pagination_default, {})
22705 ]
22706 }
22707 )
22708 }
22709 );
22710 }
22711
22712 // packages/dataviews/build-module/components/dataviews-search/index.mjs
22713 var import_i18n31 = __toESM(require_i18n(), 1);
22714 var import_element62 = __toESM(require_element(), 1);
22715 var import_components26 = __toESM(require_components(), 1);
22716 var import_compose10 = __toESM(require_compose(), 1);
22717 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
22718 var DataViewsSearch = (0, import_element62.memo)(function Search({ label }) {
22719 const { view, onChangeView } = (0, import_element62.useContext)(dataviews_context_default);
22720 const [search, setSearch, debouncedSearch] = (0, import_compose10.useDebouncedInput)(
22721 view.search
22722 );
22723 (0, import_element62.useEffect)(() => {
22724 if (view.search !== debouncedSearch) {
22725 setSearch(view.search ?? "");
22726 }
22727 }, [view.search, setSearch]);
22728 const onChangeViewRef = (0, import_element62.useRef)(onChangeView);
22729 const viewRef = (0, import_element62.useRef)(view);
22730 (0, import_element62.useEffect)(() => {
22731 onChangeViewRef.current = onChangeView;
22732 viewRef.current = view;
22733 }, [onChangeView, view]);
22734 (0, import_element62.useEffect)(() => {
22735 if (debouncedSearch !== viewRef.current?.search) {
22736 onChangeViewRef.current({
22737 ...viewRef.current,
22738 page: view.page ? 1 : void 0,
22739 startPosition: view.startPosition ? 1 : void 0,
22740 search: debouncedSearch
22741 });
22742 }
22743 }, [debouncedSearch]);
22744 const searchLabel = label || (0, import_i18n31.__)("Search");
22745 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22746 import_components26.SearchControl,
22747 {
22748 className: "dataviews-search",
22749 onChange: setSearch,
22750 value: search,
22751 label: searchLabel,
22752 placeholder: searchLabel,
22753 size: "compact"
22754 }
22755 );
22756 });
22757 var dataviews_search_default = DataViewsSearch;
22758
22759 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
22760 var import_components27 = __toESM(require_components(), 1);
22761 var import_i18n32 = __toESM(require_i18n(), 1);
22762 var import_element63 = __toESM(require_element(), 1);
22763 var import_warning = __toESM(require_warning(), 1);
22764 var import_compose11 = __toESM(require_compose(), 1);
22765 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
22766 var { Menu: Menu5 } = unlock2(import_components27.privateApis);
22767 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
22768 className: "dataviews-config__popover",
22769 placement: "bottom-end",
22770 offset: 9
22771 };
22772 function ViewTypeMenu() {
22773 const { view, onChangeView, defaultLayouts } = (0, import_element63.useContext)(dataviews_context_default);
22774 const availableLayouts = Object.keys(defaultLayouts);
22775 if (availableLayouts.length <= 1) {
22776 return null;
22777 }
22778 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
22779 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(Menu5, { children: [
22780 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22781 Menu5.TriggerButton,
22782 {
22783 render: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22784 import_components27.Button,
22785 {
22786 size: "compact",
22787 icon: activeView?.icon,
22788 label: (0, import_i18n32.__)("Layout")
22789 }
22790 )
22791 }
22792 ),
22793 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
22794 const config = VIEW_LAYOUTS.find(
22795 (v2) => v2.type === layout
22796 );
22797 if (!config) {
22798 return null;
22799 }
22800 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22801 Menu5.RadioItem,
22802 {
22803 value: layout,
22804 name: "view-actions-available-view",
22805 checked: layout === view.type,
22806 hideOnClick: true,
22807 onChange: (e2) => {
22808 switch (e2.target.value) {
22809 case "list":
22810 case "grid":
22811 case "table":
22812 case "pickerGrid":
22813 case "pickerTable":
22814 case "pickerActivity":
22815 case "activity":
22816 const viewWithoutLayout = { ...view };
22817 if ("layout" in viewWithoutLayout) {
22818 delete viewWithoutLayout.layout;
22819 }
22820 return onChangeView({
22821 ...viewWithoutLayout,
22822 type: e2.target.value,
22823 ...defaultLayouts[e2.target.value]
22824 });
22825 }
22826 (0, import_warning.default)("Invalid dataview");
22827 },
22828 children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(Menu5.ItemLabel, { children: config.label })
22829 },
22830 layout
22831 );
22832 }) })
22833 ] });
22834 }
22835 function SortFieldControl() {
22836 const { view, fields, onChangeView } = (0, import_element63.useContext)(dataviews_context_default);
22837 const orderOptions = (0, import_element63.useMemo)(() => {
22838 const sortableFields = fields.filter(
22839 (field) => field.enableSorting !== false
22840 );
22841 return sortableFields.map((field) => {
22842 return {
22843 label: field.label,
22844 value: field.id
22845 };
22846 });
22847 }, [fields]);
22848 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22849 import_components27.SelectControl,
22850 {
22851 label: (0, import_i18n32.__)("Sort by"),
22852 value: view.sort?.field,
22853 options: orderOptions,
22854 onChange: (value) => {
22855 onChangeView({
22856 ...view,
22857 sort: {
22858 direction: view?.sort?.direction || "desc",
22859 field: value
22860 },
22861 showLevels: false
22862 });
22863 }
22864 }
22865 );
22866 }
22867 function SortDirectionControl() {
22868 const { view, fields, onChangeView } = (0, import_element63.useContext)(dataviews_context_default);
22869 const sortableFields = fields.filter(
22870 (field) => field.enableSorting !== false
22871 );
22872 if (sortableFields.length === 0) {
22873 return null;
22874 }
22875 let value = view.sort?.direction;
22876 if (!value && view.sort?.field) {
22877 value = "desc";
22878 }
22879 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22880 import_components27.__experimentalToggleGroupControl,
22881 {
22882 className: "dataviews-view-config__sort-direction",
22883 isBlock: true,
22884 label: (0, import_i18n32.__)("Order"),
22885 value,
22886 onChange: (newDirection) => {
22887 if (newDirection === "asc" || newDirection === "desc") {
22888 onChangeView({
22889 ...view,
22890 sort: {
22891 direction: newDirection,
22892 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
22893 fields.find(
22894 (field) => field.enableSorting !== false
22895 )?.id || ""
22896 },
22897 showLevels: false
22898 });
22899 return;
22900 }
22901 (0, import_warning.default)("Invalid direction");
22902 },
22903 children: SORTING_DIRECTIONS.map((direction) => {
22904 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22905 import_components27.__experimentalToggleGroupControlOptionIcon,
22906 {
22907 value: direction,
22908 icon: sortIcons[direction],
22909 label: sortLabels[direction]
22910 },
22911 direction
22912 );
22913 })
22914 }
22915 );
22916 }
22917 function ItemsPerPageControl() {
22918 const { view, config, onChangeView } = (0, import_element63.useContext)(dataviews_context_default);
22919 const { infiniteScrollEnabled } = view;
22920 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
22921 return null;
22922 }
22923 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22924 import_components27.__experimentalToggleGroupControl,
22925 {
22926 isBlock: true,
22927 label: (0, import_i18n32.__)("Items per page"),
22928 value: view.perPage || 10,
22929 disabled: !view?.sort?.field,
22930 onChange: (newItemsPerPage) => {
22931 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
22932 onChangeView({
22933 ...view,
22934 perPage: newItemsPerPageNumber,
22935 page: 1
22936 });
22937 },
22938 children: config.perPageSizes.map((value) => {
22939 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22940 import_components27.__experimentalToggleGroupControlOption,
22941 {
22942 value,
22943 label: value.toString()
22944 },
22945 value
22946 );
22947 })
22948 }
22949 );
22950 }
22951 function ResetViewButton() {
22952 const { onReset } = (0, import_element63.useContext)(dataviews_context_default);
22953 if (onReset === void 0) {
22954 return null;
22955 }
22956 const isDisabled = onReset === false;
22957 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22958 import_components27.Button,
22959 {
22960 variant: "tertiary",
22961 size: "compact",
22962 disabled: isDisabled,
22963 accessibleWhenDisabled: true,
22964 className: "dataviews-view-config__reset-button",
22965 onClick: () => {
22966 if (typeof onReset === "function") {
22967 onReset();
22968 }
22969 },
22970 children: (0, import_i18n32.__)("Reset view")
22971 }
22972 );
22973 }
22974 function DataviewsViewConfigDropdown() {
22975 const { view, onReset } = (0, import_element63.useContext)(dataviews_context_default);
22976 const popoverId = (0, import_compose11.useInstanceId)(
22977 _DataViewsViewConfig,
22978 "dataviews-view-config-dropdown"
22979 );
22980 const activeLayout = VIEW_LAYOUTS.find(
22981 (layout) => layout.type === view.type
22982 );
22983 const isModified = typeof onReset === "function";
22984 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22985 import_components27.Dropdown,
22986 {
22987 expandOnMobile: true,
22988 popoverProps: {
22989 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
22990 id: popoverId
22991 },
22992 renderToggle: ({ onToggle, isOpen }) => {
22993 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
22994 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22995 import_components27.Button,
22996 {
22997 size: "compact",
22998 icon: cog_default,
22999 label: (0, import_i18n32._x)(
23000 "View options",
23001 "View is used as a noun"
23002 ),
23003 onClick: onToggle,
23004 "aria-expanded": isOpen ? "true" : "false",
23005 "aria-controls": popoverId
23006 }
23007 ),
23008 isModified && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
23009 ] });
23010 },
23011 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
23012 import_components27.__experimentalDropdownContentWrapper,
23013 {
23014 paddingSize: "medium",
23015 className: "dataviews-config__popover-content-wrapper",
23016 children: /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(
23017 Stack,
23018 {
23019 direction: "column",
23020 className: "dataviews-view-config",
23021 gap: "xl",
23022 children: [
23023 /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(
23024 Stack,
23025 {
23026 direction: "row",
23027 justify: "space-between",
23028 align: "center",
23029 className: "dataviews-view-config__header",
23030 children: [
23031 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
23032 import_components27.__experimentalHeading,
23033 {
23034 level: 2,
23035 className: "dataviews-settings-section__title",
23036 children: (0, import_i18n32.__)("Appearance")
23037 }
23038 ),
23039 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(ResetViewButton, {})
23040 ]
23041 }
23042 ),
23043 /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23044 /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(
23045 Stack,
23046 {
23047 direction: "row",
23048 gap: "sm",
23049 className: "dataviews-view-config__sort-controls",
23050 children: [
23051 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(SortFieldControl, {}),
23052 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(SortDirectionControl, {})
23053 ]
23054 }
23055 ),
23056 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(activeLayout.viewConfigOptions, {}),
23057 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(ItemsPerPageControl, {}),
23058 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(PropertiesSection, {})
23059 ] })
23060 ]
23061 }
23062 )
23063 }
23064 )
23065 }
23066 );
23067 }
23068 function _DataViewsViewConfig() {
23069 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(import_jsx_runtime92.Fragment, { children: [
23070 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(ViewTypeMenu, {}),
23071 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(DataviewsViewConfigDropdown, {})
23072 ] });
23073 }
23074 var DataViewsViewConfig = (0, import_element63.memo)(_DataViewsViewConfig);
23075 var dataviews_view_config_default = DataViewsViewConfig;
23076
23077 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
23078 var import_components28 = __toESM(require_components(), 1);
23079 var import_element64 = __toESM(require_element(), 1);
23080
23081 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
23082 function getCustomValidity(isValid2, validity) {
23083 let customValidity;
23084 if (isValid2?.required && validity?.required) {
23085 customValidity = validity?.required?.message ? validity.required : void 0;
23086 } else if (isValid2?.pattern && validity?.pattern) {
23087 customValidity = validity.pattern;
23088 } else if (isValid2?.min && validity?.min) {
23089 customValidity = validity.min;
23090 } else if (isValid2?.max && validity?.max) {
23091 customValidity = validity.max;
23092 } else if (isValid2?.minLength && validity?.minLength) {
23093 customValidity = validity.minLength;
23094 } else if (isValid2?.maxLength && validity?.maxLength) {
23095 customValidity = validity.maxLength;
23096 } else if (isValid2?.elements && validity?.elements) {
23097 customValidity = validity.elements;
23098 } else if (validity?.custom) {
23099 customValidity = validity.custom;
23100 }
23101 return customValidity;
23102 }
23103
23104 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
23105 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
23106 var { ValidatedCheckboxControl } = unlock2(import_components28.privateApis);
23107 function Checkbox({
23108 field,
23109 onChange,
23110 data,
23111 hideLabelFromVision,
23112 markWhenOptional,
23113 validity
23114 }) {
23115 const { getValue, setValue, label, description, isValid: isValid2 } = field;
23116 const disabled2 = field.isDisabled({ item: data, field });
23117 const onChangeControl = (0, import_element64.useCallback)(() => {
23118 onChange(
23119 setValue({ item: data, value: !getValue({ item: data }) })
23120 );
23121 }, [data, getValue, onChange, setValue]);
23122 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
23123 ValidatedCheckboxControl,
23124 {
23125 required: !!field.isValid?.required,
23126 markWhenOptional,
23127 customValidity: getCustomValidity(isValid2, validity),
23128 hidden: hideLabelFromVision,
23129 label,
23130 help: description,
23131 checked: getValue({ item: data }),
23132 onChange: onChangeControl,
23133 disabled: disabled2
23134 }
23135 );
23136 }
23137
23138 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
23139 var import_components29 = __toESM(require_components(), 1);
23140 var import_element65 = __toESM(require_element(), 1);
23141 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
23142 var { ValidatedComboboxControl } = unlock2(import_components29.privateApis);
23143 function Combobox3({
23144 data,
23145 field,
23146 onChange,
23147 hideLabelFromVision,
23148 validity
23149 }) {
23150 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
23151 const value = getValue({ item: data }) ?? "";
23152 const onChangeControl = (0, import_element65.useCallback)(
23153 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
23154 [data, onChange, setValue]
23155 );
23156 const { elements, isLoading } = useElements({
23157 elements: field.elements,
23158 getElements: field.getElements
23159 });
23160 if (isLoading) {
23161 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components29.Spinner, {});
23162 }
23163 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23164 ValidatedComboboxControl,
23165 {
23166 required: !!field.isValid?.required,
23167 customValidity: getCustomValidity(isValid2, validity),
23168 label,
23169 value,
23170 help: description,
23171 placeholder,
23172 options: elements,
23173 onChange: onChangeControl,
23174 hideLabelFromVision,
23175 allowReset: true,
23176 expandOnFocus: true
23177 }
23178 );
23179 }
23180
23181 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
23182 var import_components31 = __toESM(require_components(), 1);
23183 var import_element68 = __toESM(require_element(), 1);
23184 var import_i18n34 = __toESM(require_i18n(), 1);
23185 var import_date3 = __toESM(require_date(), 1);
23186
23187 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
23188 var import_components30 = __toESM(require_components(), 1);
23189 var import_element66 = __toESM(require_element(), 1);
23190 var import_i18n33 = __toESM(require_i18n(), 1);
23191 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
23192 var TIME_UNITS_OPTIONS = {
23193 [OPERATOR_IN_THE_PAST]: [
23194 { value: "days", label: (0, import_i18n33.__)("Days") },
23195 { value: "weeks", label: (0, import_i18n33.__)("Weeks") },
23196 { value: "months", label: (0, import_i18n33.__)("Months") },
23197 { value: "years", label: (0, import_i18n33.__)("Years") }
23198 ],
23199 [OPERATOR_OVER]: [
23200 { value: "days", label: (0, import_i18n33.__)("Days ago") },
23201 { value: "weeks", label: (0, import_i18n33.__)("Weeks ago") },
23202 { value: "months", label: (0, import_i18n33.__)("Months ago") },
23203 { value: "years", label: (0, import_i18n33.__)("Years ago") }
23204 ]
23205 };
23206 function RelativeDateControl({
23207 className,
23208 data,
23209 field,
23210 onChange,
23211 hideLabelFromVision,
23212 operator
23213 }) {
23214 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
23215 const { id, label, description, getValue, setValue } = field;
23216 const disabled2 = field.isDisabled({ item: data, field });
23217 const fieldValue = getValue({ item: data });
23218 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
23219 const onChangeValue = (0, import_element66.useCallback)(
23220 (newValue) => onChange(
23221 setValue({
23222 item: data,
23223 value: { value: Number(newValue), unit }
23224 })
23225 ),
23226 [onChange, setValue, data, unit]
23227 );
23228 const onChangeUnit = (0, import_element66.useCallback)(
23229 (newUnit) => onChange(
23230 setValue({
23231 item: data,
23232 value: { value: relValue, unit: newUnit }
23233 })
23234 ),
23235 [onChange, setValue, data, relValue]
23236 );
23237 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23238 import_components30.BaseControl,
23239 {
23240 id,
23241 className: clsx_default(className, "dataviews-controls__relative-date"),
23242 label,
23243 hideLabelFromVision,
23244 help: description,
23245 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(Stack, { direction: "row", gap: "sm", children: [
23246 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23247 import_components30.__experimentalNumberControl,
23248 {
23249 className: "dataviews-controls__relative-date-number",
23250 spinControls: "none",
23251 min: 1,
23252 step: 1,
23253 value: relValue,
23254 onChange: onChangeValue,
23255 disabled: disabled2
23256 }
23257 ),
23258 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23259 import_components30.SelectControl,
23260 {
23261 className: "dataviews-controls__relative-date-unit",
23262 label: (0, import_i18n33.__)("Unit"),
23263 value: unit,
23264 options,
23265 onChange: onChangeUnit,
23266 hideLabelFromVision: true,
23267 disabled: disabled2
23268 }
23269 )
23270 ] })
23271 }
23272 );
23273 }
23274
23275 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
23276 var import_element67 = __toESM(require_element(), 1);
23277 function useDisabledDateMatchers(isValid2, parseDateFn) {
23278 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
23279 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
23280 const disabledMatchers = (0, import_element67.useMemo)(() => {
23281 const matchers = [];
23282 if (minConstraint) {
23283 const minDate = parseDateFn(minConstraint);
23284 if (minDate) {
23285 matchers.push({ before: minDate });
23286 }
23287 }
23288 if (maxConstraint) {
23289 const maxDate = parseDateFn(maxConstraint);
23290 if (maxDate) {
23291 matchers.push({ after: maxDate });
23292 }
23293 }
23294 return matchers.length > 0 ? matchers : void 0;
23295 }, [minConstraint, maxConstraint, parseDateFn]);
23296 return { minConstraint, maxConstraint, disabledMatchers };
23297 }
23298
23299 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
23300 var import_date2 = __toESM(require_date(), 1);
23301 function parseDateTime(dateTimeString) {
23302 if (!dateTimeString) {
23303 return null;
23304 }
23305 const parsed = (0, import_date2.getDate)(dateTimeString);
23306 return parsed && isValid(parsed) ? parsed : null;
23307 }
23308
23309 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
23310 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
23311 var { DateCalendar, ValidatedInputControl } = unlock2(import_components31.privateApis);
23312 var formatDateTime = (value) => {
23313 if (!value) {
23314 return "";
23315 }
23316 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
23317 };
23318 function CalendarDateTimeControl({
23319 data,
23320 field,
23321 onChange,
23322 hideLabelFromVision,
23323 markWhenOptional,
23324 validity,
23325 config
23326 }) {
23327 const { compact } = config || {};
23328 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
23329 const disabled2 = field.isDisabled({ item: data, field });
23330 const fieldValue = getValue({ item: data });
23331 const value = typeof fieldValue === "string" ? fieldValue : void 0;
23332 const [calendarMonth, setCalendarMonth] = (0, import_element68.useState)(() => {
23333 const parsedDate = parseDateTime(value);
23334 return parsedDate || /* @__PURE__ */ new Date();
23335 });
23336 const inputControlRef = (0, import_element68.useRef)(null);
23337 const validationTimeoutRef = (0, import_element68.useRef)(void 0);
23338 const previousFocusRef = (0, import_element68.useRef)(null);
23339 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
23340 const onChangeCallback = (0, import_element68.useCallback)(
23341 (newValue) => onChange(setValue({ item: data, value: newValue })),
23342 [data, onChange, setValue]
23343 );
23344 (0, import_element68.useEffect)(() => {
23345 return () => {
23346 if (validationTimeoutRef.current) {
23347 clearTimeout(validationTimeoutRef.current);
23348 }
23349 };
23350 }, []);
23351 const onSelectDate = (0, import_element68.useCallback)(
23352 (newDate) => {
23353 let dateTimeValue;
23354 if (newDate) {
23355 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
23356 let wpTime;
23357 if (value) {
23358 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
23359 } else {
23360 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
23361 }
23362 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
23363 dateTimeValue = finalDateTime.toISOString();
23364 onChangeCallback(dateTimeValue);
23365 if (validationTimeoutRef.current) {
23366 clearTimeout(validationTimeoutRef.current);
23367 }
23368 } else {
23369 onChangeCallback(void 0);
23370 }
23371 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
23372 validationTimeoutRef.current = setTimeout(() => {
23373 if (inputControlRef.current) {
23374 inputControlRef.current.focus();
23375 inputControlRef.current.blur();
23376 onChangeCallback(dateTimeValue);
23377 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
23378 previousFocusRef.current.focus();
23379 }
23380 }
23381 }, 0);
23382 },
23383 [onChangeCallback, value]
23384 );
23385 const handleManualDateTimeChange = (0, import_element68.useCallback)(
23386 (newValue) => {
23387 if (newValue) {
23388 const dateTime = (0, import_date3.getDate)(newValue);
23389 onChangeCallback(dateTime.toISOString());
23390 const parsedDate = parseDateTime(dateTime.toISOString());
23391 if (parsedDate) {
23392 setCalendarMonth(parsedDate);
23393 }
23394 } else {
23395 onChangeCallback(void 0);
23396 }
23397 },
23398 [onChangeCallback]
23399 );
23400 const { format: fieldFormat } = field;
23401 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
23402 const {
23403 timezone: { string: timezoneString }
23404 } = (0, import_date3.getSettings)();
23405 let displayLabel = label;
23406 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
23407 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
23408 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
23409 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
23410 }
23411 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23412 import_components31.BaseControl,
23413 {
23414 id,
23415 label: displayLabel,
23416 help: description,
23417 hideLabelFromVision,
23418 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23419 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23420 ValidatedInputControl,
23421 {
23422 ref: inputControlRef,
23423 required: !!isValid2?.required,
23424 customValidity: getCustomValidity(isValid2, validity),
23425 type: "datetime-local",
23426 label: (0, import_i18n34.__)("Date time"),
23427 hideLabelFromVision: true,
23428 value: formatDateTime(value),
23429 onChange: handleManualDateTimeChange,
23430 disabled: disabled2,
23431 min: minConstraint ? formatDateTime(minConstraint) : void 0,
23432 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
23433 }
23434 ),
23435 !compact && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23436 DateCalendar,
23437 {
23438 style: { width: "100%" },
23439 selected: value ? parseDateTime(value) || void 0 : void 0,
23440 onSelect: onSelectDate,
23441 month: calendarMonth,
23442 onMonthChange: setCalendarMonth,
23443 timeZone: timezoneString || void 0,
23444 weekStartsOn,
23445 disabled: disabled2 || disabledMatchers
23446 }
23447 )
23448 ] })
23449 }
23450 );
23451 }
23452 function DateTime({
23453 data,
23454 field,
23455 onChange,
23456 hideLabelFromVision,
23457 markWhenOptional,
23458 operator,
23459 validity,
23460 config
23461 }) {
23462 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23463 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23464 RelativeDateControl,
23465 {
23466 className: "dataviews-controls__datetime",
23467 data,
23468 field,
23469 onChange,
23470 hideLabelFromVision,
23471 operator
23472 }
23473 );
23474 }
23475 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23476 CalendarDateTimeControl,
23477 {
23478 data,
23479 field,
23480 onChange,
23481 hideLabelFromVision,
23482 markWhenOptional,
23483 validity,
23484 config
23485 }
23486 );
23487 }
23488
23489 // packages/dataviews/build-module/components/dataform-controls/date.mjs
23490 var import_components32 = __toESM(require_components(), 1);
23491 var import_element69 = __toESM(require_element(), 1);
23492 var import_i18n35 = __toESM(require_i18n(), 1);
23493 var import_date4 = __toESM(require_date(), 1);
23494 import { speak } from "@wordpress/a11y";
23495 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
23496 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components32.privateApis);
23497 var DATE_PRESETS = [
23498 {
23499 id: "today",
23500 label: (0, import_i18n35.__)("Today"),
23501 getValue: () => (0, import_date4.getDate)(null)
23502 },
23503 {
23504 id: "yesterday",
23505 label: (0, import_i18n35.__)("Yesterday"),
23506 getValue: () => {
23507 const today = (0, import_date4.getDate)(null);
23508 return subDays(today, 1);
23509 }
23510 },
23511 {
23512 id: "past-week",
23513 label: (0, import_i18n35.__)("Past week"),
23514 getValue: () => {
23515 const today = (0, import_date4.getDate)(null);
23516 return subDays(today, 7);
23517 }
23518 },
23519 {
23520 id: "past-month",
23521 label: (0, import_i18n35.__)("Past month"),
23522 getValue: () => {
23523 const today = (0, import_date4.getDate)(null);
23524 return subMonths(today, 1);
23525 }
23526 }
23527 ];
23528 var DATE_RANGE_PRESETS = [
23529 {
23530 id: "last-7-days",
23531 label: (0, import_i18n35.__)("Last 7 days"),
23532 getValue: () => {
23533 const today = (0, import_date4.getDate)(null);
23534 return [subDays(today, 7), today];
23535 }
23536 },
23537 {
23538 id: "last-30-days",
23539 label: (0, import_i18n35.__)("Last 30 days"),
23540 getValue: () => {
23541 const today = (0, import_date4.getDate)(null);
23542 return [subDays(today, 30), today];
23543 }
23544 },
23545 {
23546 id: "month-to-date",
23547 label: (0, import_i18n35.__)("Month to date"),
23548 getValue: () => {
23549 const today = (0, import_date4.getDate)(null);
23550 return [startOfMonth(today), today];
23551 }
23552 },
23553 {
23554 id: "last-year",
23555 label: (0, import_i18n35.__)("Last year"),
23556 getValue: () => {
23557 const today = (0, import_date4.getDate)(null);
23558 return [subYears(today, 1), today];
23559 }
23560 },
23561 {
23562 id: "year-to-date",
23563 label: (0, import_i18n35.__)("Year to date"),
23564 getValue: () => {
23565 const today = (0, import_date4.getDate)(null);
23566 return [startOfYear(today), today];
23567 }
23568 }
23569 ];
23570 var parseDate = (dateString) => {
23571 if (!dateString) {
23572 return null;
23573 }
23574 const parsed = (0, import_date4.getDate)(dateString);
23575 return parsed && isValid(parsed) ? parsed : null;
23576 };
23577 var formatDate = (date) => {
23578 if (!date) {
23579 return "";
23580 }
23581 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
23582 };
23583 function ValidatedDateControl({
23584 field,
23585 validity,
23586 inputRefs,
23587 isTouched,
23588 setIsTouched,
23589 children
23590 }) {
23591 const { isValid: isValid2 } = field;
23592 const [customValidity, setCustomValidity] = (0, import_element69.useState)(void 0);
23593 const validateRefs = (0, import_element69.useCallback)(() => {
23594 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23595 for (const ref of refs) {
23596 const input = ref.current;
23597 if (input && !input.validity.valid) {
23598 setCustomValidity({
23599 type: "invalid",
23600 message: input.validationMessage
23601 });
23602 return;
23603 }
23604 }
23605 setCustomValidity(void 0);
23606 }, [inputRefs]);
23607 (0, import_element69.useEffect)(() => {
23608 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23609 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23610 for (const ref of refs) {
23611 const input = ref.current;
23612 if (input) {
23613 input.setCustomValidity(
23614 result?.type === "invalid" && result.message ? result.message : ""
23615 );
23616 }
23617 }
23618 }, [inputRefs, isValid2, validity]);
23619 (0, import_element69.useEffect)(() => {
23620 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23621 const handleInvalid = (event) => {
23622 event.preventDefault();
23623 setIsTouched(true);
23624 };
23625 for (const ref of refs) {
23626 ref.current?.addEventListener("invalid", handleInvalid);
23627 }
23628 return () => {
23629 for (const ref of refs) {
23630 ref.current?.removeEventListener("invalid", handleInvalid);
23631 }
23632 };
23633 }, [inputRefs, setIsTouched]);
23634 (0, import_element69.useEffect)(() => {
23635 if (!isTouched) {
23636 return;
23637 }
23638 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23639 if (result) {
23640 setCustomValidity(result);
23641 } else {
23642 validateRefs();
23643 }
23644 }, [isTouched, isValid2, validity, validateRefs]);
23645 (0, import_element69.useEffect)(() => {
23646 if (isTouched && customValidity?.message) {
23647 speak(customValidity.message);
23648 }
23649 }, [isTouched, customValidity?.message]);
23650 const onBlur = (event) => {
23651 if (isTouched) {
23652 return;
23653 }
23654 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
23655 setIsTouched(true);
23656 }
23657 };
23658 return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { onBlur, children: [
23659 children,
23660 customValidity && /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
23661 "p",
23662 {
23663 className: clsx_default(
23664 "components-validated-control__indicator",
23665 customValidity.type === "invalid" ? "is-invalid" : void 0
23666 ),
23667 children: [
23668 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23669 import_components32.Icon,
23670 {
23671 className: "components-validated-control__indicator-icon",
23672 icon: error_default,
23673 size: 16,
23674 fill: "currentColor"
23675 }
23676 ),
23677 customValidity.message
23678 ]
23679 }
23680 )
23681 ] });
23682 }
23683 function CalendarDateControl({
23684 data,
23685 field,
23686 onChange,
23687 hideLabelFromVision,
23688 markWhenOptional,
23689 validity
23690 }) {
23691 const {
23692 id,
23693 label,
23694 description,
23695 setValue,
23696 getValue,
23697 isValid: isValid2,
23698 format: fieldFormat
23699 } = field;
23700 const disabled2 = field.isDisabled({ item: data, field });
23701 const [selectedPresetId, setSelectedPresetId] = (0, import_element69.useState)(
23702 null
23703 );
23704 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23705 const fieldValue = getValue({ item: data });
23706 const value = typeof fieldValue === "string" ? fieldValue : void 0;
23707 const [calendarMonth, setCalendarMonth] = (0, import_element69.useState)(() => {
23708 const parsedDate = parseDate(value);
23709 return parsedDate || /* @__PURE__ */ new Date();
23710 });
23711 const [isTouched, setIsTouched] = (0, import_element69.useState)(false);
23712 const validityTargetRef = (0, import_element69.useRef)(null);
23713 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23714 const onChangeCallback = (0, import_element69.useCallback)(
23715 (newValue) => onChange(setValue({ item: data, value: newValue })),
23716 [data, onChange, setValue]
23717 );
23718 const onSelectDate = (0, import_element69.useCallback)(
23719 (newDate) => {
23720 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
23721 onChangeCallback(dateValue);
23722 setSelectedPresetId(null);
23723 setIsTouched(true);
23724 },
23725 [onChangeCallback]
23726 );
23727 const handlePresetClick = (0, import_element69.useCallback)(
23728 (preset) => {
23729 const presetDate = preset.getValue();
23730 const dateValue = formatDate(presetDate);
23731 setCalendarMonth(presetDate);
23732 onChangeCallback(dateValue);
23733 setSelectedPresetId(preset.id);
23734 setIsTouched(true);
23735 },
23736 [onChangeCallback]
23737 );
23738 const handleManualDateChange = (0, import_element69.useCallback)(
23739 (newValue) => {
23740 onChangeCallback(newValue);
23741 if (newValue) {
23742 const parsedDate = parseDate(newValue);
23743 if (parsedDate) {
23744 setCalendarMonth(parsedDate);
23745 }
23746 }
23747 setSelectedPresetId(null);
23748 setIsTouched(true);
23749 },
23750 [onChangeCallback]
23751 );
23752 const {
23753 timezone: { string: timezoneString }
23754 } = (0, import_date4.getSettings)();
23755 let displayLabel = label;
23756 if (isValid2?.required && !markWhenOptional) {
23757 displayLabel = `${label} (${(0, import_i18n35.__)("Required")})`;
23758 } else if (!isValid2?.required && markWhenOptional) {
23759 displayLabel = `${label} (${(0, import_i18n35.__)("Optional")})`;
23760 }
23761 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23762 ValidatedDateControl,
23763 {
23764 field,
23765 validity,
23766 inputRefs: validityTargetRef,
23767 isTouched,
23768 setIsTouched,
23769 children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23770 import_components32.BaseControl,
23771 {
23772 id,
23773 className: "dataviews-controls__date",
23774 label: displayLabel,
23775 help: description,
23776 hideLabelFromVision,
23777 children: /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23778 /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
23779 Stack,
23780 {
23781 direction: "row",
23782 gap: "sm",
23783 wrap: "wrap",
23784 justify: "flex-start",
23785 children: [
23786 DATE_PRESETS.map((preset) => {
23787 const isSelected2 = selectedPresetId === preset.id;
23788 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23789 import_components32.Button,
23790 {
23791 className: "dataviews-controls__date-preset",
23792 variant: "tertiary",
23793 isPressed: isSelected2,
23794 size: "small",
23795 disabled: disabled2,
23796 accessibleWhenDisabled: true,
23797 onClick: () => handlePresetClick(preset),
23798 children: preset.label
23799 },
23800 preset.id
23801 );
23802 }),
23803 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23804 import_components32.Button,
23805 {
23806 className: "dataviews-controls__date-preset",
23807 variant: "tertiary",
23808 isPressed: !selectedPresetId,
23809 size: "small",
23810 disabled: !!selectedPresetId || disabled2,
23811 accessibleWhenDisabled: true,
23812 children: (0, import_i18n35.__)("Custom")
23813 }
23814 )
23815 ]
23816 }
23817 ),
23818 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23819 import_components32.__experimentalInputControl,
23820 {
23821 ref: validityTargetRef,
23822 type: "date",
23823 label: (0, import_i18n35.__)("Date"),
23824 hideLabelFromVision: true,
23825 value,
23826 onChange: handleManualDateChange,
23827 required: !!field.isValid?.required,
23828 disabled: disabled2,
23829 min: minConstraint,
23830 max: maxConstraint
23831 }
23832 ),
23833 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23834 DateCalendar2,
23835 {
23836 style: { width: "100%" },
23837 selected: value ? parseDate(value) || void 0 : void 0,
23838 onSelect: onSelectDate,
23839 month: calendarMonth,
23840 onMonthChange: setCalendarMonth,
23841 timeZone: timezoneString || void 0,
23842 weekStartsOn,
23843 disabled: disabled2 || disabledMatchers,
23844 disableNavigation: disabled2
23845 }
23846 )
23847 ] })
23848 }
23849 )
23850 }
23851 );
23852 }
23853 function CalendarDateRangeControl({
23854 data,
23855 field,
23856 onChange,
23857 hideLabelFromVision,
23858 markWhenOptional,
23859 validity
23860 }) {
23861 const {
23862 id,
23863 label,
23864 description,
23865 getValue,
23866 setValue,
23867 isValid: isValid2,
23868 format: fieldFormat
23869 } = field;
23870 const disabled2 = field.isDisabled({ item: data, field });
23871 let value;
23872 const fieldValue = getValue({ item: data });
23873 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
23874 value = fieldValue;
23875 }
23876 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23877 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23878 const onChangeCallback = (0, import_element69.useCallback)(
23879 (newValue) => {
23880 onChange(
23881 setValue({
23882 item: data,
23883 value: newValue
23884 })
23885 );
23886 },
23887 [data, onChange, setValue]
23888 );
23889 const [selectedPresetId, setSelectedPresetId] = (0, import_element69.useState)(
23890 null
23891 );
23892 const selectedRange = (0, import_element69.useMemo)(() => {
23893 if (!value) {
23894 return { from: void 0, to: void 0 };
23895 }
23896 const [from, to] = value;
23897 return {
23898 from: parseDate(from) || void 0,
23899 to: parseDate(to) || void 0
23900 };
23901 }, [value]);
23902 const [calendarMonth, setCalendarMonth] = (0, import_element69.useState)(() => {
23903 return selectedRange.from || /* @__PURE__ */ new Date();
23904 });
23905 const [isTouched, setIsTouched] = (0, import_element69.useState)(false);
23906 const fromInputRef = (0, import_element69.useRef)(null);
23907 const toInputRef = (0, import_element69.useRef)(null);
23908 const updateDateRange = (0, import_element69.useCallback)(
23909 (fromDate, toDate2) => {
23910 if (fromDate && toDate2) {
23911 onChangeCallback([
23912 formatDate(fromDate),
23913 formatDate(toDate2)
23914 ]);
23915 } else if (!fromDate && !toDate2) {
23916 onChangeCallback(void 0);
23917 }
23918 },
23919 [onChangeCallback]
23920 );
23921 const onSelectCalendarRange = (0, import_element69.useCallback)(
23922 (newRange) => {
23923 updateDateRange(newRange?.from, newRange?.to);
23924 setSelectedPresetId(null);
23925 setIsTouched(true);
23926 },
23927 [updateDateRange]
23928 );
23929 const handlePresetClick = (0, import_element69.useCallback)(
23930 (preset) => {
23931 const [startDate, endDate] = preset.getValue();
23932 setCalendarMonth(startDate);
23933 updateDateRange(startDate, endDate);
23934 setSelectedPresetId(preset.id);
23935 setIsTouched(true);
23936 },
23937 [updateDateRange]
23938 );
23939 const handleManualDateChange = (0, import_element69.useCallback)(
23940 (fromOrTo, newValue) => {
23941 const [currentFrom, currentTo] = value || [
23942 void 0,
23943 void 0
23944 ];
23945 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
23946 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
23947 updateDateRange(updatedFrom, updatedTo);
23948 if (newValue) {
23949 const parsedDate = parseDate(newValue);
23950 if (parsedDate) {
23951 setCalendarMonth(parsedDate);
23952 }
23953 }
23954 setSelectedPresetId(null);
23955 setIsTouched(true);
23956 },
23957 [value, updateDateRange]
23958 );
23959 const { timezone } = (0, import_date4.getSettings)();
23960 let displayLabel = label;
23961 if (field.isValid?.required && !markWhenOptional) {
23962 displayLabel = `${label} (${(0, import_i18n35.__)("Required")})`;
23963 } else if (!field.isValid?.required && markWhenOptional) {
23964 displayLabel = `${label} (${(0, import_i18n35.__)("Optional")})`;
23965 }
23966 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23967 ValidatedDateControl,
23968 {
23969 field,
23970 validity,
23971 inputRefs: [fromInputRef, toInputRef],
23972 isTouched,
23973 setIsTouched,
23974 children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23975 import_components32.BaseControl,
23976 {
23977 id,
23978 className: "dataviews-controls__date",
23979 label: displayLabel,
23980 help: description,
23981 hideLabelFromVision,
23982 children: /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23983 /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
23984 Stack,
23985 {
23986 direction: "row",
23987 gap: "sm",
23988 wrap: "wrap",
23989 justify: "flex-start",
23990 children: [
23991 DATE_RANGE_PRESETS.map((preset) => {
23992 const isSelected2 = selectedPresetId === preset.id;
23993 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23994 import_components32.Button,
23995 {
23996 className: "dataviews-controls__date-preset",
23997 variant: "tertiary",
23998 isPressed: isSelected2,
23999 size: "small",
24000 disabled: disabled2,
24001 accessibleWhenDisabled: true,
24002 onClick: () => handlePresetClick(preset),
24003 children: preset.label
24004 },
24005 preset.id
24006 );
24007 }),
24008 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
24009 import_components32.Button,
24010 {
24011 className: "dataviews-controls__date-preset",
24012 variant: "tertiary",
24013 isPressed: !selectedPresetId,
24014 size: "small",
24015 accessibleWhenDisabled: true,
24016 disabled: !!selectedPresetId || disabled2,
24017 children: (0, import_i18n35.__)("Custom")
24018 }
24019 )
24020 ]
24021 }
24022 ),
24023 /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
24024 Stack,
24025 {
24026 direction: "row",
24027 gap: "sm",
24028 justify: "space-between",
24029 className: "dataviews-controls__date-range-inputs",
24030 children: [
24031 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
24032 import_components32.__experimentalInputControl,
24033 {
24034 ref: fromInputRef,
24035 type: "date",
24036 label: (0, import_i18n35.__)("From"),
24037 hideLabelFromVision: true,
24038 value: value?.[0],
24039 onChange: (newValue) => handleManualDateChange("from", newValue),
24040 required: !!field.isValid?.required,
24041 disabled: disabled2,
24042 min: minConstraint,
24043 max: maxConstraint
24044 }
24045 ),
24046 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
24047 import_components32.__experimentalInputControl,
24048 {
24049 ref: toInputRef,
24050 type: "date",
24051 label: (0, import_i18n35.__)("To"),
24052 hideLabelFromVision: true,
24053 value: value?.[1],
24054 onChange: (newValue) => handleManualDateChange("to", newValue),
24055 required: !!field.isValid?.required,
24056 disabled: disabled2,
24057 min: minConstraint,
24058 max: maxConstraint
24059 }
24060 )
24061 ]
24062 }
24063 ),
24064 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
24065 DateRangeCalendar,
24066 {
24067 style: { width: "100%" },
24068 selected: selectedRange,
24069 onSelect: onSelectCalendarRange,
24070 month: calendarMonth,
24071 onMonthChange: setCalendarMonth,
24072 timeZone: timezone.string || void 0,
24073 weekStartsOn,
24074 disabled: disabled2 || disabledMatchers
24075 }
24076 )
24077 ] })
24078 }
24079 )
24080 }
24081 );
24082 }
24083 function DateControl({
24084 data,
24085 field,
24086 onChange,
24087 hideLabelFromVision,
24088 markWhenOptional,
24089 operator,
24090 validity
24091 }) {
24092 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
24093 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
24094 RelativeDateControl,
24095 {
24096 className: "dataviews-controls__date",
24097 data,
24098 field,
24099 onChange,
24100 hideLabelFromVision,
24101 operator
24102 }
24103 );
24104 }
24105 if (operator === OPERATOR_BETWEEN) {
24106 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
24107 CalendarDateRangeControl,
24108 {
24109 data,
24110 field,
24111 onChange,
24112 hideLabelFromVision,
24113 markWhenOptional,
24114 validity
24115 }
24116 );
24117 }
24118 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
24119 CalendarDateControl,
24120 {
24121 data,
24122 field,
24123 onChange,
24124 hideLabelFromVision,
24125 markWhenOptional,
24126 validity
24127 }
24128 );
24129 }
24130
24131 // packages/dataviews/build-module/components/dataform-controls/select.mjs
24132 var import_components33 = __toESM(require_components(), 1);
24133 var import_element70 = __toESM(require_element(), 1);
24134 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
24135 var { ValidatedSelectControl } = unlock2(import_components33.privateApis);
24136 function Select({
24137 data,
24138 field,
24139 onChange,
24140 hideLabelFromVision,
24141 markWhenOptional,
24142 validity
24143 }) {
24144 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
24145 const disabled2 = field.isDisabled({ item: data, field });
24146 const isMultiple = type === "array";
24147 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
24148 const onChangeControl = (0, import_element70.useCallback)(
24149 (newValue) => onChange(setValue({ item: data, value: newValue })),
24150 [data, onChange, setValue]
24151 );
24152 const { elements, isLoading } = useElements({
24153 elements: field.elements,
24154 getElements: field.getElements
24155 });
24156 if (isLoading) {
24157 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_components33.Spinner, {});
24158 }
24159 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
24160 ValidatedSelectControl,
24161 {
24162 required: !!field.isValid?.required,
24163 markWhenOptional,
24164 customValidity: getCustomValidity(isValid2, validity),
24165 label,
24166 value,
24167 help: description,
24168 options: elements,
24169 onChange: onChangeControl,
24170 hideLabelFromVision,
24171 multiple: isMultiple,
24172 disabled: disabled2
24173 }
24174 );
24175 }
24176
24177 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
24178 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
24179 var ELEMENTS_THRESHOLD = 10;
24180 function AdaptiveSelect(props) {
24181 const { field } = props;
24182 const { elements } = useElements({
24183 elements: field.elements,
24184 getElements: field.getElements
24185 });
24186 if (elements.length >= ELEMENTS_THRESHOLD) {
24187 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(Combobox3, { ...props });
24188 }
24189 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(Select, { ...props });
24190 }
24191
24192 // packages/dataviews/build-module/components/dataform-controls/email.mjs
24193 var import_components35 = __toESM(require_components(), 1);
24194
24195 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
24196 var import_components34 = __toESM(require_components(), 1);
24197 var import_element71 = __toESM(require_element(), 1);
24198 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
24199 var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components34.privateApis);
24200 function ValidatedText({
24201 data,
24202 field,
24203 onChange,
24204 hideLabelFromVision,
24205 markWhenOptional,
24206 type,
24207 prefix,
24208 suffix,
24209 validity
24210 }) {
24211 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
24212 const value = getValue({ item: data });
24213 const disabled2 = field.isDisabled({ item: data, field });
24214 const onChangeControl = (0, import_element71.useCallback)(
24215 (newValue) => onChange(
24216 setValue({
24217 item: data,
24218 value: newValue
24219 })
24220 ),
24221 [data, setValue, onChange]
24222 );
24223 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24224 ValidatedInputControl2,
24225 {
24226 required: !!isValid2.required,
24227 markWhenOptional,
24228 customValidity: getCustomValidity(isValid2, validity),
24229 label,
24230 placeholder,
24231 value: value ?? "",
24232 help: description,
24233 onChange: onChangeControl,
24234 hideLabelFromVision,
24235 type,
24236 prefix,
24237 suffix,
24238 disabled: disabled2,
24239 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
24240 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
24241 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0
24242 }
24243 );
24244 }
24245
24246 // packages/dataviews/build-module/components/dataform-controls/email.mjs
24247 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
24248 function Email({
24249 data,
24250 field,
24251 onChange,
24252 hideLabelFromVision,
24253 markWhenOptional,
24254 validity
24255 }) {
24256 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24257 ValidatedText,
24258 {
24259 ...{
24260 data,
24261 field,
24262 onChange,
24263 hideLabelFromVision,
24264 markWhenOptional,
24265 validity,
24266 type: "email",
24267 prefix: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components35.Icon, { icon: envelope_default }) })
24268 }
24269 }
24270 );
24271 }
24272
24273 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
24274 var import_components36 = __toESM(require_components(), 1);
24275 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
24276 function Telephone({
24277 data,
24278 field,
24279 onChange,
24280 hideLabelFromVision,
24281 markWhenOptional,
24282 validity
24283 }) {
24284 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
24285 ValidatedText,
24286 {
24287 ...{
24288 data,
24289 field,
24290 onChange,
24291 hideLabelFromVision,
24292 markWhenOptional,
24293 validity,
24294 type: "tel",
24295 prefix: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components36.Icon, { icon: mobile_default }) })
24296 }
24297 }
24298 );
24299 }
24300
24301 // packages/dataviews/build-module/components/dataform-controls/url.mjs
24302 var import_components37 = __toESM(require_components(), 1);
24303 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
24304 function Url({
24305 data,
24306 field,
24307 onChange,
24308 hideLabelFromVision,
24309 markWhenOptional,
24310 validity
24311 }) {
24312 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24313 ValidatedText,
24314 {
24315 ...{
24316 data,
24317 field,
24318 onChange,
24319 hideLabelFromVision,
24320 markWhenOptional,
24321 validity,
24322 type: "url",
24323 prefix: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_components37.Icon, { icon: link_default }) })
24324 }
24325 }
24326 );
24327 }
24328
24329 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
24330 var import_components38 = __toESM(require_components(), 1);
24331 var import_element72 = __toESM(require_element(), 1);
24332 var import_i18n36 = __toESM(require_i18n(), 1);
24333 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
24334 var { ValidatedNumberControl } = unlock2(import_components38.privateApis);
24335 function toNumberOrEmpty(value) {
24336 if (value === "" || value === void 0) {
24337 return "";
24338 }
24339 const number = Number(value);
24340 return Number.isFinite(number) ? number : "";
24341 }
24342 function BetweenControls({
24343 value,
24344 onChange,
24345 hideLabelFromVision,
24346 step
24347 }) {
24348 const [min2 = "", max2 = ""] = value;
24349 const onChangeMin = (0, import_element72.useCallback)(
24350 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
24351 [onChange, max2]
24352 );
24353 const onChangeMax = (0, import_element72.useCallback)(
24354 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
24355 [onChange, min2]
24356 );
24357 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24358 import_components38.BaseControl,
24359 {
24360 help: (0, import_i18n36.__)("The max. value must be greater than the min. value."),
24361 children: /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(import_components38.Flex, { direction: "row", gap: 4, children: [
24362 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24363 import_components38.__experimentalNumberControl,
24364 {
24365 label: (0, import_i18n36.__)("Min."),
24366 value: min2,
24367 max: max2 ? Number(max2) - step : void 0,
24368 onChange: onChangeMin,
24369 hideLabelFromVision,
24370 step
24371 }
24372 ),
24373 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24374 import_components38.__experimentalNumberControl,
24375 {
24376 label: (0, import_i18n36.__)("Max."),
24377 value: max2,
24378 min: min2 ? Number(min2) + step : void 0,
24379 onChange: onChangeMax,
24380 hideLabelFromVision,
24381 step
24382 }
24383 )
24384 ] })
24385 }
24386 );
24387 }
24388 function ValidatedNumber({
24389 data,
24390 field,
24391 onChange,
24392 hideLabelFromVision,
24393 markWhenOptional,
24394 operator,
24395 validity
24396 }) {
24397 const decimals = field.format?.decimals ?? 0;
24398 const step = Math.pow(10, Math.abs(decimals) * -1);
24399 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24400 const value = getValue({ item: data }) ?? "";
24401 const disabled2 = field.isDisabled({ item: data, field });
24402 const onChangeControl = (0, import_element72.useCallback)(
24403 (newValue) => {
24404 onChange(
24405 setValue({
24406 item: data,
24407 // Do not convert an empty string or undefined to a number,
24408 // otherwise there's a mismatch between the UI control (empty)
24409 // and the data relied by onChange (0).
24410 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
24411 })
24412 );
24413 },
24414 [data, onChange, setValue]
24415 );
24416 const onChangeBetweenControls = (0, import_element72.useCallback)(
24417 (newValue) => {
24418 onChange(
24419 setValue({
24420 item: data,
24421 value: newValue
24422 })
24423 );
24424 },
24425 [data, onChange, setValue]
24426 );
24427 if (operator === OPERATOR_BETWEEN) {
24428 let valueBetween = ["", ""];
24429 if (Array.isArray(value) && value.length === 2 && value.every(
24430 (element) => typeof element === "number" || element === ""
24431 )) {
24432 valueBetween = value;
24433 }
24434 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24435 BetweenControls,
24436 {
24437 value: valueBetween,
24438 onChange: onChangeBetweenControls,
24439 hideLabelFromVision,
24440 step
24441 }
24442 );
24443 }
24444 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24445 ValidatedNumberControl,
24446 {
24447 required: !!isValid2.required,
24448 markWhenOptional,
24449 customValidity: getCustomValidity(isValid2, validity),
24450 label,
24451 help: description,
24452 value,
24453 onChange: onChangeControl,
24454 hideLabelFromVision,
24455 step,
24456 min: isValid2.min ? isValid2.min.constraint : void 0,
24457 max: isValid2.max ? isValid2.max.constraint : void 0,
24458 disabled: disabled2
24459 }
24460 );
24461 }
24462
24463 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
24464 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
24465 function Integer(props) {
24466 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(ValidatedNumber, { ...props });
24467 }
24468
24469 // packages/dataviews/build-module/components/dataform-controls/number.mjs
24470 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
24471 function Number2(props) {
24472 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(ValidatedNumber, { ...props });
24473 }
24474
24475 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
24476 var import_components39 = __toESM(require_components(), 1);
24477 var import_element73 = __toESM(require_element(), 1);
24478 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
24479 var { ValidatedRadioControl } = unlock2(import_components39.privateApis);
24480 function Radio({
24481 data,
24482 field,
24483 onChange,
24484 hideLabelFromVision,
24485 markWhenOptional,
24486 validity
24487 }) {
24488 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24489 const disabled2 = field.isDisabled({ item: data, field });
24490 const { elements, isLoading } = useElements({
24491 elements: field.elements,
24492 getElements: field.getElements
24493 });
24494 const value = getValue({ item: data });
24495 const onChangeControl = (0, import_element73.useCallback)(
24496 (newValue) => onChange(setValue({ item: data, value: newValue })),
24497 [data, onChange, setValue]
24498 );
24499 if (isLoading) {
24500 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_components39.Spinner, {});
24501 }
24502 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
24503 ValidatedRadioControl,
24504 {
24505 required: !!field.isValid?.required,
24506 markWhenOptional,
24507 customValidity: getCustomValidity(isValid2, validity),
24508 label,
24509 help: description,
24510 onChange: onChangeControl,
24511 options: elements,
24512 selected: value,
24513 hideLabelFromVision,
24514 disabled: disabled2
24515 }
24516 );
24517 }
24518
24519 // packages/dataviews/build-module/components/dataform-controls/text.mjs
24520 var import_element74 = __toESM(require_element(), 1);
24521 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
24522 function Text3({
24523 data,
24524 field,
24525 onChange,
24526 hideLabelFromVision,
24527 markWhenOptional,
24528 config,
24529 validity
24530 }) {
24531 const { prefix, suffix } = config || {};
24532 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24533 ValidatedText,
24534 {
24535 ...{
24536 data,
24537 field,
24538 onChange,
24539 hideLabelFromVision,
24540 markWhenOptional,
24541 validity,
24542 prefix: prefix ? (0, import_element74.createElement)(prefix) : void 0,
24543 suffix: suffix ? (0, import_element74.createElement)(suffix) : void 0
24544 }
24545 }
24546 );
24547 }
24548
24549 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
24550 var import_components40 = __toESM(require_components(), 1);
24551 var import_element75 = __toESM(require_element(), 1);
24552 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
24553 var { ValidatedToggleControl } = unlock2(import_components40.privateApis);
24554 function Toggle({
24555 field,
24556 onChange,
24557 data,
24558 hideLabelFromVision,
24559 markWhenOptional,
24560 validity
24561 }) {
24562 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24563 const disabled2 = field.isDisabled({ item: data, field });
24564 const onChangeControl = (0, import_element75.useCallback)(() => {
24565 onChange(
24566 setValue({ item: data, value: !getValue({ item: data }) })
24567 );
24568 }, [onChange, setValue, data, getValue]);
24569 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24570 ValidatedToggleControl,
24571 {
24572 required: !!isValid2.required,
24573 markWhenOptional,
24574 customValidity: getCustomValidity(isValid2, validity),
24575 hidden: hideLabelFromVision,
24576 label,
24577 help: description,
24578 checked: getValue({ item: data }),
24579 onChange: onChangeControl,
24580 disabled: disabled2
24581 }
24582 );
24583 }
24584
24585 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
24586 var import_components41 = __toESM(require_components(), 1);
24587 var import_element76 = __toESM(require_element(), 1);
24588 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
24589 var { ValidatedTextareaControl } = unlock2(import_components41.privateApis);
24590 function Textarea({
24591 data,
24592 field,
24593 onChange,
24594 hideLabelFromVision,
24595 markWhenOptional,
24596 config,
24597 validity
24598 }) {
24599 const { rows = 4 } = config || {};
24600 const disabled2 = field.isDisabled({ item: data, field });
24601 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24602 const value = field.getValue({ item: data });
24603 const onChangeControl = (0, import_element76.useCallback)(
24604 (newValue) => onChange(setValue({ item: data, value: newValue })),
24605 [data, onChange, setValue]
24606 );
24607 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
24608 ValidatedTextareaControl,
24609 {
24610 required: !!isValid2.required,
24611 markWhenOptional,
24612 customValidity: getCustomValidity(isValid2, validity),
24613 label,
24614 placeholder,
24615 value: value ?? "",
24616 help: description,
24617 onChange: onChangeControl,
24618 rows,
24619 disabled: disabled2,
24620 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
24621 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
24622 __next40pxDefaultSize: true,
24623 hideLabelFromVision
24624 }
24625 );
24626 }
24627
24628 // packages/dataviews/build-module/components/dataform-controls/richtext/index.mjs
24629 var import_element78 = __toESM(require_element(), 1);
24630
24631 // packages/dataviews/build-module/components/dataform-controls/richtext/control.mjs
24632 var import_components42 = __toESM(require_components(), 1);
24633 var import_compose12 = __toESM(require_compose(), 1);
24634 var import_element77 = __toESM(require_element(), 1);
24635 var import_rich_text2 = __toESM(require_rich_text(), 1);
24636
24637 // packages/dataviews/build-module/components/dataform-controls/richtext/utils.mjs
24638 var EMPTY_ARRAY6 = [];
24639 function getAllowedFormats({
24640 allowedFormats,
24641 disableFormats
24642 }) {
24643 if (disableFormats) {
24644 return EMPTY_ARRAY6;
24645 }
24646 return allowedFormats;
24647 }
24648
24649 // packages/dataviews/build-module/components/dataform-controls/richtext/format-edit.mjs
24650 var import_rich_text = __toESM(require_rich_text(), 1);
24651 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
24652 var import_react28 = __toESM(require_react(), 1);
24653 var EMPTY_CONTEXT = {};
24654 function Edit({
24655 onChange,
24656 onFocus,
24657 value,
24658 forwardedRef,
24659 settings,
24660 isVisible: isVisible2
24661 }) {
24662 const { name, edit: EditFunction } = settings;
24663 if (!EditFunction) {
24664 return null;
24665 }
24666 const activeFormat = (0, import_rich_text.getActiveFormat)(value, name);
24667 const isActive = activeFormat !== void 0;
24668 const activeObject = (0, import_rich_text.getActiveObject)(value);
24669 const isObjectActive = activeObject !== void 0 && activeObject.type === name;
24670 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24671 EditFunction,
24672 {
24673 isActive,
24674 isVisible: isVisible2,
24675 activeAttributes: isActive ? activeFormat.attributes || {} : {},
24676 isObjectActive,
24677 activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {},
24678 value,
24679 onChange,
24680 onFocus,
24681 contentRef: forwardedRef,
24682 context: EMPTY_CONTEXT
24683 },
24684 name
24685 );
24686 }
24687 function FormatEdit({
24688 formatTypes,
24689 ...props
24690 }) {
24691 return formatTypes.map((settings) => /* @__PURE__ */ (0, import_react28.createElement)(Edit, { settings, ...props, key: settings.name }));
24692 }
24693
24694 // packages/dataviews/build-module/components/dataform-controls/richtext/control.mjs
24695 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
24696 var {
24697 ValidatedContentEditableControl: RichTextControlShell,
24698 withIgnoreIMEEvents
24699 } = unlock2(import_components42.privateApis);
24700 var {
24701 useRichText,
24702 KeyboardShortcutContext,
24703 InputEventContext,
24704 shortcutsListener,
24705 inputEventsListener
24706 } = unlock2(import_rich_text2.privateApis);
24707 var EMPTY_COMPLETERS = [];
24708 function RichTextControl({
24709 label,
24710 value: attrValue,
24711 onChange,
24712 placeholder,
24713 id,
24714 clientId,
24715 className,
24716 hideLabelFromVision,
24717 help,
24718 disabled: disabled2,
24719 required,
24720 markWhenOptional,
24721 customValidity,
24722 allowedFormats,
24723 disableFormats,
24724 withoutInteractiveFormatting,
24725 preserveWhiteSpace,
24726 disableLineBreaks,
24727 focusOnMount,
24728 completers = EMPTY_COMPLETERS
24729 }) {
24730 const [selection, setSelection] = (0, import_element77.useState)({
24731 start: void 0,
24732 end: void 0
24733 });
24734 const [isSelected2, setIsSelected] = (0, import_element77.useState)(false);
24735 const anchorRef = (0, import_element77.useRef)(void 0);
24736 const inputEvents = (0, import_element77.useRef)(/* @__PURE__ */ new Set());
24737 const keyboardShortcuts = (0, import_element77.useRef)(
24738 /* @__PURE__ */ new Set()
24739 );
24740 const focusOutside = (0, import_compose12.__experimentalUseFocusOutside)(() => setIsSelected(false));
24741 const adjustedAllowedFormats = getAllowedFormats({
24742 allowedFormats,
24743 disableFormats
24744 });
24745 const {
24746 value,
24747 onChange: onRichTextChange,
24748 ref: richTextRef,
24749 formatTypes,
24750 getValue
24751 } = useRichText({
24752 value: attrValue,
24753 onChange,
24754 selectionStart: selection.start,
24755 selectionEnd: selection.end,
24756 onSelectionChange: (start, end) => setSelection({ start, end }),
24757 __unstableIsSelected: isSelected2,
24758 preserveWhiteSpace: !!preserveWhiteSpace,
24759 placeholder,
24760 __unstableDisableFormats: disableFormats,
24761 allowedFormats: adjustedAllowedFormats,
24762 withoutInteractiveFormatting,
24763 __unstableFormatTypeHandlerContext: (0, import_element77.useMemo)(
24764 () => ({
24765 richTextIdentifier: id,
24766 blockClientId: clientId
24767 }),
24768 [id, clientId]
24769 )
24770 });
24771 function onFocus() {
24772 anchorRef.current?.focus();
24773 }
24774 const eventListenersPropsRef = (0, import_element77.useRef)({
24775 keyboardShortcuts,
24776 inputEvents
24777 });
24778 const inputRulePropsRef = (0, import_element77.useRef)({
24779 formatTypes,
24780 getValue,
24781 onChange: onRichTextChange
24782 });
24783 (0, import_element77.useInsertionEffect)(() => {
24784 inputRulePropsRef.current = {
24785 formatTypes,
24786 getValue,
24787 onChange: onRichTextChange
24788 };
24789 });
24790 const enterRef = (0, import_compose12.useRefEffect)(
24791 (element) => {
24792 if (disabled2) {
24793 return;
24794 }
24795 const onKeyDown = withIgnoreIMEEvents((event) => {
24796 if (event.key !== "Enter" || event.defaultPrevented || event.metaKey || event.ctrlKey) {
24797 return;
24798 }
24799 event.preventDefault();
24800 if (disableLineBreaks) {
24801 return;
24802 }
24803 const { getValue: getCurrentValue2, onChange: handleChange } = inputRulePropsRef.current;
24804 const current = getCurrentValue2();
24805 handleChange(
24806 (0, import_rich_text2.insert)(
24807 current,
24808 "\n",
24809 current.start ?? current.text.length,
24810 current.end ?? current.text.length
24811 )
24812 );
24813 });
24814 element.addEventListener("keydown", onKeyDown);
24815 return () => element.removeEventListener("keydown", onKeyDown);
24816 },
24817 [disableLineBreaks, disabled2]
24818 );
24819 const eventListenersRef = (0, import_compose12.useRefEffect)(
24820 (element) => {
24821 if (!isSelected2) {
24822 return;
24823 }
24824 const cleanupShortcuts = shortcutsListener(
24825 eventListenersPropsRef
24826 )(element);
24827 const cleanupInputEvents = inputEventsListener(
24828 eventListenersPropsRef
24829 )(element);
24830 function onFormatInput(event) {
24831 if (event.inputType !== "insertText" && event.type !== "compositionend") {
24832 return;
24833 }
24834 const {
24835 formatTypes: types,
24836 getValue: getCurrentValue2,
24837 onChange: handleChange
24838 } = inputRulePropsRef.current;
24839 const current = getCurrentValue2();
24840 const transformed = types.reduce(
24841 (accumulator, {
24842 __unstableInputRule
24843 }) => __unstableInputRule ? __unstableInputRule(accumulator) : accumulator,
24844 current
24845 );
24846 if (transformed !== current) {
24847 handleChange({
24848 ...transformed,
24849 activeFormats: current.activeFormats
24850 });
24851 }
24852 }
24853 element.addEventListener("input", onFormatInput);
24854 element.addEventListener("compositionend", onFormatInput);
24855 return () => {
24856 cleanupShortcuts();
24857 cleanupInputEvents();
24858 element.removeEventListener("input", onFormatInput);
24859 element.removeEventListener("compositionend", onFormatInput);
24860 };
24861 },
24862 [isSelected2]
24863 );
24864 const { ref: autocompleteRef, ...autocompleteProps } = (0, import_components42.__unstableUseAutocompleteProps)(
24865 {
24866 completers,
24867 record: value,
24868 onChange: onRichTextChange,
24869 // This control's completers insert their completion into the value;
24870 // none replace the whole value, so the required `onReplace` is a
24871 // no-op here.
24872 onReplace: () => {
24873 }
24874 }
24875 );
24876 const focusOnMountRef = (0, import_compose12.useRefEffect)(
24877 (element) => {
24878 if (focusOnMount && !disabled2) {
24879 element.focus();
24880 }
24881 },
24882 [focusOnMount, disabled2]
24883 );
24884 const editableRef = (0, import_compose12.useMergeRefs)([
24885 richTextRef,
24886 anchorRef,
24887 eventListenersRef,
24888 enterRef,
24889 focusOnMountRef,
24890 autocompleteRef
24891 ]);
24892 return (
24893 // Focus boundary for the field's selection: `onFocus` selects on entry;
24894 // the spread `useFocusOutside` handlers deselect once focus leaves.
24895 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24896 "div",
24897 {
24898 ...focusOutside,
24899 onFocus: (event) => {
24900 setIsSelected(true);
24901 focusOutside.onFocus(event);
24902 },
24903 children: /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(import_components42.SlotFillProvider, { children: [
24904 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24905 RichTextControlShell,
24906 {
24907 label,
24908 id,
24909 className: clsx_default(
24910 "dataviews-controls__richtext",
24911 className
24912 ),
24913 placeholder,
24914 hideLabelFromVision,
24915 help,
24916 disabled: disabled2,
24917 required,
24918 markWhenOptional,
24919 customValidity,
24920 value: value.text,
24921 "aria-multiline": !disableLineBreaks,
24922 ...autocompleteProps,
24923 ref: editableRef
24924 }
24925 ),
24926 isSelected2 && !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24927 KeyboardShortcutContext.Provider,
24928 {
24929 value: keyboardShortcuts,
24930 children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(InputEventContext.Provider, { value: inputEvents, children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24931 FormatEdit,
24932 {
24933 value,
24934 onChange: onRichTextChange,
24935 onFocus,
24936 formatTypes,
24937 forwardedRef: anchorRef,
24938 isVisible: true
24939 }
24940 ) })
24941 }
24942 )
24943 ] })
24944 }
24945 )
24946 );
24947 }
24948
24949 // packages/dataviews/build-module/components/dataform-controls/richtext/index.mjs
24950 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
24951 function RichText({
24952 data,
24953 field,
24954 onChange,
24955 hideLabelFromVision,
24956 markWhenOptional,
24957 config,
24958 validity
24959 }) {
24960 const {
24961 className,
24962 clientId,
24963 allowedFormats,
24964 disableFormats,
24965 withoutInteractiveFormatting,
24966 preserveWhiteSpace,
24967 disableLineBreaks
24968 } = config || {};
24969 const disabled2 = field.isDisabled({ item: data, field });
24970 const { label, placeholder, description, id, setValue, isValid: isValid2 } = field;
24971 const value = field.getValue({ item: data }) ?? "";
24972 const onChangeControl = (0, import_element78.useCallback)(
24973 (newValue) => onChange(setValue({ item: data, value: newValue })),
24974 [data, onChange, setValue]
24975 );
24976 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
24977 RichTextControl,
24978 {
24979 label,
24980 value,
24981 onChange: onChangeControl,
24982 placeholder,
24983 id,
24984 hideLabelFromVision,
24985 help: description,
24986 disabled: disabled2,
24987 required: !!isValid2.required,
24988 markWhenOptional,
24989 customValidity: getCustomValidity(isValid2, validity),
24990 className,
24991 clientId,
24992 allowedFormats,
24993 disableFormats,
24994 withoutInteractiveFormatting,
24995 preserveWhiteSpace,
24996 disableLineBreaks
24997 }
24998 );
24999 }
25000
25001 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
25002 var import_components43 = __toESM(require_components(), 1);
25003 var import_element79 = __toESM(require_element(), 1);
25004 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
25005 var { ValidatedToggleGroupControl } = unlock2(import_components43.privateApis);
25006 function ToggleGroup({
25007 data,
25008 field,
25009 onChange,
25010 hideLabelFromVision,
25011 markWhenOptional,
25012 validity
25013 }) {
25014 const { getValue, setValue, isValid: isValid2 } = field;
25015 const disabled2 = field.isDisabled({ item: data, field });
25016 const value = getValue({ item: data });
25017 const onChangeControl = (0, import_element79.useCallback)(
25018 (newValue) => onChange(setValue({ item: data, value: newValue })),
25019 [data, onChange, setValue]
25020 );
25021 const { elements, isLoading } = useElements({
25022 elements: field.elements,
25023 getElements: field.getElements
25024 });
25025 if (isLoading) {
25026 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_components43.Spinner, {});
25027 }
25028 if (elements.length === 0) {
25029 return null;
25030 }
25031 const selectedOption = elements.find((el) => el.value === value);
25032 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25033 ValidatedToggleGroupControl,
25034 {
25035 required: !!field.isValid?.required,
25036 markWhenOptional,
25037 customValidity: getCustomValidity(isValid2, validity),
25038 isBlock: true,
25039 label: field.label,
25040 help: selectedOption?.description || field.description,
25041 onChange: onChangeControl,
25042 value,
25043 hideLabelFromVision,
25044 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25045 import_components43.__experimentalToggleGroupControlOption,
25046 {
25047 label: el.label,
25048 value: el.value,
25049 disabled: disabled2
25050 },
25051 el.value
25052 ))
25053 }
25054 );
25055 }
25056
25057 // packages/dataviews/build-module/components/dataform-controls/array.mjs
25058 var import_components44 = __toESM(require_components(), 1);
25059 var import_element80 = __toESM(require_element(), 1);
25060 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
25061 var { ValidatedFormTokenField } = unlock2(import_components44.privateApis);
25062 function ArrayControl({
25063 data,
25064 field,
25065 onChange,
25066 hideLabelFromVision,
25067 markWhenOptional,
25068 validity
25069 }) {
25070 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
25071 const value = getValue({ item: data });
25072 const disabled2 = field.isDisabled({ item: data, field });
25073 const { elements, isLoading } = useElements({
25074 elements: field.elements,
25075 getElements: field.getElements
25076 });
25077 const arrayValueAsElements = (0, import_element80.useMemo)(
25078 () => Array.isArray(value) ? value.map((token) => {
25079 const element = elements?.find(
25080 (suggestion) => suggestion.value === token
25081 );
25082 return element || { value: token, label: token };
25083 }) : [],
25084 [value, elements]
25085 );
25086 const onChangeControl = (0, import_element80.useCallback)(
25087 (tokens) => {
25088 const valueTokens = tokens.map((token) => {
25089 if (typeof token === "object" && "value" in token) {
25090 return token.value;
25091 }
25092 return token;
25093 });
25094 onChange(setValue({ item: data, value: valueTokens }));
25095 },
25096 [onChange, setValue, data]
25097 );
25098 if (isLoading) {
25099 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_components44.Spinner, {});
25100 }
25101 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
25102 ValidatedFormTokenField,
25103 {
25104 required: !!isValid2?.required,
25105 markWhenOptional,
25106 customValidity: getCustomValidity(isValid2, validity),
25107 label: hideLabelFromVision ? void 0 : label,
25108 value: arrayValueAsElements,
25109 onChange: onChangeControl,
25110 placeholder,
25111 suggestions: elements?.map((element) => element.value),
25112 disabled: disabled2,
25113 __experimentalValidateInput: (token) => {
25114 if (field.isValid?.elements && elements) {
25115 return elements.some(
25116 (element) => element.value === token || element.label === token
25117 );
25118 }
25119 return true;
25120 },
25121 __experimentalExpandOnFocus: elements && elements.length > 0,
25122 help: description ?? (field.isValid?.elements ? "" : void 0),
25123 displayTransform: (token) => {
25124 if (typeof token === "object" && "label" in token) {
25125 return token.label;
25126 }
25127 if (typeof token === "string" && elements) {
25128 const element = elements.find(
25129 (el) => el.value === token
25130 );
25131 return element?.label || token;
25132 }
25133 return token;
25134 },
25135 __experimentalRenderItem: ({ item }) => {
25136 if (typeof item === "string" && elements) {
25137 const element = elements.find(
25138 (el) => el.value === item
25139 );
25140 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)("span", { children: element?.label || item });
25141 }
25142 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)("span", { children: item });
25143 }
25144 }
25145 );
25146 }
25147
25148 // node_modules/colord/index.mjs
25149 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
25150 var t = function(r3) {
25151 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
25152 };
25153 var n = function(r3, t2, n2) {
25154 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
25155 };
25156 var e = function(r3, t2, n2) {
25157 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
25158 };
25159 var u = function(r3) {
25160 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
25161 };
25162 var a = function(r3) {
25163 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
25164 };
25165 var o = function(r3) {
25166 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
25167 };
25168 var i = /^#([0-9a-f]{3,8})$/i;
25169 var s = function(r3) {
25170 var t2 = r3.toString(16);
25171 return t2.length < 2 ? "0" + t2 : t2;
25172 };
25173 var h = function(r3) {
25174 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;
25175 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
25176 };
25177 var b = function(r3) {
25178 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
25179 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
25180 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;
25181 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 };
25182 };
25183 var g = function(r3) {
25184 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
25185 };
25186 var d = function(r3) {
25187 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
25188 };
25189 var f = function(r3) {
25190 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 }));
25191 var t2, n2, e2;
25192 };
25193 var c = function(r3) {
25194 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 };
25195 var t2, n2, e2, u2;
25196 };
25197 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
25198 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
25199 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
25200 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
25201 var y = { string: [[function(r3) {
25202 var t2 = i.exec(r3);
25203 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;
25204 }, "hex"], [function(r3) {
25205 var t2 = v.exec(r3) || m.exec(r3);
25206 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;
25207 }, "rgb"], [function(t2) {
25208 var n2 = l.exec(t2) || p.exec(t2);
25209 if (!n2) return null;
25210 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) });
25211 return f(a2);
25212 }, "hsl"]], object: [[function(r3) {
25213 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
25214 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
25215 }, "rgb"], [function(r3) {
25216 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
25217 if (!t(n2) || !t(e2) || !t(u2)) return null;
25218 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
25219 return f(i2);
25220 }, "hsl"], [function(r3) {
25221 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
25222 if (!t(n2) || !t(a2) || !t(o2)) return null;
25223 var h2 = (function(r4) {
25224 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
25225 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
25226 return b(h2);
25227 }, "hsv"]] };
25228 var N = function(r3, t2) {
25229 for (var n2 = 0; n2 < t2.length; n2++) {
25230 var e2 = t2[n2][0](r3);
25231 if (e2) return [e2, t2[n2][1]];
25232 }
25233 return [null, void 0];
25234 };
25235 var x = function(r3) {
25236 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
25237 };
25238 var M = function(r3, t2) {
25239 var n2 = c(r3);
25240 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
25241 };
25242 var H = function(r3) {
25243 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
25244 };
25245 var $ = function(r3, t2) {
25246 var n2 = c(r3);
25247 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
25248 };
25249 var j = (function() {
25250 function r3(r4) {
25251 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
25252 }
25253 return r3.prototype.isValid = function() {
25254 return null !== this.parsed;
25255 }, r3.prototype.brightness = function() {
25256 return n(H(this.rgba), 2);
25257 }, r3.prototype.isDark = function() {
25258 return H(this.rgba) < 0.5;
25259 }, r3.prototype.isLight = function() {
25260 return H(this.rgba) >= 0.5;
25261 }, r3.prototype.toHex = function() {
25262 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;
25263 var r4, t2, e2, u2, a2, i2;
25264 }, r3.prototype.toRgb = function() {
25265 return o(this.rgba);
25266 }, r3.prototype.toRgbString = function() {
25267 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 + ")";
25268 var r4, t2, n2, e2, u2;
25269 }, r3.prototype.toHsl = function() {
25270 return d(c(this.rgba));
25271 }, r3.prototype.toHslString = function() {
25272 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 + "%)";
25273 var r4, t2, n2, e2, u2;
25274 }, r3.prototype.toHsv = function() {
25275 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
25276 var r4;
25277 }, r3.prototype.invert = function() {
25278 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
25279 var r4;
25280 }, r3.prototype.saturate = function(r4) {
25281 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
25282 }, r3.prototype.desaturate = function(r4) {
25283 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
25284 }, r3.prototype.grayscale = function() {
25285 return w(M(this.rgba, -1));
25286 }, r3.prototype.lighten = function(r4) {
25287 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
25288 }, r3.prototype.darken = function(r4) {
25289 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
25290 }, r3.prototype.rotate = function(r4) {
25291 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
25292 }, r3.prototype.alpha = function(r4) {
25293 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
25294 var t2;
25295 }, r3.prototype.hue = function(r4) {
25296 var t2 = c(this.rgba);
25297 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
25298 }, r3.prototype.isEqual = function(r4) {
25299 return this.toHex() === w(r4).toHex();
25300 }, r3;
25301 })();
25302 var w = function(r3) {
25303 return r3 instanceof j ? r3 : new j(r3);
25304 };
25305
25306 // packages/dataviews/build-module/components/dataform-controls/color.mjs
25307 var import_components45 = __toESM(require_components(), 1);
25308 var import_element81 = __toESM(require_element(), 1);
25309 var import_i18n37 = __toESM(require_i18n(), 1);
25310 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
25311 var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components45.privateApis);
25312 var ColorPickerDropdown = ({
25313 color,
25314 onColorChange,
25315 disabled: disabled2
25316 }) => {
25317 const validColor = color && w(color).isValid() ? color : "#ffffff";
25318 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
25319 import_components45.Dropdown,
25320 {
25321 className: "dataviews-controls__color-picker-dropdown",
25322 popoverProps: { resize: false },
25323 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
25324 import_components45.Button,
25325 {
25326 onClick: onToggle,
25327 "aria-label": (0, import_i18n37.__)("Open color picker"),
25328 size: "small",
25329 disabled: disabled2,
25330 accessibleWhenDisabled: true,
25331 icon: () => /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(import_components45.ColorIndicator, { colorValue: validColor })
25332 }
25333 ),
25334 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(import_components45.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
25335 import_components45.ColorPicker,
25336 {
25337 color: validColor,
25338 onChange: onColorChange,
25339 enableAlpha: true
25340 }
25341 ) })
25342 }
25343 );
25344 };
25345 function Color({
25346 data,
25347 field,
25348 onChange,
25349 hideLabelFromVision,
25350 markWhenOptional,
25351 validity
25352 }) {
25353 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
25354 const disabled2 = field.isDisabled({ item: data, field });
25355 const value = field.getValue({ item: data }) || "";
25356 const handleColorChange = (0, import_element81.useCallback)(
25357 (newColor) => {
25358 onChange(setValue({ item: data, value: newColor }));
25359 },
25360 [data, onChange, setValue]
25361 );
25362 const handleInputChange = (0, import_element81.useCallback)(
25363 (newValue) => {
25364 onChange(setValue({ item: data, value: newValue || "" }));
25365 },
25366 [data, onChange, setValue]
25367 );
25368 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
25369 ValidatedInputControl3,
25370 {
25371 required: !!field.isValid?.required,
25372 markWhenOptional,
25373 customValidity: getCustomValidity(isValid2, validity),
25374 label,
25375 placeholder,
25376 value,
25377 help: description,
25378 onChange: handleInputChange,
25379 hideLabelFromVision,
25380 type: "text",
25381 disabled: disabled2,
25382 prefix: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(import_components45.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
25383 ColorPickerDropdown,
25384 {
25385 color: value,
25386 onColorChange: handleColorChange,
25387 disabled: disabled2
25388 }
25389 ) })
25390 }
25391 );
25392 }
25393
25394 // packages/dataviews/build-module/components/dataform-controls/password.mjs
25395 var import_components46 = __toESM(require_components(), 1);
25396 var import_element82 = __toESM(require_element(), 1);
25397 var import_i18n38 = __toESM(require_i18n(), 1);
25398 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
25399 function Password({
25400 data,
25401 field,
25402 onChange,
25403 hideLabelFromVision,
25404 markWhenOptional,
25405 validity
25406 }) {
25407 const [isVisible2, setIsVisible] = (0, import_element82.useState)(false);
25408 const disabled2 = field.isDisabled({ item: data, field });
25409 const toggleVisibility = (0, import_element82.useCallback)(() => {
25410 setIsVisible((prev) => !prev);
25411 }, []);
25412 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
25413 ValidatedText,
25414 {
25415 ...{
25416 data,
25417 field,
25418 onChange,
25419 hideLabelFromVision,
25420 markWhenOptional,
25421 validity,
25422 type: isVisible2 ? "text" : "password",
25423 suffix: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(import_components46.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
25424 import_components46.Button,
25425 {
25426 icon: isVisible2 ? unseen_default : seen_default,
25427 onClick: toggleVisibility,
25428 size: "small",
25429 label: isVisible2 ? (0, import_i18n38.__)("Hide password") : (0, import_i18n38.__)("Show password"),
25430 disabled: disabled2,
25431 accessibleWhenDisabled: true
25432 }
25433 ) })
25434 }
25435 }
25436 );
25437 }
25438
25439 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
25440 function hasElements(field) {
25441 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
25442 }
25443
25444 // packages/dataviews/build-module/components/dataform-controls/index.mjs
25445 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1);
25446 var FORM_CONTROLS = {
25447 adaptiveSelect: AdaptiveSelect,
25448 array: ArrayControl,
25449 checkbox: Checkbox,
25450 color: Color,
25451 combobox: Combobox3,
25452 datetime: DateTime,
25453 date: DateControl,
25454 email: Email,
25455 telephone: Telephone,
25456 url: Url,
25457 integer: Integer,
25458 number: Number2,
25459 password: Password,
25460 radio: Radio,
25461 select: Select,
25462 text: Text3,
25463 toggle: Toggle,
25464 textarea: Textarea,
25465 richtext: RichText,
25466 toggleGroup: ToggleGroup
25467 };
25468 function isEditConfig(value) {
25469 return value && typeof value === "object" && typeof value.control === "string";
25470 }
25471 function createConfiguredControl(config) {
25472 const { control, ...controlConfig } = config;
25473 const BaseControlType = getControlByType(control);
25474 if (BaseControlType === null) {
25475 return null;
25476 }
25477 return function ConfiguredControl(props) {
25478 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(BaseControlType, { ...props, config: controlConfig });
25479 };
25480 }
25481 function getControl(field, fallback) {
25482 if (typeof field.Edit === "function") {
25483 return field.Edit;
25484 }
25485 if (typeof field.Edit === "string") {
25486 return getControlByType(field.Edit);
25487 }
25488 if (isEditConfig(field.Edit)) {
25489 return createConfiguredControl(field.Edit);
25490 }
25491 if (hasElements(field) && field.type !== "array") {
25492 return getControlByType("adaptiveSelect");
25493 }
25494 if (fallback === null) {
25495 return null;
25496 }
25497 return getControlByType(fallback);
25498 }
25499 function getControlByType(type) {
25500 if (Object.keys(FORM_CONTROLS).includes(type)) {
25501 return FORM_CONTROLS[type];
25502 }
25503 return null;
25504 }
25505
25506 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
25507 function getFilterBy(field, defaultOperators, validOperators) {
25508 if (field.filterBy === false) {
25509 return false;
25510 }
25511 const operators = field.filterBy?.operators?.filter(
25512 (op) => validOperators.includes(op)
25513 ) ?? defaultOperators;
25514 if (operators.length === 0) {
25515 return false;
25516 }
25517 return {
25518 isPrimary: !!field.filterBy?.isPrimary,
25519 operators
25520 };
25521 }
25522 var get_filter_by_default = getFilterBy;
25523
25524 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
25525 var getValueFromId = (id) => ({ item }) => {
25526 const path = id.split(".");
25527 let value = item;
25528 for (const segment of path) {
25529 if (value.hasOwnProperty(segment)) {
25530 value = value[segment];
25531 } else {
25532 value = void 0;
25533 }
25534 }
25535 return value;
25536 };
25537 var get_value_from_id_default = getValueFromId;
25538
25539 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
25540 var setValueFromId = (id) => ({ value }) => {
25541 const path = id.split(".");
25542 const result = {};
25543 let current = result;
25544 for (const segment of path.slice(0, -1)) {
25545 current[segment] = {};
25546 current = current[segment];
25547 }
25548 current[path.at(-1)] = value;
25549 return result;
25550 };
25551 var set_value_from_id_default = setValueFromId;
25552
25553 // packages/dataviews/build-module/field-types/email.mjs
25554 var import_i18n39 = __toESM(require_i18n(), 1);
25555
25556 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
25557 function RenderFromElements({
25558 item,
25559 field
25560 }) {
25561 const { elements, isLoading } = useElements({
25562 elements: field.elements,
25563 getElements: field.getElements
25564 });
25565 const value = field.getValue({ item });
25566 if (isLoading) {
25567 return value;
25568 }
25569 if (elements.length === 0) {
25570 return value;
25571 }
25572 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
25573 }
25574
25575 // packages/dataviews/build-module/field-types/utils/render-default.mjs
25576 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1);
25577 function render({
25578 item,
25579 field
25580 }) {
25581 if (field.hasElements) {
25582 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(RenderFromElements, { item, field });
25583 }
25584 return field.getValueFormatted({ item, field });
25585 }
25586
25587 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
25588 var sort_text_default = (a2, b2, direction) => {
25589 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
25590 };
25591
25592 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
25593 function isValidRequired(item, field) {
25594 const value = field.getValue({ item });
25595 return ![void 0, "", null].includes(value);
25596 }
25597
25598 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
25599 function isValidMinLength(item, field) {
25600 if (typeof field.isValid.minLength?.constraint !== "number") {
25601 return false;
25602 }
25603 const value = field.getValue({ item });
25604 if ([void 0, "", null].includes(value)) {
25605 return true;
25606 }
25607 return String(value).length >= field.isValid.minLength.constraint;
25608 }
25609
25610 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
25611 function isValidMaxLength(item, field) {
25612 if (typeof field.isValid.maxLength?.constraint !== "number") {
25613 return false;
25614 }
25615 const value = field.getValue({ item });
25616 if ([void 0, "", null].includes(value)) {
25617 return true;
25618 }
25619 return String(value).length <= field.isValid.maxLength.constraint;
25620 }
25621
25622 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
25623 function isValidPattern(item, field) {
25624 if (field.isValid.pattern?.constraint === void 0) {
25625 return true;
25626 }
25627 try {
25628 const regexp = new RegExp(field.isValid.pattern.constraint);
25629 const value = field.getValue({ item });
25630 if ([void 0, "", null].includes(value)) {
25631 return true;
25632 }
25633 return regexp.test(String(value));
25634 } catch {
25635 return false;
25636 }
25637 }
25638
25639 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
25640 function isValidElements(item, field) {
25641 const elements = field.elements ?? [];
25642 const validValues = elements.map((el) => el.value);
25643 if (validValues.length === 0) {
25644 return true;
25645 }
25646 const value = field.getValue({ item });
25647 return [].concat(value).every((v2) => validValues.includes(v2));
25648 }
25649
25650 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
25651 function getValueFormatted({
25652 item,
25653 field
25654 }) {
25655 return field.getValue({ item });
25656 }
25657 var get_value_formatted_default_default = getValueFormatted;
25658
25659 // packages/dataviews/build-module/field-types/email.mjs
25660 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])?)*$/;
25661 function isValidCustom(item, field) {
25662 const value = field.getValue({ item });
25663 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
25664 return (0, import_i18n39.__)("Value must be a valid email address.");
25665 }
25666 return null;
25667 }
25668 var email_default = {
25669 type: "email",
25670 render,
25671 Edit: "email",
25672 sort: sort_text_default,
25673 enableSorting: true,
25674 enableGlobalSearch: false,
25675 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25676 validOperators: [
25677 OPERATOR_IS,
25678 OPERATOR_IS_NOT,
25679 OPERATOR_CONTAINS,
25680 OPERATOR_NOT_CONTAINS,
25681 OPERATOR_STARTS_WITH,
25682 // Multiple selection
25683 OPERATOR_IS_ANY,
25684 OPERATOR_IS_NONE,
25685 OPERATOR_IS_ALL,
25686 OPERATOR_IS_NOT_ALL
25687 ],
25688 format: {},
25689 getValueFormatted: get_value_formatted_default_default,
25690 validate: {
25691 required: isValidRequired,
25692 pattern: isValidPattern,
25693 minLength: isValidMinLength,
25694 maxLength: isValidMaxLength,
25695 elements: isValidElements,
25696 custom: isValidCustom
25697 }
25698 };
25699
25700 // packages/dataviews/build-module/field-types/integer.mjs
25701 var import_i18n40 = __toESM(require_i18n(), 1);
25702
25703 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
25704 var sort_number_default = (a2, b2, direction) => {
25705 return direction === "asc" ? a2 - b2 : b2 - a2;
25706 };
25707
25708 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
25709 function isValidMin(item, field) {
25710 if (typeof field.isValid.min?.constraint !== "number") {
25711 return false;
25712 }
25713 const value = field.getValue({ item });
25714 if ([void 0, "", null].includes(value)) {
25715 return true;
25716 }
25717 return Number(value) >= field.isValid.min.constraint;
25718 }
25719
25720 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
25721 function isValidMax(item, field) {
25722 if (typeof field.isValid.max?.constraint !== "number") {
25723 return false;
25724 }
25725 const value = field.getValue({ item });
25726 if ([void 0, "", null].includes(value)) {
25727 return true;
25728 }
25729 return Number(value) <= field.isValid.max.constraint;
25730 }
25731
25732 // packages/dataviews/build-module/field-types/integer.mjs
25733 var format2 = {
25734 separatorThousand: ","
25735 };
25736 function getValueFormatted2({
25737 item,
25738 field
25739 }) {
25740 let value = field.getValue({ item });
25741 if (value === null || value === void 0) {
25742 return "";
25743 }
25744 value = Number(value);
25745 if (!Number.isFinite(value)) {
25746 return String(value);
25747 }
25748 let formatInteger;
25749 if (field.type !== "integer") {
25750 formatInteger = format2;
25751 } else {
25752 formatInteger = field.format;
25753 }
25754 const { separatorThousand } = formatInteger;
25755 const integerValue = Math.trunc(value);
25756 if (!separatorThousand) {
25757 return String(integerValue);
25758 }
25759 return String(integerValue).replace(
25760 /\B(?=(\d{3})+(?!\d))/g,
25761 separatorThousand
25762 );
25763 }
25764 function isValidCustom2(item, field) {
25765 const value = field.getValue({ item });
25766 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
25767 return (0, import_i18n40.__)("Value must be an integer.");
25768 }
25769 return null;
25770 }
25771 var integer_default = {
25772 type: "integer",
25773 render,
25774 Edit: "integer",
25775 sort: sort_number_default,
25776 enableSorting: true,
25777 enableGlobalSearch: false,
25778 defaultOperators: [
25779 OPERATOR_IS,
25780 OPERATOR_IS_NOT,
25781 OPERATOR_LESS_THAN,
25782 OPERATOR_GREATER_THAN,
25783 OPERATOR_LESS_THAN_OR_EQUAL,
25784 OPERATOR_GREATER_THAN_OR_EQUAL,
25785 OPERATOR_BETWEEN
25786 ],
25787 validOperators: [
25788 // Single-selection
25789 OPERATOR_IS,
25790 OPERATOR_IS_NOT,
25791 OPERATOR_LESS_THAN,
25792 OPERATOR_GREATER_THAN,
25793 OPERATOR_LESS_THAN_OR_EQUAL,
25794 OPERATOR_GREATER_THAN_OR_EQUAL,
25795 OPERATOR_BETWEEN,
25796 // Multiple-selection
25797 OPERATOR_IS_ANY,
25798 OPERATOR_IS_NONE,
25799 OPERATOR_IS_ALL,
25800 OPERATOR_IS_NOT_ALL
25801 ],
25802 format: format2,
25803 getValueFormatted: getValueFormatted2,
25804 validate: {
25805 required: isValidRequired,
25806 min: isValidMin,
25807 max: isValidMax,
25808 elements: isValidElements,
25809 custom: isValidCustom2
25810 }
25811 };
25812
25813 // packages/dataviews/build-module/field-types/number.mjs
25814 var import_i18n41 = __toESM(require_i18n(), 1);
25815 var format3 = {
25816 separatorThousand: ",",
25817 separatorDecimal: ".",
25818 decimals: 2
25819 };
25820 function getValueFormatted3({
25821 item,
25822 field
25823 }) {
25824 let value = field.getValue({ item });
25825 if (value === null || value === void 0) {
25826 return "";
25827 }
25828 value = Number(value);
25829 if (!Number.isFinite(value)) {
25830 return String(value);
25831 }
25832 let formatNumber;
25833 if (field.type !== "number") {
25834 formatNumber = format3;
25835 } else {
25836 formatNumber = field.format;
25837 }
25838 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
25839 const fixedValue = value.toFixed(decimals);
25840 const [integerPart, decimalPart] = fixedValue.split(".");
25841 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
25842 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
25843 }
25844 function isEmpty(value) {
25845 return value === "" || value === void 0 || value === null;
25846 }
25847 function isValidCustom3(item, field) {
25848 const value = field.getValue({ item });
25849 if (!isEmpty(value) && !Number.isFinite(value)) {
25850 return (0, import_i18n41.__)("Value must be a number.");
25851 }
25852 return null;
25853 }
25854 var number_default = {
25855 type: "number",
25856 render,
25857 Edit: "number",
25858 sort: sort_number_default,
25859 enableSorting: true,
25860 enableGlobalSearch: false,
25861 defaultOperators: [
25862 OPERATOR_IS,
25863 OPERATOR_IS_NOT,
25864 OPERATOR_LESS_THAN,
25865 OPERATOR_GREATER_THAN,
25866 OPERATOR_LESS_THAN_OR_EQUAL,
25867 OPERATOR_GREATER_THAN_OR_EQUAL,
25868 OPERATOR_BETWEEN
25869 ],
25870 validOperators: [
25871 // Single-selection
25872 OPERATOR_IS,
25873 OPERATOR_IS_NOT,
25874 OPERATOR_LESS_THAN,
25875 OPERATOR_GREATER_THAN,
25876 OPERATOR_LESS_THAN_OR_EQUAL,
25877 OPERATOR_GREATER_THAN_OR_EQUAL,
25878 OPERATOR_BETWEEN,
25879 // Multiple-selection
25880 OPERATOR_IS_ANY,
25881 OPERATOR_IS_NONE,
25882 OPERATOR_IS_ALL,
25883 OPERATOR_IS_NOT_ALL
25884 ],
25885 format: format3,
25886 getValueFormatted: getValueFormatted3,
25887 validate: {
25888 required: isValidRequired,
25889 min: isValidMin,
25890 max: isValidMax,
25891 elements: isValidElements,
25892 custom: isValidCustom3
25893 }
25894 };
25895
25896 // packages/dataviews/build-module/field-types/text.mjs
25897 var text_default = {
25898 type: "text",
25899 render,
25900 Edit: "text",
25901 sort: sort_text_default,
25902 enableSorting: true,
25903 enableGlobalSearch: false,
25904 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25905 validOperators: [
25906 // Single selection
25907 OPERATOR_IS,
25908 OPERATOR_IS_NOT,
25909 OPERATOR_CONTAINS,
25910 OPERATOR_NOT_CONTAINS,
25911 OPERATOR_STARTS_WITH,
25912 // Multiple selection
25913 OPERATOR_IS_ANY,
25914 OPERATOR_IS_NONE,
25915 OPERATOR_IS_ALL,
25916 OPERATOR_IS_NOT_ALL
25917 ],
25918 format: {},
25919 getValueFormatted: get_value_formatted_default_default,
25920 validate: {
25921 required: isValidRequired,
25922 pattern: isValidPattern,
25923 minLength: isValidMinLength,
25924 maxLength: isValidMaxLength,
25925 elements: isValidElements
25926 }
25927 };
25928
25929 // packages/dataviews/build-module/field-types/datetime.mjs
25930 var import_date7 = __toESM(require_date(), 1);
25931
25932 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
25933 var import_date6 = __toESM(require_date(), 1);
25934 function parseDateLike(value) {
25935 if (!value) {
25936 return null;
25937 }
25938 if (!isValid(new Date(value))) {
25939 return null;
25940 }
25941 const parsed = (0, import_date6.getDate)(value);
25942 return parsed && isValid(parsed) ? parsed : null;
25943 }
25944 function validateDateLikeBoundary(item, field, boundary) {
25945 const constraint = field.isValid[boundary]?.constraint;
25946 if (typeof constraint !== "string") {
25947 return false;
25948 }
25949 const value = field.getValue({ item });
25950 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
25951 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
25952 return true;
25953 }
25954 const parsedConstraint = parseDateLike(constraint);
25955 const parsedValue = parseDateLike(String(boundaryValue));
25956 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
25957 }
25958 function isValidMinDate(item, field) {
25959 return validateDateLikeBoundary(item, field, "min");
25960 }
25961 function isValidMaxDate(item, field) {
25962 return validateDateLikeBoundary(item, field, "max");
25963 }
25964
25965 // packages/dataviews/build-module/field-types/datetime.mjs
25966 var format4 = {
25967 datetime: (0, import_date7.getSettings)().formats.datetime,
25968 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
25969 };
25970 function getValueFormatted4({
25971 item,
25972 field
25973 }) {
25974 const value = field.getValue({ item });
25975 if (["", void 0, null].includes(value)) {
25976 return "";
25977 }
25978 let formatDatetime;
25979 if (field.type !== "datetime") {
25980 formatDatetime = format4;
25981 } else {
25982 formatDatetime = field.format;
25983 }
25984 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
25985 }
25986 var sort = (a2, b2, direction) => {
25987 const timeA = new Date(a2).getTime();
25988 const timeB = new Date(b2).getTime();
25989 return direction === "asc" ? timeA - timeB : timeB - timeA;
25990 };
25991 var datetime_default = {
25992 type: "datetime",
25993 render,
25994 Edit: "datetime",
25995 sort,
25996 enableSorting: true,
25997 enableGlobalSearch: false,
25998 defaultOperators: [
25999 OPERATOR_ON,
26000 OPERATOR_NOT_ON,
26001 OPERATOR_BEFORE,
26002 OPERATOR_AFTER,
26003 OPERATOR_BEFORE_INC,
26004 OPERATOR_AFTER_INC,
26005 OPERATOR_IN_THE_PAST,
26006 OPERATOR_OVER
26007 ],
26008 validOperators: [
26009 OPERATOR_ON,
26010 OPERATOR_NOT_ON,
26011 OPERATOR_BEFORE,
26012 OPERATOR_AFTER,
26013 OPERATOR_BEFORE_INC,
26014 OPERATOR_AFTER_INC,
26015 OPERATOR_IN_THE_PAST,
26016 OPERATOR_OVER
26017 ],
26018 format: format4,
26019 getValueFormatted: getValueFormatted4,
26020 validate: {
26021 required: isValidRequired,
26022 elements: isValidElements,
26023 min: isValidMinDate,
26024 max: isValidMaxDate
26025 }
26026 };
26027
26028 // packages/dataviews/build-module/field-types/date.mjs
26029 var import_date8 = __toESM(require_date(), 1);
26030 var format5 = {
26031 date: (0, import_date8.getSettings)().formats.date,
26032 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
26033 };
26034 function getValueFormatted5({
26035 item,
26036 field
26037 }) {
26038 const value = field.getValue({ item });
26039 if (["", void 0, null].includes(value)) {
26040 return "";
26041 }
26042 let formatDate2;
26043 if (field.type !== "date") {
26044 formatDate2 = format5;
26045 } else {
26046 formatDate2 = field.format;
26047 }
26048 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
26049 }
26050 var sort2 = (a2, b2, direction) => {
26051 const timeA = new Date(a2).getTime();
26052 const timeB = new Date(b2).getTime();
26053 return direction === "asc" ? timeA - timeB : timeB - timeA;
26054 };
26055 var date_default = {
26056 type: "date",
26057 render,
26058 Edit: "date",
26059 sort: sort2,
26060 enableSorting: true,
26061 enableGlobalSearch: false,
26062 defaultOperators: [
26063 OPERATOR_ON,
26064 OPERATOR_NOT_ON,
26065 OPERATOR_BEFORE,
26066 OPERATOR_AFTER,
26067 OPERATOR_BEFORE_INC,
26068 OPERATOR_AFTER_INC,
26069 OPERATOR_IN_THE_PAST,
26070 OPERATOR_OVER,
26071 OPERATOR_BETWEEN
26072 ],
26073 validOperators: [
26074 OPERATOR_ON,
26075 OPERATOR_NOT_ON,
26076 OPERATOR_BEFORE,
26077 OPERATOR_AFTER,
26078 OPERATOR_BEFORE_INC,
26079 OPERATOR_AFTER_INC,
26080 OPERATOR_IN_THE_PAST,
26081 OPERATOR_OVER,
26082 OPERATOR_BETWEEN
26083 ],
26084 format: format5,
26085 getValueFormatted: getValueFormatted5,
26086 validate: {
26087 required: isValidRequired,
26088 elements: isValidElements,
26089 min: isValidMinDate,
26090 max: isValidMaxDate
26091 }
26092 };
26093
26094 // packages/dataviews/build-module/field-types/boolean.mjs
26095 var import_i18n42 = __toESM(require_i18n(), 1);
26096
26097 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
26098 function isValidRequiredForBool(item, field) {
26099 const value = field.getValue({ item });
26100 return value === true;
26101 }
26102
26103 // packages/dataviews/build-module/field-types/boolean.mjs
26104 function getValueFormatted6({
26105 item,
26106 field
26107 }) {
26108 const value = field.getValue({ item });
26109 if (value === true) {
26110 return (0, import_i18n42.__)("True");
26111 }
26112 if (value === false) {
26113 return (0, import_i18n42.__)("False");
26114 }
26115 return "";
26116 }
26117 function isValidCustom4(item, field) {
26118 const value = field.getValue({ item });
26119 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
26120 return (0, import_i18n42.__)("Value must be true, false, or undefined");
26121 }
26122 return null;
26123 }
26124 var sort3 = (a2, b2, direction) => {
26125 const boolA = Boolean(a2);
26126 const boolB = Boolean(b2);
26127 if (boolA === boolB) {
26128 return 0;
26129 }
26130 if (direction === "asc") {
26131 return boolA ? 1 : -1;
26132 }
26133 return boolA ? -1 : 1;
26134 };
26135 var boolean_default = {
26136 type: "boolean",
26137 render,
26138 Edit: "checkbox",
26139 sort: sort3,
26140 validate: {
26141 required: isValidRequiredForBool,
26142 elements: isValidElements,
26143 custom: isValidCustom4
26144 },
26145 enableSorting: true,
26146 enableGlobalSearch: false,
26147 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
26148 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
26149 format: {},
26150 getValueFormatted: getValueFormatted6
26151 };
26152
26153 // packages/dataviews/build-module/field-types/media.mjs
26154 var media_default = {
26155 type: "media",
26156 render: () => null,
26157 Edit: null,
26158 sort: () => 0,
26159 enableSorting: false,
26160 enableGlobalSearch: false,
26161 defaultOperators: [],
26162 validOperators: [],
26163 format: {},
26164 getValueFormatted: get_value_formatted_default_default,
26165 // cannot validate any constraint, so
26166 // the only available validation for the field author
26167 // would be providing a custom validator.
26168 validate: {}
26169 };
26170
26171 // packages/dataviews/build-module/field-types/array.mjs
26172 var import_i18n43 = __toESM(require_i18n(), 1);
26173
26174 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
26175 function isValidRequiredForArray(item, field) {
26176 const value = field.getValue({ item });
26177 return Array.isArray(value) && value.length > 0 && value.every(
26178 (element) => ![void 0, "", null].includes(element)
26179 );
26180 }
26181
26182 // packages/dataviews/build-module/field-types/array.mjs
26183 function getValueFormatted7({
26184 item,
26185 field
26186 }) {
26187 const value = field.getValue({ item });
26188 const arr = Array.isArray(value) ? value : [];
26189 return arr.join(", ");
26190 }
26191 function render2({ item, field }) {
26192 return getValueFormatted7({ item, field });
26193 }
26194 function isValidCustom5(item, field) {
26195 const value = field.getValue({ item });
26196 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
26197 return (0, import_i18n43.__)("Value must be an array.");
26198 }
26199 if (!value.every((v2) => typeof v2 === "string")) {
26200 return (0, import_i18n43.__)("Every value must be a string.");
26201 }
26202 return null;
26203 }
26204 var sort4 = (a2, b2, direction) => {
26205 const arrA = Array.isArray(a2) ? a2 : [];
26206 const arrB = Array.isArray(b2) ? b2 : [];
26207 if (arrA.length !== arrB.length) {
26208 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
26209 }
26210 const joinedA = arrA.join(",");
26211 const joinedB = arrB.join(",");
26212 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
26213 };
26214 var array_default = {
26215 type: "array",
26216 render: render2,
26217 Edit: "array",
26218 sort: sort4,
26219 enableSorting: true,
26220 enableGlobalSearch: false,
26221 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
26222 validOperators: [
26223 OPERATOR_IS_ANY,
26224 OPERATOR_IS_NONE,
26225 OPERATOR_IS_ALL,
26226 OPERATOR_IS_NOT_ALL
26227 ],
26228 format: {},
26229 getValueFormatted: getValueFormatted7,
26230 validate: {
26231 required: isValidRequiredForArray,
26232 elements: isValidElements,
26233 custom: isValidCustom5
26234 }
26235 };
26236
26237 // packages/dataviews/build-module/field-types/password.mjs
26238 function getValueFormatted8({
26239 item,
26240 field
26241 }) {
26242 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
26243 }
26244 var password_default = {
26245 type: "password",
26246 render,
26247 Edit: "password",
26248 sort: () => 0,
26249 // Passwords should not be sortable for security reasons
26250 enableSorting: false,
26251 enableGlobalSearch: false,
26252 defaultOperators: [],
26253 validOperators: [],
26254 format: {},
26255 getValueFormatted: getValueFormatted8,
26256 validate: {
26257 required: isValidRequired,
26258 pattern: isValidPattern,
26259 minLength: isValidMinLength,
26260 maxLength: isValidMaxLength,
26261 elements: isValidElements
26262 }
26263 };
26264
26265 // packages/dataviews/build-module/field-types/telephone.mjs
26266 var telephone_default = {
26267 type: "telephone",
26268 render,
26269 Edit: "telephone",
26270 sort: sort_text_default,
26271 enableSorting: true,
26272 enableGlobalSearch: false,
26273 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
26274 validOperators: [
26275 OPERATOR_IS,
26276 OPERATOR_IS_NOT,
26277 OPERATOR_CONTAINS,
26278 OPERATOR_NOT_CONTAINS,
26279 OPERATOR_STARTS_WITH,
26280 // Multiple selection
26281 OPERATOR_IS_ANY,
26282 OPERATOR_IS_NONE,
26283 OPERATOR_IS_ALL,
26284 OPERATOR_IS_NOT_ALL
26285 ],
26286 format: {},
26287 getValueFormatted: get_value_formatted_default_default,
26288 validate: {
26289 required: isValidRequired,
26290 pattern: isValidPattern,
26291 minLength: isValidMinLength,
26292 maxLength: isValidMaxLength,
26293 elements: isValidElements
26294 }
26295 };
26296
26297 // packages/dataviews/build-module/field-types/color.mjs
26298 var import_i18n44 = __toESM(require_i18n(), 1);
26299 var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1);
26300 function render3({ item, field }) {
26301 if (field.hasElements) {
26302 return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(RenderFromElements, { item, field });
26303 }
26304 const value = get_value_formatted_default_default({ item, field });
26305 if (!value || !w(value).isValid()) {
26306 return value;
26307 }
26308 return /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
26309 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
26310 "div",
26311 {
26312 style: {
26313 width: "16px",
26314 height: "16px",
26315 borderRadius: "50%",
26316 backgroundColor: value,
26317 border: "1px solid #ddd",
26318 flexShrink: 0
26319 }
26320 }
26321 ),
26322 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)("span", { children: value })
26323 ] });
26324 }
26325 function isValidCustom6(item, field) {
26326 const value = field.getValue({ item });
26327 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
26328 return (0, import_i18n44.__)("Value must be a valid color.");
26329 }
26330 return null;
26331 }
26332 var sort5 = (a2, b2, direction) => {
26333 const colorA = w(a2);
26334 const colorB = w(b2);
26335 if (!colorA.isValid() && !colorB.isValid()) {
26336 return 0;
26337 }
26338 if (!colorA.isValid()) {
26339 return direction === "asc" ? 1 : -1;
26340 }
26341 if (!colorB.isValid()) {
26342 return direction === "asc" ? -1 : 1;
26343 }
26344 const hslA = colorA.toHsl();
26345 const hslB = colorB.toHsl();
26346 if (hslA.h !== hslB.h) {
26347 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
26348 }
26349 if (hslA.s !== hslB.s) {
26350 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
26351 }
26352 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
26353 };
26354 var color_default = {
26355 type: "color",
26356 render: render3,
26357 Edit: "color",
26358 sort: sort5,
26359 enableSorting: true,
26360 enableGlobalSearch: false,
26361 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
26362 validOperators: [
26363 OPERATOR_IS,
26364 OPERATOR_IS_NOT,
26365 OPERATOR_IS_ANY,
26366 OPERATOR_IS_NONE
26367 ],
26368 format: {},
26369 getValueFormatted: get_value_formatted_default_default,
26370 validate: {
26371 required: isValidRequired,
26372 elements: isValidElements,
26373 custom: isValidCustom6
26374 }
26375 };
26376
26377 // packages/dataviews/build-module/field-types/url.mjs
26378 var url_default = {
26379 type: "url",
26380 render,
26381 Edit: "url",
26382 sort: sort_text_default,
26383 enableSorting: true,
26384 enableGlobalSearch: false,
26385 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
26386 validOperators: [
26387 OPERATOR_IS,
26388 OPERATOR_IS_NOT,
26389 OPERATOR_CONTAINS,
26390 OPERATOR_NOT_CONTAINS,
26391 OPERATOR_STARTS_WITH,
26392 // Multiple selection
26393 OPERATOR_IS_ANY,
26394 OPERATOR_IS_NONE,
26395 OPERATOR_IS_ALL,
26396 OPERATOR_IS_NOT_ALL
26397 ],
26398 format: {},
26399 getValueFormatted: get_value_formatted_default_default,
26400 validate: {
26401 required: isValidRequired,
26402 pattern: isValidPattern,
26403 minLength: isValidMinLength,
26404 maxLength: isValidMaxLength,
26405 elements: isValidElements
26406 }
26407 };
26408
26409 // packages/dataviews/build-module/field-types/no-type.mjs
26410 var sort6 = (a2, b2, direction) => {
26411 if (typeof a2 === "number" && typeof b2 === "number") {
26412 return sort_number_default(a2, b2, direction);
26413 }
26414 return sort_text_default(a2, b2, direction);
26415 };
26416 var no_type_default = {
26417 // type: no type for this one
26418 render,
26419 Edit: null,
26420 sort: sort6,
26421 enableSorting: true,
26422 enableGlobalSearch: false,
26423 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
26424 validOperators: getAllOperatorNames(),
26425 format: {},
26426 getValueFormatted: get_value_formatted_default_default,
26427 validate: {
26428 required: isValidRequired,
26429 elements: isValidElements
26430 }
26431 };
26432
26433 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
26434 function supportsNumericRangeConstraint(type) {
26435 return type === "integer" || type === "number";
26436 }
26437 function supportsDateRangeConstraint(type) {
26438 return type === "date" || type === "datetime";
26439 }
26440 function normalizeRangeRule(value, fieldType, key) {
26441 const validator = fieldType.validate[key];
26442 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
26443 return { constraint: value, validate: validator };
26444 }
26445 return void 0;
26446 }
26447 function getIsValid(field, fieldType) {
26448 const rules = field.isValid;
26449 let required;
26450 if (rules?.required === true && fieldType.validate.required !== void 0) {
26451 required = {
26452 constraint: true,
26453 validate: fieldType.validate.required
26454 };
26455 }
26456 let elements;
26457 if ((rules?.elements === true || // elements is enabled unless the field opts-out
26458 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
26459 elements = {
26460 constraint: true,
26461 validate: fieldType.validate.elements
26462 };
26463 }
26464 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
26465 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
26466 const minLengthValue = rules?.minLength;
26467 let minLength;
26468 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
26469 minLength = {
26470 constraint: minLengthValue,
26471 validate: fieldType.validate.minLength
26472 };
26473 }
26474 const maxLengthValue = rules?.maxLength;
26475 let maxLength;
26476 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
26477 maxLength = {
26478 constraint: maxLengthValue,
26479 validate: fieldType.validate.maxLength
26480 };
26481 }
26482 const patternValue = rules?.pattern;
26483 let pattern;
26484 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
26485 pattern = {
26486 constraint: patternValue,
26487 validate: fieldType.validate.pattern
26488 };
26489 }
26490 const custom = rules?.custom ?? fieldType.validate.custom;
26491 return {
26492 required,
26493 elements,
26494 min: min2,
26495 max: max2,
26496 minLength,
26497 maxLength,
26498 pattern,
26499 custom
26500 };
26501 }
26502
26503 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
26504 function getFilter(fieldType) {
26505 return fieldType.validOperators.reduce((accumulator, operator) => {
26506 const operatorObj = getOperatorByName(operator);
26507 if (operatorObj?.filter) {
26508 accumulator[operator] = operatorObj.filter;
26509 }
26510 return accumulator;
26511 }, {});
26512 }
26513
26514 // packages/dataviews/build-module/field-types/utils/get-format.mjs
26515 function getFormat(field, fieldType) {
26516 return {
26517 ...fieldType.format,
26518 ...field.format
26519 };
26520 }
26521 var get_format_default = getFormat;
26522
26523 // packages/dataviews/build-module/field-types/index.mjs
26524 function getFieldTypeByName(type) {
26525 const found = [
26526 email_default,
26527 integer_default,
26528 number_default,
26529 text_default,
26530 datetime_default,
26531 date_default,
26532 boolean_default,
26533 media_default,
26534 array_default,
26535 password_default,
26536 telephone_default,
26537 color_default,
26538 url_default
26539 ].find((fieldType) => fieldType?.type === type);
26540 if (!!found) {
26541 return found;
26542 }
26543 return no_type_default;
26544 }
26545 function normalizeFields(fields) {
26546 return fields.map((field) => {
26547 const fieldType = getFieldTypeByName(field.type);
26548 const getValue = field.getValue || get_value_from_id_default(field.id);
26549 const sort7 = function(a2, b2, direction) {
26550 const aValue = getValue({ item: a2 });
26551 const bValue = getValue({ item: b2 });
26552 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
26553 };
26554 return {
26555 id: field.id,
26556 label: field.label || field.id,
26557 header: field.header || field.label || field.id,
26558 description: field.description,
26559 placeholder: field.placeholder,
26560 getValue,
26561 setValue: field.setValue || set_value_from_id_default(field.id),
26562 elements: field.elements,
26563 getElements: field.getElements,
26564 hasElements: hasElements(field),
26565 isVisible: field.isVisible,
26566 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
26567 enableHiding: field.enableHiding ?? true,
26568 readOnly: field.readOnly ?? false,
26569 // The type provides defaults for the following props
26570 type: fieldType.type,
26571 render: field.render ?? fieldType.render,
26572 Edit: getControl(field, fieldType.Edit),
26573 sort: sort7,
26574 enableSorting: field.enableSorting ?? fieldType.enableSorting,
26575 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
26576 isValid: getIsValid(field, fieldType),
26577 filterBy: get_filter_by_default(
26578 field,
26579 fieldType.defaultOperators,
26580 fieldType.validOperators
26581 ),
26582 filter: getFilter(fieldType),
26583 format: get_format_default(field, fieldType),
26584 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
26585 };
26586 });
26587 }
26588
26589 // packages/dataviews/build-module/hooks/use-data.mjs
26590 var import_element83 = __toESM(require_element(), 1);
26591 function useData({
26592 view,
26593 data: shownData,
26594 getItemId,
26595 isLoading,
26596 paginationInfo,
26597 selection
26598 }) {
26599 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
26600 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element83.useState)(
26601 !isLoading
26602 );
26603 (0, import_element83.useEffect)(() => {
26604 if (!isLoading) {
26605 setHasInitiallyLoaded(true);
26606 }
26607 }, [isLoading]);
26608 const previousDataRef = (0, import_element83.useRef)(shownData);
26609 const previousPaginationInfoRef = (0, import_element83.useRef)(paginationInfo);
26610 (0, import_element83.useEffect)(() => {
26611 if (!isLoading) {
26612 previousDataRef.current = shownData;
26613 previousPaginationInfoRef.current = paginationInfo;
26614 }
26615 }, [shownData, isLoading, paginationInfo]);
26616 const [visibleEntries, setVisibleEntries] = (0, import_element83.useState)([]);
26617 const positionMapRef = (0, import_element83.useRef)(/* @__PURE__ */ new Map());
26618 const allLoadedRecordsRef = (0, import_element83.useRef)([]);
26619 const prevViewParamsRef = (0, import_element83.useRef)({
26620 search: void 0,
26621 filters: void 0,
26622 perPage: void 0
26623 });
26624 const scrollDirectionRef = (0, import_element83.useRef)(void 0);
26625 const prevStartPositionRef = (0, import_element83.useRef)(void 0);
26626 const hasInitializedRef = (0, import_element83.useRef)(false);
26627 const allLoadedRecords = (0, import_element83.useMemo)(() => {
26628 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
26629 if (view.startPosition < prevStartPositionRef.current) {
26630 scrollDirectionRef.current = "up";
26631 } else if (view.startPosition > prevStartPositionRef.current) {
26632 scrollDirectionRef.current = "down";
26633 }
26634 }
26635 prevStartPositionRef.current = view.startPosition;
26636 const currentFiltersKey = JSON.stringify(view.filters ?? []);
26637 const prevFiltersKey = prevViewParamsRef.current.filters;
26638 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
26639 hasInitializedRef.current = true;
26640 prevViewParamsRef.current = {
26641 search: view.search,
26642 filters: currentFiltersKey,
26643 perPage: view.perPage
26644 };
26645 if (shouldReset) {
26646 positionMapRef.current.clear();
26647 scrollDirectionRef.current = void 0;
26648 const startPosition = view.search ? 1 : view.startPosition ?? 1;
26649 const records = shownData.map((record, index2) => {
26650 const position = startPosition + index2;
26651 positionMapRef.current.set(getItemId(record), position);
26652 return {
26653 ...record,
26654 position
26655 };
26656 });
26657 allLoadedRecordsRef.current = records;
26658 return records;
26659 }
26660 const prev = allLoadedRecordsRef.current;
26661 const shownDataIds = new Set(shownData.map(getItemId));
26662 const scrollDirection = scrollDirectionRef.current;
26663 const basePosition = view.search ? 1 : view.startPosition ?? 1;
26664 const newRecords = shownData.map((record, index2) => {
26665 const itemId = getItemId(record);
26666 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
26667 if (position !== void 0) {
26668 positionMapRef.current.set(itemId, position);
26669 }
26670 return {
26671 ...record,
26672 position
26673 };
26674 });
26675 if (newRecords.length === 0) {
26676 return prev;
26677 }
26678 const prevWithoutDuplicates = prev.filter(
26679 (record) => !shownDataIds.has(getItemId(record))
26680 );
26681 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
26682 allRecords.sort((a2, b2) => {
26683 const posA = a2.position;
26684 const posB = b2.position;
26685 return posA - posB;
26686 });
26687 let result = allRecords;
26688 if (visibleEntries.length > 0) {
26689 const visibleMin = Math.min(...visibleEntries);
26690 const visibleMax = Math.max(...visibleEntries);
26691 const buffer = 20;
26692 const recordPositions = allRecords.map(
26693 (r3) => r3.position
26694 );
26695 const minRecordPos = Math.min(...recordPositions);
26696 const maxRecordPos = Math.max(...recordPositions);
26697 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
26698 if (hasOverlap) {
26699 result = allRecords.filter((record) => {
26700 const itemId = getItemId(record);
26701 const isSelected2 = selection?.includes(itemId);
26702 if (isSelected2) {
26703 return true;
26704 }
26705 const itemPosition = record.position;
26706 if (scrollDirection === "up") {
26707 return itemPosition <= visibleMax + buffer;
26708 } else if (scrollDirection === "down") {
26709 return itemPosition >= visibleMin - buffer;
26710 }
26711 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
26712 });
26713 }
26714 }
26715 allLoadedRecordsRef.current = result;
26716 return result;
26717 }, [
26718 shownData,
26719 view.search,
26720 view.filters,
26721 view.perPage,
26722 view.startPosition,
26723 view.infiniteScrollEnabled,
26724 visibleEntries,
26725 selection,
26726 getItemId
26727 ]);
26728 if (!isInfiniteScrollEnabled) {
26729 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
26730 return {
26731 data: dataToReturn.map((item) => ({
26732 ...item,
26733 position: void 0
26734 })),
26735 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
26736 hasInitiallyLoaded,
26737 setVisibleEntries: void 0
26738 };
26739 }
26740 return {
26741 data: allLoadedRecords,
26742 paginationInfo,
26743 hasInitiallyLoaded,
26744 setVisibleEntries
26745 };
26746 }
26747
26748 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
26749 var import_element84 = __toESM(require_element(), 1);
26750 var import_compose13 = __toESM(require_compose(), 1);
26751 function captureAnchorElement(container, anchorElementRef, direction) {
26752 const containerRect = container.getBoundingClientRect();
26753 const centerY = containerRect.top + containerRect.height / 2;
26754 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
26755 if (items.length === 0) {
26756 return false;
26757 }
26758 const bestAnchor = items.reduce((best, item) => {
26759 const itemRect = item.getBoundingClientRect();
26760 const itemCenterY = itemRect.top + itemRect.height / 2;
26761 const distance = Math.abs(itemCenterY - centerY);
26762 const bestRect = best.getBoundingClientRect();
26763 const bestCenterY = bestRect.top + bestRect.height / 2;
26764 const bestDistance = Math.abs(bestCenterY - centerY);
26765 return distance < bestDistance ? item : best;
26766 });
26767 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
26768 const anchorRect = bestAnchor.getBoundingClientRect();
26769 anchorElementRef.current = {
26770 posinset,
26771 viewportOffset: anchorRect.top - containerRect.top,
26772 scrollTop: container.scrollTop,
26773 direction
26774 };
26775 return true;
26776 }
26777 function useInfiniteScroll({
26778 view,
26779 onChangeView,
26780 isLoading,
26781 paginationInfo,
26782 containerRef,
26783 setVisibleEntries
26784 }) {
26785 const anchorElementRef = (0, import_element84.useRef)(null);
26786 const viewRef = (0, import_element84.useRef)(view);
26787 const isLoadingRef = (0, import_element84.useRef)(isLoading);
26788 const onChangeViewRef = (0, import_element84.useRef)(onChangeView);
26789 const totalItemsRef = (0, import_element84.useRef)(paginationInfo.totalItems);
26790 (0, import_element84.useLayoutEffect)(() => {
26791 viewRef.current = view;
26792 isLoadingRef.current = isLoading;
26793 onChangeViewRef.current = onChangeView;
26794 totalItemsRef.current = paginationInfo.totalItems;
26795 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
26796 const intersectionObserverCallback = (0, import_element84.useCallback)(
26797 (entries) => {
26798 if (!setVisibleEntries) {
26799 return;
26800 }
26801 setVisibleEntries((prev) => {
26802 const newVisibleEntries = new Set(prev);
26803 let hasChanged = false;
26804 entries.forEach((entry) => {
26805 const posInSet = Number(
26806 entry.target?.attributes?.getNamedItem(
26807 "aria-posinset"
26808 )?.value
26809 );
26810 if (isNaN(posInSet)) {
26811 return;
26812 }
26813 if (entry.isIntersecting) {
26814 if (!newVisibleEntries.has(posInSet)) {
26815 newVisibleEntries.add(posInSet);
26816 hasChanged = true;
26817 }
26818 } else if (newVisibleEntries.has(posInSet)) {
26819 newVisibleEntries.delete(posInSet);
26820 hasChanged = true;
26821 }
26822 });
26823 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
26824 });
26825 },
26826 [setVisibleEntries]
26827 );
26828 (0, import_element84.useLayoutEffect)(() => {
26829 const container = containerRef.current;
26830 const anchor = anchorElementRef.current;
26831 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
26832 return;
26833 }
26834 const anchorElement = container.querySelector(
26835 `[aria-posinset="${anchor.posinset}"]`
26836 );
26837 if (anchorElement) {
26838 const containerRect = container.getBoundingClientRect();
26839 const anchorRect = anchorElement.getBoundingClientRect();
26840 const currentOffset = anchorRect.top - containerRect.top;
26841 const scrollAdjustment = currentOffset - anchor.viewportOffset + (container.scrollTop - anchor.scrollTop);
26842 if (Math.abs(scrollAdjustment) > 1) {
26843 container.scrollTop += scrollAdjustment;
26844 }
26845 }
26846 anchorElementRef.current = null;
26847 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
26848 const intersectionObserverRef = (0, import_element84.useRef)(
26849 null
26850 );
26851 (0, import_element84.useEffect)(() => {
26852 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
26853 if (intersectionObserverRef.current) {
26854 intersectionObserverRef.current.disconnect();
26855 intersectionObserverRef.current = null;
26856 }
26857 return;
26858 }
26859 intersectionObserverRef.current = new IntersectionObserver(
26860 intersectionObserverCallback,
26861 { root: null, rootMargin: "0px", threshold: 0.1 }
26862 );
26863 return () => {
26864 if (intersectionObserverRef.current) {
26865 intersectionObserverRef.current.disconnect();
26866 intersectionObserverRef.current = null;
26867 }
26868 };
26869 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
26870 (0, import_element84.useEffect)(() => {
26871 if (!view.infiniteScrollEnabled || !containerRef.current) {
26872 return;
26873 }
26874 let lastScrollTop = 0;
26875 const BOTTOM_THRESHOLD = 600;
26876 const TOP_THRESHOLD = 800;
26877 const handleScroll = (0, import_compose13.throttle)((event) => {
26878 const currentView = viewRef.current;
26879 const totalItems = totalItemsRef.current;
26880 const target = event.target;
26881 const scrollTop = target.scrollTop;
26882 const scrollHeight = target.scrollHeight;
26883 const clientHeight = target.clientHeight;
26884 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
26885 lastScrollTop = scrollTop;
26886 if (isLoadingRef.current) {
26887 return;
26888 }
26889 const currentStartPosition = currentView.startPosition || 1;
26890 const batchSize = currentView.perPage || 10;
26891 const currentEndPosition = Math.min(
26892 currentStartPosition + batchSize,
26893 totalItems
26894 );
26895 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
26896 if (currentEndPosition < totalItems) {
26897 const newStartPosition = currentEndPosition;
26898 captureAnchorElement(target, anchorElementRef, "down");
26899 onChangeViewRef.current({
26900 ...currentView,
26901 startPosition: newStartPosition
26902 });
26903 }
26904 }
26905 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
26906 if (currentStartPosition > 1) {
26907 const calculatedStartPosition = currentStartPosition - batchSize;
26908 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
26909 captureAnchorElement(target, anchorElementRef, "up");
26910 onChangeViewRef.current({
26911 ...currentView,
26912 startPosition: newStartPosition
26913 });
26914 }
26915 }
26916 }, 50);
26917 const container = containerRef.current;
26918 container.addEventListener("scroll", handleScroll);
26919 return () => {
26920 container.removeEventListener("scroll", handleScroll);
26921 handleScroll.cancel();
26922 };
26923 }, [containerRef, view.infiniteScrollEnabled]);
26924 return {
26925 intersectionObserver: intersectionObserverRef.current
26926 };
26927 }
26928
26929 // packages/dataviews/build-module/dataviews/index.mjs
26930 var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1);
26931 var defaultGetItemId = (item) => item.id;
26932 var defaultIsItemClickable = () => true;
26933 var EMPTY_ARRAY7 = [];
26934 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
26935 var dataViewsLayouts = VIEW_LAYOUTS.filter(
26936 (viewLayout) => !viewLayout.isPicker
26937 );
26938 function DefaultUI({
26939 header,
26940 search = true,
26941 searchLabel = void 0
26942 }) {
26943 const { view } = (0, import_element85.useContext)(dataviews_context_default);
26944 const isInfiniteScroll = view.infiniteScrollEnabled;
26945 return /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(import_jsx_runtime121.Fragment, { children: [
26946 /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(
26947 Stack,
26948 {
26949 direction: "row",
26950 align: "top",
26951 justify: "space-between",
26952 className: clsx_default("dataviews__view-actions", {
26953 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
26954 }),
26955 gap: "xs",
26956 children: [
26957 /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(
26958 Stack,
26959 {
26960 direction: "row",
26961 justify: "start",
26962 gap: "sm",
26963 className: "dataviews__search",
26964 children: [
26965 search && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(dataviews_search_default, { label: searchLabel }),
26966 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(toggle_default, {})
26967 ]
26968 }
26969 ),
26970 /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
26971 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(dataviews_view_config_default, {}),
26972 header
26973 ] })
26974 ]
26975 }
26976 ),
26977 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
26978 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(DataViewsLayout, {}),
26979 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(DataViewsFooter, {})
26980 ] });
26981 }
26982 function DataViews({
26983 view,
26984 onChangeView,
26985 fields,
26986 search = true,
26987 searchLabel = void 0,
26988 actions = EMPTY_ARRAY7,
26989 data,
26990 getItemId = defaultGetItemId,
26991 getItemLevel,
26992 isLoading = false,
26993 paginationInfo,
26994 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
26995 selection: selectionProperty,
26996 onChangeSelection,
26997 onClickItem,
26998 renderItemLink,
26999 isItemClickable = defaultIsItemClickable,
27000 header,
27001 children,
27002 config = { perPageSizes: [10, 20, 50, 100] },
27003 empty,
27004 onReset
27005 }) {
27006 const [selectionState, setSelectionState] = (0, import_element85.useState)([]);
27007 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
27008 const selection = isUncontrolled ? selectionState : selectionProperty;
27009 const {
27010 data: displayData,
27011 paginationInfo: displayPaginationInfo,
27012 hasInitiallyLoaded,
27013 setVisibleEntries
27014 } = useData({
27015 view,
27016 data,
27017 getItemId,
27018 isLoading,
27019 selection,
27020 paginationInfo
27021 });
27022 const containerRef = (0, import_element85.useRef)(null);
27023 const [containerWidth, setContainerWidth] = (0, import_element85.useState)(0);
27024 const resizeObserverRef = (0, import_compose14.useResizeObserver)(
27025 (resizeObserverEntries) => {
27026 setContainerWidth(
27027 resizeObserverEntries[0].borderBoxSize[0].inlineSize
27028 );
27029 },
27030 { box: "border-box" }
27031 );
27032 const [openedFilter, setOpenedFilter] = (0, import_element85.useState)(null);
27033 function setSelectionWithChange(value) {
27034 const newValue = typeof value === "function" ? value(selection) : value;
27035 if (isUncontrolled) {
27036 setSelectionState(newValue);
27037 }
27038 if (onChangeSelection) {
27039 onChangeSelection(newValue);
27040 }
27041 }
27042 const _fields = (0, import_element85.useMemo)(() => normalizeFields(fields), [fields]);
27043 const _selection = (0, import_element85.useMemo)(() => {
27044 if (view.infiniteScrollEnabled) {
27045 return selection;
27046 }
27047 return selection.filter(
27048 (id) => data.some((item) => getItemId(item) === id)
27049 );
27050 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
27051 const filters = use_filters_default(_fields, view);
27052 const hasPrimaryOrLockedFilters = (0, import_element85.useMemo)(
27053 () => (filters || []).some(
27054 (filter) => filter.isPrimary || filter.isLocked
27055 ),
27056 [filters]
27057 );
27058 const [isShowingFilter, setIsShowingFilter] = (0, import_element85.useState)(
27059 hasPrimaryOrLockedFilters
27060 );
27061 const { intersectionObserver } = useInfiniteScroll({
27062 view,
27063 onChangeView,
27064 isLoading,
27065 paginationInfo,
27066 containerRef,
27067 setVisibleEntries
27068 });
27069 (0, import_element85.useEffect)(() => {
27070 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
27071 setIsShowingFilter(true);
27072 }
27073 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
27074 const defaultLayouts = (0, import_element85.useMemo)(
27075 () => Object.fromEntries(
27076 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
27077 return dataViewsLayouts.some(
27078 (viewLayout) => viewLayout.type === layoutType
27079 );
27080 }).map(([key, value]) => [
27081 key,
27082 value === true ? {} : value
27083 ])
27084 ),
27085 [defaultLayoutsProperty]
27086 );
27087 if (!defaultLayouts[view.type]) {
27088 return null;
27089 }
27090 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
27091 dataviews_context_default.Provider,
27092 {
27093 value: {
27094 view,
27095 onChangeView,
27096 fields: _fields,
27097 actions,
27098 data: displayData,
27099 isLoading,
27100 paginationInfo: displayPaginationInfo,
27101 selection: _selection,
27102 onChangeSelection: setSelectionWithChange,
27103 openedFilter,
27104 setOpenedFilter,
27105 getItemId,
27106 getItemLevel,
27107 isItemClickable,
27108 onClickItem,
27109 renderItemLink,
27110 containerWidth,
27111 containerRef,
27112 resizeObserverRef,
27113 defaultLayouts,
27114 filters,
27115 isShowingFilter,
27116 setIsShowingFilter,
27117 config,
27118 empty,
27119 hasInitiallyLoaded,
27120 onReset,
27121 intersectionObserver
27122 },
27123 children: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
27124 DefaultUI,
27125 {
27126 header,
27127 search,
27128 searchLabel
27129 }
27130 ) })
27131 }
27132 );
27133 }
27134 var DataViewsSubComponents = DataViews;
27135 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
27136 DataViewsSubComponents.Filters = filters_default;
27137 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
27138 DataViewsSubComponents.FiltersToggle = toggle_default;
27139 DataViewsSubComponents.Layout = DataViewsLayout;
27140 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
27141 DataViewsSubComponents.Pagination = DataViewsPagination;
27142 DataViewsSubComponents.Search = dataviews_search_default;
27143 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
27144 DataViewsSubComponents.Footer = DataViewsFooter;
27145 var dataviews_default = DataViewsSubComponents;
27146
27147 // widgets/news/components/news-list/news-list.tsx
27148 var import_date10 = __toESM(require_date());
27149 var import_element86 = __toESM(require_element());
27150 var import_html_entities = __toESM(require_html_entities());
27151 var import_i18n45 = __toESM(require_i18n());
27152
27153 // packages/style-runtime/src/index.ts
27154 var STYLE_HASH_ATTRIBUTE14 = "data-wp-hash";
27155 function getRuntime14() {
27156 const globalScope = globalThis;
27157 if (globalScope.__wpStyleRuntime) {
27158 return globalScope.__wpStyleRuntime;
27159 }
27160 globalScope.__wpStyleRuntime = {
27161 documents: /* @__PURE__ */ new Map(),
27162 styles: /* @__PURE__ */ new Map(),
27163 injectedStyles: /* @__PURE__ */ new WeakMap()
27164 };
27165 if (typeof document !== "undefined") {
27166 registerDocument14(document);
27167 }
27168 return globalScope.__wpStyleRuntime;
27169 }
27170 function documentContainsStyleHash14(targetDocument, hash) {
27171 if (!targetDocument.head) {
27172 return false;
27173 }
27174 for (const style of targetDocument.head.querySelectorAll(
27175 `style[${STYLE_HASH_ATTRIBUTE14}]`
27176 )) {
27177 if (style.getAttribute(STYLE_HASH_ATTRIBUTE14) === hash) {
27178 return true;
27179 }
27180 }
27181 return false;
27182 }
27183 function injectStyle14(targetDocument, hash, css) {
27184 if (!targetDocument.head) {
27185 return;
27186 }
27187 const runtime = getRuntime14();
27188 let injectedStyles = runtime.injectedStyles.get(targetDocument);
27189 if (!injectedStyles) {
27190 injectedStyles = /* @__PURE__ */ new Set();
27191 runtime.injectedStyles.set(targetDocument, injectedStyles);
27192 }
27193 if (injectedStyles.has(hash)) {
27194 return;
27195 }
27196 if (documentContainsStyleHash14(targetDocument, hash)) {
27197 injectedStyles.add(hash);
27198 return;
27199 }
27200 const style = targetDocument.createElement("style");
27201 style.setAttribute(STYLE_HASH_ATTRIBUTE14, hash);
27202 style.appendChild(targetDocument.createTextNode(css));
27203 targetDocument.head.appendChild(style);
27204 injectedStyles.add(hash);
27205 }
27206 function registerDocument14(targetDocument) {
27207 const runtime = getRuntime14();
27208 runtime.documents.set(
27209 targetDocument,
27210 (runtime.documents.get(targetDocument) ?? 0) + 1
27211 );
27212 for (const [hash, css] of runtime.styles) {
27213 injectStyle14(targetDocument, hash, css);
27214 }
27215 return () => {
27216 const count = runtime.documents.get(targetDocument);
27217 if (count === void 0) {
27218 return;
27219 }
27220 if (count <= 1) {
27221 runtime.documents.delete(targetDocument);
27222 return;
27223 }
27224 runtime.documents.set(targetDocument, count - 1);
27225 };
27226 }
27227 function registerStyle14(hash, css) {
27228 const runtime = getRuntime14();
27229 runtime.styles.set(hash, css);
27230 for (const targetDocument of runtime.documents.keys()) {
27231 injectStyle14(targetDocument, hash, css);
27232 }
27233 }
27234
27235 // widgets/news/components/news-list/news-list.module.css
27236 if (typeof process === "undefined" || true) {
27237 registerStyle14("9549c96cba", ".bdaa5dfae93273b5__root{flex:1;min-height:0;min-width:0;overflow:auto}._2861fc2db3e2384a__feedIcon{align-items:center;background-color:var(--wpds-color-background-track-neutral-weak,#f0f0f0);border-radius:var(--wpds-border-radius-md,4px);color:var(--wpds-color-foreground-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-foreground-content-neutral-weak,#707070)}");
27238 }
27239 var news_list_default = { "root": "bdaa5dfae93273b5__root", "feedIcon": "_2861fc2db3e2384a__feedIcon", "titleLink": "_0b17b846e53f552a__titleLink", "meta": "_33e124d0c35f629a__meta" };
27240
27241 // widgets/news/components/news-list/news-list.tsx
27242 var import_jsx_runtime122 = __toESM(require_jsx_runtime());
27243 var NEWS_FEEDS = [
27244 {
27245 key: "news",
27246 label: (0, import_i18n45.__)("WordPress Blog"),
27247 siteUrl: (0, import_i18n45._x)("https://wordpress.org/news/", "News dashboard widget"),
27248 apiUrl: "https://wordpress.org/news/wp-json/wp/v2/posts?per_page=4&_fields=id,title,link,date"
27249 },
27250 {
27251 key: "planet",
27252 label: (0, import_i18n45.__)("Other WordPress News"),
27253 siteUrl: (0, import_i18n45._x)("https://planet.wordpress.org/", "News dashboard widget"),
27254 apiUrl: "https://planet.wordpress.org/wp-json/wp/v2/posts?per_page=4&_fields=id,title,link,date"
27255 }
27256 ];
27257 var DEFAULT_LAYOUTS2 = { list: {} };
27258 var INITIAL_VIEW = {
27259 type: "list",
27260 page: 1,
27261 perPage: 4,
27262 search: "",
27263 filters: [],
27264 fields: [],
27265 titleField: "title",
27266 descriptionField: "meta",
27267 mediaField: "feedIcon",
27268 showMedia: true,
27269 layout: { density: "compact" }
27270 };
27271 function FeedIcon({ item }) {
27272 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("div", { className: news_list_default.feedIcon, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(Icon, { icon: item.feedKey === "news" ? wordpress_default : globe_default }) });
27273 }
27274 function NewsTitle({ item }) {
27275 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(Link, { href: item.url, openInNewTab: true, className: news_list_default.titleLink, children: item.title });
27276 }
27277 function NewsMeta({ item }) {
27278 return /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(Text, { variant: "body-sm", className: news_list_default.meta, children: [
27279 item.feedLabel,
27280 " \xB7 ",
27281 (0, import_date10.dateI18n)((0, import_i18n45.__)("M j, Y g:i a"), item.date)
27282 ] });
27283 }
27284 var emptyState = /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(Stack, { align: "center", justify: "center", style: { margin: "24px 0" }, children: /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(empty_state_exports.Root, { children: [
27285 /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(empty_state_exports.Icon, { icon: post_list_default }),
27286 /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(empty_state_exports.Title, { children: (0, import_i18n45.__)("Quiet for now \u2014 the next headline is on its way.") })
27287 ] }) });
27288 function combineFeedPosts(newsFeeds) {
27289 return newsFeeds.flatMap(
27290 (feed) => feed.posts.map((post) => ({
27291 id: `${feed.key}-${post.id}`,
27292 feedKey: feed.key,
27293 feedLabel: feed.label,
27294 title: (0, import_html_entities.decodeEntities)(post.title.rendered),
27295 url: post.link,
27296 date: post.date
27297 }))
27298 ).sort(
27299 (a2, b2) => new Date(b2.date).getTime() - new Date(a2.date).getTime()
27300 );
27301 }
27302 function NewsList() {
27303 const [view, setView] = (0, import_element86.useState)(INITIAL_VIEW);
27304 const [newsFeeds, setNewsFeeds] = (0, import_element86.useState)([]);
27305 const [isLoading, setIsLoading] = (0, import_element86.useState)(true);
27306 (0, import_element86.useEffect)(() => {
27307 Promise.all(
27308 NEWS_FEEDS.map(async (feed) => {
27309 try {
27310 const posts = await fetch(feed.apiUrl).then(
27311 (r3) => r3.json()
27312 );
27313 return {
27314 key: feed.key,
27315 label: feed.label,
27316 siteUrl: feed.siteUrl,
27317 posts
27318 };
27319 } catch {
27320 return {
27321 key: feed.key,
27322 label: feed.label,
27323 siteUrl: feed.siteUrl,
27324 posts: []
27325 };
27326 }
27327 })
27328 ).then(setNewsFeeds).finally(() => setIsLoading(false));
27329 }, []);
27330 const items = (0, import_element86.useMemo)(() => combineFeedPosts(newsFeeds), [newsFeeds]);
27331 const fields = (0, import_element86.useMemo)(
27332 () => [
27333 {
27334 id: "title",
27335 label: (0, import_i18n45.__)("Title"),
27336 enableSorting: false,
27337 enableHiding: false,
27338 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(NewsTitle, { item })
27339 },
27340 {
27341 id: "meta",
27342 label: (0, import_i18n45.__)("Source"),
27343 enableSorting: false,
27344 enableHiding: false,
27345 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(NewsMeta, { item })
27346 },
27347 {
27348 id: "feedIcon",
27349 label: (0, import_i18n45.__)("Source"),
27350 enableSorting: false,
27351 enableHiding: false,
27352 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(FeedIcon, { item })
27353 }
27354 ],
27355 []
27356 );
27357 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("div", { className: news_list_default.root, children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
27358 dataviews_default,
27359 {
27360 data: items,
27361 fields,
27362 view,
27363 onChangeView: setView,
27364 getItemId: (item) => item.id,
27365 isLoading,
27366 paginationInfo: {
27367 totalItems: items.length,
27368 totalPages: 1
27369 },
27370 defaultLayouts: DEFAULT_LAYOUTS2,
27371 empty: emptyState,
27372 children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(dataviews_default.Layout, {})
27373 }
27374 ) });
27375 }
27376
27377 // widgets/news/render.module.css
27378 if (typeof process === "undefined" || true) {
27379 registerStyle14("316bb0f754", "._2ab2c8be44ad767d__footer{border-block-start:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);padding-block:var(--wpds-dimension-padding-lg,16px);padding-inline:var(--wpds-dimension-padding-2xl,24px)}");
27380 }
27381 var render_default = { "footer": "_2ab2c8be44ad767d__footer" };
27382
27383 // widgets/news/render.tsx
27384 var import_jsx_runtime123 = __toESM(require_jsx_runtime());
27385 function WordPressNews() {
27386 return /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(import_jsx_runtime123.Fragment, { children: [
27387 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(NewsList, {}),
27388 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: render_default.footer, children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
27389 Link,
27390 {
27391 href: (0, import_i18n46._x)(
27392 "https://wordpress.org/news/all-posts/",
27393 "News dashboard widget"
27394 ),
27395 openInNewTab: true,
27396 children: (0, import_i18n46.__)("See all")
27397 }
27398 ) })
27399 ] });
27400 }
27401 export {
27402 WordPressNews as default
27403 };
27404 /*! Bundled license information:
27405
27406 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
27407 (**
27408 * @license React
27409 * use-sync-external-store-shim.development.js
27410 *
27411 * Copyright (c) Meta Platforms, Inc. and affiliates.
27412 *
27413 * This source code is licensed under the MIT license found in the
27414 * LICENSE file in the root directory of this source tree.
27415 *)
27416
27417 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
27418 (**
27419 * @license React
27420 * use-sync-external-store-shim/with-selector.development.js
27421 *
27422 * Copyright (c) Meta Platforms, Inc. and affiliates.
27423 *
27424 * This source code is licensed under the MIT license found in the
27425 * LICENSE file in the root directory of this source tree.
27426 *)
27427 */
27428