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

content.js in Gutenberg 23.3.1, at build/routes/pattern-list/content.js

26,961 lines 915.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var __create = Object.create;
2 var __defProp = Object.defineProperty;
3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4 var __getOwnPropNames = Object.getOwnPropertyNames;
5 var __getProtoOf = Object.getPrototypeOf;
6 var __hasOwnProp = Object.prototype.hasOwnProperty;
7 var __commonJS = (cb, mod) => function __require() {
8 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9 };
10 var __export = (target, all) => {
11 for (var name in all)
12 __defProp(target, name, { get: all[name], enumerable: true });
13 };
14 var __copyProps = (to, from, except, desc) => {
15 if (from && typeof from === "object" || typeof from === "function") {
16 for (let key of __getOwnPropNames(from))
17 if (!__hasOwnProp.call(to, key) && key !== except)
18 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19 }
20 return to;
21 };
22 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23 // If the importer is in node compatibility mode or this is not an ESM
24 // file that has been converted to a CommonJS file using a Babel-
25 // compatible transform (i.e. "__esModule" has not been set), then set
26 // "default" to the CommonJS "module.exports" for node compatibility.
27 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28 mod
29 ));
30
31 // package-external:@wordpress/element
32 var require_element = __commonJS({
33 "package-external:@wordpress/element"(exports, module) {
34 module.exports = window.wp.element;
35 }
36 });
37
38 // package-external:@wordpress/data
39 var require_data = __commonJS({
40 "package-external:@wordpress/data"(exports, module) {
41 module.exports = window.wp.data;
42 }
43 });
44
45 // package-external:@wordpress/preferences
46 var require_preferences = __commonJS({
47 "package-external:@wordpress/preferences"(exports, module) {
48 module.exports = window.wp.preferences;
49 }
50 });
51
52 // package-external:@wordpress/core-data
53 var require_core_data = __commonJS({
54 "package-external:@wordpress/core-data"(exports, module) {
55 module.exports = window.wp.coreData;
56 }
57 });
58
59 // package-external:@wordpress/private-apis
60 var require_private_apis = __commonJS({
61 "package-external:@wordpress/private-apis"(exports, module) {
62 module.exports = window.wp.privateApis;
63 }
64 });
65
66 // package-external:@wordpress/compose
67 var require_compose = __commonJS({
68 "package-external:@wordpress/compose"(exports, module) {
69 module.exports = window.wp.compose;
70 }
71 });
72
73 // vendor-external:react
74 var require_react = __commonJS({
75 "vendor-external:react"(exports, module) {
76 module.exports = window.React;
77 }
78 });
79
80 // vendor-external:react/jsx-runtime
81 var require_jsx_runtime = __commonJS({
82 "vendor-external:react/jsx-runtime"(exports, module) {
83 module.exports = window.ReactJSXRuntime;
84 }
85 });
86
87 // vendor-external:react-dom
88 var require_react_dom = __commonJS({
89 "vendor-external:react-dom"(exports, module) {
90 module.exports = window.ReactDOM;
91 }
92 });
93
94 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
95 var require_use_sync_external_store_shim_development = __commonJS({
96 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
97 "use strict";
98 (function() {
99 function is(x2, y2) {
100 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
101 }
102 function useSyncExternalStore$2(subscribe2, getSnapshot) {
103 didWarnOld18Alpha || void 0 === React52.startTransition || (didWarnOld18Alpha = true, console.error(
104 "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."
105 ));
106 var value = getSnapshot();
107 if (!didWarnUncachedGetSnapshot) {
108 var cachedValue = getSnapshot();
109 objectIs(value, cachedValue) || (console.error(
110 "The result of getSnapshot should be cached to avoid an infinite loop"
111 ), didWarnUncachedGetSnapshot = true);
112 }
113 cachedValue = useState36({
114 inst: { value, getSnapshot }
115 });
116 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
117 useLayoutEffect6(
118 function() {
119 inst.value = value;
120 inst.getSnapshot = getSnapshot;
121 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
122 },
123 [subscribe2, value, getSnapshot]
124 );
125 useEffect31(
126 function() {
127 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
128 return subscribe2(function() {
129 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
130 });
131 },
132 [subscribe2]
133 );
134 useDebugValue2(value);
135 return value;
136 }
137 function checkIfSnapshotChanged(inst) {
138 var latestGetSnapshot = inst.getSnapshot;
139 inst = inst.value;
140 try {
141 var nextValue = latestGetSnapshot();
142 return !objectIs(inst, nextValue);
143 } catch (error) {
144 return true;
145 }
146 }
147 function useSyncExternalStore$1(subscribe2, getSnapshot) {
148 return getSnapshot();
149 }
150 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
151 var React52 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState36 = React52.useState, useEffect31 = React52.useEffect, useLayoutEffect6 = React52.useLayoutEffect, useDebugValue2 = React52.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
152 exports.useSyncExternalStore = void 0 !== React52.useSyncExternalStore ? React52.useSyncExternalStore : shim;
153 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
154 })();
155 }
156 });
157
158 // node_modules/use-sync-external-store/shim/index.js
159 var require_shim = __commonJS({
160 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
161 "use strict";
162 if (false) {
163 module.exports = null;
164 } else {
165 module.exports = require_use_sync_external_store_shim_development();
166 }
167 }
168 });
169
170 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
171 var require_with_selector_development = __commonJS({
172 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
173 "use strict";
174 (function() {
175 function is(x2, y2) {
176 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
177 }
178 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
179 var React52 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef44 = React52.useRef, useEffect31 = React52.useEffect, useMemo43 = React52.useMemo, useDebugValue2 = React52.useDebugValue;
180 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
181 var instRef = useRef44(null);
182 if (null === instRef.current) {
183 var inst = { hasValue: false, value: null };
184 instRef.current = inst;
185 } else inst = instRef.current;
186 instRef = useMemo43(
187 function() {
188 function memoizedSelector(nextSnapshot) {
189 if (!hasMemo) {
190 hasMemo = true;
191 memoizedSnapshot = nextSnapshot;
192 nextSnapshot = selector2(nextSnapshot);
193 if (void 0 !== isEqual && inst.hasValue) {
194 var currentSelection = inst.value;
195 if (isEqual(currentSelection, nextSnapshot))
196 return memoizedSelection = currentSelection;
197 }
198 return memoizedSelection = nextSnapshot;
199 }
200 currentSelection = memoizedSelection;
201 if (objectIs(memoizedSnapshot, nextSnapshot))
202 return currentSelection;
203 var nextSelection = selector2(nextSnapshot);
204 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
205 return memoizedSnapshot = nextSnapshot, currentSelection;
206 memoizedSnapshot = nextSnapshot;
207 return memoizedSelection = nextSelection;
208 }
209 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
210 return [
211 function() {
212 return memoizedSelector(getSnapshot());
213 },
214 null === maybeGetServerSnapshot ? void 0 : function() {
215 return memoizedSelector(maybeGetServerSnapshot());
216 }
217 ];
218 },
219 [getSnapshot, getServerSnapshot, selector2, isEqual]
220 );
221 var value = useSyncExternalStore3(subscribe2, instRef[0], instRef[1]);
222 useEffect31(
223 function() {
224 inst.hasValue = true;
225 inst.value = value;
226 },
227 [value]
228 );
229 useDebugValue2(value);
230 return value;
231 };
232 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
233 })();
234 }
235 });
236
237 // node_modules/use-sync-external-store/shim/with-selector.js
238 var require_with_selector = __commonJS({
239 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
240 "use strict";
241 if (false) {
242 module.exports = null;
243 } else {
244 module.exports = require_with_selector_development();
245 }
246 }
247 });
248
249 // package-external:@wordpress/i18n
250 var require_i18n = __commonJS({
251 "package-external:@wordpress/i18n"(exports, module) {
252 module.exports = window.wp.i18n;
253 }
254 });
255
256 // package-external:@wordpress/primitives
257 var require_primitives = __commonJS({
258 "package-external:@wordpress/primitives"(exports, module) {
259 module.exports = window.wp.primitives;
260 }
261 });
262
263 // package-external:@wordpress/theme
264 var require_theme = __commonJS({
265 "package-external:@wordpress/theme"(exports, module) {
266 module.exports = window.wp.theme;
267 }
268 });
269
270 // package-external:@wordpress/components
271 var require_components = __commonJS({
272 "package-external:@wordpress/components"(exports, module) {
273 module.exports = window.wp.components;
274 }
275 });
276
277 // package-external:@wordpress/keycodes
278 var require_keycodes = __commonJS({
279 "package-external:@wordpress/keycodes"(exports, module) {
280 module.exports = window.wp.keycodes;
281 }
282 });
283
284 // node_modules/remove-accents/index.js
285 var require_remove_accents = __commonJS({
286 "node_modules/remove-accents/index.js"(exports, module) {
287 var characterMap = {
288 "\xC0": "A",
289 "\xC1": "A",
290 "\xC2": "A",
291 "\xC3": "A",
292 "\xC4": "A",
293 "\xC5": "A",
294 "\u1EA4": "A",
295 "\u1EAE": "A",
296 "\u1EB2": "A",
297 "\u1EB4": "A",
298 "\u1EB6": "A",
299 "\xC6": "AE",
300 "\u1EA6": "A",
301 "\u1EB0": "A",
302 "\u0202": "A",
303 "\u1EA2": "A",
304 "\u1EA0": "A",
305 "\u1EA8": "A",
306 "\u1EAA": "A",
307 "\u1EAC": "A",
308 "\xC7": "C",
309 "\u1E08": "C",
310 "\xC8": "E",
311 "\xC9": "E",
312 "\xCA": "E",
313 "\xCB": "E",
314 "\u1EBE": "E",
315 "\u1E16": "E",
316 "\u1EC0": "E",
317 "\u1E14": "E",
318 "\u1E1C": "E",
319 "\u0206": "E",
320 "\u1EBA": "E",
321 "\u1EBC": "E",
322 "\u1EB8": "E",
323 "\u1EC2": "E",
324 "\u1EC4": "E",
325 "\u1EC6": "E",
326 "\xCC": "I",
327 "\xCD": "I",
328 "\xCE": "I",
329 "\xCF": "I",
330 "\u1E2E": "I",
331 "\u020A": "I",
332 "\u1EC8": "I",
333 "\u1ECA": "I",
334 "\xD0": "D",
335 "\xD1": "N",
336 "\xD2": "O",
337 "\xD3": "O",
338 "\xD4": "O",
339 "\xD5": "O",
340 "\xD6": "O",
341 "\xD8": "O",
342 "\u1ED0": "O",
343 "\u1E4C": "O",
344 "\u1E52": "O",
345 "\u020E": "O",
346 "\u1ECE": "O",
347 "\u1ECC": "O",
348 "\u1ED4": "O",
349 "\u1ED6": "O",
350 "\u1ED8": "O",
351 "\u1EDC": "O",
352 "\u1EDE": "O",
353 "\u1EE0": "O",
354 "\u1EDA": "O",
355 "\u1EE2": "O",
356 "\xD9": "U",
357 "\xDA": "U",
358 "\xDB": "U",
359 "\xDC": "U",
360 "\u1EE6": "U",
361 "\u1EE4": "U",
362 "\u1EEC": "U",
363 "\u1EEE": "U",
364 "\u1EF0": "U",
365 "\xDD": "Y",
366 "\xE0": "a",
367 "\xE1": "a",
368 "\xE2": "a",
369 "\xE3": "a",
370 "\xE4": "a",
371 "\xE5": "a",
372 "\u1EA5": "a",
373 "\u1EAF": "a",
374 "\u1EB3": "a",
375 "\u1EB5": "a",
376 "\u1EB7": "a",
377 "\xE6": "ae",
378 "\u1EA7": "a",
379 "\u1EB1": "a",
380 "\u0203": "a",
381 "\u1EA3": "a",
382 "\u1EA1": "a",
383 "\u1EA9": "a",
384 "\u1EAB": "a",
385 "\u1EAD": "a",
386 "\xE7": "c",
387 "\u1E09": "c",
388 "\xE8": "e",
389 "\xE9": "e",
390 "\xEA": "e",
391 "\xEB": "e",
392 "\u1EBF": "e",
393 "\u1E17": "e",
394 "\u1EC1": "e",
395 "\u1E15": "e",
396 "\u1E1D": "e",
397 "\u0207": "e",
398 "\u1EBB": "e",
399 "\u1EBD": "e",
400 "\u1EB9": "e",
401 "\u1EC3": "e",
402 "\u1EC5": "e",
403 "\u1EC7": "e",
404 "\xEC": "i",
405 "\xED": "i",
406 "\xEE": "i",
407 "\xEF": "i",
408 "\u1E2F": "i",
409 "\u020B": "i",
410 "\u1EC9": "i",
411 "\u1ECB": "i",
412 "\xF0": "d",
413 "\xF1": "n",
414 "\xF2": "o",
415 "\xF3": "o",
416 "\xF4": "o",
417 "\xF5": "o",
418 "\xF6": "o",
419 "\xF8": "o",
420 "\u1ED1": "o",
421 "\u1E4D": "o",
422 "\u1E53": "o",
423 "\u020F": "o",
424 "\u1ECF": "o",
425 "\u1ECD": "o",
426 "\u1ED5": "o",
427 "\u1ED7": "o",
428 "\u1ED9": "o",
429 "\u1EDD": "o",
430 "\u1EDF": "o",
431 "\u1EE1": "o",
432 "\u1EDB": "o",
433 "\u1EE3": "o",
434 "\xF9": "u",
435 "\xFA": "u",
436 "\xFB": "u",
437 "\xFC": "u",
438 "\u1EE7": "u",
439 "\u1EE5": "u",
440 "\u1EED": "u",
441 "\u1EEF": "u",
442 "\u1EF1": "u",
443 "\xFD": "y",
444 "\xFF": "y",
445 "\u0100": "A",
446 "\u0101": "a",
447 "\u0102": "A",
448 "\u0103": "a",
449 "\u0104": "A",
450 "\u0105": "a",
451 "\u0106": "C",
452 "\u0107": "c",
453 "\u0108": "C",
454 "\u0109": "c",
455 "\u010A": "C",
456 "\u010B": "c",
457 "\u010C": "C",
458 "\u010D": "c",
459 "C\u0306": "C",
460 "c\u0306": "c",
461 "\u010E": "D",
462 "\u010F": "d",
463 "\u0110": "D",
464 "\u0111": "d",
465 "\u0112": "E",
466 "\u0113": "e",
467 "\u0114": "E",
468 "\u0115": "e",
469 "\u0116": "E",
470 "\u0117": "e",
471 "\u0118": "E",
472 "\u0119": "e",
473 "\u011A": "E",
474 "\u011B": "e",
475 "\u011C": "G",
476 "\u01F4": "G",
477 "\u011D": "g",
478 "\u01F5": "g",
479 "\u011E": "G",
480 "\u011F": "g",
481 "\u0120": "G",
482 "\u0121": "g",
483 "\u0122": "G",
484 "\u0123": "g",
485 "\u0124": "H",
486 "\u0125": "h",
487 "\u0126": "H",
488 "\u0127": "h",
489 "\u1E2A": "H",
490 "\u1E2B": "h",
491 "\u0128": "I",
492 "\u0129": "i",
493 "\u012A": "I",
494 "\u012B": "i",
495 "\u012C": "I",
496 "\u012D": "i",
497 "\u012E": "I",
498 "\u012F": "i",
499 "\u0130": "I",
500 "\u0131": "i",
501 "\u0132": "IJ",
502 "\u0133": "ij",
503 "\u0134": "J",
504 "\u0135": "j",
505 "\u0136": "K",
506 "\u0137": "k",
507 "\u1E30": "K",
508 "\u1E31": "k",
509 "K\u0306": "K",
510 "k\u0306": "k",
511 "\u0139": "L",
512 "\u013A": "l",
513 "\u013B": "L",
514 "\u013C": "l",
515 "\u013D": "L",
516 "\u013E": "l",
517 "\u013F": "L",
518 "\u0140": "l",
519 "\u0141": "l",
520 "\u0142": "l",
521 "\u1E3E": "M",
522 "\u1E3F": "m",
523 "M\u0306": "M",
524 "m\u0306": "m",
525 "\u0143": "N",
526 "\u0144": "n",
527 "\u0145": "N",
528 "\u0146": "n",
529 "\u0147": "N",
530 "\u0148": "n",
531 "\u0149": "n",
532 "N\u0306": "N",
533 "n\u0306": "n",
534 "\u014C": "O",
535 "\u014D": "o",
536 "\u014E": "O",
537 "\u014F": "o",
538 "\u0150": "O",
539 "\u0151": "o",
540 "\u0152": "OE",
541 "\u0153": "oe",
542 "P\u0306": "P",
543 "p\u0306": "p",
544 "\u0154": "R",
545 "\u0155": "r",
546 "\u0156": "R",
547 "\u0157": "r",
548 "\u0158": "R",
549 "\u0159": "r",
550 "R\u0306": "R",
551 "r\u0306": "r",
552 "\u0212": "R",
553 "\u0213": "r",
554 "\u015A": "S",
555 "\u015B": "s",
556 "\u015C": "S",
557 "\u015D": "s",
558 "\u015E": "S",
559 "\u0218": "S",
560 "\u0219": "s",
561 "\u015F": "s",
562 "\u0160": "S",
563 "\u0161": "s",
564 "\u0162": "T",
565 "\u0163": "t",
566 "\u021B": "t",
567 "\u021A": "T",
568 "\u0164": "T",
569 "\u0165": "t",
570 "\u0166": "T",
571 "\u0167": "t",
572 "T\u0306": "T",
573 "t\u0306": "t",
574 "\u0168": "U",
575 "\u0169": "u",
576 "\u016A": "U",
577 "\u016B": "u",
578 "\u016C": "U",
579 "\u016D": "u",
580 "\u016E": "U",
581 "\u016F": "u",
582 "\u0170": "U",
583 "\u0171": "u",
584 "\u0172": "U",
585 "\u0173": "u",
586 "\u0216": "U",
587 "\u0217": "u",
588 "V\u0306": "V",
589 "v\u0306": "v",
590 "\u0174": "W",
591 "\u0175": "w",
592 "\u1E82": "W",
593 "\u1E83": "w",
594 "X\u0306": "X",
595 "x\u0306": "x",
596 "\u0176": "Y",
597 "\u0177": "y",
598 "\u0178": "Y",
599 "Y\u0306": "Y",
600 "y\u0306": "y",
601 "\u0179": "Z",
602 "\u017A": "z",
603 "\u017B": "Z",
604 "\u017C": "z",
605 "\u017D": "Z",
606 "\u017E": "z",
607 "\u017F": "s",
608 "\u0192": "f",
609 "\u01A0": "O",
610 "\u01A1": "o",
611 "\u01AF": "U",
612 "\u01B0": "u",
613 "\u01CD": "A",
614 "\u01CE": "a",
615 "\u01CF": "I",
616 "\u01D0": "i",
617 "\u01D1": "O",
618 "\u01D2": "o",
619 "\u01D3": "U",
620 "\u01D4": "u",
621 "\u01D5": "U",
622 "\u01D6": "u",
623 "\u01D7": "U",
624 "\u01D8": "u",
625 "\u01D9": "U",
626 "\u01DA": "u",
627 "\u01DB": "U",
628 "\u01DC": "u",
629 "\u1EE8": "U",
630 "\u1EE9": "u",
631 "\u1E78": "U",
632 "\u1E79": "u",
633 "\u01FA": "A",
634 "\u01FB": "a",
635 "\u01FC": "AE",
636 "\u01FD": "ae",
637 "\u01FE": "O",
638 "\u01FF": "o",
639 "\xDE": "TH",
640 "\xFE": "th",
641 "\u1E54": "P",
642 "\u1E55": "p",
643 "\u1E64": "S",
644 "\u1E65": "s",
645 "X\u0301": "X",
646 "x\u0301": "x",
647 "\u0403": "\u0413",
648 "\u0453": "\u0433",
649 "\u040C": "\u041A",
650 "\u045C": "\u043A",
651 "A\u030B": "A",
652 "a\u030B": "a",
653 "E\u030B": "E",
654 "e\u030B": "e",
655 "I\u030B": "I",
656 "i\u030B": "i",
657 "\u01F8": "N",
658 "\u01F9": "n",
659 "\u1ED2": "O",
660 "\u1ED3": "o",
661 "\u1E50": "O",
662 "\u1E51": "o",
663 "\u1EEA": "U",
664 "\u1EEB": "u",
665 "\u1E80": "W",
666 "\u1E81": "w",
667 "\u1EF2": "Y",
668 "\u1EF3": "y",
669 "\u0200": "A",
670 "\u0201": "a",
671 "\u0204": "E",
672 "\u0205": "e",
673 "\u0208": "I",
674 "\u0209": "i",
675 "\u020C": "O",
676 "\u020D": "o",
677 "\u0210": "R",
678 "\u0211": "r",
679 "\u0214": "U",
680 "\u0215": "u",
681 "B\u030C": "B",
682 "b\u030C": "b",
683 "\u010C\u0323": "C",
684 "\u010D\u0323": "c",
685 "\xCA\u030C": "E",
686 "\xEA\u030C": "e",
687 "F\u030C": "F",
688 "f\u030C": "f",
689 "\u01E6": "G",
690 "\u01E7": "g",
691 "\u021E": "H",
692 "\u021F": "h",
693 "J\u030C": "J",
694 "\u01F0": "j",
695 "\u01E8": "K",
696 "\u01E9": "k",
697 "M\u030C": "M",
698 "m\u030C": "m",
699 "P\u030C": "P",
700 "p\u030C": "p",
701 "Q\u030C": "Q",
702 "q\u030C": "q",
703 "\u0158\u0329": "R",
704 "\u0159\u0329": "r",
705 "\u1E66": "S",
706 "\u1E67": "s",
707 "V\u030C": "V",
708 "v\u030C": "v",
709 "W\u030C": "W",
710 "w\u030C": "w",
711 "X\u030C": "X",
712 "x\u030C": "x",
713 "Y\u030C": "Y",
714 "y\u030C": "y",
715 "A\u0327": "A",
716 "a\u0327": "a",
717 "B\u0327": "B",
718 "b\u0327": "b",
719 "\u1E10": "D",
720 "\u1E11": "d",
721 "\u0228": "E",
722 "\u0229": "e",
723 "\u0190\u0327": "E",
724 "\u025B\u0327": "e",
725 "\u1E28": "H",
726 "\u1E29": "h",
727 "I\u0327": "I",
728 "i\u0327": "i",
729 "\u0197\u0327": "I",
730 "\u0268\u0327": "i",
731 "M\u0327": "M",
732 "m\u0327": "m",
733 "O\u0327": "O",
734 "o\u0327": "o",
735 "Q\u0327": "Q",
736 "q\u0327": "q",
737 "U\u0327": "U",
738 "u\u0327": "u",
739 "X\u0327": "X",
740 "x\u0327": "x",
741 "Z\u0327": "Z",
742 "z\u0327": "z",
743 "\u0439": "\u0438",
744 "\u0419": "\u0418",
745 "\u0451": "\u0435",
746 "\u0401": "\u0415"
747 };
748 var chars = Object.keys(characterMap).join("|");
749 var allAccents = new RegExp(chars, "g");
750 var firstAccent = new RegExp(chars, "");
751 function matcher(match2) {
752 return characterMap[match2];
753 }
754 var removeAccents3 = function(string) {
755 return string.replace(allAccents, matcher);
756 };
757 var hasAccents = function(string) {
758 return !!string.match(firstAccent);
759 };
760 module.exports = removeAccents3;
761 module.exports.has = hasAccents;
762 module.exports.remove = removeAccents3;
763 }
764 });
765
766 // node_modules/fast-deep-equal/es6/index.js
767 var require_es6 = __commonJS({
768 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
769 "use strict";
770 module.exports = function equal(a2, b2) {
771 if (a2 === b2) return true;
772 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
773 if (a2.constructor !== b2.constructor) return false;
774 var length, i2, keys;
775 if (Array.isArray(a2)) {
776 length = a2.length;
777 if (length != b2.length) return false;
778 for (i2 = length; i2-- !== 0; )
779 if (!equal(a2[i2], b2[i2])) return false;
780 return true;
781 }
782 if (a2 instanceof Map && b2 instanceof Map) {
783 if (a2.size !== b2.size) return false;
784 for (i2 of a2.entries())
785 if (!b2.has(i2[0])) return false;
786 for (i2 of a2.entries())
787 if (!equal(i2[1], b2.get(i2[0]))) return false;
788 return true;
789 }
790 if (a2 instanceof Set && b2 instanceof Set) {
791 if (a2.size !== b2.size) return false;
792 for (i2 of a2.entries())
793 if (!b2.has(i2[0])) return false;
794 return true;
795 }
796 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
797 length = a2.length;
798 if (length != b2.length) return false;
799 for (i2 = length; i2-- !== 0; )
800 if (a2[i2] !== b2[i2]) return false;
801 return true;
802 }
803 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
804 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
805 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
806 keys = Object.keys(a2);
807 length = keys.length;
808 if (length !== Object.keys(b2).length) return false;
809 for (i2 = length; i2-- !== 0; )
810 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
811 for (i2 = length; i2-- !== 0; ) {
812 var key = keys[i2];
813 if (!equal(a2[key], b2[key])) return false;
814 }
815 return true;
816 }
817 return a2 !== a2 && b2 !== b2;
818 };
819 }
820 });
821
822 // package-external:@wordpress/date
823 var require_date = __commonJS({
824 "package-external:@wordpress/date"(exports, module) {
825 module.exports = window.wp.date;
826 }
827 });
828
829 // package-external:@wordpress/warning
830 var require_warning = __commonJS({
831 "package-external:@wordpress/warning"(exports, module) {
832 module.exports = window.wp.warning;
833 }
834 });
835
836 // package-external:@wordpress/deprecated
837 var require_deprecated = __commonJS({
838 "package-external:@wordpress/deprecated"(exports, module) {
839 module.exports = window.wp.deprecated;
840 }
841 });
842
843 // package-external:@wordpress/editor
844 var require_editor = __commonJS({
845 "package-external:@wordpress/editor"(exports, module) {
846 module.exports = window.wp.editor;
847 }
848 });
849
850 // package-external:@wordpress/patterns
851 var require_patterns = __commonJS({
852 "package-external:@wordpress/patterns"(exports, module) {
853 module.exports = window.wp.patterns;
854 }
855 });
856
857 // package-external:@wordpress/block-editor
858 var require_block_editor = __commonJS({
859 "package-external:@wordpress/block-editor"(exports, module) {
860 module.exports = window.wp.blockEditor;
861 }
862 });
863
864 // routes/pattern-list/stage.tsx
865 import {
866 useParams,
867 useNavigate,
868 useSearch,
869 Link,
870 useInvalidate
871 } from "@wordpress/route";
872
873 // node_modules/dequal/dist/index.mjs
874 var has = Object.prototype.hasOwnProperty;
875 function find(iter, tar, key) {
876 for (key of iter.keys()) {
877 if (dequal(key, tar)) return key;
878 }
879 }
880 function dequal(foo, bar) {
881 var ctor, len, tmp;
882 if (foo === bar) return true;
883 if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
884 if (ctor === Date) return foo.getTime() === bar.getTime();
885 if (ctor === RegExp) return foo.toString() === bar.toString();
886 if (ctor === Array) {
887 if ((len = foo.length) === bar.length) {
888 while (len-- && dequal(foo[len], bar[len])) ;
889 }
890 return len === -1;
891 }
892 if (ctor === Set) {
893 if (foo.size !== bar.size) {
894 return false;
895 }
896 for (len of foo) {
897 tmp = len;
898 if (tmp && typeof tmp === "object") {
899 tmp = find(bar, tmp);
900 if (!tmp) return false;
901 }
902 if (!bar.has(tmp)) return false;
903 }
904 return true;
905 }
906 if (ctor === Map) {
907 if (foo.size !== bar.size) {
908 return false;
909 }
910 for (len of foo) {
911 tmp = len[0];
912 if (tmp && typeof tmp === "object") {
913 tmp = find(bar, tmp);
914 if (!tmp) return false;
915 }
916 if (!dequal(len[1], bar.get(tmp))) {
917 return false;
918 }
919 }
920 return true;
921 }
922 if (ctor === ArrayBuffer) {
923 foo = new Uint8Array(foo);
924 bar = new Uint8Array(bar);
925 } else if (ctor === DataView) {
926 if ((len = foo.byteLength) === bar.byteLength) {
927 while (len-- && foo.getInt8(len) === bar.getInt8(len)) ;
928 }
929 return len === -1;
930 }
931 if (ArrayBuffer.isView(foo)) {
932 if ((len = foo.byteLength) === bar.byteLength) {
933 while (len-- && foo[len] === bar[len]) ;
934 }
935 return len === -1;
936 }
937 if (!ctor || typeof foo === "object") {
938 len = 0;
939 for (ctor in foo) {
940 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
941 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
942 }
943 return Object.keys(bar).length === len;
944 }
945 }
946 return foo !== foo && bar !== bar;
947 }
948
949 // packages/views/build-module/use-view.mjs
950 var import_element = __toESM(require_element(), 1);
951 var import_data = __toESM(require_data(), 1);
952 var import_preferences = __toESM(require_preferences(), 1);
953
954 // packages/views/build-module/preference-keys.mjs
955 function generatePreferenceKey(kind, name, slug) {
956 return `dataviews-${kind}-${name}-${slug}`;
957 }
958
959 // packages/views/build-module/filter-utils.mjs
960 var SCALAR_VALUES = [
961 "titleField",
962 "mediaField",
963 "descriptionField",
964 "showTitle",
965 "showMedia",
966 "showDescription",
967 "showLevels",
968 "infiniteScrollEnabled"
969 ];
970 function mergeActiveViewOverrides(view, activeViewOverrides, defaultView) {
971 if (!activeViewOverrides) {
972 return view;
973 }
974 let result = view;
975 for (const key of SCALAR_VALUES) {
976 if (key in activeViewOverrides) {
977 result = { ...result, [key]: activeViewOverrides[key] };
978 }
979 }
980 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
981 const activeFields = new Set(
982 activeViewOverrides.filters.map((f2) => f2.field)
983 );
984 const preserved = (view.filters ?? []).filter(
985 (f2) => !activeFields.has(f2.field)
986 );
987 result = {
988 ...result,
989 filters: [...preserved, ...activeViewOverrides.filters]
990 };
991 }
992 if (activeViewOverrides.sort) {
993 const isDefaultSort = defaultView && view.sort?.field === defaultView.sort?.field && view.sort?.direction === defaultView.sort?.direction;
994 if (isDefaultSort) {
995 result = {
996 ...result,
997 sort: activeViewOverrides.sort
998 };
999 }
1000 }
1001 if (activeViewOverrides.layout) {
1002 result = {
1003 ...result,
1004 layout: {
1005 ...result.layout,
1006 ...activeViewOverrides.layout
1007 }
1008 };
1009 }
1010 if (activeViewOverrides.groupBy) {
1011 result = {
1012 ...result,
1013 groupBy: activeViewOverrides.groupBy
1014 };
1015 }
1016 return result;
1017 }
1018 function stripActiveViewOverrides(view, activeViewOverrides, defaultView) {
1019 if (!activeViewOverrides) {
1020 return view;
1021 }
1022 let result = view;
1023 for (const key of SCALAR_VALUES) {
1024 if (key in activeViewOverrides) {
1025 const { [key]: _, ...rest } = result;
1026 result = rest;
1027 }
1028 }
1029 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
1030 const activeFields = new Set(
1031 activeViewOverrides.filters.map((f2) => f2.field)
1032 );
1033 result = {
1034 ...result,
1035 filters: (view.filters ?? []).filter(
1036 (f2) => !activeFields.has(f2.field)
1037 )
1038 };
1039 }
1040 if (activeViewOverrides.sort && view.sort?.field === activeViewOverrides.sort.field && view.sort?.direction === activeViewOverrides.sort.direction) {
1041 result = {
1042 ...result,
1043 sort: defaultView?.sort
1044 };
1045 }
1046 if (activeViewOverrides.layout && "layout" in result && result.layout) {
1047 const layout = { ...result.layout };
1048 for (const key of Object.keys(activeViewOverrides.layout)) {
1049 delete layout[key];
1050 }
1051 result = {
1052 ...result,
1053 layout: Object.keys(layout).length > 0 ? layout : void 0
1054 };
1055 }
1056 if (activeViewOverrides.groupBy && "groupBy" in result) {
1057 const { groupBy: _, ...rest } = result;
1058 result = rest;
1059 }
1060 return result;
1061 }
1062
1063 // packages/views/build-module/use-view.mjs
1064 function omit(obj, keys) {
1065 const result = { ...obj };
1066 for (const key of keys) {
1067 delete result[key];
1068 }
1069 return result;
1070 }
1071 function useView(config) {
1072 const {
1073 kind,
1074 name,
1075 slug,
1076 defaultView,
1077 activeViewOverrides,
1078 queryParams,
1079 onChangeQueryParams
1080 } = config;
1081 const preferenceKey = generatePreferenceKey(kind, name, slug);
1082 const persistedView = (0, import_data.useSelect)(
1083 (select2) => {
1084 return select2(import_preferences.store).get(
1085 "core/views",
1086 preferenceKey
1087 );
1088 },
1089 [preferenceKey]
1090 );
1091 const { set: set2 } = (0, import_data.useDispatch)(import_preferences.store);
1092 const baseView = (0, import_element.useMemo)(
1093 () => persistedView ?? defaultView ?? {},
1094 [persistedView, defaultView]
1095 );
1096 const page = Number(queryParams?.page ?? baseView.page ?? 1);
1097 const search = queryParams?.search ?? baseView.search ?? "";
1098 const combinedOverrides = (0, import_element.useMemo)(() => {
1099 const rawDefaults = config.defaultLayouts?.[baseView.type];
1100 const layoutTypeDefaults = !rawDefaults || rawDefaults === true ? {} : rawDefaults;
1101 return { ...layoutTypeDefaults, ...activeViewOverrides };
1102 }, [config.defaultLayouts, baseView.type, activeViewOverrides]);
1103 const view = (0, import_element.useMemo)(() => {
1104 return mergeActiveViewOverrides(
1105 {
1106 ...baseView,
1107 page,
1108 search
1109 },
1110 combinedOverrides,
1111 defaultView
1112 );
1113 }, [baseView, page, search, combinedOverrides, defaultView]);
1114 const isModified = !!persistedView;
1115 const updateView = (0, import_element.useCallback)(
1116 (newView) => {
1117 const urlParams = {
1118 page: newView?.page,
1119 search: newView?.search
1120 };
1121 const preferenceView = stripActiveViewOverrides(
1122 omit(newView, ["page", "search"]),
1123 combinedOverrides,
1124 defaultView
1125 );
1126 if (onChangeQueryParams && !dequal(urlParams, { page, search })) {
1127 onChangeQueryParams(urlParams);
1128 }
1129 const comparableBaseView = stripActiveViewOverrides(
1130 baseView,
1131 combinedOverrides,
1132 defaultView
1133 );
1134 const comparableDefaultView = stripActiveViewOverrides(
1135 defaultView,
1136 combinedOverrides,
1137 defaultView
1138 );
1139 if (!dequal(comparableBaseView, preferenceView)) {
1140 if (dequal(preferenceView, comparableDefaultView)) {
1141 set2("core/views", preferenceKey, void 0);
1142 } else {
1143 set2("core/views", preferenceKey, preferenceView);
1144 }
1145 }
1146 },
1147 [
1148 onChangeQueryParams,
1149 page,
1150 search,
1151 baseView,
1152 defaultView,
1153 combinedOverrides,
1154 set2,
1155 preferenceKey
1156 ]
1157 );
1158 const resetToDefault = (0, import_element.useCallback)(() => {
1159 set2("core/views", preferenceKey, void 0);
1160 }, [preferenceKey, set2]);
1161 return {
1162 view,
1163 isModified,
1164 updateView,
1165 resetToDefault
1166 };
1167 }
1168
1169 // packages/views/build-module/load-view.mjs
1170 var import_data2 = __toESM(require_data(), 1);
1171 var import_preferences2 = __toESM(require_preferences(), 1);
1172
1173 // packages/views/build-module/use-view-config.mjs
1174 var import_data3 = __toESM(require_data(), 1);
1175 var import_core_data = __toESM(require_core_data(), 1);
1176
1177 // packages/views/build-module/lock-unlock.mjs
1178 var import_private_apis = __toESM(require_private_apis(), 1);
1179 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
1180 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
1181 "@wordpress/views"
1182 );
1183
1184 // node_modules/clsx/dist/clsx.mjs
1185 function r(e2) {
1186 var t2, f2, n2 = "";
1187 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
1188 else if ("object" == typeof e2) if (Array.isArray(e2)) {
1189 var o2 = e2.length;
1190 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
1191 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
1192 return n2;
1193 }
1194 function clsx() {
1195 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
1196 return n2;
1197 }
1198 var clsx_default = clsx;
1199
1200 // packages/dataviews/build-module/dataviews/index.mjs
1201 var import_element72 = __toESM(require_element(), 1);
1202 var import_compose12 = __toESM(require_compose(), 1);
1203
1204 // node_modules/@base-ui/utils/esm/useStableCallback.js
1205 var React3 = __toESM(require_react(), 1);
1206
1207 // node_modules/@base-ui/utils/esm/useRefWithInit.js
1208 var React2 = __toESM(require_react(), 1);
1209 var UNINITIALIZED = {};
1210 function useRefWithInit(init2, initArg) {
1211 const ref = React2.useRef(UNINITIALIZED);
1212 if (ref.current === UNINITIALIZED) {
1213 ref.current = init2(initArg);
1214 }
1215 return ref;
1216 }
1217
1218 // node_modules/@base-ui/utils/esm/useStableCallback.js
1219 var useInsertionEffect = React3[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0, -3)];
1220 var useSafeInsertionEffect = (
1221 // React 17 doesn't have useInsertionEffect.
1222 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
1223 useInsertionEffect !== React3.useLayoutEffect ? useInsertionEffect : (fn) => fn()
1224 );
1225 function useStableCallback(callback) {
1226 const stable = useRefWithInit(createStableCallback).current;
1227 stable.next = callback;
1228 useSafeInsertionEffect(stable.effect);
1229 return stable.trampoline;
1230 }
1231 function createStableCallback() {
1232 const stable = {
1233 next: void 0,
1234 callback: assertNotCalled,
1235 trampoline: (...args) => stable.callback?.(...args),
1236 effect: () => {
1237 stable.callback = stable.next;
1238 }
1239 };
1240 return stable;
1241 }
1242 function assertNotCalled() {
1243 if (true) {
1244 throw (
1245 /* minify-error-disabled */
1246 new Error("Base UI: Cannot call an event handler while rendering.")
1247 );
1248 }
1249 }
1250
1251 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
1252 var React4 = __toESM(require_react(), 1);
1253 var noop = () => {
1254 };
1255 var useIsoLayoutEffect = typeof document !== "undefined" ? React4.useLayoutEffect : noop;
1256
1257 // node_modules/@base-ui/utils/esm/warn.js
1258 var set;
1259 if (true) {
1260 set = /* @__PURE__ */ new Set();
1261 }
1262 function warn(...messages) {
1263 if (true) {
1264 const messageKey = messages.join(" ");
1265 if (!set.has(messageKey)) {
1266 set.add(messageKey);
1267 console.warn(`Base UI: ${messageKey}`);
1268 }
1269 }
1270 }
1271
1272 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js
1273 var React5 = __toESM(require_react(), 1);
1274 var DirectionContext = /* @__PURE__ */ React5.createContext(void 0);
1275 if (true) DirectionContext.displayName = "DirectionContext";
1276 function useDirection() {
1277 const context = React5.useContext(DirectionContext);
1278 return context?.direction ?? "ltr";
1279 }
1280
1281 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1282 var React8 = __toESM(require_react(), 1);
1283
1284 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1285 function useMergedRefs(a2, b2, c2, d2) {
1286 const forkRef = useRefWithInit(createForkRef).current;
1287 if (didChange(forkRef, a2, b2, c2, d2)) {
1288 update(forkRef, [a2, b2, c2, d2]);
1289 }
1290 return forkRef.callback;
1291 }
1292 function useMergedRefsN(refs) {
1293 const forkRef = useRefWithInit(createForkRef).current;
1294 if (didChangeN(forkRef, refs)) {
1295 update(forkRef, refs);
1296 }
1297 return forkRef.callback;
1298 }
1299 function createForkRef() {
1300 return {
1301 callback: null,
1302 cleanup: null,
1303 refs: []
1304 };
1305 }
1306 function didChange(forkRef, a2, b2, c2, d2) {
1307 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1308 }
1309 function didChangeN(forkRef, newRefs) {
1310 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
1311 }
1312 function update(forkRef, refs) {
1313 forkRef.refs = refs;
1314 if (refs.every((ref) => ref == null)) {
1315 forkRef.callback = null;
1316 return;
1317 }
1318 forkRef.callback = (instance) => {
1319 if (forkRef.cleanup) {
1320 forkRef.cleanup();
1321 forkRef.cleanup = null;
1322 }
1323 if (instance != null) {
1324 const cleanupCallbacks = Array(refs.length).fill(null);
1325 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1326 const ref = refs[i2];
1327 if (ref == null) {
1328 continue;
1329 }
1330 switch (typeof ref) {
1331 case "function": {
1332 const refCleanup = ref(instance);
1333 if (typeof refCleanup === "function") {
1334 cleanupCallbacks[i2] = refCleanup;
1335 }
1336 break;
1337 }
1338 case "object": {
1339 ref.current = instance;
1340 break;
1341 }
1342 default:
1343 }
1344 }
1345 forkRef.cleanup = () => {
1346 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1347 const ref = refs[i2];
1348 if (ref == null) {
1349 continue;
1350 }
1351 switch (typeof ref) {
1352 case "function": {
1353 const cleanupCallback = cleanupCallbacks[i2];
1354 if (typeof cleanupCallback === "function") {
1355 cleanupCallback();
1356 } else {
1357 ref(null);
1358 }
1359 break;
1360 }
1361 case "object": {
1362 ref.current = null;
1363 break;
1364 }
1365 default:
1366 }
1367 }
1368 };
1369 }
1370 };
1371 }
1372
1373 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1374 var React7 = __toESM(require_react(), 1);
1375
1376 // node_modules/@base-ui/utils/esm/reactVersion.js
1377 var React6 = __toESM(require_react(), 1);
1378 var majorVersion = parseInt(React6.version, 10);
1379 function isReactVersionAtLeast(reactVersionToCheck) {
1380 return majorVersion >= reactVersionToCheck;
1381 }
1382
1383 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1384 function getReactElementRef(element) {
1385 if (!/* @__PURE__ */ React7.isValidElement(element)) {
1386 return null;
1387 }
1388 const reactElement = element;
1389 const propsWithRef = reactElement.props;
1390 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1391 }
1392
1393 // node_modules/@base-ui/utils/esm/mergeObjects.js
1394 function mergeObjects(a2, b2) {
1395 if (a2 && !b2) {
1396 return a2;
1397 }
1398 if (!a2 && b2) {
1399 return b2;
1400 }
1401 if (a2 || b2) {
1402 return {
1403 ...a2,
1404 ...b2
1405 };
1406 }
1407 return void 0;
1408 }
1409
1410 // node_modules/@base-ui/utils/esm/empty.js
1411 function NOOP() {
1412 }
1413 var EMPTY_ARRAY = Object.freeze([]);
1414 var EMPTY_OBJECT = Object.freeze({});
1415
1416 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1417 function getStateAttributesProps(state, customMapping) {
1418 const props = {};
1419 for (const key in state) {
1420 const value = state[key];
1421 if (customMapping?.hasOwnProperty(key)) {
1422 const customProps = customMapping[key](value);
1423 if (customProps != null) {
1424 Object.assign(props, customProps);
1425 }
1426 continue;
1427 }
1428 if (value === true) {
1429 props[`data-${key.toLowerCase()}`] = "";
1430 } else if (value) {
1431 props[`data-${key.toLowerCase()}`] = value.toString();
1432 }
1433 }
1434 return props;
1435 }
1436
1437 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1438 function resolveClassName(className, state) {
1439 return typeof className === "function" ? className(state) : className;
1440 }
1441
1442 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1443 function resolveStyle(style, state) {
1444 return typeof style === "function" ? style(state) : style;
1445 }
1446
1447 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1448 var EMPTY_PROPS = {};
1449 function mergeProps(a2, b2, c2, d2, e2) {
1450 if (!c2 && !d2 && !e2 && !a2) {
1451 return createInitialMergedProps(b2);
1452 }
1453 let merged = createInitialMergedProps(a2);
1454 if (b2) {
1455 merged = mergeInto(merged, b2);
1456 }
1457 if (c2) {
1458 merged = mergeInto(merged, c2);
1459 }
1460 if (d2) {
1461 merged = mergeInto(merged, d2);
1462 }
1463 if (e2) {
1464 merged = mergeInto(merged, e2);
1465 }
1466 return merged;
1467 }
1468 function mergePropsN(props) {
1469 if (props.length === 0) {
1470 return EMPTY_PROPS;
1471 }
1472 if (props.length === 1) {
1473 return createInitialMergedProps(props[0]);
1474 }
1475 let merged = createInitialMergedProps(props[0]);
1476 for (let i2 = 1; i2 < props.length; i2 += 1) {
1477 merged = mergeInto(merged, props[i2]);
1478 }
1479 return merged;
1480 }
1481 function createInitialMergedProps(inputProps) {
1482 if (isPropsGetter(inputProps)) {
1483 return {
1484 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1485 };
1486 }
1487 return copyInitialProps(inputProps);
1488 }
1489 function mergeInto(merged, inputProps) {
1490 if (isPropsGetter(inputProps)) {
1491 return resolvePropsGetter(inputProps, merged);
1492 }
1493 return mutablyMergeInto(merged, inputProps);
1494 }
1495 function copyInitialProps(inputProps) {
1496 const copiedProps = {
1497 ...inputProps
1498 };
1499 for (const propName in copiedProps) {
1500 const propValue = copiedProps[propName];
1501 if (isEventHandler(propName, propValue)) {
1502 copiedProps[propName] = wrapEventHandler(propValue);
1503 }
1504 }
1505 return copiedProps;
1506 }
1507 function mutablyMergeInto(mergedProps, externalProps) {
1508 if (!externalProps) {
1509 return mergedProps;
1510 }
1511 for (const propName in externalProps) {
1512 const externalPropValue = externalProps[propName];
1513 switch (propName) {
1514 case "style": {
1515 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1516 break;
1517 }
1518 case "className": {
1519 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1520 break;
1521 }
1522 default: {
1523 if (isEventHandler(propName, externalPropValue)) {
1524 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1525 } else {
1526 mergedProps[propName] = externalPropValue;
1527 }
1528 }
1529 }
1530 }
1531 return mergedProps;
1532 }
1533 function isEventHandler(key, value) {
1534 const code0 = key.charCodeAt(0);
1535 const code1 = key.charCodeAt(1);
1536 const code2 = key.charCodeAt(2);
1537 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1538 }
1539 function isPropsGetter(inputProps) {
1540 return typeof inputProps === "function";
1541 }
1542 function resolvePropsGetter(inputProps, previousProps) {
1543 if (isPropsGetter(inputProps)) {
1544 return inputProps(previousProps);
1545 }
1546 return inputProps ?? EMPTY_PROPS;
1547 }
1548 function mergeEventHandlers(ourHandler, theirHandler) {
1549 if (!theirHandler) {
1550 return ourHandler;
1551 }
1552 if (!ourHandler) {
1553 return wrapEventHandler(theirHandler);
1554 }
1555 return (...args) => {
1556 const event = args[0];
1557 if (isSyntheticEvent(event)) {
1558 const baseUIEvent = event;
1559 makeEventPreventable(baseUIEvent);
1560 const result2 = theirHandler(...args);
1561 if (!baseUIEvent.baseUIHandlerPrevented) {
1562 ourHandler?.(...args);
1563 }
1564 return result2;
1565 }
1566 const result = theirHandler(...args);
1567 ourHandler?.(...args);
1568 return result;
1569 };
1570 }
1571 function wrapEventHandler(handler) {
1572 if (!handler) {
1573 return handler;
1574 }
1575 return (...args) => {
1576 const event = args[0];
1577 if (isSyntheticEvent(event)) {
1578 makeEventPreventable(event);
1579 }
1580 return handler(...args);
1581 };
1582 }
1583 function makeEventPreventable(event) {
1584 event.preventBaseUIHandler = () => {
1585 event.baseUIHandlerPrevented = true;
1586 };
1587 return event;
1588 }
1589 function mergeClassNames(ourClassName, theirClassName) {
1590 if (theirClassName) {
1591 if (ourClassName) {
1592 return theirClassName + " " + ourClassName;
1593 }
1594 return theirClassName;
1595 }
1596 return ourClassName;
1597 }
1598 function isSyntheticEvent(event) {
1599 return event != null && typeof event === "object" && "nativeEvent" in event;
1600 }
1601
1602 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1603 var import_react = __toESM(require_react(), 1);
1604 function useRenderElement(element, componentProps, params = {}) {
1605 const renderProp = componentProps.render;
1606 const outProps = useRenderElementProps(componentProps, params);
1607 if (params.enabled === false) {
1608 return null;
1609 }
1610 const state = params.state ?? EMPTY_OBJECT;
1611 return evaluateRenderProp(element, renderProp, outProps, state);
1612 }
1613 function useRenderElementProps(componentProps, params = {}) {
1614 const {
1615 className: classNameProp,
1616 style: styleProp,
1617 render: renderProp
1618 } = componentProps;
1619 const {
1620 state = EMPTY_OBJECT,
1621 ref,
1622 props,
1623 stateAttributesMapping: stateAttributesMapping3,
1624 enabled = true
1625 } = params;
1626 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1627 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1628 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
1629 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1630 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1631 if (typeof document !== "undefined") {
1632 if (!enabled) {
1633 useMergedRefs(null, null);
1634 } else if (Array.isArray(ref)) {
1635 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1636 } else {
1637 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1638 }
1639 }
1640 if (!enabled) {
1641 return EMPTY_OBJECT;
1642 }
1643 if (className !== void 0) {
1644 outProps.className = mergeClassNames(outProps.className, className);
1645 }
1646 if (style !== void 0) {
1647 outProps.style = mergeObjects(outProps.style, style);
1648 }
1649 return outProps;
1650 }
1651 function resolveRenderFunctionProps(props) {
1652 if (Array.isArray(props)) {
1653 return mergePropsN(props);
1654 }
1655 return mergeProps(void 0, props);
1656 }
1657 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1658 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1659 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1660 function evaluateRenderProp(element, render4, props, state) {
1661 if (render4) {
1662 if (typeof render4 === "function") {
1663 if (true) {
1664 warnIfRenderPropLooksLikeComponent(render4);
1665 }
1666 return render4(props, state);
1667 }
1668 const mergedProps = mergeProps(props, render4.props);
1669 mergedProps.ref = props.ref;
1670 let newElement = render4;
1671 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1672 const children = React8.Children.toArray(render4);
1673 newElement = children[0];
1674 }
1675 if (true) {
1676 if (!/* @__PURE__ */ React8.isValidElement(newElement)) {
1677 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"));
1678 }
1679 }
1680 return /* @__PURE__ */ React8.cloneElement(newElement, mergedProps);
1681 }
1682 if (element) {
1683 if (typeof element === "string") {
1684 return renderTag(element, props);
1685 }
1686 }
1687 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1688 }
1689 function warnIfRenderPropLooksLikeComponent(renderFn) {
1690 const functionName = renderFn.name;
1691 if (functionName.length === 0) {
1692 return;
1693 }
1694 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1695 return;
1696 }
1697 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1698 return;
1699 }
1700 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");
1701 }
1702 function renderTag(Tag, props) {
1703 if (Tag === "button") {
1704 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1705 type: "button",
1706 ...props,
1707 key: props.key
1708 });
1709 }
1710 if (Tag === "img") {
1711 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1712 alt: "",
1713 ...props,
1714 key: props.key
1715 });
1716 }
1717 return /* @__PURE__ */ React8.createElement(Tag, props);
1718 }
1719
1720 // node_modules/@base-ui/react/esm/internals/reason-parts.js
1721 var reason_parts_exports = {};
1722 __export(reason_parts_exports, {
1723 cancelOpen: () => cancelOpen,
1724 chipRemovePress: () => chipRemovePress,
1725 clearPress: () => clearPress,
1726 closePress: () => closePress,
1727 closeWatcher: () => closeWatcher,
1728 decrementPress: () => decrementPress,
1729 disabled: () => disabled,
1730 drag: () => drag,
1731 escapeKey: () => escapeKey,
1732 focusOut: () => focusOut,
1733 imperativeAction: () => imperativeAction,
1734 incrementPress: () => incrementPress,
1735 inputBlur: () => inputBlur,
1736 inputChange: () => inputChange,
1737 inputClear: () => inputClear,
1738 inputPaste: () => inputPaste,
1739 inputPress: () => inputPress,
1740 itemPress: () => itemPress,
1741 keyboard: () => keyboard,
1742 linkPress: () => linkPress,
1743 listNavigation: () => listNavigation,
1744 none: () => none,
1745 outsidePress: () => outsidePress,
1746 pointer: () => pointer,
1747 scrub: () => scrub,
1748 siblingOpen: () => siblingOpen,
1749 swipe: () => swipe,
1750 trackPress: () => trackPress,
1751 triggerFocus: () => triggerFocus,
1752 triggerHover: () => triggerHover,
1753 triggerPress: () => triggerPress,
1754 wheel: () => wheel,
1755 windowResize: () => windowResize
1756 });
1757 var none = "none";
1758 var triggerPress = "trigger-press";
1759 var triggerHover = "trigger-hover";
1760 var triggerFocus = "trigger-focus";
1761 var outsidePress = "outside-press";
1762 var itemPress = "item-press";
1763 var closePress = "close-press";
1764 var linkPress = "link-press";
1765 var clearPress = "clear-press";
1766 var chipRemovePress = "chip-remove-press";
1767 var trackPress = "track-press";
1768 var incrementPress = "increment-press";
1769 var decrementPress = "decrement-press";
1770 var inputChange = "input-change";
1771 var inputClear = "input-clear";
1772 var inputBlur = "input-blur";
1773 var inputPaste = "input-paste";
1774 var inputPress = "input-press";
1775 var focusOut = "focus-out";
1776 var escapeKey = "escape-key";
1777 var closeWatcher = "close-watcher";
1778 var listNavigation = "list-navigation";
1779 var keyboard = "keyboard";
1780 var pointer = "pointer";
1781 var drag = "drag";
1782 var wheel = "wheel";
1783 var scrub = "scrub";
1784 var cancelOpen = "cancel-open";
1785 var siblingOpen = "sibling-open";
1786 var disabled = "disabled";
1787 var imperativeAction = "imperative-action";
1788 var swipe = "swipe";
1789 var windowResize = "window-resize";
1790
1791 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
1792 function createChangeEventDetails(reason, event, trigger, customProperties) {
1793 let canceled = false;
1794 let allowPropagation = false;
1795 const custom = customProperties ?? EMPTY_OBJECT;
1796 const details = {
1797 reason,
1798 event: event ?? new Event("base-ui"),
1799 cancel() {
1800 canceled = true;
1801 },
1802 allowPropagation() {
1803 allowPropagation = true;
1804 },
1805 get isCanceled() {
1806 return canceled;
1807 },
1808 get isPropagationAllowed() {
1809 return allowPropagation;
1810 },
1811 trigger,
1812 ...custom
1813 };
1814 return details;
1815 }
1816
1817 // node_modules/@base-ui/utils/esm/useId.js
1818 var React10 = __toESM(require_react(), 1);
1819
1820 // node_modules/@base-ui/utils/esm/safeReact.js
1821 var React9 = __toESM(require_react(), 1);
1822 var SafeReact = {
1823 ...React9
1824 };
1825
1826 // node_modules/@base-ui/utils/esm/useId.js
1827 var globalId = 0;
1828 function useGlobalId(idOverride, prefix = "mui") {
1829 const [defaultId, setDefaultId] = React10.useState(idOverride);
1830 const id = idOverride || defaultId;
1831 React10.useEffect(() => {
1832 if (defaultId == null) {
1833 globalId += 1;
1834 setDefaultId(`${prefix}-${globalId}`);
1835 }
1836 }, [defaultId, prefix]);
1837 return id;
1838 }
1839 var maybeReactUseId = SafeReact.useId;
1840 function useId(idOverride, prefix) {
1841 if (maybeReactUseId !== void 0) {
1842 const reactId = maybeReactUseId();
1843 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1844 }
1845 return useGlobalId(idOverride, prefix);
1846 }
1847
1848 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
1849 function useBaseUiId(idOverride) {
1850 return useId(idOverride, "base-ui");
1851 }
1852
1853 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1854 var ReactDOM = __toESM(require_react_dom(), 1);
1855
1856 // node_modules/@base-ui/utils/esm/useOnMount.js
1857 var React11 = __toESM(require_react(), 1);
1858 var EMPTY = [];
1859 function useOnMount(fn) {
1860 React11.useEffect(fn, EMPTY);
1861 }
1862
1863 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1864 var EMPTY2 = null;
1865 var LAST_RAF = globalThis.requestAnimationFrame;
1866 var Scheduler = class {
1867 /* This implementation uses an array as a backing data-structure for frame callbacks.
1868 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1869 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1870 * be much more efficient if there is a call pattern that alterns as
1871 * "request-cancel-request-cancel-…".
1872 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1873 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1874 callbacks = [];
1875 callbacksCount = 0;
1876 nextId = 1;
1877 startId = 1;
1878 isScheduled = false;
1879 tick = (timestamp) => {
1880 this.isScheduled = false;
1881 const currentCallbacks = this.callbacks;
1882 const currentCallbacksCount = this.callbacksCount;
1883 this.callbacks = [];
1884 this.callbacksCount = 0;
1885 this.startId = this.nextId;
1886 if (currentCallbacksCount > 0) {
1887 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1888 currentCallbacks[i2]?.(timestamp);
1889 }
1890 }
1891 };
1892 request(fn) {
1893 const id = this.nextId;
1894 this.nextId += 1;
1895 this.callbacks.push(fn);
1896 this.callbacksCount += 1;
1897 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1898 if (!this.isScheduled || didRAFChange) {
1899 requestAnimationFrame(this.tick);
1900 this.isScheduled = true;
1901 }
1902 return id;
1903 }
1904 cancel(id) {
1905 const index2 = id - this.startId;
1906 if (index2 < 0 || index2 >= this.callbacks.length) {
1907 return;
1908 }
1909 this.callbacks[index2] = null;
1910 this.callbacksCount -= 1;
1911 }
1912 };
1913 var scheduler = new Scheduler();
1914 var AnimationFrame = class _AnimationFrame {
1915 static create() {
1916 return new _AnimationFrame();
1917 }
1918 static request(fn) {
1919 return scheduler.request(fn);
1920 }
1921 static cancel(id) {
1922 return scheduler.cancel(id);
1923 }
1924 currentId = EMPTY2;
1925 /**
1926 * Executes `fn` after `delay`, clearing any previously scheduled call.
1927 */
1928 request(fn) {
1929 this.cancel();
1930 this.currentId = scheduler.request(() => {
1931 this.currentId = EMPTY2;
1932 fn();
1933 });
1934 }
1935 cancel = () => {
1936 if (this.currentId !== EMPTY2) {
1937 scheduler.cancel(this.currentId);
1938 this.currentId = EMPTY2;
1939 }
1940 };
1941 disposeEffect = () => {
1942 return this.cancel;
1943 };
1944 };
1945 function useAnimationFrame() {
1946 const timeout = useRefWithInit(AnimationFrame.create).current;
1947 useOnMount(timeout.disposeEffect);
1948 return timeout;
1949 }
1950
1951 // node_modules/@base-ui/react/esm/utils/resolveRef.js
1952 function resolveRef(maybeRef) {
1953 if (maybeRef == null) {
1954 return maybeRef;
1955 }
1956 return "current" in maybeRef ? maybeRef.current : maybeRef;
1957 }
1958
1959 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
1960 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1961 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1962 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1963 return TransitionStatusDataAttributes2;
1964 })({});
1965 var STARTING_HOOK = {
1966 [TransitionStatusDataAttributes.startingStyle]: ""
1967 };
1968 var ENDING_HOOK = {
1969 [TransitionStatusDataAttributes.endingStyle]: ""
1970 };
1971 var transitionStatusMapping = {
1972 transitionStatus(value) {
1973 if (value === "starting") {
1974 return STARTING_HOOK;
1975 }
1976 if (value === "ending") {
1977 return ENDING_HOOK;
1978 }
1979 return null;
1980 }
1981 };
1982
1983 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1984 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
1985 const frame = useAnimationFrame();
1986 return useStableCallback((fnToExecute, signal = null) => {
1987 frame.cancel();
1988 const element = resolveRef(elementOrRef);
1989 if (element == null) {
1990 return;
1991 }
1992 const resolvedElement = element;
1993 const done = () => {
1994 ReactDOM.flushSync(fnToExecute);
1995 };
1996 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
1997 fnToExecute();
1998 return;
1999 }
2000 function exec() {
2001 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
2002 if (!signal?.aborted) {
2003 done();
2004 }
2005 }).catch(() => {
2006 if (treatAbortedAsFinished) {
2007 if (!signal?.aborted) {
2008 done();
2009 }
2010 return;
2011 }
2012 const currentAnimations = resolvedElement.getAnimations();
2013 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
2014 exec();
2015 }
2016 });
2017 }
2018 if (waitForStartingStyleRemoved) {
2019 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
2020 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2021 frame.request(exec);
2022 return;
2023 }
2024 const attributeObserver = new MutationObserver(() => {
2025 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2026 attributeObserver.disconnect();
2027 exec();
2028 }
2029 });
2030 attributeObserver.observe(resolvedElement, {
2031 attributes: true,
2032 attributeFilter: [startingStyleAttribute]
2033 });
2034 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
2035 once: true
2036 });
2037 return;
2038 }
2039 frame.request(exec);
2040 });
2041 }
2042
2043 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
2044 var React12 = __toESM(require_react(), 1);
2045 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
2046 const [transitionStatus, setTransitionStatus] = React12.useState(open && enableIdleState ? "idle" : void 0);
2047 const [mounted, setMounted] = React12.useState(open);
2048 if (open && !mounted) {
2049 setMounted(true);
2050 setTransitionStatus("starting");
2051 }
2052 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
2053 setTransitionStatus("ending");
2054 }
2055 if (!open && !mounted && transitionStatus === "ending") {
2056 setTransitionStatus(void 0);
2057 }
2058 useIsoLayoutEffect(() => {
2059 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
2060 const frame = AnimationFrame.request(() => {
2061 setTransitionStatus("ending");
2062 });
2063 return () => {
2064 AnimationFrame.cancel(frame);
2065 };
2066 }
2067 return void 0;
2068 }, [open, mounted, transitionStatus, deferEndingState]);
2069 useIsoLayoutEffect(() => {
2070 if (!open || enableIdleState) {
2071 return void 0;
2072 }
2073 const frame = AnimationFrame.request(() => {
2074 setTransitionStatus(void 0);
2075 });
2076 return () => {
2077 AnimationFrame.cancel(frame);
2078 };
2079 }, [enableIdleState, open]);
2080 useIsoLayoutEffect(() => {
2081 if (!open || !enableIdleState) {
2082 return void 0;
2083 }
2084 if (open && mounted && transitionStatus !== "idle") {
2085 setTransitionStatus("starting");
2086 }
2087 const frame = AnimationFrame.request(() => {
2088 setTransitionStatus("idle");
2089 });
2090 return () => {
2091 AnimationFrame.cancel(frame);
2092 };
2093 }, [enableIdleState, open, mounted, transitionStatus]);
2094 return {
2095 mounted,
2096 setMounted,
2097 transitionStatus
2098 };
2099 }
2100
2101 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
2102 function hasWindow() {
2103 return typeof window !== "undefined";
2104 }
2105 function getNodeName(node) {
2106 if (isNode(node)) {
2107 return (node.nodeName || "").toLowerCase();
2108 }
2109 return "#document";
2110 }
2111 function getWindow(node) {
2112 var _node$ownerDocument;
2113 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2114 }
2115 function getDocumentElement(node) {
2116 var _ref;
2117 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2118 }
2119 function isNode(value) {
2120 if (!hasWindow()) {
2121 return false;
2122 }
2123 return value instanceof Node || value instanceof getWindow(value).Node;
2124 }
2125 function isElement(value) {
2126 if (!hasWindow()) {
2127 return false;
2128 }
2129 return value instanceof Element || value instanceof getWindow(value).Element;
2130 }
2131 function isHTMLElement(value) {
2132 if (!hasWindow()) {
2133 return false;
2134 }
2135 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2136 }
2137 function isShadowRoot(value) {
2138 if (!hasWindow() || typeof ShadowRoot === "undefined") {
2139 return false;
2140 }
2141 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2142 }
2143 function isOverflowElement(element) {
2144 const {
2145 overflow,
2146 overflowX,
2147 overflowY,
2148 display
2149 } = getComputedStyle2(element);
2150 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
2151 }
2152 function isTableElement(element) {
2153 return /^(table|td|th)$/.test(getNodeName(element));
2154 }
2155 function isTopLayer(element) {
2156 try {
2157 if (element.matches(":popover-open")) {
2158 return true;
2159 }
2160 } catch (_e) {
2161 }
2162 try {
2163 return element.matches(":modal");
2164 } catch (_e) {
2165 return false;
2166 }
2167 }
2168 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
2169 var containRe = /paint|layout|strict|content/;
2170 var isNotNone = (value) => !!value && value !== "none";
2171 var isWebKitValue;
2172 function isContainingBlock(elementOrCss) {
2173 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
2174 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 || "");
2175 }
2176 function getContainingBlock(element) {
2177 let currentNode = getParentNode(element);
2178 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2179 if (isContainingBlock(currentNode)) {
2180 return currentNode;
2181 } else if (isTopLayer(currentNode)) {
2182 return null;
2183 }
2184 currentNode = getParentNode(currentNode);
2185 }
2186 return null;
2187 }
2188 function isWebKit() {
2189 if (isWebKitValue == null) {
2190 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
2191 }
2192 return isWebKitValue;
2193 }
2194 function isLastTraversableNode(node) {
2195 return /^(html|body|#document)$/.test(getNodeName(node));
2196 }
2197 function getComputedStyle2(element) {
2198 return getWindow(element).getComputedStyle(element);
2199 }
2200 function getNodeScroll(element) {
2201 if (isElement(element)) {
2202 return {
2203 scrollLeft: element.scrollLeft,
2204 scrollTop: element.scrollTop
2205 };
2206 }
2207 return {
2208 scrollLeft: element.scrollX,
2209 scrollTop: element.scrollY
2210 };
2211 }
2212 function getParentNode(node) {
2213 if (getNodeName(node) === "html") {
2214 return node;
2215 }
2216 const result = (
2217 // Step into the shadow DOM of the parent of a slotted node.
2218 node.assignedSlot || // DOM Element detected.
2219 node.parentNode || // ShadowRoot detected.
2220 isShadowRoot(node) && node.host || // Fallback.
2221 getDocumentElement(node)
2222 );
2223 return isShadowRoot(result) ? result.host : result;
2224 }
2225 function getNearestOverflowAncestor(node) {
2226 const parentNode = getParentNode(node);
2227 if (isLastTraversableNode(parentNode)) {
2228 return node.ownerDocument ? node.ownerDocument.body : node.body;
2229 }
2230 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2231 return parentNode;
2232 }
2233 return getNearestOverflowAncestor(parentNode);
2234 }
2235 function getOverflowAncestors(node, list, traverseIframes) {
2236 var _node$ownerDocument2;
2237 if (list === void 0) {
2238 list = [];
2239 }
2240 if (traverseIframes === void 0) {
2241 traverseIframes = true;
2242 }
2243 const scrollableAncestor = getNearestOverflowAncestor(node);
2244 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2245 const win = getWindow(scrollableAncestor);
2246 if (isBody) {
2247 const frameElement = getFrameElement(win);
2248 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2249 } else {
2250 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2251 }
2252 }
2253 function getFrameElement(win) {
2254 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2255 }
2256
2257 // node_modules/@base-ui/utils/esm/detectBrowser.js
2258 var hasNavigator = typeof navigator !== "undefined";
2259 var nav = getNavigatorData();
2260 var platform = getPlatform();
2261 var userAgent = getUserAgent();
2262 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
2263 var isIOS = (
2264 // iPads can claim to be MacIntel
2265 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
2266 );
2267 var isFirefox = hasNavigator && /firefox/i.test(userAgent);
2268 var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
2269 var isEdge = hasNavigator && /Edg/i.test(userAgent);
2270 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
2271 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
2272 var isJSDOM = userAgent.includes("jsdom/");
2273 function getNavigatorData() {
2274 if (!hasNavigator) {
2275 return {
2276 platform: "",
2277 maxTouchPoints: -1
2278 };
2279 }
2280 const uaData = navigator.userAgentData;
2281 if (uaData?.platform) {
2282 return {
2283 platform: uaData.platform,
2284 maxTouchPoints: navigator.maxTouchPoints
2285 };
2286 }
2287 return {
2288 platform: navigator.platform ?? "",
2289 maxTouchPoints: navigator.maxTouchPoints ?? -1
2290 };
2291 }
2292 function getUserAgent() {
2293 if (!hasNavigator) {
2294 return "";
2295 }
2296 const uaData = navigator.userAgentData;
2297 if (uaData && Array.isArray(uaData.brands)) {
2298 return uaData.brands.map(({
2299 brand,
2300 version: version2
2301 }) => `${brand}/${version2}`).join(" ");
2302 }
2303 return navigator.userAgent;
2304 }
2305 function getPlatform() {
2306 if (!hasNavigator) {
2307 return "";
2308 }
2309 const uaData = navigator.userAgentData;
2310 if (uaData?.platform) {
2311 return uaData.platform;
2312 }
2313 return navigator.platform ?? "";
2314 }
2315
2316 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js
2317 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
2318 var ACTIVE_KEY = "active";
2319 var SELECTED_KEY = "selected";
2320 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
2321
2322 // node_modules/@base-ui/react/esm/internals/shadowDom.js
2323 function activeElement(doc) {
2324 let element = doc.activeElement;
2325 while (element?.shadowRoot?.activeElement != null) {
2326 element = element.shadowRoot.activeElement;
2327 }
2328 return element;
2329 }
2330 function contains(parent, child) {
2331 if (!parent || !child) {
2332 return false;
2333 }
2334 const rootNode = child.getRootNode?.();
2335 if (parent.contains(child)) {
2336 return true;
2337 }
2338 if (rootNode && isShadowRoot(rootNode)) {
2339 let next = child;
2340 while (next) {
2341 if (parent === next) {
2342 return true;
2343 }
2344 next = next.parentNode || next.host;
2345 }
2346 }
2347 return false;
2348 }
2349 function getTarget(event) {
2350 if ("composedPath" in event) {
2351 return event.composedPath()[0];
2352 }
2353 return event.target;
2354 }
2355
2356 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js
2357 function isTargetInsideEnabledTrigger(target, triggerElements) {
2358 if (!isElement(target)) {
2359 return false;
2360 }
2361 const targetElement = target;
2362 if (triggerElements.hasElement(targetElement)) {
2363 return !targetElement.hasAttribute("data-trigger-disabled");
2364 }
2365 for (const [, trigger] of triggerElements.entries()) {
2366 if (contains(trigger, targetElement)) {
2367 return !trigger.hasAttribute("data-trigger-disabled");
2368 }
2369 }
2370 return false;
2371 }
2372 function isEventTargetWithin(event, node) {
2373 if (node == null) {
2374 return false;
2375 }
2376 if ("composedPath" in event) {
2377 return event.composedPath().includes(node);
2378 }
2379 const eventAgain = event;
2380 return eventAgain.target != null && node.contains(eventAgain.target);
2381 }
2382 function isRootElement(element) {
2383 return element.matches("html,body");
2384 }
2385 function isTypeableElement(element) {
2386 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
2387 }
2388 function isInteractiveElement(element) {
2389 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
2390 }
2391 function matchesFocusVisible(element) {
2392 if (!element || isJSDOM) {
2393 return true;
2394 }
2395 try {
2396 return element.matches(":focus-visible");
2397 } catch (_e) {
2398 return true;
2399 }
2400 }
2401
2402 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js
2403 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
2404 const directChildren = nodes.filter((node) => node.parentId === id);
2405 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
2406 }
2407
2408 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js
2409 function isReactEvent(event) {
2410 return "nativeEvent" in event;
2411 }
2412 function isMouseLikePointerType(pointerType, strict) {
2413 const values = ["mouse", "pen"];
2414 if (!strict) {
2415 values.push("", void 0);
2416 }
2417 return values.includes(pointerType);
2418 }
2419 function isClickLikeEvent(event) {
2420 const type = event.type;
2421 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2422 }
2423
2424 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2425 var sides = ["top", "right", "bottom", "left"];
2426 var min = Math.min;
2427 var max = Math.max;
2428 var round = Math.round;
2429 var floor = Math.floor;
2430 var createCoords = (v2) => ({
2431 x: v2,
2432 y: v2
2433 });
2434 var oppositeSideMap = {
2435 left: "right",
2436 right: "left",
2437 bottom: "top",
2438 top: "bottom"
2439 };
2440 function clamp(start, value, end) {
2441 return max(start, min(value, end));
2442 }
2443 function evaluate(value, param) {
2444 return typeof value === "function" ? value(param) : value;
2445 }
2446 function getSide(placement) {
2447 return placement.split("-")[0];
2448 }
2449 function getAlignment(placement) {
2450 return placement.split("-")[1];
2451 }
2452 function getOppositeAxis(axis) {
2453 return axis === "x" ? "y" : "x";
2454 }
2455 function getAxisLength(axis) {
2456 return axis === "y" ? "height" : "width";
2457 }
2458 function getSideAxis(placement) {
2459 const firstChar = placement[0];
2460 return firstChar === "t" || firstChar === "b" ? "y" : "x";
2461 }
2462 function getAlignmentAxis(placement) {
2463 return getOppositeAxis(getSideAxis(placement));
2464 }
2465 function getAlignmentSides(placement, rects, rtl) {
2466 if (rtl === void 0) {
2467 rtl = false;
2468 }
2469 const alignment = getAlignment(placement);
2470 const alignmentAxis = getAlignmentAxis(placement);
2471 const length = getAxisLength(alignmentAxis);
2472 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
2473 if (rects.reference[length] > rects.floating[length]) {
2474 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
2475 }
2476 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
2477 }
2478 function getExpandedPlacements(placement) {
2479 const oppositePlacement = getOppositePlacement(placement);
2480 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
2481 }
2482 function getOppositeAlignmentPlacement(placement) {
2483 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
2484 }
2485 var lrPlacement = ["left", "right"];
2486 var rlPlacement = ["right", "left"];
2487 var tbPlacement = ["top", "bottom"];
2488 var btPlacement = ["bottom", "top"];
2489 function getSideList(side, isStart, rtl) {
2490 switch (side) {
2491 case "top":
2492 case "bottom":
2493 if (rtl) return isStart ? rlPlacement : lrPlacement;
2494 return isStart ? lrPlacement : rlPlacement;
2495 case "left":
2496 case "right":
2497 return isStart ? tbPlacement : btPlacement;
2498 default:
2499 return [];
2500 }
2501 }
2502 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
2503 const alignment = getAlignment(placement);
2504 let list = getSideList(getSide(placement), direction === "start", rtl);
2505 if (alignment) {
2506 list = list.map((side) => side + "-" + alignment);
2507 if (flipAlignment) {
2508 list = list.concat(list.map(getOppositeAlignmentPlacement));
2509 }
2510 }
2511 return list;
2512 }
2513 function getOppositePlacement(placement) {
2514 const side = getSide(placement);
2515 return oppositeSideMap[side] + placement.slice(side.length);
2516 }
2517 function expandPaddingObject(padding) {
2518 return {
2519 top: 0,
2520 right: 0,
2521 bottom: 0,
2522 left: 0,
2523 ...padding
2524 };
2525 }
2526 function getPaddingObject(padding) {
2527 return typeof padding !== "number" ? expandPaddingObject(padding) : {
2528 top: padding,
2529 right: padding,
2530 bottom: padding,
2531 left: padding
2532 };
2533 }
2534 function rectToClientRect(rect) {
2535 const {
2536 x: x2,
2537 y: y2,
2538 width,
2539 height
2540 } = rect;
2541 return {
2542 width,
2543 height,
2544 top: y2,
2545 left: x2,
2546 right: x2 + width,
2547 bottom: y2 + height,
2548 x: x2,
2549 y: y2
2550 };
2551 }
2552
2553 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
2554 function isHiddenByStyles(styles) {
2555 return styles.visibility === "hidden" || styles.visibility === "collapse";
2556 }
2557 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
2558 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
2559 return false;
2560 }
2561 if (typeof element.checkVisibility === "function") {
2562 return element.checkVisibility();
2563 }
2564 return styles.display !== "none" && styles.display !== "contents";
2565 }
2566
2567 // node_modules/@base-ui/utils/esm/owner.js
2568 function ownerDocument(node) {
2569 return node?.ownerDocument || document;
2570 }
2571
2572 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js
2573 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
2574 function getParentElement(element) {
2575 const assignedSlot = element.assignedSlot;
2576 if (assignedSlot) {
2577 return assignedSlot;
2578 }
2579 if (element.parentElement) {
2580 return element.parentElement;
2581 }
2582 const rootNode = element.getRootNode();
2583 return isShadowRoot(rootNode) ? rootNode.host : null;
2584 }
2585 function getDetailsSummary(details) {
2586 for (const child of Array.from(details.children)) {
2587 if (getNodeName(child) === "summary") {
2588 return child;
2589 }
2590 }
2591 return null;
2592 }
2593 function isWithinOpenDetailsSummary(element, details) {
2594 const summary = getDetailsSummary(details);
2595 return !!summary && (element === summary || contains(summary, element));
2596 }
2597 function isFocusableCandidate(element) {
2598 const nodeName = element ? getNodeName(element) : "";
2599 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");
2600 }
2601 function isFocusableElement(element) {
2602 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
2603 return false;
2604 }
2605 for (let current = element; current; current = getParentElement(current)) {
2606 const isAncestor = current !== element;
2607 const isSlot = getNodeName(current) === "slot";
2608 if (current.hasAttribute("inert")) {
2609 return false;
2610 }
2611 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
2612 return false;
2613 }
2614 }
2615 return true;
2616 }
2617 function isVisibleInTabbableTree(element, isAncestor) {
2618 const styles = getComputedStyle2(element);
2619 if (!isAncestor) {
2620 return isElementVisible(element, styles);
2621 }
2622 return styles.display !== "none";
2623 }
2624 function getTabIndex(element) {
2625 const tabIndex = element.tabIndex;
2626 if (tabIndex < 0) {
2627 const nodeName = getNodeName(element);
2628 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
2629 return 0;
2630 }
2631 }
2632 return tabIndex;
2633 }
2634 function getNamedRadioInput(element) {
2635 if (getNodeName(element) !== "input") {
2636 return null;
2637 }
2638 const input = element;
2639 return input.type === "radio" && input.name !== "" ? input : null;
2640 }
2641 function isTabbableRadio(element, candidates) {
2642 const input = getNamedRadioInput(element);
2643 if (!input) {
2644 return true;
2645 }
2646 const checkedRadio = candidates.find((candidate) => {
2647 const radio = getNamedRadioInput(candidate);
2648 return radio?.name === input.name && radio.form === input.form && radio.checked;
2649 });
2650 if (checkedRadio) {
2651 return checkedRadio === input;
2652 }
2653 return candidates.find((candidate) => {
2654 const radio = getNamedRadioInput(candidate);
2655 return radio?.name === input.name && radio.form === input.form;
2656 }) === input;
2657 }
2658 function getComposedChildren(container) {
2659 if (isHTMLElement(container) && getNodeName(container) === "slot") {
2660 const assignedElements = container.assignedElements({
2661 flatten: true
2662 });
2663 if (assignedElements.length > 0) {
2664 return assignedElements;
2665 }
2666 }
2667 if (isHTMLElement(container) && container.shadowRoot) {
2668 return Array.from(container.shadowRoot.children);
2669 }
2670 return Array.from(container.children);
2671 }
2672 function appendCandidates(container, list) {
2673 getComposedChildren(container).forEach((child) => {
2674 if (isFocusableCandidate(child)) {
2675 list.push(child);
2676 }
2677 appendCandidates(child, list);
2678 });
2679 }
2680 function appendMatchingElements(container, selector2, list) {
2681 getComposedChildren(container).forEach((child) => {
2682 if (isHTMLElement(child) && child.matches(selector2)) {
2683 list.push(child);
2684 }
2685 appendMatchingElements(child, selector2, list);
2686 });
2687 }
2688 function focusable(container) {
2689 const candidates = [];
2690 appendCandidates(container, candidates);
2691 return candidates.filter(isFocusableElement);
2692 }
2693 function tabbable(container) {
2694 const candidates = focusable(container);
2695 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
2696 }
2697 function getTabbableIn(container, dir) {
2698 const list = tabbable(container);
2699 const len = list.length;
2700 if (len === 0) {
2701 return void 0;
2702 }
2703 const active = activeElement(ownerDocument(container));
2704 const index2 = list.indexOf(active);
2705 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
2706 return list[nextIndex];
2707 }
2708 function getNextTabbable(referenceElement) {
2709 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
2710 }
2711 function getPreviousTabbable(referenceElement) {
2712 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
2713 }
2714 function isOutsideEvent(event, container) {
2715 const containerElement = container || event.currentTarget;
2716 const relatedTarget = event.relatedTarget;
2717 return !relatedTarget || !contains(containerElement, relatedTarget);
2718 }
2719 function disableFocusInside(container) {
2720 const tabbableElements = tabbable(container);
2721 tabbableElements.forEach((element) => {
2722 element.dataset.tabindex = element.getAttribute("tabindex") || "";
2723 element.setAttribute("tabindex", "-1");
2724 });
2725 }
2726 function enableFocusInside(container) {
2727 const elements = [];
2728 appendMatchingElements(container, "[data-tabindex]", elements);
2729 elements.forEach((element) => {
2730 const tabindex = element.dataset.tabindex;
2731 delete element.dataset.tabindex;
2732 if (tabindex) {
2733 element.setAttribute("tabindex", tabindex);
2734 } else {
2735 element.removeAttribute("tabindex");
2736 }
2737 });
2738 }
2739
2740 // node_modules/@base-ui/utils/esm/addEventListener.js
2741 function addEventListener(target, type, listener, options) {
2742 target.addEventListener(type, listener, options);
2743 return () => {
2744 target.removeEventListener(type, listener, options);
2745 };
2746 }
2747
2748 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2749 var React13 = __toESM(require_react(), 1);
2750 function useOpenChangeComplete(parameters) {
2751 const {
2752 enabled = true,
2753 open,
2754 ref,
2755 onComplete: onCompleteParam
2756 } = parameters;
2757 const onComplete = useStableCallback(onCompleteParam);
2758 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2759 React13.useEffect(() => {
2760 if (!enabled) {
2761 return void 0;
2762 }
2763 const abortController = new AbortController();
2764 runOnceAnimationsFinish(onComplete, abortController.signal);
2765 return () => {
2766 abortController.abort();
2767 };
2768 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2769 }
2770
2771 // node_modules/@base-ui/utils/esm/useOnFirstRender.js
2772 var React14 = __toESM(require_react(), 1);
2773 function useOnFirstRender(fn) {
2774 const ref = React14.useRef(true);
2775 if (ref.current) {
2776 ref.current = false;
2777 fn();
2778 }
2779 }
2780
2781 // node_modules/@base-ui/utils/esm/useTimeout.js
2782 var EMPTY3 = 0;
2783 var Timeout = class _Timeout {
2784 static create() {
2785 return new _Timeout();
2786 }
2787 currentId = EMPTY3;
2788 /**
2789 * Executes `fn` after `delay`, clearing any previously scheduled call.
2790 */
2791 start(delay, fn) {
2792 this.clear();
2793 this.currentId = setTimeout(() => {
2794 this.currentId = EMPTY3;
2795 fn();
2796 }, delay);
2797 }
2798 isStarted() {
2799 return this.currentId !== EMPTY3;
2800 }
2801 clear = () => {
2802 if (this.currentId !== EMPTY3) {
2803 clearTimeout(this.currentId);
2804 this.currentId = EMPTY3;
2805 }
2806 };
2807 disposeEffect = () => {
2808 return this.clear;
2809 };
2810 };
2811 function useTimeout() {
2812 const timeout = useRefWithInit(Timeout.create).current;
2813 useOnMount(timeout.disposeEffect);
2814 return timeout;
2815 }
2816
2817 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2818 var React15 = __toESM(require_react(), 1);
2819
2820 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js
2821 function resolveValue(value, pointerType) {
2822 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
2823 return 0;
2824 }
2825 if (typeof value === "function") {
2826 return value();
2827 }
2828 return value;
2829 }
2830 function getDelay(value, prop, pointerType) {
2831 const result = resolveValue(value, pointerType);
2832 if (typeof result === "number") {
2833 return result;
2834 }
2835 return result?.[prop];
2836 }
2837 function getRestMs(value) {
2838 if (typeof value === "function") {
2839 return value();
2840 }
2841 return value;
2842 }
2843 function isClickLikeOpenEvent(openEventType, interactedInside) {
2844 return interactedInside || openEventType === "click" || openEventType === "mousedown";
2845 }
2846
2847 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2848 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
2849 var FloatingDelayGroupContext = /* @__PURE__ */ React15.createContext({
2850 hasProvider: false,
2851 timeoutMs: 0,
2852 delayRef: {
2853 current: 0
2854 },
2855 initialDelayRef: {
2856 current: 0
2857 },
2858 timeout: new Timeout(),
2859 currentIdRef: {
2860 current: null
2861 },
2862 currentContextRef: {
2863 current: null
2864 }
2865 });
2866 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
2867 function FloatingDelayGroup(props) {
2868 const {
2869 children,
2870 delay,
2871 timeoutMs = 0
2872 } = props;
2873 const delayRef = React15.useRef(delay);
2874 const initialDelayRef = React15.useRef(delay);
2875 const currentIdRef = React15.useRef(null);
2876 const currentContextRef = React15.useRef(null);
2877 const timeout = useTimeout();
2878 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
2879 value: React15.useMemo(() => ({
2880 hasProvider: true,
2881 delayRef,
2882 initialDelayRef,
2883 currentIdRef,
2884 timeoutMs,
2885 currentContextRef,
2886 timeout
2887 }), [timeoutMs, timeout]),
2888 children
2889 });
2890 }
2891 function useDelayGroup(context, options = {
2892 open: false
2893 }) {
2894 const store = "rootStore" in context ? context.rootStore : context;
2895 const floatingId = store.useState("floatingId");
2896 const {
2897 open
2898 } = options;
2899 const groupContext = React15.useContext(FloatingDelayGroupContext);
2900 const {
2901 currentIdRef,
2902 delayRef,
2903 timeoutMs,
2904 initialDelayRef,
2905 currentContextRef,
2906 hasProvider,
2907 timeout
2908 } = groupContext;
2909 const [isInstantPhase, setIsInstantPhase] = React15.useState(false);
2910 useIsoLayoutEffect(() => {
2911 function unset() {
2912 setIsInstantPhase(false);
2913 currentContextRef.current?.setIsInstantPhase(false);
2914 currentIdRef.current = null;
2915 currentContextRef.current = null;
2916 delayRef.current = initialDelayRef.current;
2917 }
2918 if (!currentIdRef.current) {
2919 return void 0;
2920 }
2921 if (!open && currentIdRef.current === floatingId) {
2922 setIsInstantPhase(false);
2923 if (timeoutMs) {
2924 const closingId = floatingId;
2925 timeout.start(timeoutMs, () => {
2926 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
2927 return;
2928 }
2929 unset();
2930 });
2931 return () => {
2932 timeout.clear();
2933 };
2934 }
2935 unset();
2936 }
2937 return void 0;
2938 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
2939 useIsoLayoutEffect(() => {
2940 if (!open) {
2941 return;
2942 }
2943 const prevContext = currentContextRef.current;
2944 const prevId = currentIdRef.current;
2945 timeout.clear();
2946 currentContextRef.current = {
2947 onOpenChange: store.setOpen,
2948 setIsInstantPhase
2949 };
2950 currentIdRef.current = floatingId;
2951 delayRef.current = {
2952 open: 0,
2953 close: getDelay(initialDelayRef.current, "close")
2954 };
2955 if (prevId !== null && prevId !== floatingId) {
2956 setIsInstantPhase(true);
2957 prevContext?.setIsInstantPhase(true);
2958 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
2959 } else {
2960 setIsInstantPhase(false);
2961 prevContext?.setIsInstantPhase(false);
2962 }
2963 }, [open, floatingId, store, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout]);
2964 useIsoLayoutEffect(() => {
2965 return () => {
2966 currentContextRef.current = null;
2967 };
2968 }, [currentContextRef]);
2969 return React15.useMemo(() => ({
2970 hasProvider,
2971 delayRef,
2972 isInstantPhase
2973 }), [hasProvider, delayRef, isInstantPhase]);
2974 }
2975
2976 // node_modules/@base-ui/utils/esm/mergeCleanups.js
2977 function mergeCleanups(...cleanups) {
2978 return () => {
2979 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
2980 const cleanup = cleanups[i2];
2981 if (cleanup) {
2982 cleanup();
2983 }
2984 }
2985 };
2986 }
2987
2988 // node_modules/@base-ui/utils/esm/useValueAsRef.js
2989 function useValueAsRef(value) {
2990 const latest = useRefWithInit(createLatestRef, value).current;
2991 latest.next = value;
2992 useIsoLayoutEffect(latest.effect);
2993 return latest;
2994 }
2995 function createLatestRef(value) {
2996 const latest = {
2997 current: value,
2998 next: value,
2999 effect: () => {
3000 latest.current = latest.next;
3001 }
3002 };
3003 return latest;
3004 }
3005
3006 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
3007 var React16 = __toESM(require_react(), 1);
3008
3009 // node_modules/@base-ui/utils/esm/visuallyHidden.js
3010 var visuallyHiddenBase = {
3011 clipPath: "inset(50%)",
3012 overflow: "hidden",
3013 whiteSpace: "nowrap",
3014 border: 0,
3015 padding: 0,
3016 width: 1,
3017 height: 1,
3018 margin: -1
3019 };
3020 var visuallyHidden = {
3021 ...visuallyHiddenBase,
3022 position: "fixed",
3023 top: 0,
3024 left: 0
3025 };
3026 var visuallyHiddenInput = {
3027 ...visuallyHiddenBase,
3028 position: "absolute"
3029 };
3030
3031 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
3032 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
3033 var FocusGuard = /* @__PURE__ */ React16.forwardRef(function FocusGuard2(props, ref) {
3034 const [role, setRole] = React16.useState();
3035 useIsoLayoutEffect(() => {
3036 if (isSafari) {
3037 setRole("button");
3038 }
3039 }, []);
3040 const restProps = {
3041 tabIndex: 0,
3042 // Role is only for VoiceOver
3043 role
3044 };
3045 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
3046 ...props,
3047 ref,
3048 style: visuallyHidden,
3049 "aria-hidden": role ? void 0 : true,
3050 ...restProps,
3051 "data-base-ui-focus-guard": ""
3052 });
3053 });
3054 if (true) FocusGuard.displayName = "FocusGuard";
3055
3056 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js
3057 function createAttribute(name) {
3058 return `data-base-ui-${name}`;
3059 }
3060
3061 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
3062 var React17 = __toESM(require_react(), 1);
3063 var ReactDOM2 = __toESM(require_react_dom(), 1);
3064
3065 // node_modules/@base-ui/react/esm/internals/constants.js
3066 var DISABLED_TRANSITIONS_STYLE = {
3067 style: {
3068 transition: "none"
3069 }
3070 };
3071 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
3072 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
3073 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
3074 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
3075 var POPUP_COLLISION_AVOIDANCE = {
3076 fallbackAxisSide: "end"
3077 };
3078 var ownerVisuallyHidden = {
3079 clipPath: "inset(50%)",
3080 position: "fixed",
3081 top: 0,
3082 left: 0
3083 };
3084
3085 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
3086 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
3087 var PortalContext = /* @__PURE__ */ React17.createContext(null);
3088 if (true) PortalContext.displayName = "PortalContext";
3089 var usePortalContext = () => React17.useContext(PortalContext);
3090 var attr = createAttribute("portal");
3091 function useFloatingPortalNode(props = {}) {
3092 const {
3093 ref,
3094 container: containerProp,
3095 componentProps = EMPTY_OBJECT,
3096 elementProps
3097 } = props;
3098 const uniqueId = useId();
3099 const portalContext = usePortalContext();
3100 const parentPortalNode = portalContext?.portalNode;
3101 const [containerElement, setContainerElement] = React17.useState(null);
3102 const [portalNode, setPortalNode] = React17.useState(null);
3103 const setPortalNodeRef = useStableCallback((node) => {
3104 if (node !== null) {
3105 setPortalNode(node);
3106 }
3107 });
3108 const containerRef = React17.useRef(null);
3109 useIsoLayoutEffect(() => {
3110 if (containerProp === null) {
3111 if (containerRef.current) {
3112 containerRef.current = null;
3113 setPortalNode(null);
3114 setContainerElement(null);
3115 }
3116 return;
3117 }
3118 if (uniqueId == null) {
3119 return;
3120 }
3121 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
3122 if (resolvedContainer == null) {
3123 if (containerRef.current) {
3124 containerRef.current = null;
3125 setPortalNode(null);
3126 setContainerElement(null);
3127 }
3128 return;
3129 }
3130 if (containerRef.current !== resolvedContainer) {
3131 containerRef.current = resolvedContainer;
3132 setPortalNode(null);
3133 setContainerElement(resolvedContainer);
3134 }
3135 }, [containerProp, parentPortalNode, uniqueId]);
3136 const portalElement = useRenderElement("div", componentProps, {
3137 ref: [ref, setPortalNodeRef],
3138 props: [{
3139 id: uniqueId,
3140 [attr]: ""
3141 }, elementProps]
3142 });
3143 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
3144 return {
3145 portalNode,
3146 portalSubtree
3147 };
3148 }
3149 var FloatingPortal = /* @__PURE__ */ React17.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
3150 const {
3151 children,
3152 container,
3153 className,
3154 render: render4,
3155 renderGuards,
3156 style,
3157 ...elementProps
3158 } = componentProps;
3159 const {
3160 portalNode,
3161 portalSubtree
3162 } = useFloatingPortalNode({
3163 container,
3164 ref: forwardedRef,
3165 componentProps,
3166 elementProps
3167 });
3168 const beforeOutsideRef = React17.useRef(null);
3169 const afterOutsideRef = React17.useRef(null);
3170 const beforeInsideRef = React17.useRef(null);
3171 const afterInsideRef = React17.useRef(null);
3172 const [focusManagerState, setFocusManagerState] = React17.useState(null);
3173 const focusInsideDisabledRef = React17.useRef(false);
3174 const modal = focusManagerState?.modal;
3175 const open = focusManagerState?.open;
3176 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
3177 React17.useEffect(() => {
3178 if (!portalNode || modal) {
3179 return void 0;
3180 }
3181 function onFocus(event) {
3182 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
3183 if (event.type === "focusin") {
3184 if (focusInsideDisabledRef.current) {
3185 enableFocusInside(portalNode);
3186 focusInsideDisabledRef.current = false;
3187 }
3188 } else {
3189 disableFocusInside(portalNode);
3190 focusInsideDisabledRef.current = true;
3191 }
3192 }
3193 }
3194 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
3195 }, [portalNode, modal]);
3196 React17.useEffect(() => {
3197 if (!portalNode || open !== false) {
3198 return;
3199 }
3200 enableFocusInside(portalNode);
3201 focusInsideDisabledRef.current = false;
3202 }, [open, portalNode]);
3203 const portalContextValue = React17.useMemo(() => ({
3204 beforeOutsideRef,
3205 afterOutsideRef,
3206 beforeInsideRef,
3207 afterInsideRef,
3208 portalNode,
3209 setFocusManagerState
3210 }), [portalNode]);
3211 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React17.Fragment, {
3212 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
3213 value: portalContextValue,
3214 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3215 "data-type": "outside",
3216 ref: beforeOutsideRef,
3217 onFocus: (event) => {
3218 if (isOutsideEvent(event, portalNode)) {
3219 beforeInsideRef.current?.focus();
3220 } else {
3221 const domReference = focusManagerState ? focusManagerState.domReference : null;
3222 const prevTabbable = getPreviousTabbable(domReference);
3223 prevTabbable?.focus();
3224 }
3225 }
3226 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
3227 "aria-owns": portalNode.id,
3228 style: ownerVisuallyHidden
3229 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3230 "data-type": "outside",
3231 ref: afterOutsideRef,
3232 onFocus: (event) => {
3233 if (isOutsideEvent(event, portalNode)) {
3234 afterInsideRef.current?.focus();
3235 } else {
3236 const domReference = focusManagerState ? focusManagerState.domReference : null;
3237 const nextTabbable = getNextTabbable(domReference);
3238 nextTabbable?.focus();
3239 if (focusManagerState?.closeOnFocusOut) {
3240 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
3241 }
3242 }
3243 }
3244 })]
3245 })]
3246 });
3247 });
3248 if (true) FloatingPortal.displayName = "FloatingPortal";
3249
3250 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3251 var React18 = __toESM(require_react(), 1);
3252
3253 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js
3254 function createEventEmitter() {
3255 const map = /* @__PURE__ */ new Map();
3256 return {
3257 emit(event, data) {
3258 map.get(event)?.forEach((listener) => listener(data));
3259 },
3260 on(event, listener) {
3261 if (!map.has(event)) {
3262 map.set(event, /* @__PURE__ */ new Set());
3263 }
3264 map.get(event).add(listener);
3265 },
3266 off(event, listener) {
3267 map.get(event)?.delete(listener);
3268 }
3269 };
3270 }
3271
3272 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3273 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
3274 var FloatingNodeContext = /* @__PURE__ */ React18.createContext(null);
3275 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
3276 var FloatingTreeContext = /* @__PURE__ */ React18.createContext(null);
3277 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3278 var useFloatingParentNodeId = () => React18.useContext(FloatingNodeContext)?.id || null;
3279 var useFloatingTree = (externalTree) => {
3280 const contextTree = React18.useContext(FloatingTreeContext);
3281 return externalTree ?? contextTree;
3282 };
3283
3284 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js
3285 var React19 = __toESM(require_react(), 1);
3286 function createVirtualElement(domElement, data) {
3287 let offsetX = null;
3288 let offsetY = null;
3289 let isAutoUpdateEvent = false;
3290 return {
3291 contextElement: domElement || void 0,
3292 getBoundingClientRect() {
3293 const domRect = domElement?.getBoundingClientRect() || {
3294 width: 0,
3295 height: 0,
3296 x: 0,
3297 y: 0
3298 };
3299 const isXAxis = data.axis === "x" || data.axis === "both";
3300 const isYAxis = data.axis === "y" || data.axis === "both";
3301 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
3302 let width = domRect.width;
3303 let height = domRect.height;
3304 let x2 = domRect.x;
3305 let y2 = domRect.y;
3306 if (offsetX == null && data.x && isXAxis) {
3307 offsetX = domRect.x - data.x;
3308 }
3309 if (offsetY == null && data.y && isYAxis) {
3310 offsetY = domRect.y - data.y;
3311 }
3312 x2 -= offsetX || 0;
3313 y2 -= offsetY || 0;
3314 width = 0;
3315 height = 0;
3316 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
3317 width = data.axis === "y" ? domRect.width : 0;
3318 height = data.axis === "x" ? domRect.height : 0;
3319 x2 = isXAxis && data.x != null ? data.x : x2;
3320 y2 = isYAxis && data.y != null ? data.y : y2;
3321 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
3322 height = data.axis === "x" ? domRect.height : height;
3323 width = data.axis === "y" ? domRect.width : width;
3324 }
3325 isAutoUpdateEvent = true;
3326 return {
3327 width,
3328 height,
3329 x: x2,
3330 y: y2,
3331 top: y2,
3332 right: x2 + width,
3333 bottom: y2 + height,
3334 left: x2
3335 };
3336 }
3337 };
3338 }
3339 function isMouseBasedEvent(event) {
3340 return event != null && event.clientX != null;
3341 }
3342 function useClientPoint(context, props = {}) {
3343 const store = "rootStore" in context ? context.rootStore : context;
3344 const open = store.useState("open");
3345 const floating = store.useState("floatingElement");
3346 const domReference = store.useState("domReferenceElement");
3347 const dataRef = store.context.dataRef;
3348 const {
3349 enabled = true,
3350 axis = "both"
3351 } = props;
3352 const initialRef = React19.useRef(false);
3353 const cleanupListenerRef = React19.useRef(null);
3354 const [pointerType, setPointerType] = React19.useState();
3355 const [reactive, setReactive] = React19.useState([]);
3356 const setReference = useStableCallback((newX, newY, referenceElement) => {
3357 if (initialRef.current) {
3358 return;
3359 }
3360 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3361 return;
3362 }
3363 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3364 x: newX,
3365 y: newY,
3366 axis,
3367 dataRef,
3368 pointerType
3369 }));
3370 });
3371 const handleReferenceEnterOrMove = useStableCallback((event) => {
3372 if (!open) {
3373 setReference(event.clientX, event.clientY, event.currentTarget);
3374 } else if (!cleanupListenerRef.current) {
3375 setReactive([]);
3376 }
3377 });
3378 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
3379 const addListener = React19.useCallback(() => {
3380 if (!openCheck || !enabled) {
3381 return void 0;
3382 }
3383 const win = getWindow(floating);
3384 function handleMouseMove(event) {
3385 const target = getTarget(event);
3386 if (!contains(floating, target)) {
3387 setReference(event.clientX, event.clientY);
3388 } else {
3389 cleanupListenerRef.current?.();
3390 cleanupListenerRef.current = null;
3391 }
3392 }
3393 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3394 const cleanup = () => {
3395 cleanupListenerRef.current?.();
3396 cleanupListenerRef.current = null;
3397 };
3398 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3399 return cleanup;
3400 }
3401 store.set("positionReference", domReference);
3402 return void 0;
3403 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference]);
3404 React19.useEffect(() => {
3405 return addListener();
3406 }, [addListener, reactive]);
3407 React19.useEffect(() => {
3408 if (enabled && !floating) {
3409 initialRef.current = false;
3410 }
3411 }, [enabled, floating]);
3412 React19.useEffect(() => {
3413 if (!enabled && open) {
3414 initialRef.current = true;
3415 }
3416 }, [enabled, open]);
3417 const reference = React19.useMemo(() => {
3418 function setPointerTypeRef(event) {
3419 setPointerType(event.pointerType);
3420 }
3421 return {
3422 onPointerDown: setPointerTypeRef,
3423 onPointerEnter: setPointerTypeRef,
3424 onMouseMove: handleReferenceEnterOrMove,
3425 onMouseEnter: handleReferenceEnterOrMove
3426 };
3427 }, [handleReferenceEnterOrMove]);
3428 return React19.useMemo(() => enabled ? {
3429 reference,
3430 trigger: reference
3431 } : {}, [enabled, reference]);
3432 }
3433
3434 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js
3435 var React20 = __toESM(require_react(), 1);
3436 var bubbleHandlerKeys = {
3437 intentional: "onClick",
3438 sloppy: "onPointerDown"
3439 };
3440 function alwaysFalse() {
3441 return false;
3442 }
3443 function normalizeProp(normalizable) {
3444 return {
3445 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
3446 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
3447 };
3448 }
3449 function useDismiss(context, props = {}) {
3450 const store = "rootStore" in context ? context.rootStore : context;
3451 const open = store.useState("open");
3452 const floatingElement = store.useState("floatingElement");
3453 const {
3454 dataRef
3455 } = store.context;
3456 const {
3457 enabled = true,
3458 escapeKey: escapeKey2 = true,
3459 outsidePress: outsidePressProp = true,
3460 outsidePressEvent = "sloppy",
3461 referencePress = alwaysFalse,
3462 referencePressEvent = "sloppy",
3463 bubbles,
3464 externalTree
3465 } = props;
3466 const tree = useFloatingTree(externalTree);
3467 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
3468 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
3469 const outsidePressEnabled = outsidePress2 !== false;
3470 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
3471 const pressStartedInsideRef = React20.useRef(false);
3472 const pressStartPreventedRef = React20.useRef(false);
3473 const suppressNextOutsideClickRef = React20.useRef(false);
3474 const {
3475 escapeKey: escapeKeyBubbles,
3476 outsidePress: outsidePressBubbles
3477 } = normalizeProp(bubbles);
3478 const touchStateRef = React20.useRef(null);
3479 const cancelDismissOnEndTimeout = useTimeout();
3480 const clearInsideReactTreeTimeout = useTimeout();
3481 const clearInsideReactTree = useStableCallback(() => {
3482 clearInsideReactTreeTimeout.clear();
3483 dataRef.current.insideReactTree = false;
3484 });
3485 const isComposingRef = React20.useRef(false);
3486 const currentPointerTypeRef = React20.useRef("");
3487 const isReferencePressEnabled = useStableCallback(referencePress);
3488 const closeOnEscapeKeyDown = useStableCallback((event) => {
3489 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
3490 return;
3491 }
3492 if (isComposingRef.current) {
3493 return;
3494 }
3495 const nodeId = dataRef.current.floatingContext?.nodeId;
3496 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3497 if (!escapeKeyBubbles) {
3498 if (children.length > 0) {
3499 let shouldDismiss = true;
3500 children.forEach((child) => {
3501 if (child.context?.open && !child.context.dataRef.current.__escapeKeyBubbles) {
3502 shouldDismiss = false;
3503 }
3504 });
3505 if (!shouldDismiss) {
3506 return;
3507 }
3508 }
3509 }
3510 const native = isReactEvent(event) ? event.nativeEvent : event;
3511 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
3512 store.setOpen(false, eventDetails);
3513 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
3514 event.stopPropagation();
3515 }
3516 });
3517 const markInsideReactTree = useStableCallback(() => {
3518 dataRef.current.insideReactTree = true;
3519 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
3520 });
3521 React20.useEffect(() => {
3522 if (!open || !enabled) {
3523 return void 0;
3524 }
3525 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
3526 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
3527 const compositionTimeout = new Timeout();
3528 const preventedPressSuppressionTimeout = new Timeout();
3529 function handleCompositionStart() {
3530 compositionTimeout.clear();
3531 isComposingRef.current = true;
3532 }
3533 function handleCompositionEnd() {
3534 compositionTimeout.start(
3535 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
3536 // Only apply to WebKit for the test to remain 0ms.
3537 isWebKit() ? 5 : 0,
3538 () => {
3539 isComposingRef.current = false;
3540 }
3541 );
3542 }
3543 function suppressImmediateOutsideClickAfterPreventedStart() {
3544 suppressNextOutsideClickRef.current = true;
3545 preventedPressSuppressionTimeout.start(0, () => {
3546 suppressNextOutsideClickRef.current = false;
3547 });
3548 }
3549 function resetPressStartState() {
3550 pressStartedInsideRef.current = false;
3551 pressStartPreventedRef.current = false;
3552 }
3553 function getOutsidePressEvent() {
3554 const type = currentPointerTypeRef.current;
3555 const computedType = type === "pen" || !type ? "mouse" : type;
3556 const outsidePressEventValue = getOutsidePressEventProp();
3557 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
3558 if (typeof resolved === "string") {
3559 return resolved;
3560 }
3561 return resolved[computedType];
3562 }
3563 function shouldIgnoreEvent(event) {
3564 const computedOutsidePressEvent = getOutsidePressEvent();
3565 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
3566 }
3567 function isEventWithinFloatingTree(event) {
3568 const nodeId = dataRef.current.floatingContext?.nodeId;
3569 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
3570 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement")) || targetIsInsideChildren;
3571 }
3572 function closeOnPressOutside(event) {
3573 if (shouldIgnoreEvent(event)) {
3574 clearInsideReactTree();
3575 return;
3576 }
3577 if (dataRef.current.insideReactTree) {
3578 clearInsideReactTree();
3579 return;
3580 }
3581 const target = getTarget(event);
3582 const inertSelector = `[${createAttribute("inert")}]`;
3583 const targetRoot = isElement(target) ? target.getRootNode() : null;
3584 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
3585 const triggers = store.context.triggerElements;
3586 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
3587 return;
3588 }
3589 let targetRootAncestor = isElement(target) ? target : null;
3590 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
3591 const nextParent = getParentNode(targetRootAncestor);
3592 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
3593 break;
3594 }
3595 targetRootAncestor = nextParent;
3596 }
3597 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
3598 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
3599 // element was injected after the floating element rendered.
3600 markers.every((marker) => !contains(targetRootAncestor, marker))) {
3601 return;
3602 }
3603 if (isHTMLElement(target) && !("touches" in event)) {
3604 const lastTraversableNode = isLastTraversableNode(target);
3605 const style = getComputedStyle2(target);
3606 const scrollRe = /auto|scroll/;
3607 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
3608 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
3609 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
3610 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
3611 const isRTL7 = style.direction === "rtl";
3612 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
3613 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
3614 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
3615 return;
3616 }
3617 }
3618 if (isEventWithinFloatingTree(event)) {
3619 return;
3620 }
3621 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
3622 preventedPressSuppressionTimeout.clear();
3623 suppressNextOutsideClickRef.current = false;
3624 return;
3625 }
3626 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3627 return;
3628 }
3629 const nodeId = dataRef.current.floatingContext?.nodeId;
3630 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3631 if (children.length > 0) {
3632 let shouldDismiss = true;
3633 children.forEach((child) => {
3634 if (child.context?.open && !child.context.dataRef.current.__outsidePressBubbles) {
3635 shouldDismiss = false;
3636 }
3637 });
3638 if (!shouldDismiss) {
3639 return;
3640 }
3641 }
3642 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
3643 clearInsideReactTree();
3644 }
3645 function handlePointerDown(event) {
3646 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3647 return;
3648 }
3649 closeOnPressOutside(event);
3650 }
3651 function handleTouchStart(event) {
3652 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3653 return;
3654 }
3655 const touch = event.touches[0];
3656 if (touch) {
3657 touchStateRef.current = {
3658 startTime: Date.now(),
3659 startX: touch.clientX,
3660 startY: touch.clientY,
3661 dismissOnTouchEnd: false,
3662 dismissOnMouseDown: true
3663 };
3664 cancelDismissOnEndTimeout.start(1e3, () => {
3665 if (touchStateRef.current) {
3666 touchStateRef.current.dismissOnTouchEnd = false;
3667 touchStateRef.current.dismissOnMouseDown = false;
3668 }
3669 });
3670 }
3671 }
3672 function addTargetEventListenerOnce(event, listener) {
3673 const target = getTarget(event);
3674 if (!target) {
3675 return;
3676 }
3677 const unsubscribe2 = addEventListener(target, event.type, () => {
3678 listener(event);
3679 unsubscribe2();
3680 });
3681 }
3682 function handleTouchStartCapture(event) {
3683 currentPointerTypeRef.current = "touch";
3684 addTargetEventListenerOnce(event, handleTouchStart);
3685 }
3686 function closeOnPressOutsideCapture(event) {
3687 cancelDismissOnEndTimeout.clear();
3688 if (event.type === "pointerdown") {
3689 currentPointerTypeRef.current = event.pointerType;
3690 }
3691 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
3692 return;
3693 }
3694 addTargetEventListenerOnce(event, (targetEvent) => {
3695 if (targetEvent.type === "pointerdown") {
3696 handlePointerDown(targetEvent);
3697 } else {
3698 closeOnPressOutside(targetEvent);
3699 }
3700 });
3701 }
3702 function handlePressEndCapture(event) {
3703 if (!pressStartedInsideRef.current) {
3704 return;
3705 }
3706 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
3707 resetPressStartState();
3708 if (getOutsidePressEvent() !== "intentional") {
3709 return;
3710 }
3711 if (event.type === "pointercancel") {
3712 if (pressStartedInsideDefaultPrevented) {
3713 suppressImmediateOutsideClickAfterPreventedStart();
3714 }
3715 return;
3716 }
3717 if (isEventWithinFloatingTree(event)) {
3718 return;
3719 }
3720 if (pressStartedInsideDefaultPrevented) {
3721 suppressImmediateOutsideClickAfterPreventedStart();
3722 return;
3723 }
3724 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3725 return;
3726 }
3727 preventedPressSuppressionTimeout.clear();
3728 suppressNextOutsideClickRef.current = true;
3729 clearInsideReactTree();
3730 }
3731 function handleTouchMove(event) {
3732 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3733 return;
3734 }
3735 const touch = event.touches[0];
3736 if (!touch) {
3737 return;
3738 }
3739 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
3740 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
3741 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
3742 if (distance > 5) {
3743 touchStateRef.current.dismissOnTouchEnd = true;
3744 }
3745 if (distance > 10) {
3746 closeOnPressOutside(event);
3747 cancelDismissOnEndTimeout.clear();
3748 touchStateRef.current = null;
3749 }
3750 }
3751 function handleTouchMoveCapture(event) {
3752 addTargetEventListenerOnce(event, handleTouchMove);
3753 }
3754 function handleTouchEnd(event) {
3755 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3756 return;
3757 }
3758 if (touchStateRef.current.dismissOnTouchEnd) {
3759 closeOnPressOutside(event);
3760 }
3761 cancelDismissOnEndTimeout.clear();
3762 touchStateRef.current = null;
3763 }
3764 function handleTouchEndCapture(event) {
3765 addTargetEventListenerOnce(event, handleTouchEnd);
3766 }
3767 const doc = ownerDocument(floatingElement);
3768 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)));
3769 return () => {
3770 unsubscribe();
3771 compositionTimeout.clear();
3772 preventedPressSuppressionTimeout.clear();
3773 resetPressStartState();
3774 suppressNextOutsideClickRef.current = false;
3775 };
3776 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, tree, store, cancelDismissOnEndTimeout]);
3777 React20.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
3778 const reference = React20.useMemo(() => ({
3779 onKeyDown: closeOnEscapeKeyDown,
3780 [bubbleHandlerKeys[referencePressEvent]]: (event) => {
3781 if (!isReferencePressEnabled()) {
3782 return;
3783 }
3784 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3785 },
3786 ...referencePressEvent !== "intentional" && {
3787 onClick(event) {
3788 if (!isReferencePressEnabled()) {
3789 return;
3790 }
3791 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3792 }
3793 }
3794 }), [closeOnEscapeKeyDown, store, referencePressEvent, isReferencePressEnabled]);
3795 const markPressStartedInsideReactTree = useStableCallback((event) => {
3796 if (!open || !enabled || event.button !== 0) {
3797 return;
3798 }
3799 const target = getTarget(event.nativeEvent);
3800 if (!contains(store.select("floatingElement"), target)) {
3801 return;
3802 }
3803 if (!pressStartedInsideRef.current) {
3804 pressStartedInsideRef.current = true;
3805 pressStartPreventedRef.current = false;
3806 }
3807 });
3808 const markInsidePressStartPrevented = useStableCallback((event) => {
3809 if (!open || !enabled) {
3810 return;
3811 }
3812 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
3813 return;
3814 }
3815 if (pressStartedInsideRef.current) {
3816 pressStartPreventedRef.current = true;
3817 }
3818 });
3819 const floating = React20.useMemo(() => ({
3820 onKeyDown: closeOnEscapeKeyDown,
3821 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
3822 // `onPointerDown`, such as with <NumberField.ScrubArea>.
3823 // See https://github.com/mui/base-ui/pull/3379
3824 onPointerDown: markInsidePressStartPrevented,
3825 onMouseDown: markInsidePressStartPrevented,
3826 onClickCapture: markInsideReactTree,
3827 onMouseDownCapture(event) {
3828 markInsideReactTree();
3829 markPressStartedInsideReactTree(event);
3830 },
3831 onPointerDownCapture(event) {
3832 markInsideReactTree();
3833 markPressStartedInsideReactTree(event);
3834 },
3835 onMouseUpCapture: markInsideReactTree,
3836 onTouchEndCapture: markInsideReactTree,
3837 onTouchMoveCapture: markInsideReactTree
3838 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
3839 return React20.useMemo(() => enabled ? {
3840 reference,
3841 floating,
3842 trigger: reference
3843 } : {}, [enabled, reference, floating]);
3844 }
3845
3846 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
3847 var React26 = __toESM(require_react(), 1);
3848
3849 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
3850 function computeCoordsFromPlacement(_ref, placement, rtl) {
3851 let {
3852 reference,
3853 floating
3854 } = _ref;
3855 const sideAxis = getSideAxis(placement);
3856 const alignmentAxis = getAlignmentAxis(placement);
3857 const alignLength = getAxisLength(alignmentAxis);
3858 const side = getSide(placement);
3859 const isVertical = sideAxis === "y";
3860 const commonX = reference.x + reference.width / 2 - floating.width / 2;
3861 const commonY = reference.y + reference.height / 2 - floating.height / 2;
3862 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
3863 let coords;
3864 switch (side) {
3865 case "top":
3866 coords = {
3867 x: commonX,
3868 y: reference.y - floating.height
3869 };
3870 break;
3871 case "bottom":
3872 coords = {
3873 x: commonX,
3874 y: reference.y + reference.height
3875 };
3876 break;
3877 case "right":
3878 coords = {
3879 x: reference.x + reference.width,
3880 y: commonY
3881 };
3882 break;
3883 case "left":
3884 coords = {
3885 x: reference.x - floating.width,
3886 y: commonY
3887 };
3888 break;
3889 default:
3890 coords = {
3891 x: reference.x,
3892 y: reference.y
3893 };
3894 }
3895 switch (getAlignment(placement)) {
3896 case "start":
3897 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
3898 break;
3899 case "end":
3900 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
3901 break;
3902 }
3903 return coords;
3904 }
3905 async function detectOverflow(state, options) {
3906 var _await$platform$isEle;
3907 if (options === void 0) {
3908 options = {};
3909 }
3910 const {
3911 x: x2,
3912 y: y2,
3913 platform: platform3,
3914 rects,
3915 elements,
3916 strategy
3917 } = state;
3918 const {
3919 boundary = "clippingAncestors",
3920 rootBoundary = "viewport",
3921 elementContext = "floating",
3922 altBoundary = false,
3923 padding = 0
3924 } = evaluate(options, state);
3925 const paddingObject = getPaddingObject(padding);
3926 const altContext = elementContext === "floating" ? "reference" : "floating";
3927 const element = elements[altBoundary ? altContext : elementContext];
3928 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
3929 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)),
3930 boundary,
3931 rootBoundary,
3932 strategy
3933 }));
3934 const rect = elementContext === "floating" ? {
3935 x: x2,
3936 y: y2,
3937 width: rects.floating.width,
3938 height: rects.floating.height
3939 } : rects.reference;
3940 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
3941 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
3942 x: 1,
3943 y: 1
3944 } : {
3945 x: 1,
3946 y: 1
3947 };
3948 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
3949 elements,
3950 rect,
3951 offsetParent,
3952 strategy
3953 }) : rect);
3954 return {
3955 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
3956 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
3957 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
3958 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
3959 };
3960 }
3961 var MAX_RESET_COUNT = 50;
3962 var computePosition = async (reference, floating, config) => {
3963 const {
3964 placement = "bottom",
3965 strategy = "absolute",
3966 middleware = [],
3967 platform: platform3
3968 } = config;
3969 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
3970 ...platform3,
3971 detectOverflow
3972 };
3973 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
3974 let rects = await platform3.getElementRects({
3975 reference,
3976 floating,
3977 strategy
3978 });
3979 let {
3980 x: x2,
3981 y: y2
3982 } = computeCoordsFromPlacement(rects, placement, rtl);
3983 let statefulPlacement = placement;
3984 let resetCount = 0;
3985 const middlewareData = {};
3986 for (let i2 = 0; i2 < middleware.length; i2++) {
3987 const currentMiddleware = middleware[i2];
3988 if (!currentMiddleware) {
3989 continue;
3990 }
3991 const {
3992 name,
3993 fn
3994 } = currentMiddleware;
3995 const {
3996 x: nextX,
3997 y: nextY,
3998 data,
3999 reset
4000 } = await fn({
4001 x: x2,
4002 y: y2,
4003 initialPlacement: placement,
4004 placement: statefulPlacement,
4005 strategy,
4006 middlewareData,
4007 rects,
4008 platform: platformWithDetectOverflow,
4009 elements: {
4010 reference,
4011 floating
4012 }
4013 });
4014 x2 = nextX != null ? nextX : x2;
4015 y2 = nextY != null ? nextY : y2;
4016 middlewareData[name] = {
4017 ...middlewareData[name],
4018 ...data
4019 };
4020 if (reset && resetCount < MAX_RESET_COUNT) {
4021 resetCount++;
4022 if (typeof reset === "object") {
4023 if (reset.placement) {
4024 statefulPlacement = reset.placement;
4025 }
4026 if (reset.rects) {
4027 rects = reset.rects === true ? await platform3.getElementRects({
4028 reference,
4029 floating,
4030 strategy
4031 }) : reset.rects;
4032 }
4033 ({
4034 x: x2,
4035 y: y2
4036 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
4037 }
4038 i2 = -1;
4039 }
4040 }
4041 return {
4042 x: x2,
4043 y: y2,
4044 placement: statefulPlacement,
4045 strategy,
4046 middlewareData
4047 };
4048 };
4049 var flip = function(options) {
4050 if (options === void 0) {
4051 options = {};
4052 }
4053 return {
4054 name: "flip",
4055 options,
4056 async fn(state) {
4057 var _middlewareData$arrow, _middlewareData$flip;
4058 const {
4059 placement,
4060 middlewareData,
4061 rects,
4062 initialPlacement,
4063 platform: platform3,
4064 elements
4065 } = state;
4066 const {
4067 mainAxis: checkMainAxis = true,
4068 crossAxis: checkCrossAxis = true,
4069 fallbackPlacements: specifiedFallbackPlacements,
4070 fallbackStrategy = "bestFit",
4071 fallbackAxisSideDirection = "none",
4072 flipAlignment = true,
4073 ...detectOverflowOptions
4074 } = evaluate(options, state);
4075 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4076 return {};
4077 }
4078 const side = getSide(placement);
4079 const initialSideAxis = getSideAxis(initialPlacement);
4080 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
4081 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4082 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
4083 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
4084 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
4085 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
4086 }
4087 const placements2 = [initialPlacement, ...fallbackPlacements];
4088 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4089 const overflows = [];
4090 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
4091 if (checkMainAxis) {
4092 overflows.push(overflow[side]);
4093 }
4094 if (checkCrossAxis) {
4095 const sides2 = getAlignmentSides(placement, rects, rtl);
4096 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
4097 }
4098 overflowsData = [...overflowsData, {
4099 placement,
4100 overflows
4101 }];
4102 if (!overflows.every((side2) => side2 <= 0)) {
4103 var _middlewareData$flip2, _overflowsData$filter;
4104 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
4105 const nextPlacement = placements2[nextIndex];
4106 if (nextPlacement) {
4107 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
4108 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
4109 // overflows the main axis.
4110 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
4111 return {
4112 data: {
4113 index: nextIndex,
4114 overflows: overflowsData
4115 },
4116 reset: {
4117 placement: nextPlacement
4118 }
4119 };
4120 }
4121 }
4122 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;
4123 if (!resetPlacement) {
4124 switch (fallbackStrategy) {
4125 case "bestFit": {
4126 var _overflowsData$filter2;
4127 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
4128 if (hasFallbackAxisSideDirection) {
4129 const currentSideAxis = getSideAxis(d2.placement);
4130 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
4131 // reading directions favoring greater width.
4132 currentSideAxis === "y";
4133 }
4134 return true;
4135 }).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];
4136 if (placement2) {
4137 resetPlacement = placement2;
4138 }
4139 break;
4140 }
4141 case "initialPlacement":
4142 resetPlacement = initialPlacement;
4143 break;
4144 }
4145 }
4146 if (placement !== resetPlacement) {
4147 return {
4148 reset: {
4149 placement: resetPlacement
4150 }
4151 };
4152 }
4153 }
4154 return {};
4155 }
4156 };
4157 };
4158 function getSideOffsets(overflow, rect) {
4159 return {
4160 top: overflow.top - rect.height,
4161 right: overflow.right - rect.width,
4162 bottom: overflow.bottom - rect.height,
4163 left: overflow.left - rect.width
4164 };
4165 }
4166 function isAnySideFullyClipped(overflow) {
4167 return sides.some((side) => overflow[side] >= 0);
4168 }
4169 var hide = function(options) {
4170 if (options === void 0) {
4171 options = {};
4172 }
4173 return {
4174 name: "hide",
4175 options,
4176 async fn(state) {
4177 const {
4178 rects,
4179 platform: platform3
4180 } = state;
4181 const {
4182 strategy = "referenceHidden",
4183 ...detectOverflowOptions
4184 } = evaluate(options, state);
4185 switch (strategy) {
4186 case "referenceHidden": {
4187 const overflow = await platform3.detectOverflow(state, {
4188 ...detectOverflowOptions,
4189 elementContext: "reference"
4190 });
4191 const offsets = getSideOffsets(overflow, rects.reference);
4192 return {
4193 data: {
4194 referenceHiddenOffsets: offsets,
4195 referenceHidden: isAnySideFullyClipped(offsets)
4196 }
4197 };
4198 }
4199 case "escaped": {
4200 const overflow = await platform3.detectOverflow(state, {
4201 ...detectOverflowOptions,
4202 altBoundary: true
4203 });
4204 const offsets = getSideOffsets(overflow, rects.floating);
4205 return {
4206 data: {
4207 escapedOffsets: offsets,
4208 escaped: isAnySideFullyClipped(offsets)
4209 }
4210 };
4211 }
4212 default: {
4213 return {};
4214 }
4215 }
4216 }
4217 };
4218 };
4219 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
4220 async function convertValueToCoords(state, options) {
4221 const {
4222 placement,
4223 platform: platform3,
4224 elements
4225 } = state;
4226 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4227 const side = getSide(placement);
4228 const alignment = getAlignment(placement);
4229 const isVertical = getSideAxis(placement) === "y";
4230 const mainAxisMulti = originSides.has(side) ? -1 : 1;
4231 const crossAxisMulti = rtl && isVertical ? -1 : 1;
4232 const rawValue = evaluate(options, state);
4233 let {
4234 mainAxis,
4235 crossAxis,
4236 alignmentAxis
4237 } = typeof rawValue === "number" ? {
4238 mainAxis: rawValue,
4239 crossAxis: 0,
4240 alignmentAxis: null
4241 } : {
4242 mainAxis: rawValue.mainAxis || 0,
4243 crossAxis: rawValue.crossAxis || 0,
4244 alignmentAxis: rawValue.alignmentAxis
4245 };
4246 if (alignment && typeof alignmentAxis === "number") {
4247 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
4248 }
4249 return isVertical ? {
4250 x: crossAxis * crossAxisMulti,
4251 y: mainAxis * mainAxisMulti
4252 } : {
4253 x: mainAxis * mainAxisMulti,
4254 y: crossAxis * crossAxisMulti
4255 };
4256 }
4257 var offset = function(options) {
4258 if (options === void 0) {
4259 options = 0;
4260 }
4261 return {
4262 name: "offset",
4263 options,
4264 async fn(state) {
4265 var _middlewareData$offse, _middlewareData$arrow;
4266 const {
4267 x: x2,
4268 y: y2,
4269 placement,
4270 middlewareData
4271 } = state;
4272 const diffCoords = await convertValueToCoords(state, options);
4273 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4274 return {};
4275 }
4276 return {
4277 x: x2 + diffCoords.x,
4278 y: y2 + diffCoords.y,
4279 data: {
4280 ...diffCoords,
4281 placement
4282 }
4283 };
4284 }
4285 };
4286 };
4287 var shift = function(options) {
4288 if (options === void 0) {
4289 options = {};
4290 }
4291 return {
4292 name: "shift",
4293 options,
4294 async fn(state) {
4295 const {
4296 x: x2,
4297 y: y2,
4298 placement,
4299 platform: platform3
4300 } = state;
4301 const {
4302 mainAxis: checkMainAxis = true,
4303 crossAxis: checkCrossAxis = false,
4304 limiter = {
4305 fn: (_ref) => {
4306 let {
4307 x: x3,
4308 y: y3
4309 } = _ref;
4310 return {
4311 x: x3,
4312 y: y3
4313 };
4314 }
4315 },
4316 ...detectOverflowOptions
4317 } = evaluate(options, state);
4318 const coords = {
4319 x: x2,
4320 y: y2
4321 };
4322 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4323 const crossAxis = getSideAxis(getSide(placement));
4324 const mainAxis = getOppositeAxis(crossAxis);
4325 let mainAxisCoord = coords[mainAxis];
4326 let crossAxisCoord = coords[crossAxis];
4327 if (checkMainAxis) {
4328 const minSide = mainAxis === "y" ? "top" : "left";
4329 const maxSide = mainAxis === "y" ? "bottom" : "right";
4330 const min2 = mainAxisCoord + overflow[minSide];
4331 const max2 = mainAxisCoord - overflow[maxSide];
4332 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
4333 }
4334 if (checkCrossAxis) {
4335 const minSide = crossAxis === "y" ? "top" : "left";
4336 const maxSide = crossAxis === "y" ? "bottom" : "right";
4337 const min2 = crossAxisCoord + overflow[minSide];
4338 const max2 = crossAxisCoord - overflow[maxSide];
4339 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
4340 }
4341 const limitedCoords = limiter.fn({
4342 ...state,
4343 [mainAxis]: mainAxisCoord,
4344 [crossAxis]: crossAxisCoord
4345 });
4346 return {
4347 ...limitedCoords,
4348 data: {
4349 x: limitedCoords.x - x2,
4350 y: limitedCoords.y - y2,
4351 enabled: {
4352 [mainAxis]: checkMainAxis,
4353 [crossAxis]: checkCrossAxis
4354 }
4355 }
4356 };
4357 }
4358 };
4359 };
4360 var limitShift = function(options) {
4361 if (options === void 0) {
4362 options = {};
4363 }
4364 return {
4365 options,
4366 fn(state) {
4367 const {
4368 x: x2,
4369 y: y2,
4370 placement,
4371 rects,
4372 middlewareData
4373 } = state;
4374 const {
4375 offset: offset4 = 0,
4376 mainAxis: checkMainAxis = true,
4377 crossAxis: checkCrossAxis = true
4378 } = evaluate(options, state);
4379 const coords = {
4380 x: x2,
4381 y: y2
4382 };
4383 const crossAxis = getSideAxis(placement);
4384 const mainAxis = getOppositeAxis(crossAxis);
4385 let mainAxisCoord = coords[mainAxis];
4386 let crossAxisCoord = coords[crossAxis];
4387 const rawOffset = evaluate(offset4, state);
4388 const computedOffset = typeof rawOffset === "number" ? {
4389 mainAxis: rawOffset,
4390 crossAxis: 0
4391 } : {
4392 mainAxis: 0,
4393 crossAxis: 0,
4394 ...rawOffset
4395 };
4396 if (checkMainAxis) {
4397 const len = mainAxis === "y" ? "height" : "width";
4398 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
4399 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
4400 if (mainAxisCoord < limitMin) {
4401 mainAxisCoord = limitMin;
4402 } else if (mainAxisCoord > limitMax) {
4403 mainAxisCoord = limitMax;
4404 }
4405 }
4406 if (checkCrossAxis) {
4407 var _middlewareData$offse, _middlewareData$offse2;
4408 const len = mainAxis === "y" ? "width" : "height";
4409 const isOriginSide = originSides.has(getSide(placement));
4410 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);
4411 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);
4412 if (crossAxisCoord < limitMin) {
4413 crossAxisCoord = limitMin;
4414 } else if (crossAxisCoord > limitMax) {
4415 crossAxisCoord = limitMax;
4416 }
4417 }
4418 return {
4419 [mainAxis]: mainAxisCoord,
4420 [crossAxis]: crossAxisCoord
4421 };
4422 }
4423 };
4424 };
4425 var size = function(options) {
4426 if (options === void 0) {
4427 options = {};
4428 }
4429 return {
4430 name: "size",
4431 options,
4432 async fn(state) {
4433 var _state$middlewareData, _state$middlewareData2;
4434 const {
4435 placement,
4436 rects,
4437 platform: platform3,
4438 elements
4439 } = state;
4440 const {
4441 apply = () => {
4442 },
4443 ...detectOverflowOptions
4444 } = evaluate(options, state);
4445 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4446 const side = getSide(placement);
4447 const alignment = getAlignment(placement);
4448 const isYAxis = getSideAxis(placement) === "y";
4449 const {
4450 width,
4451 height
4452 } = rects.floating;
4453 let heightSide;
4454 let widthSide;
4455 if (side === "top" || side === "bottom") {
4456 heightSide = side;
4457 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
4458 } else {
4459 widthSide = side;
4460 heightSide = alignment === "end" ? "top" : "bottom";
4461 }
4462 const maximumClippingHeight = height - overflow.top - overflow.bottom;
4463 const maximumClippingWidth = width - overflow.left - overflow.right;
4464 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
4465 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
4466 const noShift = !state.middlewareData.shift;
4467 let availableHeight = overflowAvailableHeight;
4468 let availableWidth = overflowAvailableWidth;
4469 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
4470 availableWidth = maximumClippingWidth;
4471 }
4472 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
4473 availableHeight = maximumClippingHeight;
4474 }
4475 if (noShift && !alignment) {
4476 const xMin = max(overflow.left, 0);
4477 const xMax = max(overflow.right, 0);
4478 const yMin = max(overflow.top, 0);
4479 const yMax = max(overflow.bottom, 0);
4480 if (isYAxis) {
4481 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
4482 } else {
4483 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
4484 }
4485 }
4486 await apply({
4487 ...state,
4488 availableWidth,
4489 availableHeight
4490 });
4491 const nextDimensions = await platform3.getDimensions(elements.floating);
4492 if (width !== nextDimensions.width || height !== nextDimensions.height) {
4493 return {
4494 reset: {
4495 rects: true
4496 }
4497 };
4498 }
4499 return {};
4500 }
4501 };
4502 };
4503
4504 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
4505 function getCssDimensions(element) {
4506 const css = getComputedStyle2(element);
4507 let width = parseFloat(css.width) || 0;
4508 let height = parseFloat(css.height) || 0;
4509 const hasOffset = isHTMLElement(element);
4510 const offsetWidth = hasOffset ? element.offsetWidth : width;
4511 const offsetHeight = hasOffset ? element.offsetHeight : height;
4512 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
4513 if (shouldFallback) {
4514 width = offsetWidth;
4515 height = offsetHeight;
4516 }
4517 return {
4518 width,
4519 height,
4520 $: shouldFallback
4521 };
4522 }
4523 function unwrapElement(element) {
4524 return !isElement(element) ? element.contextElement : element;
4525 }
4526 function getScale(element) {
4527 const domElement = unwrapElement(element);
4528 if (!isHTMLElement(domElement)) {
4529 return createCoords(1);
4530 }
4531 const rect = domElement.getBoundingClientRect();
4532 const {
4533 width,
4534 height,
4535 $: $2
4536 } = getCssDimensions(domElement);
4537 let x2 = ($2 ? round(rect.width) : rect.width) / width;
4538 let y2 = ($2 ? round(rect.height) : rect.height) / height;
4539 if (!x2 || !Number.isFinite(x2)) {
4540 x2 = 1;
4541 }
4542 if (!y2 || !Number.isFinite(y2)) {
4543 y2 = 1;
4544 }
4545 return {
4546 x: x2,
4547 y: y2
4548 };
4549 }
4550 var noOffsets = /* @__PURE__ */ createCoords(0);
4551 function getVisualOffsets(element) {
4552 const win = getWindow(element);
4553 if (!isWebKit() || !win.visualViewport) {
4554 return noOffsets;
4555 }
4556 return {
4557 x: win.visualViewport.offsetLeft,
4558 y: win.visualViewport.offsetTop
4559 };
4560 }
4561 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
4562 if (isFixed === void 0) {
4563 isFixed = false;
4564 }
4565 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
4566 return false;
4567 }
4568 return isFixed;
4569 }
4570 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
4571 if (includeScale === void 0) {
4572 includeScale = false;
4573 }
4574 if (isFixedStrategy === void 0) {
4575 isFixedStrategy = false;
4576 }
4577 const clientRect = element.getBoundingClientRect();
4578 const domElement = unwrapElement(element);
4579 let scale = createCoords(1);
4580 if (includeScale) {
4581 if (offsetParent) {
4582 if (isElement(offsetParent)) {
4583 scale = getScale(offsetParent);
4584 }
4585 } else {
4586 scale = getScale(element);
4587 }
4588 }
4589 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
4590 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
4591 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
4592 let width = clientRect.width / scale.x;
4593 let height = clientRect.height / scale.y;
4594 if (domElement) {
4595 const win = getWindow(domElement);
4596 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
4597 let currentWin = win;
4598 let currentIFrame = getFrameElement(currentWin);
4599 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
4600 const iframeScale = getScale(currentIFrame);
4601 const iframeRect = currentIFrame.getBoundingClientRect();
4602 const css = getComputedStyle2(currentIFrame);
4603 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
4604 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
4605 x2 *= iframeScale.x;
4606 y2 *= iframeScale.y;
4607 width *= iframeScale.x;
4608 height *= iframeScale.y;
4609 x2 += left;
4610 y2 += top;
4611 currentWin = getWindow(currentIFrame);
4612 currentIFrame = getFrameElement(currentWin);
4613 }
4614 }
4615 return rectToClientRect({
4616 width,
4617 height,
4618 x: x2,
4619 y: y2
4620 });
4621 }
4622 function getWindowScrollBarX(element, rect) {
4623 const leftScroll = getNodeScroll(element).scrollLeft;
4624 if (!rect) {
4625 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
4626 }
4627 return rect.left + leftScroll;
4628 }
4629 function getHTMLOffset(documentElement, scroll) {
4630 const htmlRect = documentElement.getBoundingClientRect();
4631 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
4632 const y2 = htmlRect.top + scroll.scrollTop;
4633 return {
4634 x: x2,
4635 y: y2
4636 };
4637 }
4638 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
4639 let {
4640 elements,
4641 rect,
4642 offsetParent,
4643 strategy
4644 } = _ref;
4645 const isFixed = strategy === "fixed";
4646 const documentElement = getDocumentElement(offsetParent);
4647 const topLayer = elements ? isTopLayer(elements.floating) : false;
4648 if (offsetParent === documentElement || topLayer && isFixed) {
4649 return rect;
4650 }
4651 let scroll = {
4652 scrollLeft: 0,
4653 scrollTop: 0
4654 };
4655 let scale = createCoords(1);
4656 const offsets = createCoords(0);
4657 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4658 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4659 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4660 scroll = getNodeScroll(offsetParent);
4661 }
4662 if (isOffsetParentAnElement) {
4663 const offsetRect = getBoundingClientRect(offsetParent);
4664 scale = getScale(offsetParent);
4665 offsets.x = offsetRect.x + offsetParent.clientLeft;
4666 offsets.y = offsetRect.y + offsetParent.clientTop;
4667 }
4668 }
4669 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4670 return {
4671 width: rect.width * scale.x,
4672 height: rect.height * scale.y,
4673 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
4674 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
4675 };
4676 }
4677 function getClientRects(element) {
4678 return Array.from(element.getClientRects());
4679 }
4680 function getDocumentRect(element) {
4681 const html = getDocumentElement(element);
4682 const scroll = getNodeScroll(element);
4683 const body = element.ownerDocument.body;
4684 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
4685 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
4686 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
4687 const y2 = -scroll.scrollTop;
4688 if (getComputedStyle2(body).direction === "rtl") {
4689 x2 += max(html.clientWidth, body.clientWidth) - width;
4690 }
4691 return {
4692 width,
4693 height,
4694 x: x2,
4695 y: y2
4696 };
4697 }
4698 var SCROLLBAR_MAX = 25;
4699 function getViewportRect(element, strategy) {
4700 const win = getWindow(element);
4701 const html = getDocumentElement(element);
4702 const visualViewport = win.visualViewport;
4703 let width = html.clientWidth;
4704 let height = html.clientHeight;
4705 let x2 = 0;
4706 let y2 = 0;
4707 if (visualViewport) {
4708 width = visualViewport.width;
4709 height = visualViewport.height;
4710 const visualViewportBased = isWebKit();
4711 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
4712 x2 = visualViewport.offsetLeft;
4713 y2 = visualViewport.offsetTop;
4714 }
4715 }
4716 const windowScrollbarX = getWindowScrollBarX(html);
4717 if (windowScrollbarX <= 0) {
4718 const doc = html.ownerDocument;
4719 const body = doc.body;
4720 const bodyStyles = getComputedStyle(body);
4721 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
4722 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
4723 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
4724 width -= clippingStableScrollbarWidth;
4725 }
4726 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
4727 width += windowScrollbarX;
4728 }
4729 return {
4730 width,
4731 height,
4732 x: x2,
4733 y: y2
4734 };
4735 }
4736 function getInnerBoundingClientRect(element, strategy) {
4737 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
4738 const top = clientRect.top + element.clientTop;
4739 const left = clientRect.left + element.clientLeft;
4740 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
4741 const width = element.clientWidth * scale.x;
4742 const height = element.clientHeight * scale.y;
4743 const x2 = left * scale.x;
4744 const y2 = top * scale.y;
4745 return {
4746 width,
4747 height,
4748 x: x2,
4749 y: y2
4750 };
4751 }
4752 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
4753 let rect;
4754 if (clippingAncestor === "viewport") {
4755 rect = getViewportRect(element, strategy);
4756 } else if (clippingAncestor === "document") {
4757 rect = getDocumentRect(getDocumentElement(element));
4758 } else if (isElement(clippingAncestor)) {
4759 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
4760 } else {
4761 const visualOffsets = getVisualOffsets(element);
4762 rect = {
4763 x: clippingAncestor.x - visualOffsets.x,
4764 y: clippingAncestor.y - visualOffsets.y,
4765 width: clippingAncestor.width,
4766 height: clippingAncestor.height
4767 };
4768 }
4769 return rectToClientRect(rect);
4770 }
4771 function hasFixedPositionAncestor(element, stopNode) {
4772 const parentNode = getParentNode(element);
4773 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
4774 return false;
4775 }
4776 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
4777 }
4778 function getClippingElementAncestors(element, cache) {
4779 const cachedResult = cache.get(element);
4780 if (cachedResult) {
4781 return cachedResult;
4782 }
4783 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
4784 let currentContainingBlockComputedStyle = null;
4785 const elementIsFixed = getComputedStyle2(element).position === "fixed";
4786 let currentNode = elementIsFixed ? getParentNode(element) : element;
4787 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
4788 const computedStyle = getComputedStyle2(currentNode);
4789 const currentNodeIsContaining = isContainingBlock(currentNode);
4790 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
4791 currentContainingBlockComputedStyle = null;
4792 }
4793 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
4794 if (shouldDropCurrentNode) {
4795 result = result.filter((ancestor) => ancestor !== currentNode);
4796 } else {
4797 currentContainingBlockComputedStyle = computedStyle;
4798 }
4799 currentNode = getParentNode(currentNode);
4800 }
4801 cache.set(element, result);
4802 return result;
4803 }
4804 function getClippingRect(_ref) {
4805 let {
4806 element,
4807 boundary,
4808 rootBoundary,
4809 strategy
4810 } = _ref;
4811 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
4812 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
4813 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
4814 let top = firstRect.top;
4815 let right = firstRect.right;
4816 let bottom = firstRect.bottom;
4817 let left = firstRect.left;
4818 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
4819 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
4820 top = max(rect.top, top);
4821 right = min(rect.right, right);
4822 bottom = min(rect.bottom, bottom);
4823 left = max(rect.left, left);
4824 }
4825 return {
4826 width: right - left,
4827 height: bottom - top,
4828 x: left,
4829 y: top
4830 };
4831 }
4832 function getDimensions(element) {
4833 const {
4834 width,
4835 height
4836 } = getCssDimensions(element);
4837 return {
4838 width,
4839 height
4840 };
4841 }
4842 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
4843 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4844 const documentElement = getDocumentElement(offsetParent);
4845 const isFixed = strategy === "fixed";
4846 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
4847 let scroll = {
4848 scrollLeft: 0,
4849 scrollTop: 0
4850 };
4851 const offsets = createCoords(0);
4852 function setLeftRTLScrollbarOffset() {
4853 offsets.x = getWindowScrollBarX(documentElement);
4854 }
4855 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4856 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4857 scroll = getNodeScroll(offsetParent);
4858 }
4859 if (isOffsetParentAnElement) {
4860 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
4861 offsets.x = offsetRect.x + offsetParent.clientLeft;
4862 offsets.y = offsetRect.y + offsetParent.clientTop;
4863 } else if (documentElement) {
4864 setLeftRTLScrollbarOffset();
4865 }
4866 }
4867 if (isFixed && !isOffsetParentAnElement && documentElement) {
4868 setLeftRTLScrollbarOffset();
4869 }
4870 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4871 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
4872 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
4873 return {
4874 x: x2,
4875 y: y2,
4876 width: rect.width,
4877 height: rect.height
4878 };
4879 }
4880 function isStaticPositioned(element) {
4881 return getComputedStyle2(element).position === "static";
4882 }
4883 function getTrueOffsetParent(element, polyfill) {
4884 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
4885 return null;
4886 }
4887 if (polyfill) {
4888 return polyfill(element);
4889 }
4890 let rawOffsetParent = element.offsetParent;
4891 if (getDocumentElement(element) === rawOffsetParent) {
4892 rawOffsetParent = rawOffsetParent.ownerDocument.body;
4893 }
4894 return rawOffsetParent;
4895 }
4896 function getOffsetParent(element, polyfill) {
4897 const win = getWindow(element);
4898 if (isTopLayer(element)) {
4899 return win;
4900 }
4901 if (!isHTMLElement(element)) {
4902 let svgOffsetParent = getParentNode(element);
4903 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
4904 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
4905 return svgOffsetParent;
4906 }
4907 svgOffsetParent = getParentNode(svgOffsetParent);
4908 }
4909 return win;
4910 }
4911 let offsetParent = getTrueOffsetParent(element, polyfill);
4912 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
4913 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
4914 }
4915 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
4916 return win;
4917 }
4918 return offsetParent || getContainingBlock(element) || win;
4919 }
4920 var getElementRects = async function(data) {
4921 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
4922 const getDimensionsFn = this.getDimensions;
4923 const floatingDimensions = await getDimensionsFn(data.floating);
4924 return {
4925 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
4926 floating: {
4927 x: 0,
4928 y: 0,
4929 width: floatingDimensions.width,
4930 height: floatingDimensions.height
4931 }
4932 };
4933 };
4934 function isRTL(element) {
4935 return getComputedStyle2(element).direction === "rtl";
4936 }
4937 var platform2 = {
4938 convertOffsetParentRelativeRectToViewportRelativeRect,
4939 getDocumentElement,
4940 getClippingRect,
4941 getOffsetParent,
4942 getElementRects,
4943 getClientRects,
4944 getDimensions,
4945 getScale,
4946 isElement,
4947 isRTL
4948 };
4949 function rectsAreEqual(a2, b2) {
4950 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
4951 }
4952 function observeMove(element, onMove) {
4953 let io = null;
4954 let timeoutId;
4955 const root = getDocumentElement(element);
4956 function cleanup() {
4957 var _io;
4958 clearTimeout(timeoutId);
4959 (_io = io) == null || _io.disconnect();
4960 io = null;
4961 }
4962 function refresh(skip, threshold) {
4963 if (skip === void 0) {
4964 skip = false;
4965 }
4966 if (threshold === void 0) {
4967 threshold = 1;
4968 }
4969 cleanup();
4970 const elementRectForRootMargin = element.getBoundingClientRect();
4971 const {
4972 left,
4973 top,
4974 width,
4975 height
4976 } = elementRectForRootMargin;
4977 if (!skip) {
4978 onMove();
4979 }
4980 if (!width || !height) {
4981 return;
4982 }
4983 const insetTop = floor(top);
4984 const insetRight = floor(root.clientWidth - (left + width));
4985 const insetBottom = floor(root.clientHeight - (top + height));
4986 const insetLeft = floor(left);
4987 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
4988 const options = {
4989 rootMargin,
4990 threshold: max(0, min(1, threshold)) || 1
4991 };
4992 let isFirstUpdate = true;
4993 function handleObserve(entries) {
4994 const ratio = entries[0].intersectionRatio;
4995 if (ratio !== threshold) {
4996 if (!isFirstUpdate) {
4997 return refresh();
4998 }
4999 if (!ratio) {
5000 timeoutId = setTimeout(() => {
5001 refresh(false, 1e-7);
5002 }, 1e3);
5003 } else {
5004 refresh(false, ratio);
5005 }
5006 }
5007 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
5008 refresh();
5009 }
5010 isFirstUpdate = false;
5011 }
5012 try {
5013 io = new IntersectionObserver(handleObserve, {
5014 ...options,
5015 // Handle <iframe>s
5016 root: root.ownerDocument
5017 });
5018 } catch (_e) {
5019 io = new IntersectionObserver(handleObserve, options);
5020 }
5021 io.observe(element);
5022 }
5023 refresh(true);
5024 return cleanup;
5025 }
5026 function autoUpdate(reference, floating, update2, options) {
5027 if (options === void 0) {
5028 options = {};
5029 }
5030 const {
5031 ancestorScroll = true,
5032 ancestorResize = true,
5033 elementResize = typeof ResizeObserver === "function",
5034 layoutShift = typeof IntersectionObserver === "function",
5035 animationFrame = false
5036 } = options;
5037 const referenceEl = unwrapElement(reference);
5038 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
5039 ancestors.forEach((ancestor) => {
5040 ancestorScroll && ancestor.addEventListener("scroll", update2, {
5041 passive: true
5042 });
5043 ancestorResize && ancestor.addEventListener("resize", update2);
5044 });
5045 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
5046 let reobserveFrame = -1;
5047 let resizeObserver = null;
5048 if (elementResize) {
5049 resizeObserver = new ResizeObserver((_ref) => {
5050 let [firstEntry] = _ref;
5051 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
5052 resizeObserver.unobserve(floating);
5053 cancelAnimationFrame(reobserveFrame);
5054 reobserveFrame = requestAnimationFrame(() => {
5055 var _resizeObserver;
5056 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
5057 });
5058 }
5059 update2();
5060 });
5061 if (referenceEl && !animationFrame) {
5062 resizeObserver.observe(referenceEl);
5063 }
5064 if (floating) {
5065 resizeObserver.observe(floating);
5066 }
5067 }
5068 let frameId;
5069 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
5070 if (animationFrame) {
5071 frameLoop();
5072 }
5073 function frameLoop() {
5074 const nextRefRect = getBoundingClientRect(reference);
5075 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
5076 update2();
5077 }
5078 prevRefRect = nextRefRect;
5079 frameId = requestAnimationFrame(frameLoop);
5080 }
5081 update2();
5082 return () => {
5083 var _resizeObserver2;
5084 ancestors.forEach((ancestor) => {
5085 ancestorScroll && ancestor.removeEventListener("scroll", update2);
5086 ancestorResize && ancestor.removeEventListener("resize", update2);
5087 });
5088 cleanupIo == null || cleanupIo();
5089 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
5090 resizeObserver = null;
5091 if (animationFrame) {
5092 cancelAnimationFrame(frameId);
5093 }
5094 };
5095 }
5096 var offset2 = offset;
5097 var shift2 = shift;
5098 var flip2 = flip;
5099 var size2 = size;
5100 var hide2 = hide;
5101 var limitShift2 = limitShift;
5102 var computePosition2 = (reference, floating, options) => {
5103 const cache = /* @__PURE__ */ new Map();
5104 const mergedOptions = {
5105 platform: platform2,
5106 ...options
5107 };
5108 const platformWithCache = {
5109 ...mergedOptions.platform,
5110 _c: cache
5111 };
5112 return computePosition(reference, floating, {
5113 ...mergedOptions,
5114 platform: platformWithCache
5115 });
5116 };
5117
5118 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
5119 var React21 = __toESM(require_react(), 1);
5120 var import_react2 = __toESM(require_react(), 1);
5121 var ReactDOM3 = __toESM(require_react_dom(), 1);
5122 var isClient = typeof document !== "undefined";
5123 var noop2 = function noop3() {
5124 };
5125 var index = isClient ? import_react2.useLayoutEffect : noop2;
5126 function deepEqual(a2, b2) {
5127 if (a2 === b2) {
5128 return true;
5129 }
5130 if (typeof a2 !== typeof b2) {
5131 return false;
5132 }
5133 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
5134 return true;
5135 }
5136 let length;
5137 let i2;
5138 let keys;
5139 if (a2 && b2 && typeof a2 === "object") {
5140 if (Array.isArray(a2)) {
5141 length = a2.length;
5142 if (length !== b2.length) return false;
5143 for (i2 = length; i2-- !== 0; ) {
5144 if (!deepEqual(a2[i2], b2[i2])) {
5145 return false;
5146 }
5147 }
5148 return true;
5149 }
5150 keys = Object.keys(a2);
5151 length = keys.length;
5152 if (length !== Object.keys(b2).length) {
5153 return false;
5154 }
5155 for (i2 = length; i2-- !== 0; ) {
5156 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
5157 return false;
5158 }
5159 }
5160 for (i2 = length; i2-- !== 0; ) {
5161 const key = keys[i2];
5162 if (key === "_owner" && a2.$$typeof) {
5163 continue;
5164 }
5165 if (!deepEqual(a2[key], b2[key])) {
5166 return false;
5167 }
5168 }
5169 return true;
5170 }
5171 return a2 !== a2 && b2 !== b2;
5172 }
5173 function getDPR(element) {
5174 if (typeof window === "undefined") {
5175 return 1;
5176 }
5177 const win = element.ownerDocument.defaultView || window;
5178 return win.devicePixelRatio || 1;
5179 }
5180 function roundByDPR(element, value) {
5181 const dpr = getDPR(element);
5182 return Math.round(value * dpr) / dpr;
5183 }
5184 function useLatestRef(value) {
5185 const ref = React21.useRef(value);
5186 index(() => {
5187 ref.current = value;
5188 });
5189 return ref;
5190 }
5191 function useFloating(options) {
5192 if (options === void 0) {
5193 options = {};
5194 }
5195 const {
5196 placement = "bottom",
5197 strategy = "absolute",
5198 middleware = [],
5199 platform: platform3,
5200 elements: {
5201 reference: externalReference,
5202 floating: externalFloating
5203 } = {},
5204 transform = true,
5205 whileElementsMounted,
5206 open
5207 } = options;
5208 const [data, setData] = React21.useState({
5209 x: 0,
5210 y: 0,
5211 strategy,
5212 placement,
5213 middlewareData: {},
5214 isPositioned: false
5215 });
5216 const [latestMiddleware, setLatestMiddleware] = React21.useState(middleware);
5217 if (!deepEqual(latestMiddleware, middleware)) {
5218 setLatestMiddleware(middleware);
5219 }
5220 const [_reference, _setReference] = React21.useState(null);
5221 const [_floating, _setFloating] = React21.useState(null);
5222 const setReference = React21.useCallback((node) => {
5223 if (node !== referenceRef.current) {
5224 referenceRef.current = node;
5225 _setReference(node);
5226 }
5227 }, []);
5228 const setFloating = React21.useCallback((node) => {
5229 if (node !== floatingRef.current) {
5230 floatingRef.current = node;
5231 _setFloating(node);
5232 }
5233 }, []);
5234 const referenceEl = externalReference || _reference;
5235 const floatingEl = externalFloating || _floating;
5236 const referenceRef = React21.useRef(null);
5237 const floatingRef = React21.useRef(null);
5238 const dataRef = React21.useRef(data);
5239 const hasWhileElementsMounted = whileElementsMounted != null;
5240 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5241 const platformRef = useLatestRef(platform3);
5242 const openRef = useLatestRef(open);
5243 const update2 = React21.useCallback(() => {
5244 if (!referenceRef.current || !floatingRef.current) {
5245 return;
5246 }
5247 const config = {
5248 placement,
5249 strategy,
5250 middleware: latestMiddleware
5251 };
5252 if (platformRef.current) {
5253 config.platform = platformRef.current;
5254 }
5255 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
5256 const fullData = {
5257 ...data2,
5258 // The floating element's position may be recomputed while it's closed
5259 // but still mounted (such as when transitioning out). To ensure
5260 // `isPositioned` will be `false` initially on the next open, avoid
5261 // setting it to `true` when `open === false` (must be specified).
5262 isPositioned: openRef.current !== false
5263 };
5264 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5265 dataRef.current = fullData;
5266 ReactDOM3.flushSync(() => {
5267 setData(fullData);
5268 });
5269 }
5270 });
5271 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
5272 index(() => {
5273 if (open === false && dataRef.current.isPositioned) {
5274 dataRef.current.isPositioned = false;
5275 setData((data2) => ({
5276 ...data2,
5277 isPositioned: false
5278 }));
5279 }
5280 }, [open]);
5281 const isMountedRef = React21.useRef(false);
5282 index(() => {
5283 isMountedRef.current = true;
5284 return () => {
5285 isMountedRef.current = false;
5286 };
5287 }, []);
5288 index(() => {
5289 if (referenceEl) referenceRef.current = referenceEl;
5290 if (floatingEl) floatingRef.current = floatingEl;
5291 if (referenceEl && floatingEl) {
5292 if (whileElementsMountedRef.current) {
5293 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
5294 }
5295 update2();
5296 }
5297 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
5298 const refs = React21.useMemo(() => ({
5299 reference: referenceRef,
5300 floating: floatingRef,
5301 setReference,
5302 setFloating
5303 }), [setReference, setFloating]);
5304 const elements = React21.useMemo(() => ({
5305 reference: referenceEl,
5306 floating: floatingEl
5307 }), [referenceEl, floatingEl]);
5308 const floatingStyles = React21.useMemo(() => {
5309 const initialStyles = {
5310 position: strategy,
5311 left: 0,
5312 top: 0
5313 };
5314 if (!elements.floating) {
5315 return initialStyles;
5316 }
5317 const x2 = roundByDPR(elements.floating, data.x);
5318 const y2 = roundByDPR(elements.floating, data.y);
5319 if (transform) {
5320 return {
5321 ...initialStyles,
5322 transform: "translate(" + x2 + "px, " + y2 + "px)",
5323 ...getDPR(elements.floating) >= 1.5 && {
5324 willChange: "transform"
5325 }
5326 };
5327 }
5328 return {
5329 position: strategy,
5330 left: x2,
5331 top: y2
5332 };
5333 }, [strategy, transform, elements.floating, data.x, data.y]);
5334 return React21.useMemo(() => ({
5335 ...data,
5336 update: update2,
5337 refs,
5338 elements,
5339 floatingStyles
5340 }), [data, update2, refs, elements, floatingStyles]);
5341 }
5342 var offset3 = (options, deps) => {
5343 const result = offset2(options);
5344 return {
5345 name: result.name,
5346 fn: result.fn,
5347 options: [options, deps]
5348 };
5349 };
5350 var shift3 = (options, deps) => {
5351 const result = shift2(options);
5352 return {
5353 name: result.name,
5354 fn: result.fn,
5355 options: [options, deps]
5356 };
5357 };
5358 var limitShift3 = (options, deps) => {
5359 const result = limitShift2(options);
5360 return {
5361 fn: result.fn,
5362 options: [options, deps]
5363 };
5364 };
5365 var flip3 = (options, deps) => {
5366 const result = flip2(options);
5367 return {
5368 name: result.name,
5369 fn: result.fn,
5370 options: [options, deps]
5371 };
5372 };
5373 var size3 = (options, deps) => {
5374 const result = size2(options);
5375 return {
5376 name: result.name,
5377 fn: result.fn,
5378 options: [options, deps]
5379 };
5380 };
5381 var hide3 = (options, deps) => {
5382 const result = hide2(options);
5383 return {
5384 name: result.name,
5385 fn: result.fn,
5386 options: [options, deps]
5387 };
5388 };
5389
5390 // node_modules/@base-ui/utils/esm/store/createSelector.js
5391 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
5392 if (other.length > 0) {
5393 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
5394 }
5395 let selector2;
5396 if (a2 && b2 && c2 && d2 && e2 && f2) {
5397 selector2 = (state, a1, a22, a3) => {
5398 const va = a2(state, a1, a22, a3);
5399 const vb = b2(state, a1, a22, a3);
5400 const vc = c2(state, a1, a22, a3);
5401 const vd = d2(state, a1, a22, a3);
5402 const ve = e2(state, a1, a22, a3);
5403 return f2(va, vb, vc, vd, ve, a1, a22, a3);
5404 };
5405 } else if (a2 && b2 && c2 && d2 && e2) {
5406 selector2 = (state, a1, a22, a3) => {
5407 const va = a2(state, a1, a22, a3);
5408 const vb = b2(state, a1, a22, a3);
5409 const vc = c2(state, a1, a22, a3);
5410 const vd = d2(state, a1, a22, a3);
5411 return e2(va, vb, vc, vd, a1, a22, a3);
5412 };
5413 } else if (a2 && b2 && c2 && d2) {
5414 selector2 = (state, a1, a22, a3) => {
5415 const va = a2(state, a1, a22, a3);
5416 const vb = b2(state, a1, a22, a3);
5417 const vc = c2(state, a1, a22, a3);
5418 return d2(va, vb, vc, a1, a22, a3);
5419 };
5420 } else if (a2 && b2 && c2) {
5421 selector2 = (state, a1, a22, a3) => {
5422 const va = a2(state, a1, a22, a3);
5423 const vb = b2(state, a1, a22, a3);
5424 return c2(va, vb, a1, a22, a3);
5425 };
5426 } else if (a2 && b2) {
5427 selector2 = (state, a1, a22, a3) => {
5428 const va = a2(state, a1, a22, a3);
5429 return b2(va, a1, a22, a3);
5430 };
5431 } else if (a2) {
5432 selector2 = a2;
5433 } else {
5434 throw (
5435 /* minify-error-disabled */
5436 new Error("Missing arguments")
5437 );
5438 }
5439 return selector2;
5440 };
5441
5442 // node_modules/@base-ui/utils/esm/store/useStore.js
5443 var React23 = __toESM(require_react(), 1);
5444 var import_shim = __toESM(require_shim(), 1);
5445 var import_with_selector = __toESM(require_with_selector(), 1);
5446
5447 // node_modules/@base-ui/utils/esm/fastHooks.js
5448 var React22 = __toESM(require_react(), 1);
5449 var hooks = [];
5450 var currentInstance = void 0;
5451 function getInstance() {
5452 return currentInstance;
5453 }
5454 function register(hook) {
5455 hooks.push(hook);
5456 }
5457 function fastComponent(fn) {
5458 const FastComponent = (props, forwardedRef) => {
5459 const instance = useRefWithInit(createInstance).current;
5460 let result;
5461 try {
5462 currentInstance = instance;
5463 for (const hook of hooks) {
5464 hook.before(instance);
5465 }
5466 result = fn(props, forwardedRef);
5467 for (const hook of hooks) {
5468 hook.after(instance);
5469 }
5470 instance.didInitialize = true;
5471 } finally {
5472 currentInstance = void 0;
5473 }
5474 return result;
5475 };
5476 FastComponent.displayName = fn.displayName || fn.name;
5477 return FastComponent;
5478 }
5479 function fastComponentRef(fn) {
5480 return /* @__PURE__ */ React22.forwardRef(fastComponent(fn));
5481 }
5482 function createInstance() {
5483 return {
5484 didInitialize: false
5485 };
5486 }
5487
5488 // node_modules/@base-ui/utils/esm/store/useStore.js
5489 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
5490 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
5491 function useStore(store, selector2, a1, a2, a3) {
5492 return useStoreImplementation(store, selector2, a1, a2, a3);
5493 }
5494 function useStoreR19(store, selector2, a1, a2, a3) {
5495 const getSelection = React23.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
5496 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
5497 }
5498 register({
5499 before(instance) {
5500 instance.syncIndex = 0;
5501 if (!instance.didInitialize) {
5502 instance.syncTick = 1;
5503 instance.syncHooks = [];
5504 instance.didChangeStore = true;
5505 instance.getSnapshot = () => {
5506 let didChange2 = false;
5507 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
5508 const hook = instance.syncHooks[i2];
5509 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
5510 if (hook.didChange || !Object.is(hook.value, value)) {
5511 didChange2 = true;
5512 hook.value = value;
5513 hook.didChange = false;
5514 }
5515 }
5516 if (didChange2) {
5517 instance.syncTick += 1;
5518 }
5519 return instance.syncTick;
5520 };
5521 }
5522 },
5523 after(instance) {
5524 if (instance.syncHooks.length > 0) {
5525 if (instance.didChangeStore) {
5526 instance.didChangeStore = false;
5527 instance.subscribe = (onStoreChange) => {
5528 const stores = /* @__PURE__ */ new Set();
5529 for (const hook of instance.syncHooks) {
5530 stores.add(hook.store);
5531 }
5532 const unsubscribes = [];
5533 for (const store of stores) {
5534 unsubscribes.push(store.subscribe(onStoreChange));
5535 }
5536 return () => {
5537 for (const unsubscribe of unsubscribes) {
5538 unsubscribe();
5539 }
5540 };
5541 };
5542 }
5543 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
5544 }
5545 }
5546 });
5547 function useStoreFast(store, selector2, a1, a2, a3) {
5548 const instance = getInstance();
5549 if (!instance) {
5550 return useStoreR19(store, selector2, a1, a2, a3);
5551 }
5552 const index2 = instance.syncIndex;
5553 instance.syncIndex += 1;
5554 let hook;
5555 if (!instance.didInitialize) {
5556 hook = {
5557 store,
5558 selector: selector2,
5559 a1,
5560 a2,
5561 a3,
5562 value: selector2(store.getSnapshot(), a1, a2, a3),
5563 didChange: false
5564 };
5565 instance.syncHooks.push(hook);
5566 } else {
5567 hook = instance.syncHooks[index2];
5568 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
5569 if (hook.store !== store) {
5570 instance.didChangeStore = true;
5571 }
5572 hook.store = store;
5573 hook.selector = selector2;
5574 hook.a1 = a1;
5575 hook.a2 = a2;
5576 hook.a3 = a3;
5577 hook.didChange = true;
5578 }
5579 }
5580 return hook.value;
5581 }
5582 function useStoreLegacy(store, selector2, a1, a2, a3) {
5583 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
5584 }
5585
5586 // node_modules/@base-ui/utils/esm/store/Store.js
5587 var Store = class {
5588 /**
5589 * The current state of the store.
5590 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
5591 * 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).
5592 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
5593 *
5594 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
5595 */
5596 // Internal state to handle recursive `setState()` calls
5597 constructor(state) {
5598 this.state = state;
5599 this.listeners = /* @__PURE__ */ new Set();
5600 this.updateTick = 0;
5601 }
5602 /**
5603 * Registers a listener that will be called whenever the store's state changes.
5604 *
5605 * @param fn The listener function to be called on state changes.
5606 * @returns A function to unsubscribe the listener.
5607 */
5608 subscribe = (fn) => {
5609 this.listeners.add(fn);
5610 return () => {
5611 this.listeners.delete(fn);
5612 };
5613 };
5614 /**
5615 * Returns the current state of the store.
5616 */
5617 getSnapshot = () => {
5618 return this.state;
5619 };
5620 /**
5621 * Updates the entire store's state and notifies all registered listeners.
5622 *
5623 * @param newState The new state to set for the store.
5624 */
5625 setState(newState) {
5626 if (this.state === newState) {
5627 return;
5628 }
5629 this.state = newState;
5630 this.updateTick += 1;
5631 const currentTick = this.updateTick;
5632 for (const listener of this.listeners) {
5633 if (currentTick !== this.updateTick) {
5634 return;
5635 }
5636 listener(newState);
5637 }
5638 }
5639 /**
5640 * Merges the provided changes into the current state and notifies listeners if there are changes.
5641 *
5642 * @param changes An object containing the changes to apply to the current state.
5643 */
5644 update(changes) {
5645 for (const key in changes) {
5646 if (!Object.is(this.state[key], changes[key])) {
5647 this.setState({
5648 ...this.state,
5649 ...changes
5650 });
5651 return;
5652 }
5653 }
5654 }
5655 /**
5656 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
5657 *
5658 * @param key The key in the store's state to update.
5659 * @param value The new value to set for the specified key.
5660 */
5661 set(key, value) {
5662 if (!Object.is(this.state[key], value)) {
5663 this.setState({
5664 ...this.state,
5665 [key]: value
5666 });
5667 }
5668 }
5669 /**
5670 * Gives the state a new reference and updates all registered listeners.
5671 */
5672 notifyAll() {
5673 const newState = {
5674 ...this.state
5675 };
5676 this.setState(newState);
5677 }
5678 use(selector2, a1, a2, a3) {
5679 return useStore(this, selector2, a1, a2, a3);
5680 }
5681 };
5682
5683 // node_modules/@base-ui/utils/esm/store/ReactStore.js
5684 var React24 = __toESM(require_react(), 1);
5685 var ReactStore = class extends Store {
5686 /**
5687 * Creates a new ReactStore instance.
5688 *
5689 * @param state Initial state of the store.
5690 * @param context Non-reactive context values.
5691 * @param selectors Optional selectors for use with `useState`.
5692 */
5693 constructor(state, context = {}, selectors3) {
5694 super(state);
5695 this.context = context;
5696 this.selectors = selectors3;
5697 }
5698 /**
5699 * Non-reactive values such as refs, callbacks, etc.
5700 */
5701 /**
5702 * Synchronizes a single external value into the store.
5703 *
5704 * Note that the while the value in `state` is updated immediately, the value returned
5705 * by `useState` is updated before the next render (similarly to React's `useState`).
5706 */
5707 useSyncedValue(key, value) {
5708 React24.useDebugValue(key);
5709 useIsoLayoutEffect(() => {
5710 if (this.state[key] !== value) {
5711 this.set(key, value);
5712 }
5713 }, [key, value]);
5714 }
5715 /**
5716 * Synchronizes a single external value into the store and
5717 * cleans it up (sets to `undefined`) on unmount.
5718 *
5719 * Note that the while the value in `state` is updated immediately, the value returned
5720 * by `useState` is updated before the next render (similarly to React's `useState`).
5721 */
5722 useSyncedValueWithCleanup(key, value) {
5723 const store = this;
5724 useIsoLayoutEffect(() => {
5725 if (store.state[key] !== value) {
5726 store.set(key, value);
5727 }
5728 return () => {
5729 store.set(key, void 0);
5730 };
5731 }, [store, key, value]);
5732 }
5733 /**
5734 * Synchronizes multiple external values into the store.
5735 *
5736 * Note that the while the values in `state` are updated immediately, the values returned
5737 * by `useState` are updated before the next render (similarly to React's `useState`).
5738 */
5739 useSyncedValues(statePart) {
5740 const store = this;
5741 if (true) {
5742 React24.useDebugValue(statePart, (p2) => Object.keys(p2));
5743 const keys = React24.useRef(Object.keys(statePart)).current;
5744 const nextKeys = Object.keys(statePart);
5745 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
5746 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
5747 }
5748 }
5749 const dependencies = Object.values(statePart);
5750 useIsoLayoutEffect(() => {
5751 store.update(statePart);
5752 }, [store, ...dependencies]);
5753 }
5754 /**
5755 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
5756 * is non-undefined, the store's state at `key` is updated to match `controlled`.
5757 */
5758 useControlledProp(key, controlled) {
5759 React24.useDebugValue(key);
5760 const isControlled = controlled !== void 0;
5761 useIsoLayoutEffect(() => {
5762 if (isControlled && !Object.is(this.state[key], controlled)) {
5763 super.setState({
5764 ...this.state,
5765 [key]: controlled
5766 });
5767 }
5768 }, [key, controlled, isControlled]);
5769 if (true) {
5770 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
5771 if (!cache.has(key)) {
5772 cache.set(key, isControlled);
5773 }
5774 const previouslyControlled = cache.get(key);
5775 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
5776 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).`);
5777 }
5778 }
5779 }
5780 /** Gets the current value from the store using a selector with the provided key.
5781 *
5782 * @param key Key of the selector to use.
5783 */
5784 select(key, a1, a2, a3) {
5785 const selector2 = this.selectors[key];
5786 return selector2(this.state, a1, a2, a3);
5787 }
5788 /**
5789 * Returns a value from the store's state using a selector function.
5790 * Used to subscribe to specific parts of the state.
5791 * This methods causes a rerender whenever the selected state changes.
5792 *
5793 * @param key Key of the selector to use.
5794 */
5795 useState(key, a1, a2, a3) {
5796 React24.useDebugValue(key);
5797 return useStore(this, this.selectors[key], a1, a2, a3);
5798 }
5799 /**
5800 * Wraps a function with `useStableCallback` to ensure it has a stable reference
5801 * and assigns it to the context.
5802 *
5803 * @param key Key of the event callback. Must be a function in the context.
5804 * @param fn Function to assign.
5805 */
5806 useContextCallback(key, fn) {
5807 React24.useDebugValue(key);
5808 const stableFunction = useStableCallback(fn ?? NOOP);
5809 this.context[key] = stableFunction;
5810 }
5811 /**
5812 * Returns a stable setter function for a specific key in the store's state.
5813 * It's commonly used to pass as a ref callback to React elements.
5814 *
5815 * @param key Key of the state to set.
5816 */
5817 useStateSetter(key) {
5818 const ref = React24.useRef(void 0);
5819 if (ref.current === void 0) {
5820 ref.current = (value) => {
5821 this.set(key, value);
5822 };
5823 }
5824 return ref.current;
5825 }
5826 /**
5827 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
5828 *
5829 * @param key Key of the selector to observe.
5830 * @param listener Listener function called when the selector result changes.
5831 */
5832 observe(selector2, listener) {
5833 let selectFn;
5834 if (typeof selector2 === "function") {
5835 selectFn = selector2;
5836 } else {
5837 selectFn = this.selectors[selector2];
5838 }
5839 let prevValue = selectFn(this.state);
5840 listener(prevValue, prevValue, this);
5841 return this.subscribe((nextState) => {
5842 const nextValue = selectFn(nextState);
5843 if (!Object.is(prevValue, nextValue)) {
5844 const oldValue = prevValue;
5845 prevValue = nextValue;
5846 listener(nextValue, oldValue, this);
5847 }
5848 });
5849 }
5850 };
5851
5852 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js
5853 var selectors = {
5854 open: createSelector((state) => state.open),
5855 transitionStatus: createSelector((state) => state.transitionStatus),
5856 domReferenceElement: createSelector((state) => state.domReferenceElement),
5857 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
5858 floatingElement: createSelector((state) => state.floatingElement),
5859 floatingId: createSelector((state) => state.floatingId)
5860 };
5861 var FloatingRootStore = class extends ReactStore {
5862 constructor(options) {
5863 const {
5864 syncOnly,
5865 nested,
5866 onOpenChange,
5867 triggerElements,
5868 ...initialState
5869 } = options;
5870 super({
5871 ...initialState,
5872 positionReference: initialState.referenceElement,
5873 domReferenceElement: initialState.referenceElement
5874 }, {
5875 onOpenChange,
5876 dataRef: {
5877 current: {}
5878 },
5879 events: createEventEmitter(),
5880 nested,
5881 triggerElements
5882 }, selectors);
5883 this.syncOnly = syncOnly;
5884 }
5885 /**
5886 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
5887 */
5888 syncOpenEvent = (newOpen, event) => {
5889 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
5890 // click events to upgrade a hover-open.
5891 event != null && isClickLikeEvent(event)) {
5892 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
5893 }
5894 };
5895 /**
5896 * Runs the root-owned side effects for an open state change.
5897 */
5898 dispatchOpenChange = (newOpen, eventDetails) => {
5899 this.syncOpenEvent(newOpen, eventDetails.event);
5900 const details = {
5901 open: newOpen,
5902 reason: eventDetails.reason,
5903 nativeEvent: eventDetails.event,
5904 nested: this.context.nested,
5905 triggerElement: eventDetails.trigger
5906 };
5907 this.context.events.emit("openchange", details);
5908 };
5909 /**
5910 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
5911 *
5912 * @param newOpen The new open state.
5913 * @param eventDetails Details about the event that triggered the open state change.
5914 */
5915 setOpen = (newOpen, eventDetails) => {
5916 if (this.syncOnly) {
5917 this.context.onOpenChange?.(newOpen, eventDetails);
5918 return;
5919 }
5920 this.dispatchOpenChange(newOpen, eventDetails);
5921 this.context.onOpenChange?.(newOpen, eventDetails);
5922 };
5923 };
5924
5925 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5926 var React25 = __toESM(require_react(), 1);
5927 function useTriggerRegistration(id, store) {
5928 const registeredElementIdRef = React25.useRef(null);
5929 const registeredElementRef = React25.useRef(null);
5930 return React25.useCallback((element) => {
5931 if (id === void 0) {
5932 return;
5933 }
5934 if (registeredElementIdRef.current !== null) {
5935 const registeredId = registeredElementIdRef.current;
5936 const registeredElement = registeredElementRef.current;
5937 const currentElement = store.context.triggerElements.getById(registeredId);
5938 if (registeredElement && currentElement === registeredElement) {
5939 store.context.triggerElements.delete(registeredId);
5940 }
5941 registeredElementIdRef.current = null;
5942 registeredElementRef.current = null;
5943 }
5944 if (element !== null) {
5945 registeredElementIdRef.current = id;
5946 registeredElementRef.current = element;
5947 store.context.triggerElements.add(id, element);
5948 }
5949 }, [store, id]);
5950 }
5951 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
5952 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
5953 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
5954 const registerTrigger = useStableCallback((element) => {
5955 baseRegisterTrigger(element);
5956 if (!element || !store.select("open")) {
5957 return;
5958 }
5959 const activeTriggerId = store.select("activeTriggerId");
5960 if (activeTriggerId === triggerId) {
5961 store.update({
5962 activeTriggerElement: element,
5963 ...stateUpdates
5964 });
5965 return;
5966 }
5967 if (activeTriggerId == null) {
5968 store.update({
5969 activeTriggerId: triggerId,
5970 activeTriggerElement: element,
5971 ...stateUpdates
5972 });
5973 }
5974 });
5975 useIsoLayoutEffect(() => {
5976 if (isMountedByThisTrigger) {
5977 store.update({
5978 activeTriggerElement: triggerElementRef.current,
5979 ...stateUpdates
5980 });
5981 }
5982 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
5983 return {
5984 registerTrigger,
5985 isMountedByThisTrigger
5986 };
5987 }
5988 function useImplicitActiveTrigger(store) {
5989 const open = store.useState("open");
5990 useIsoLayoutEffect(() => {
5991 if (open && !store.select("activeTriggerId") && store.context.triggerElements.size === 1) {
5992 const iteratorResult = store.context.triggerElements.entries().next();
5993 if (!iteratorResult.done) {
5994 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
5995 store.update({
5996 activeTriggerId: implicitTriggerId,
5997 activeTriggerElement: implicitTriggerElement
5998 });
5999 }
6000 }
6001 }, [open, store]);
6002 }
6003 function useOpenStateTransitions(open, store, onUnmount) {
6004 const {
6005 mounted,
6006 setMounted,
6007 transitionStatus
6008 } = useTransitionStatus(open);
6009 store.useSyncedValues({
6010 mounted,
6011 transitionStatus
6012 });
6013 const forceUnmount = useStableCallback(() => {
6014 setMounted(false);
6015 store.update({
6016 activeTriggerId: null,
6017 activeTriggerElement: null,
6018 mounted: false
6019 });
6020 onUnmount?.();
6021 store.context.onOpenChangeComplete?.(false);
6022 });
6023 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
6024 useOpenChangeComplete({
6025 enabled: !preventUnmountingOnClose,
6026 open,
6027 ref: store.context.popupRef,
6028 onComplete() {
6029 if (!open) {
6030 forceUnmount();
6031 }
6032 }
6033 });
6034 return {
6035 forceUnmount,
6036 transitionStatus
6037 };
6038 }
6039
6040 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js
6041 var PopupTriggerMap = class {
6042 constructor() {
6043 this.elementsSet = /* @__PURE__ */ new Set();
6044 this.idMap = /* @__PURE__ */ new Map();
6045 }
6046 /**
6047 * Adds a trigger element with the given ID.
6048 *
6049 * Note: The provided element is assumed to not be registered under multiple IDs.
6050 */
6051 add(id, element) {
6052 const existingElement = this.idMap.get(id);
6053 if (existingElement === element) {
6054 return;
6055 }
6056 if (existingElement !== void 0) {
6057 this.elementsSet.delete(existingElement);
6058 }
6059 this.elementsSet.add(element);
6060 this.idMap.set(id, element);
6061 if (true) {
6062 if (this.elementsSet.size !== this.idMap.size) {
6063 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
6064 }
6065 }
6066 }
6067 /**
6068 * Removes the trigger element with the given ID.
6069 */
6070 delete(id) {
6071 const element = this.idMap.get(id);
6072 if (element) {
6073 this.elementsSet.delete(element);
6074 this.idMap.delete(id);
6075 }
6076 }
6077 /**
6078 * Whether the given element is registered as a trigger.
6079 */
6080 hasElement(element) {
6081 return this.elementsSet.has(element);
6082 }
6083 /**
6084 * Whether there is a registered trigger element matching the given predicate.
6085 */
6086 hasMatchingElement(predicate) {
6087 for (const element of this.elementsSet) {
6088 if (predicate(element)) {
6089 return true;
6090 }
6091 }
6092 return false;
6093 }
6094 /**
6095 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
6096 */
6097 getById(id) {
6098 return this.idMap.get(id);
6099 }
6100 /**
6101 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
6102 */
6103 entries() {
6104 return this.idMap.entries();
6105 }
6106 /**
6107 * Returns an iterable of all registered trigger elements.
6108 */
6109 elements() {
6110 return this.elementsSet.values();
6111 }
6112 /**
6113 * Returns the number of registered trigger elements.
6114 */
6115 get size() {
6116 return this.idMap.size;
6117 }
6118 };
6119
6120 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js
6121 function getEmptyRootContext() {
6122 return new FloatingRootStore({
6123 open: false,
6124 transitionStatus: void 0,
6125 floatingElement: null,
6126 referenceElement: null,
6127 triggerElements: new PopupTriggerMap(),
6128 floatingId: "",
6129 syncOnly: false,
6130 nested: false,
6131 onOpenChange: void 0
6132 });
6133 }
6134
6135 // node_modules/@base-ui/react/esm/utils/popups/store.js
6136 function createInitialPopupStoreState() {
6137 return {
6138 open: false,
6139 openProp: void 0,
6140 mounted: false,
6141 transitionStatus: void 0,
6142 floatingRootContext: getEmptyRootContext(),
6143 preventUnmountingOnClose: false,
6144 payload: void 0,
6145 activeTriggerId: null,
6146 activeTriggerElement: null,
6147 triggerIdProp: void 0,
6148 popupElement: null,
6149 positionerElement: null,
6150 activeTriggerProps: EMPTY_OBJECT,
6151 inactiveTriggerProps: EMPTY_OBJECT,
6152 popupProps: EMPTY_OBJECT
6153 };
6154 }
6155 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
6156 var popupStoreSelectors = {
6157 open: createSelector((state) => state.openProp ?? state.open),
6158 mounted: createSelector((state) => state.mounted),
6159 transitionStatus: createSelector((state) => state.transitionStatus),
6160 floatingRootContext: createSelector((state) => state.floatingRootContext),
6161 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
6162 payload: createSelector((state) => state.payload),
6163 activeTriggerId: activeTriggerIdSelector,
6164 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
6165 /**
6166 * Whether the trigger with the given ID was used to open the popup.
6167 */
6168 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
6169 /**
6170 * Whether the popup is open and was activated by a trigger with the given ID.
6171 */
6172 isOpenedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.open),
6173 /**
6174 * Whether the popup is mounted and was activated by a trigger with the given ID.
6175 */
6176 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
6177 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
6178 popupProps: createSelector((state) => state.popupProps),
6179 popupElement: createSelector((state) => state.popupElement),
6180 positionerElement: createSelector((state) => state.positionerElement)
6181 };
6182
6183 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js
6184 function useFloatingRootContext(options) {
6185 const {
6186 open = false,
6187 onOpenChange,
6188 elements = {}
6189 } = options;
6190 const floatingId = useId();
6191 const nested = useFloatingParentNodeId() != null;
6192 if (true) {
6193 const optionDomReference = elements.reference;
6194 if (optionDomReference && !isElement(optionDomReference)) {
6195 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
6196 }
6197 }
6198 const store = useRefWithInit(() => new FloatingRootStore({
6199 open,
6200 transitionStatus: void 0,
6201 onOpenChange,
6202 referenceElement: elements.reference ?? null,
6203 floatingElement: elements.floating ?? null,
6204 triggerElements: new PopupTriggerMap(),
6205 floatingId,
6206 syncOnly: false,
6207 nested
6208 })).current;
6209 useIsoLayoutEffect(() => {
6210 const valuesToSync = {
6211 open,
6212 floatingId
6213 };
6214 if (elements.reference !== void 0) {
6215 valuesToSync.referenceElement = elements.reference;
6216 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
6217 }
6218 if (elements.floating !== void 0) {
6219 valuesToSync.floatingElement = elements.floating;
6220 }
6221 store.update(valuesToSync);
6222 }, [open, floatingId, elements.reference, elements.floating, store]);
6223 store.context.onOpenChange = onOpenChange;
6224 store.context.nested = nested;
6225 return store;
6226 }
6227
6228 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
6229 function useFloating2(options = {}) {
6230 const {
6231 nodeId,
6232 externalTree
6233 } = options;
6234 const internalRootStore = useFloatingRootContext(options);
6235 const rootContext = options.rootContext || internalRootStore;
6236 const rootContextElements = {
6237 reference: rootContext.useState("referenceElement"),
6238 floating: rootContext.useState("floatingElement"),
6239 domReference: rootContext.useState("domReferenceElement")
6240 };
6241 const [positionReference, setPositionReferenceRaw] = React26.useState(null);
6242 const domReferenceRef = React26.useRef(null);
6243 const tree = useFloatingTree(externalTree);
6244 useIsoLayoutEffect(() => {
6245 if (rootContextElements.domReference) {
6246 domReferenceRef.current = rootContextElements.domReference;
6247 }
6248 }, [rootContextElements.domReference]);
6249 const position = useFloating({
6250 ...options,
6251 elements: {
6252 ...rootContextElements,
6253 ...positionReference && {
6254 reference: positionReference
6255 }
6256 }
6257 });
6258 const setPositionReference = React26.useCallback((node) => {
6259 const computedPositionReference = isElement(node) ? {
6260 getBoundingClientRect: () => node.getBoundingClientRect(),
6261 getClientRects: () => node.getClientRects(),
6262 contextElement: node
6263 } : node;
6264 setPositionReferenceRaw(computedPositionReference);
6265 position.refs.setReference(computedPositionReference);
6266 }, [position.refs]);
6267 const [localDomReference, setLocalDomReference] = React26.useState(void 0);
6268 const [localFloatingElement, setLocalFloatingElement] = React26.useState(null);
6269 rootContext.useSyncedValue("referenceElement", localDomReference ?? null);
6270 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
6271 rootContext.useSyncedValue("domReferenceElement", localDomReference === void 0 ? rootContextElements.domReference : localDomReferenceElement);
6272 rootContext.useSyncedValue("floatingElement", localFloatingElement);
6273 const setReference = React26.useCallback((node) => {
6274 if (isElement(node) || node === null) {
6275 domReferenceRef.current = node;
6276 setLocalDomReference(node);
6277 }
6278 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
6279 // `null` to support `positionReference` + an unstable `reference`
6280 // callback ref.
6281 node !== null && !isElement(node)) {
6282 position.refs.setReference(node);
6283 }
6284 }, [position.refs, setLocalDomReference]);
6285 const setFloating = React26.useCallback((node) => {
6286 setLocalFloatingElement(node);
6287 position.refs.setFloating(node);
6288 }, [position.refs]);
6289 const refs = React26.useMemo(() => ({
6290 ...position.refs,
6291 setReference,
6292 setFloating,
6293 setPositionReference,
6294 domReference: domReferenceRef
6295 }), [position.refs, setReference, setFloating, setPositionReference]);
6296 const elements = React26.useMemo(() => ({
6297 ...position.elements,
6298 domReference: rootContextElements.domReference
6299 }), [position.elements, rootContextElements.domReference]);
6300 const open = rootContext.useState("open");
6301 const floatingId = rootContext.useState("floatingId");
6302 const context = React26.useMemo(() => ({
6303 ...position,
6304 dataRef: rootContext.context.dataRef,
6305 open,
6306 onOpenChange: rootContext.setOpen,
6307 events: rootContext.context.events,
6308 floatingId,
6309 refs,
6310 elements,
6311 nodeId,
6312 rootStore: rootContext
6313 }), [position, refs, elements, nodeId, rootContext, open, floatingId]);
6314 useIsoLayoutEffect(() => {
6315 rootContext.context.dataRef.current.floatingContext = context;
6316 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
6317 if (node) {
6318 node.context = context;
6319 }
6320 });
6321 return React26.useMemo(() => ({
6322 ...position,
6323 context,
6324 refs,
6325 elements,
6326 rootStore: rootContext
6327 }), [position, refs, elements, context, rootContext]);
6328 }
6329
6330 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
6331 function useSyncedFloatingRootContext(options) {
6332 const {
6333 popupStore,
6334 treatPopupAsFloatingElement = false,
6335 onOpenChange
6336 } = options;
6337 const floatingId = useId();
6338 const nested = useFloatingParentNodeId() != null;
6339 const open = popupStore.useState("open");
6340 const referenceElement = popupStore.useState("activeTriggerElement");
6341 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
6342 const triggerElements = popupStore.context.triggerElements;
6343 const store = useRefWithInit(() => new FloatingRootStore({
6344 open,
6345 transitionStatus: void 0,
6346 referenceElement,
6347 floatingElement,
6348 triggerElements,
6349 onOpenChange,
6350 floatingId,
6351 syncOnly: true,
6352 nested
6353 })).current;
6354 useIsoLayoutEffect(() => {
6355 const valuesToSync = {
6356 open,
6357 floatingId,
6358 referenceElement,
6359 floatingElement
6360 };
6361 if (isElement(referenceElement)) {
6362 valuesToSync.domReferenceElement = referenceElement;
6363 }
6364 if (store.state.positionReference === store.state.referenceElement) {
6365 valuesToSync.positionReference = referenceElement;
6366 }
6367 store.update(valuesToSync);
6368 }, [open, floatingId, referenceElement, floatingElement, store]);
6369 store.context.onOpenChange = onOpenChange;
6370 store.context.nested = nested;
6371 return store;
6372 }
6373
6374 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js
6375 var React27 = __toESM(require_react(), 1);
6376 var isMacSafari = isMac && isSafari;
6377 function useFocus(context, props = {}) {
6378 const store = "rootStore" in context ? context.rootStore : context;
6379 const {
6380 events,
6381 dataRef
6382 } = store.context;
6383 const {
6384 enabled = true,
6385 delay
6386 } = props;
6387 const blockFocusRef = React27.useRef(false);
6388 const blockedReferenceRef = React27.useRef(null);
6389 const timeout = useTimeout();
6390 const keyboardModalityRef = React27.useRef(true);
6391 React27.useEffect(() => {
6392 const domReference = store.select("domReferenceElement");
6393 if (!enabled) {
6394 return void 0;
6395 }
6396 const win = getWindow(domReference);
6397 function onBlur() {
6398 const currentDomReference = store.select("domReferenceElement");
6399 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
6400 blockFocusRef.current = true;
6401 }
6402 }
6403 function onKeyDown() {
6404 keyboardModalityRef.current = true;
6405 }
6406 function onPointerDown() {
6407 keyboardModalityRef.current = false;
6408 }
6409 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
6410 }, [store, enabled]);
6411 React27.useEffect(() => {
6412 if (!enabled) {
6413 return void 0;
6414 }
6415 function onOpenChangeLocal(details) {
6416 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
6417 const referenceElement = store.select("domReferenceElement");
6418 if (isElement(referenceElement)) {
6419 blockedReferenceRef.current = referenceElement;
6420 blockFocusRef.current = true;
6421 }
6422 }
6423 }
6424 events.on("openchange", onOpenChangeLocal);
6425 return () => {
6426 events.off("openchange", onOpenChangeLocal);
6427 };
6428 }, [events, enabled, store]);
6429 const reference = React27.useMemo(() => ({
6430 onMouseLeave() {
6431 blockFocusRef.current = false;
6432 blockedReferenceRef.current = null;
6433 },
6434 onFocus(event) {
6435 const focusTarget = event.currentTarget;
6436 if (blockFocusRef.current) {
6437 if (blockedReferenceRef.current === focusTarget) {
6438 return;
6439 }
6440 blockFocusRef.current = false;
6441 blockedReferenceRef.current = null;
6442 }
6443 const target = getTarget(event.nativeEvent);
6444 if (isElement(target)) {
6445 if (isMacSafari && !event.relatedTarget) {
6446 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
6447 return;
6448 }
6449 } else if (!matchesFocusVisible(target)) {
6450 return;
6451 }
6452 }
6453 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
6454 const {
6455 nativeEvent,
6456 currentTarget
6457 } = event;
6458 const delayValue = typeof delay === "function" ? delay() : delay;
6459 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
6460 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6461 return;
6462 }
6463 timeout.start(delayValue, () => {
6464 if (blockFocusRef.current) {
6465 return;
6466 }
6467 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6468 });
6469 },
6470 onBlur(event) {
6471 blockFocusRef.current = false;
6472 blockedReferenceRef.current = null;
6473 const relatedTarget = event.relatedTarget;
6474 const nativeEvent = event.nativeEvent;
6475 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
6476 timeout.start(0, () => {
6477 const domReference = store.select("domReferenceElement");
6478 const activeEl = activeElement(ownerDocument(domReference));
6479 if (!relatedTarget && activeEl === domReference) {
6480 return;
6481 }
6482 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
6483 return;
6484 }
6485 const nextFocusedElement = relatedTarget ?? activeEl;
6486 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
6487 return;
6488 }
6489 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
6490 });
6491 }
6492 }), [dataRef, store, timeout, delay]);
6493 return React27.useMemo(() => enabled ? {
6494 reference,
6495 trigger: reference
6496 } : {}, [enabled, reference]);
6497 }
6498
6499 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6500 var React28 = __toESM(require_react(), 1);
6501
6502 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js
6503 var HoverInteraction = class _HoverInteraction {
6504 constructor() {
6505 this.pointerType = void 0;
6506 this.interactedInside = false;
6507 this.handler = void 0;
6508 this.blockMouseMove = true;
6509 this.performedPointerEventsMutation = false;
6510 this.pointerEventsScopeElement = null;
6511 this.pointerEventsReferenceElement = null;
6512 this.pointerEventsFloatingElement = null;
6513 this.restTimeoutPending = false;
6514 this.openChangeTimeout = new Timeout();
6515 this.restTimeout = new Timeout();
6516 this.handleCloseOptions = void 0;
6517 }
6518 static create() {
6519 return new _HoverInteraction();
6520 }
6521 dispose = () => {
6522 this.openChangeTimeout.clear();
6523 this.restTimeout.clear();
6524 };
6525 disposeEffect = () => {
6526 return this.dispose;
6527 };
6528 };
6529 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
6530 function clearSafePolygonPointerEventsMutation(instance) {
6531 if (!instance.performedPointerEventsMutation) {
6532 return;
6533 }
6534 const scopeElement = instance.pointerEventsScopeElement;
6535 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
6536 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
6537 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
6538 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
6539 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
6540 }
6541 instance.performedPointerEventsMutation = false;
6542 instance.pointerEventsScopeElement = null;
6543 instance.pointerEventsReferenceElement = null;
6544 instance.pointerEventsFloatingElement = null;
6545 }
6546 function applySafePolygonPointerEventsMutation(instance, options) {
6547 const {
6548 scopeElement,
6549 referenceElement,
6550 floatingElement
6551 } = options;
6552 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
6553 if (existingOwner && existingOwner !== instance) {
6554 clearSafePolygonPointerEventsMutation(existingOwner);
6555 }
6556 clearSafePolygonPointerEventsMutation(instance);
6557 instance.performedPointerEventsMutation = true;
6558 instance.pointerEventsScopeElement = scopeElement;
6559 instance.pointerEventsReferenceElement = referenceElement;
6560 instance.pointerEventsFloatingElement = floatingElement;
6561 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
6562 scopeElement.style.pointerEvents = "none";
6563 referenceElement.style.pointerEvents = "auto";
6564 floatingElement.style.pointerEvents = "auto";
6565 }
6566 function useHoverInteractionSharedState(store) {
6567 const instance = useRefWithInit(HoverInteraction.create).current;
6568 const data = store.context.dataRef.current;
6569 if (!data.hoverInteractionState) {
6570 data.hoverInteractionState = instance;
6571 }
6572 useOnMount(data.hoverInteractionState.disposeEffect);
6573 return data.hoverInteractionState;
6574 }
6575
6576 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6577 function useHoverFloatingInteraction(context, parameters = {}) {
6578 const store = "rootStore" in context ? context.rootStore : context;
6579 const open = store.useState("open");
6580 const floatingElement = store.useState("floatingElement");
6581 const domReferenceElement = store.useState("domReferenceElement");
6582 const {
6583 dataRef
6584 } = store.context;
6585 const {
6586 enabled = true,
6587 closeDelay: closeDelayProp = 0,
6588 nodeId: nodeIdProp
6589 } = parameters;
6590 const instance = useHoverInteractionSharedState(store);
6591 const tree = useFloatingTree();
6592 const parentId = useFloatingParentNodeId();
6593 const isClickLikeOpenEvent2 = useStableCallback(() => {
6594 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6595 });
6596 const isHoverOpen = useStableCallback(() => {
6597 const type = dataRef.current.openEvent?.type;
6598 return type?.includes("mouse") && type !== "mousedown";
6599 });
6600 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => {
6601 return isTargetInsideEnabledTrigger(target, store.context.triggerElements);
6602 });
6603 const closeWithDelay = React28.useCallback((event) => {
6604 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
6605 const close = () => {
6606 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6607 tree?.events.emit("floating.closed", event);
6608 };
6609 if (closeDelay) {
6610 instance.openChangeTimeout.start(closeDelay, close);
6611 } else {
6612 instance.openChangeTimeout.clear();
6613 close();
6614 }
6615 }, [closeDelayProp, store, instance, tree]);
6616 const clearPointerEvents = useStableCallback(() => {
6617 clearSafePolygonPointerEventsMutation(instance);
6618 });
6619 const handleInteractInside = useStableCallback((event) => {
6620 const target = getTarget(event);
6621 if (!isInteractiveElement(target)) {
6622 instance.interactedInside = false;
6623 return;
6624 }
6625 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
6626 });
6627 useIsoLayoutEffect(() => {
6628 if (!open) {
6629 instance.pointerType = void 0;
6630 instance.restTimeoutPending = false;
6631 instance.interactedInside = false;
6632 clearPointerEvents();
6633 }
6634 }, [open, instance, clearPointerEvents]);
6635 React28.useEffect(() => {
6636 return clearPointerEvents;
6637 }, [clearPointerEvents]);
6638 useIsoLayoutEffect(() => {
6639 if (!enabled) {
6640 return void 0;
6641 }
6642 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
6643 const ref = domReferenceElement;
6644 const floatingEl = floatingElement;
6645 const doc = ownerDocument(floatingElement);
6646 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
6647 if (parentFloating) {
6648 parentFloating.style.pointerEvents = "";
6649 }
6650 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? instance.pointerEventsScopeElement ?? parentFloating ?? ref.closest("[data-rootownerid]") ?? doc.body;
6651 applySafePolygonPointerEventsMutation(instance, {
6652 scopeElement,
6653 referenceElement: ref,
6654 floatingElement: floatingEl
6655 });
6656 return () => {
6657 clearPointerEvents();
6658 };
6659 }
6660 return void 0;
6661 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
6662 const childClosedTimeout = useTimeout();
6663 React28.useEffect(() => {
6664 if (!enabled) {
6665 return void 0;
6666 }
6667 function onFloatingMouseEnter() {
6668 instance.openChangeTimeout.clear();
6669 childClosedTimeout.clear();
6670 tree?.events.off("floating.closed", onNodeClosed);
6671 clearPointerEvents();
6672 }
6673 function onFloatingMouseLeave(event) {
6674 if (tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
6675 tree.events.on("floating.closed", onNodeClosed);
6676 return;
6677 }
6678 if (isRelatedTargetInsideEnabledTrigger(event.relatedTarget)) {
6679 return;
6680 }
6681 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
6682 const relatedTarget = event.relatedTarget;
6683 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
6684 if (isMovingIntoDescendantFloating) {
6685 return;
6686 }
6687 if (instance.handler) {
6688 instance.handler(event);
6689 return;
6690 }
6691 clearPointerEvents();
6692 if (!isClickLikeOpenEvent2()) {
6693 closeWithDelay(event);
6694 }
6695 }
6696 function onNodeClosed(event) {
6697 if (!tree || !parentId || getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
6698 return;
6699 }
6700 childClosedTimeout.start(0, () => {
6701 tree.events.off("floating.closed", onNodeClosed);
6702 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6703 tree.events.emit("floating.closed", event);
6704 });
6705 }
6706 const floating = floatingElement;
6707 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
6708 tree?.events.off("floating.closed", onNodeClosed);
6709 });
6710 }, [enabled, floatingElement, store, dataRef, nodeIdProp, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, closeWithDelay, clearPointerEvents, handleInteractInside, instance, tree, parentId, childClosedTimeout]);
6711 }
6712
6713 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js
6714 var React29 = __toESM(require_react(), 1);
6715 var ReactDOM4 = __toESM(require_react_dom(), 1);
6716 var EMPTY_REF = {
6717 current: null
6718 };
6719 function useHoverReferenceInteraction(context, props = {}) {
6720 const store = "rootStore" in context ? context.rootStore : context;
6721 const {
6722 dataRef,
6723 events
6724 } = store.context;
6725 const {
6726 enabled = true,
6727 delay = 0,
6728 handleClose = null,
6729 mouseOnly = false,
6730 restMs = 0,
6731 move = true,
6732 triggerElementRef = EMPTY_REF,
6733 externalTree,
6734 isActiveTrigger = true,
6735 getHandleCloseContext,
6736 isClosing
6737 } = props;
6738 const tree = useFloatingTree(externalTree);
6739 const instance = useHoverInteractionSharedState(store);
6740 const isHoverCloseActiveRef = React29.useRef(false);
6741 const handleCloseRef = useValueAsRef(handleClose);
6742 const delayRef = useValueAsRef(delay);
6743 const restMsRef = useValueAsRef(restMs);
6744 const enabledRef = useValueAsRef(enabled);
6745 const isClosingRef = useValueAsRef(isClosing);
6746 if (isActiveTrigger) {
6747 instance.handleCloseOptions = handleCloseRef.current?.__options;
6748 }
6749 const isClickLikeOpenEvent2 = useStableCallback(() => {
6750 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6751 });
6752 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => {
6753 return isTargetInsideEnabledTrigger(target, store.context.triggerElements);
6754 });
6755 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
6756 const allTriggers = store.context.triggerElements;
6757 if (allTriggers.hasElement(currentTarget)) {
6758 return !currentDomReference || !contains(currentDomReference, currentTarget);
6759 }
6760 if (!isElement(target)) {
6761 return false;
6762 }
6763 const targetElement = target;
6764 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
6765 });
6766 const closeWithDelay = useStableCallback((event, runElseBranch = true) => {
6767 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
6768 if (closeDelay) {
6769 instance.openChangeTimeout.start(closeDelay, () => {
6770 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6771 tree?.events.emit("floating.closed", event);
6772 });
6773 } else if (runElseBranch) {
6774 instance.openChangeTimeout.clear();
6775 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6776 tree?.events.emit("floating.closed", event);
6777 }
6778 });
6779 const cleanupMouseMoveHandler = useStableCallback(() => {
6780 if (!instance.handler) {
6781 return;
6782 }
6783 const doc = ownerDocument(store.select("domReferenceElement"));
6784 doc.removeEventListener("mousemove", instance.handler);
6785 instance.handler = void 0;
6786 });
6787 const clearPointerEvents = useStableCallback(() => {
6788 clearSafePolygonPointerEventsMutation(instance);
6789 });
6790 React29.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
6791 React29.useEffect(() => {
6792 if (!enabled) {
6793 return void 0;
6794 }
6795 function onOpenChangeLocal(details) {
6796 if (!details.open) {
6797 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
6798 cleanupMouseMoveHandler();
6799 instance.openChangeTimeout.clear();
6800 instance.restTimeout.clear();
6801 instance.blockMouseMove = true;
6802 instance.restTimeoutPending = false;
6803 } else {
6804 isHoverCloseActiveRef.current = false;
6805 }
6806 }
6807 events.on("openchange", onOpenChangeLocal);
6808 return () => {
6809 events.off("openchange", onOpenChangeLocal);
6810 };
6811 }, [enabled, events, instance, cleanupMouseMoveHandler]);
6812 React29.useEffect(() => {
6813 if (!enabled) {
6814 return void 0;
6815 }
6816 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
6817 if (!isElement(trigger)) {
6818 return void 0;
6819 }
6820 function onMouseEnter(event) {
6821 instance.openChangeTimeout.clear();
6822 instance.blockMouseMove = false;
6823 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6824 return;
6825 }
6826 const restMsValue = getRestMs(restMsRef.current);
6827 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
6828 const eventTarget = getTarget(event);
6829 const currentTarget = event.currentTarget ?? null;
6830 const currentDomReference = store.select("domReferenceElement");
6831 let triggerNode = currentTarget;
6832 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
6833 for (const triggerElement of store.context.triggerElements.elements()) {
6834 if (contains(triggerElement, eventTarget)) {
6835 triggerNode = triggerElement;
6836 break;
6837 }
6838 }
6839 }
6840 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
6841 triggerNode = currentDomReference;
6842 }
6843 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
6844 const isOpen = store.select("open");
6845 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
6846 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
6847 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
6848 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
6849 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
6850 const shouldOpen = !isOpen || isOverInactive;
6851 if (shouldOpenImmediately) {
6852 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6853 return;
6854 }
6855 if (isRestOnlyDelay) {
6856 return;
6857 }
6858 if (openDelay) {
6859 instance.openChangeTimeout.start(openDelay, () => {
6860 if (shouldOpen) {
6861 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6862 }
6863 });
6864 } else if (shouldOpen) {
6865 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6866 }
6867 }
6868 function onMouseLeave(event) {
6869 if (isClickLikeOpenEvent2()) {
6870 clearPointerEvents();
6871 return;
6872 }
6873 cleanupMouseMoveHandler();
6874 const domReferenceElement = store.select("domReferenceElement");
6875 const doc = ownerDocument(domReferenceElement);
6876 instance.restTimeout.clear();
6877 instance.restTimeoutPending = false;
6878 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
6879 const ignoreRelatedTargetTrigger = isRelatedTargetInsideEnabledTrigger(event.relatedTarget);
6880 if (ignoreRelatedTargetTrigger) {
6881 return;
6882 }
6883 if (handleCloseRef.current && handleCloseContextBase) {
6884 if (!store.select("open")) {
6885 instance.openChangeTimeout.clear();
6886 }
6887 const currentTrigger = triggerElementRef.current;
6888 instance.handler = handleCloseRef.current({
6889 ...handleCloseContextBase,
6890 tree,
6891 x: event.clientX,
6892 y: event.clientY,
6893 onClose() {
6894 clearPointerEvents();
6895 cleanupMouseMoveHandler();
6896 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
6897 closeWithDelay(event, true);
6898 }
6899 }
6900 });
6901 doc.addEventListener("mousemove", instance.handler);
6902 instance.handler(event);
6903 return;
6904 }
6905 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
6906 if (shouldClose) {
6907 closeWithDelay(event);
6908 }
6909 }
6910 if (move) {
6911 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
6912 once: true
6913 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6914 }
6915 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6916 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, closeWithDelay, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef]);
6917 return React29.useMemo(() => {
6918 if (!enabled) {
6919 return void 0;
6920 }
6921 function setPointerRef(event) {
6922 instance.pointerType = event.pointerType;
6923 }
6924 return {
6925 onPointerDown: setPointerRef,
6926 onPointerEnter: setPointerRef,
6927 onMouseMove(event) {
6928 const {
6929 nativeEvent
6930 } = event;
6931 const trigger = event.currentTarget;
6932 const currentDomReference = store.select("domReferenceElement");
6933 const currentOpen = store.select("open");
6934 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
6935 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6936 return;
6937 }
6938 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
6939 const floatingElement = store.select("floatingElement");
6940 if (floatingElement) {
6941 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
6942 applySafePolygonPointerEventsMutation(instance, {
6943 scopeElement,
6944 referenceElement: trigger,
6945 floatingElement
6946 });
6947 }
6948 }
6949 const restMsValue = getRestMs(restMsRef.current);
6950 if (currentOpen && !isOverInactive || restMsValue === 0) {
6951 return;
6952 }
6953 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
6954 return;
6955 }
6956 instance.restTimeout.clear();
6957 function handleMouseMove() {
6958 instance.restTimeoutPending = false;
6959 if (isClickLikeOpenEvent2()) {
6960 return;
6961 }
6962 const latestOpen = store.select("open");
6963 if (!instance.blockMouseMove && (!latestOpen || isOverInactive)) {
6964 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
6965 }
6966 }
6967 if (instance.pointerType === "touch") {
6968 ReactDOM4.flushSync(() => {
6969 handleMouseMove();
6970 });
6971 } else if (isOverInactive && currentOpen) {
6972 handleMouseMove();
6973 } else {
6974 instance.restTimeoutPending = true;
6975 instance.restTimeout.start(restMsValue, handleMouseMove);
6976 }
6977 }
6978 };
6979 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef]);
6980 }
6981
6982 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useInteractions.js
6983 var React30 = __toESM(require_react(), 1);
6984 function useInteractions(propsList = []) {
6985 const referenceDeps = propsList.map((key) => key?.reference);
6986 const floatingDeps = propsList.map((key) => key?.floating);
6987 const itemDeps = propsList.map((key) => key?.item);
6988 const triggerDeps = propsList.map((key) => key?.trigger);
6989 const getReferenceProps = React30.useCallback(
6990 (userProps) => mergeProps2(userProps, propsList, "reference"),
6991 // eslint-disable-next-line react-hooks/exhaustive-deps
6992 referenceDeps
6993 );
6994 const getFloatingProps = React30.useCallback(
6995 (userProps) => mergeProps2(userProps, propsList, "floating"),
6996 // eslint-disable-next-line react-hooks/exhaustive-deps
6997 floatingDeps
6998 );
6999 const getItemProps = React30.useCallback(
7000 (userProps) => mergeProps2(userProps, propsList, "item"),
7001 // eslint-disable-next-line react-hooks/exhaustive-deps
7002 itemDeps
7003 );
7004 const getTriggerProps = React30.useCallback(
7005 (userProps) => mergeProps2(userProps, propsList, "trigger"),
7006 // eslint-disable-next-line react-hooks/exhaustive-deps
7007 triggerDeps
7008 );
7009 return React30.useMemo(() => ({
7010 getReferenceProps,
7011 getFloatingProps,
7012 getItemProps,
7013 getTriggerProps
7014 }), [getReferenceProps, getFloatingProps, getItemProps, getTriggerProps]);
7015 }
7016 function mergeProps2(userProps, propsList, elementKey) {
7017 const eventHandlers = /* @__PURE__ */ new Map();
7018 const isItem2 = elementKey === "item";
7019 const outputProps = {};
7020 if (elementKey === "floating") {
7021 outputProps.tabIndex = -1;
7022 outputProps[FOCUSABLE_ATTRIBUTE] = "";
7023 }
7024 for (const key in userProps) {
7025 if (isItem2 && userProps) {
7026 if (key === ACTIVE_KEY || key === SELECTED_KEY) {
7027 continue;
7028 }
7029 }
7030 outputProps[key] = userProps[key];
7031 }
7032 for (let i2 = 0; i2 < propsList.length; i2 += 1) {
7033 let props;
7034 const propsOrGetProps = propsList[i2]?.[elementKey];
7035 if (typeof propsOrGetProps === "function") {
7036 props = userProps ? propsOrGetProps(userProps) : null;
7037 } else {
7038 props = propsOrGetProps;
7039 }
7040 if (!props) {
7041 continue;
7042 }
7043 mutablyMergeProps(outputProps, props, isItem2, eventHandlers);
7044 }
7045 mutablyMergeProps(outputProps, userProps, isItem2, eventHandlers);
7046 return outputProps;
7047 }
7048 function mutablyMergeProps(outputProps, props, isItem2, eventHandlers) {
7049 for (const key in props) {
7050 const value = props[key];
7051 if (isItem2 && (key === ACTIVE_KEY || key === SELECTED_KEY)) {
7052 continue;
7053 }
7054 if (!key.startsWith("on")) {
7055 outputProps[key] = value;
7056 } else {
7057 if (!eventHandlers.has(key)) {
7058 eventHandlers.set(key, []);
7059 }
7060 if (typeof value === "function") {
7061 eventHandlers.get(key)?.push(value);
7062 outputProps[key] = (...args) => {
7063 return eventHandlers.get(key)?.map((fn) => fn(...args)).find((val) => val !== void 0);
7064 };
7065 }
7066 }
7067 }
7068 }
7069
7070 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js
7071 var CURSOR_SPEED_THRESHOLD = 0.1;
7072 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
7073 var POLYGON_BUFFER = 0.5;
7074 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
7075 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
7076 }
7077 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
7078 let isInsideValue = false;
7079 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
7080 isInsideValue = !isInsideValue;
7081 }
7082 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
7083 isInsideValue = !isInsideValue;
7084 }
7085 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
7086 isInsideValue = !isInsideValue;
7087 }
7088 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
7089 isInsideValue = !isInsideValue;
7090 }
7091 return isInsideValue;
7092 }
7093 function isInsideRect(pointX, pointY, rect) {
7094 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
7095 }
7096 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
7097 const minX = Math.min(x1, x2);
7098 const maxX = Math.max(x1, x2);
7099 const minY = Math.min(y1, y2);
7100 const maxY = Math.max(y1, y2);
7101 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
7102 }
7103 function safePolygon(options = {}) {
7104 const {
7105 blockPointerEvents = false
7106 } = options;
7107 const timeout = new Timeout();
7108 const fn = ({
7109 x: x2,
7110 y: y2,
7111 placement,
7112 elements,
7113 onClose,
7114 nodeId,
7115 tree
7116 }) => {
7117 const side = placement?.split("-")[0];
7118 let hasLanded = false;
7119 let lastX = null;
7120 let lastY = null;
7121 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
7122 function isCursorMovingSlowly(nextX, nextY) {
7123 const currentTime = performance.now();
7124 const elapsedTime = currentTime - lastCursorTime;
7125 if (lastX === null || lastY === null || elapsedTime === 0) {
7126 lastX = nextX;
7127 lastY = nextY;
7128 lastCursorTime = currentTime;
7129 return false;
7130 }
7131 const deltaX = nextX - lastX;
7132 const deltaY = nextY - lastY;
7133 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
7134 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
7135 lastX = nextX;
7136 lastY = nextY;
7137 lastCursorTime = currentTime;
7138 return distanceSquared < thresholdSquared;
7139 }
7140 function close() {
7141 timeout.clear();
7142 onClose();
7143 }
7144 return function onMouseMove(event) {
7145 timeout.clear();
7146 const domReference = elements.domReference;
7147 const floating = elements.floating;
7148 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
7149 return void 0;
7150 }
7151 const {
7152 clientX,
7153 clientY
7154 } = event;
7155 const target = getTarget(event);
7156 const isLeave = event.type === "mouseleave";
7157 const isOverFloatingEl = contains(floating, target);
7158 const isOverReferenceEl = contains(domReference, target);
7159 if (isOverFloatingEl) {
7160 hasLanded = true;
7161 if (!isLeave) {
7162 return void 0;
7163 }
7164 }
7165 if (isOverReferenceEl) {
7166 hasLanded = false;
7167 if (!isLeave) {
7168 hasLanded = true;
7169 return void 0;
7170 }
7171 }
7172 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
7173 return void 0;
7174 }
7175 function hasOpenChildNode() {
7176 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
7177 }
7178 function closeIfNoOpenChild() {
7179 if (!hasOpenChildNode()) {
7180 close();
7181 }
7182 }
7183 if (hasOpenChildNode()) {
7184 return void 0;
7185 }
7186 const refRect = domReference.getBoundingClientRect();
7187 const rect = floating.getBoundingClientRect();
7188 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
7189 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
7190 const isFloatingWider = rect.width > refRect.width;
7191 const isFloatingTaller = rect.height > refRect.height;
7192 const left = (isFloatingWider ? refRect : rect).left;
7193 const right = (isFloatingWider ? refRect : rect).right;
7194 const top = (isFloatingTaller ? refRect : rect).top;
7195 const bottom = (isFloatingTaller ? refRect : rect).bottom;
7196 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) {
7197 closeIfNoOpenChild();
7198 return void 0;
7199 }
7200 let isInsideTroughRect = false;
7201 switch (side) {
7202 case "top":
7203 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
7204 break;
7205 case "bottom":
7206 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
7207 break;
7208 case "left":
7209 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
7210 break;
7211 case "right":
7212 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
7213 break;
7214 default:
7215 }
7216 if (isInsideTroughRect) {
7217 return void 0;
7218 }
7219 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
7220 closeIfNoOpenChild();
7221 return void 0;
7222 }
7223 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
7224 closeIfNoOpenChild();
7225 return void 0;
7226 }
7227 let isInsidePolygon = false;
7228 switch (side) {
7229 case "top": {
7230 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7231 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7232 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7233 const cursorPointY = y2 + POLYGON_BUFFER + 1;
7234 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
7235 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
7236 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7237 break;
7238 }
7239 case "bottom": {
7240 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7241 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7242 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7243 const cursorPointY = y2 - POLYGON_BUFFER;
7244 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
7245 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
7246 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7247 break;
7248 }
7249 case "left": {
7250 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7251 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7252 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7253 const cursorPointX = x2 + POLYGON_BUFFER + 1;
7254 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
7255 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
7256 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
7257 break;
7258 }
7259 case "right": {
7260 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7261 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7262 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7263 const cursorPointX = x2 - POLYGON_BUFFER;
7264 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
7265 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
7266 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
7267 break;
7268 }
7269 default:
7270 }
7271 if (!isInsidePolygon) {
7272 closeIfNoOpenChild();
7273 } else if (!hasLanded) {
7274 timeout.start(40, closeIfNoOpenChild);
7275 }
7276 return void 0;
7277 };
7278 };
7279 fn.__options = {
7280 ...options,
7281 blockPointerEvents
7282 };
7283 return fn;
7284 }
7285
7286 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js
7287 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
7288 CommonPopupDataAttributes2["open"] = "data-open";
7289 CommonPopupDataAttributes2["closed"] = "data-closed";
7290 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
7291 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
7292 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
7293 CommonPopupDataAttributes2["side"] = "data-side";
7294 CommonPopupDataAttributes2["align"] = "data-align";
7295 return CommonPopupDataAttributes2;
7296 })({});
7297 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
7298 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
7299 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
7300 return CommonTriggerDataAttributes2;
7301 })({});
7302 var TRIGGER_HOOK = {
7303 [CommonTriggerDataAttributes.popupOpen]: ""
7304 };
7305 var PRESSABLE_TRIGGER_HOOK = {
7306 [CommonTriggerDataAttributes.popupOpen]: "",
7307 [CommonTriggerDataAttributes.pressed]: ""
7308 };
7309 var POPUP_OPEN_HOOK = {
7310 [CommonPopupDataAttributes.open]: ""
7311 };
7312 var POPUP_CLOSED_HOOK = {
7313 [CommonPopupDataAttributes.closed]: ""
7314 };
7315 var ANCHOR_HIDDEN_HOOK = {
7316 [CommonPopupDataAttributes.anchorHidden]: ""
7317 };
7318 var triggerOpenStateMapping = {
7319 open(value) {
7320 if (value) {
7321 return TRIGGER_HOOK;
7322 }
7323 return null;
7324 }
7325 };
7326 var popupStateMapping = {
7327 open(value) {
7328 if (value) {
7329 return POPUP_OPEN_HOOK;
7330 }
7331 return POPUP_CLOSED_HOOK;
7332 },
7333 anchorHidden(value) {
7334 if (value) {
7335 return ANCHOR_HIDDEN_HOOK;
7336 }
7337 return null;
7338 }
7339 };
7340
7341 // node_modules/@base-ui/utils/esm/inertValue.js
7342 function inertValue(value) {
7343 if (isReactVersionAtLeast(19)) {
7344 return value;
7345 }
7346 return value ? "true" : void 0;
7347 }
7348
7349 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7350 var React31 = __toESM(require_react(), 1);
7351
7352 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js
7353 var baseArrow = (options) => ({
7354 name: "arrow",
7355 options,
7356 async fn(state) {
7357 const {
7358 x: x2,
7359 y: y2,
7360 placement,
7361 rects,
7362 platform: platform3,
7363 elements,
7364 middlewareData
7365 } = state;
7366 const {
7367 element,
7368 padding = 0,
7369 offsetParent = "real"
7370 } = evaluate(options, state) || {};
7371 if (element == null) {
7372 return {};
7373 }
7374 const paddingObject = getPaddingObject(padding);
7375 const coords = {
7376 x: x2,
7377 y: y2
7378 };
7379 const axis = getAlignmentAxis(placement);
7380 const length = getAxisLength(axis);
7381 const arrowDimensions = await platform3.getDimensions(element);
7382 const isYAxis = axis === "y";
7383 const minProp = isYAxis ? "top" : "left";
7384 const maxProp = isYAxis ? "bottom" : "right";
7385 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
7386 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
7387 const startDiff = coords[axis] - rects.reference[axis];
7388 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
7389 let clientSize = elements.floating[clientProp] || rects.floating[length];
7390 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
7391 clientSize = elements.floating[clientProp] || rects.floating[length];
7392 }
7393 const centerToReference = endDiff / 2 - startDiff / 2;
7394 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
7395 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
7396 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
7397 const min2 = minPadding;
7398 const max2 = clientSize - arrowDimensions[length] - maxPadding;
7399 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
7400 const offset4 = clamp(min2, center, max2);
7401 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
7402 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
7403 return {
7404 [axis]: coords[axis] + alignmentOffset,
7405 data: {
7406 [axis]: offset4,
7407 centerOffset: center - offset4 - alignmentOffset,
7408 ...shouldAddOffset && {
7409 alignmentOffset
7410 }
7411 },
7412 reset: shouldAddOffset
7413 };
7414 }
7415 });
7416 var arrow4 = (options, deps) => ({
7417 ...baseArrow(options),
7418 options: [options, deps]
7419 });
7420
7421 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js
7422 var hide4 = {
7423 name: "hide",
7424 async fn(state) {
7425 const {
7426 width,
7427 height,
7428 x: x2,
7429 y: y2
7430 } = state.rects.reference;
7431 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
7432 const nativeHideResult = await hide3().fn(state);
7433 return {
7434 data: {
7435 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
7436 }
7437 };
7438 }
7439 };
7440
7441 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js
7442 var DEFAULT_SIDES = {
7443 sideX: "left",
7444 sideY: "top"
7445 };
7446 var adaptiveOrigin = {
7447 name: "adaptiveOrigin",
7448 async fn(state) {
7449 const {
7450 x: rawX,
7451 y: rawY,
7452 rects: {
7453 floating: floatRect
7454 },
7455 elements: {
7456 floating
7457 },
7458 platform: platform3,
7459 strategy,
7460 placement
7461 } = state;
7462 const win = getWindow(floating);
7463 const styles = win.getComputedStyle(floating);
7464 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
7465 if (!hasTransition) {
7466 return {
7467 x: rawX,
7468 y: rawY,
7469 data: DEFAULT_SIDES
7470 };
7471 }
7472 const offsetParent = await platform3.getOffsetParent?.(floating);
7473 let offsetDimensions = {
7474 width: 0,
7475 height: 0
7476 };
7477 if (strategy === "fixed" && win?.visualViewport) {
7478 offsetDimensions = {
7479 width: win.visualViewport.width,
7480 height: win.visualViewport.height
7481 };
7482 } else if (offsetParent === win) {
7483 const doc = ownerDocument(floating);
7484 offsetDimensions = {
7485 width: doc.documentElement.clientWidth,
7486 height: doc.documentElement.clientHeight
7487 };
7488 } else if (await platform3.isElement?.(offsetParent)) {
7489 offsetDimensions = await platform3.getDimensions(offsetParent);
7490 }
7491 const currentSide = getSide(placement);
7492 let x2 = rawX;
7493 let y2 = rawY;
7494 if (currentSide === "left") {
7495 x2 = offsetDimensions.width - (rawX + floatRect.width);
7496 }
7497 if (currentSide === "top") {
7498 y2 = offsetDimensions.height - (rawY + floatRect.height);
7499 }
7500 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
7501 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
7502 return {
7503 x: x2,
7504 y: y2,
7505 data: {
7506 sideX,
7507 sideY
7508 }
7509 };
7510 }
7511 };
7512
7513 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7514 function getLogicalSide(sideParam, renderedSide, isRtl) {
7515 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
7516 const logicalRight = isRtl ? "inline-start" : "inline-end";
7517 const logicalLeft = isRtl ? "inline-end" : "inline-start";
7518 return {
7519 top: "top",
7520 right: isLogicalSideParam ? logicalRight : "right",
7521 bottom: "bottom",
7522 left: isLogicalSideParam ? logicalLeft : "left"
7523 }[renderedSide];
7524 }
7525 function getOffsetData(state, sideParam, isRtl) {
7526 const {
7527 rects,
7528 placement
7529 } = state;
7530 const data = {
7531 side: getLogicalSide(sideParam, getSide(placement), isRtl),
7532 align: getAlignment(placement) || "center",
7533 anchor: {
7534 width: rects.reference.width,
7535 height: rects.reference.height
7536 },
7537 positioner: {
7538 width: rects.floating.width,
7539 height: rects.floating.height
7540 }
7541 };
7542 return data;
7543 }
7544 function useAnchorPositioning(params) {
7545 const {
7546 // Public parameters
7547 anchor,
7548 positionMethod = "absolute",
7549 side: sideParam = "bottom",
7550 sideOffset = 0,
7551 align = "center",
7552 alignOffset = 0,
7553 collisionBoundary,
7554 collisionPadding: collisionPaddingParam = 5,
7555 sticky = false,
7556 arrowPadding = 5,
7557 disableAnchorTracking = false,
7558 // Private parameters
7559 keepMounted = false,
7560 floatingRootContext,
7561 mounted,
7562 collisionAvoidance,
7563 shiftCrossAxis = false,
7564 nodeId,
7565 adaptiveOrigin: adaptiveOrigin2,
7566 lazyFlip = false,
7567 externalTree
7568 } = params;
7569 const [mountSide, setMountSide] = React31.useState(null);
7570 if (!mounted && mountSide !== null) {
7571 setMountSide(null);
7572 }
7573 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
7574 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
7575 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
7576 const anchorFn = typeof anchor === "function" ? anchor : void 0;
7577 const anchorFnCallback = useStableCallback(anchorFn);
7578 const anchorDep = anchorFn ? anchorFnCallback : anchor;
7579 const anchorValueRef = useValueAsRef(anchor);
7580 const mountedRef = useValueAsRef(mounted);
7581 const direction = useDirection();
7582 const isRtl = direction === "rtl";
7583 const side = mountSide || {
7584 top: "top",
7585 right: "right",
7586 bottom: "bottom",
7587 left: "left",
7588 "inline-end": isRtl ? "left" : "right",
7589 "inline-start": isRtl ? "right" : "left"
7590 }[sideParam];
7591 const placement = align === "center" ? side : `${side}-${align}`;
7592 let collisionPadding = collisionPaddingParam;
7593 const bias = 1;
7594 const biasTop = sideParam === "bottom" ? bias : 0;
7595 const biasBottom = sideParam === "top" ? bias : 0;
7596 const biasLeft = sideParam === "right" ? bias : 0;
7597 const biasRight = sideParam === "left" ? bias : 0;
7598 if (typeof collisionPadding === "number") {
7599 collisionPadding = {
7600 top: collisionPadding + biasTop,
7601 right: collisionPadding + biasRight,
7602 bottom: collisionPadding + biasBottom,
7603 left: collisionPadding + biasLeft
7604 };
7605 } else if (collisionPadding) {
7606 collisionPadding = {
7607 top: (collisionPadding.top || 0) + biasTop,
7608 right: (collisionPadding.right || 0) + biasRight,
7609 bottom: (collisionPadding.bottom || 0) + biasBottom,
7610 left: (collisionPadding.left || 0) + biasLeft
7611 };
7612 }
7613 const commonCollisionProps = {
7614 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
7615 padding: collisionPadding
7616 };
7617 const arrowRef = React31.useRef(null);
7618 const sideOffsetRef = useValueAsRef(sideOffset);
7619 const alignOffsetRef = useValueAsRef(alignOffset);
7620 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
7621 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
7622 const middleware = [offset3((state) => {
7623 const data = getOffsetData(state, sideParam, isRtl);
7624 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
7625 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
7626 return {
7627 mainAxis: sideAxis,
7628 crossAxis: alignAxis,
7629 alignmentAxis: alignAxis
7630 };
7631 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam])];
7632 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
7633 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
7634 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
7635 ...commonCollisionProps,
7636 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
7637 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
7638 padding: {
7639 top: collisionPadding.top + bias,
7640 right: collisionPadding.right + bias,
7641 bottom: collisionPadding.bottom + bias,
7642 left: collisionPadding.left + bias
7643 },
7644 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
7645 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
7646 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
7647 });
7648 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
7649 const html = ownerDocument(data.elements.floating).documentElement;
7650 return {
7651 ...commonCollisionProps,
7652 // Use the Layout Viewport to avoid shifting around when pinch-zooming
7653 // for context menus.
7654 rootBoundary: shiftCrossAxis ? {
7655 x: 0,
7656 y: 0,
7657 width: html.clientWidth,
7658 height: html.clientHeight
7659 } : void 0,
7660 mainAxis: collisionAvoidanceAlign !== "none",
7661 crossAxis: crossAxisShiftEnabled,
7662 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
7663 if (!arrowRef.current) {
7664 return {};
7665 }
7666 const {
7667 width,
7668 height
7669 } = arrowRef.current.getBoundingClientRect();
7670 const sideAxis = getSideAxis(getSide(limitData.placement));
7671 const arrowSize = sideAxis === "y" ? width : height;
7672 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
7673 return {
7674 offset: arrowSize / 2 + offsetAmount / 2
7675 };
7676 })
7677 };
7678 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
7679 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
7680 middleware.push(shiftMiddleware, flipMiddleware);
7681 } else {
7682 middleware.push(flipMiddleware, shiftMiddleware);
7683 }
7684 middleware.push(size3({
7685 ...commonCollisionProps,
7686 apply({
7687 elements: {
7688 floating
7689 },
7690 availableWidth,
7691 availableHeight,
7692 rects
7693 }) {
7694 if (!mountedRef.current) {
7695 return;
7696 }
7697 const floatingStyle = floating.style;
7698 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
7699 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
7700 const dpr = getWindow(floating).devicePixelRatio || 1;
7701 const {
7702 x: x3,
7703 y: y3,
7704 width,
7705 height
7706 } = rects.reference;
7707 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
7708 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
7709 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
7710 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
7711 }
7712 }), arrow4(() => ({
7713 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
7714 // we'll create a fake element.
7715 element: arrowRef.current || ownerDocument(arrowRef.current).createElement("div"),
7716 padding: arrowPadding,
7717 offsetParent: "floating"
7718 }), [arrowPadding]), {
7719 name: "transformOrigin",
7720 fn(state) {
7721 const {
7722 elements: elements2,
7723 middlewareData: middlewareData2,
7724 placement: renderedPlacement2,
7725 rects,
7726 y: y3
7727 } = state;
7728 const currentRenderedSide = getSide(renderedPlacement2);
7729 const currentRenderedAxis = getSideAxis(currentRenderedSide);
7730 const arrowEl = arrowRef.current;
7731 const arrowX = middlewareData2.arrow?.x || 0;
7732 const arrowY = middlewareData2.arrow?.y || 0;
7733 const arrowWidth = arrowEl?.clientWidth || 0;
7734 const arrowHeight = arrowEl?.clientHeight || 0;
7735 const transformX = arrowX + arrowWidth / 2;
7736 const transformY = arrowY + arrowHeight / 2;
7737 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
7738 const halfAnchorHeight = rects.reference.height / 2;
7739 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
7740 const isOverlappingAnchor = shiftY > sideOffsetValue;
7741 const adjacentTransformOrigin = {
7742 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
7743 bottom: `${transformX}px ${-sideOffsetValue}px`,
7744 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
7745 right: `${-sideOffsetValue}px ${transformY}px`
7746 }[currentRenderedSide];
7747 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
7748 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
7749 return {};
7750 }
7751 }, hide4, adaptiveOrigin2);
7752 useIsoLayoutEffect(() => {
7753 if (!mounted && floatingRootContext) {
7754 floatingRootContext.update({
7755 referenceElement: null,
7756 floatingElement: null,
7757 domReferenceElement: null,
7758 positionReference: null
7759 });
7760 }
7761 }, [mounted, floatingRootContext]);
7762 const autoUpdateOptions = React31.useMemo(() => ({
7763 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
7764 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
7765 }), [disableAnchorTracking]);
7766 const {
7767 refs,
7768 elements,
7769 x: x2,
7770 y: y2,
7771 middlewareData,
7772 update: update2,
7773 placement: renderedPlacement,
7774 context,
7775 isPositioned,
7776 floatingStyles: originalFloatingStyles
7777 } = useFloating2({
7778 rootContext: floatingRootContext,
7779 open: keepMounted ? mounted : void 0,
7780 placement,
7781 middleware,
7782 strategy: positionMethod,
7783 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
7784 nodeId,
7785 externalTree
7786 });
7787 const {
7788 sideX,
7789 sideY
7790 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
7791 const resolvedPosition = isPositioned ? positionMethod : "fixed";
7792 const floatingStyles = React31.useMemo(() => {
7793 const base = adaptiveOrigin2 ? {
7794 position: resolvedPosition,
7795 [sideX]: x2,
7796 [sideY]: y2
7797 } : {
7798 position: resolvedPosition,
7799 ...originalFloatingStyles
7800 };
7801 if (!isPositioned) {
7802 base.opacity = 0;
7803 }
7804 return base;
7805 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
7806 const registeredPositionReferenceRef = React31.useRef(null);
7807 useIsoLayoutEffect(() => {
7808 if (!mounted) {
7809 return;
7810 }
7811 const anchorValue = anchorValueRef.current;
7812 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
7813 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
7814 const finalAnchor = unwrappedElement || null;
7815 if (finalAnchor !== registeredPositionReferenceRef.current) {
7816 refs.setPositionReference(finalAnchor);
7817 registeredPositionReferenceRef.current = finalAnchor;
7818 }
7819 }, [mounted, refs, anchorDep, anchorValueRef]);
7820 React31.useEffect(() => {
7821 if (!mounted) {
7822 return;
7823 }
7824 const anchorValue = anchorValueRef.current;
7825 if (typeof anchorValue === "function") {
7826 return;
7827 }
7828 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
7829 refs.setPositionReference(anchorValue.current);
7830 registeredPositionReferenceRef.current = anchorValue.current;
7831 }
7832 }, [mounted, refs, anchorDep, anchorValueRef]);
7833 React31.useEffect(() => {
7834 if (keepMounted && mounted && elements.domReference && elements.floating) {
7835 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions);
7836 }
7837 return void 0;
7838 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
7839 const renderedSide = getSide(renderedPlacement);
7840 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
7841 const renderedAlign = getAlignment(renderedPlacement) || "center";
7842 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
7843 useIsoLayoutEffect(() => {
7844 if (lazyFlip && mounted && isPositioned) {
7845 setMountSide(renderedSide);
7846 }
7847 }, [lazyFlip, mounted, isPositioned, renderedSide]);
7848 const arrowStyles = React31.useMemo(() => ({
7849 position: "absolute",
7850 top: middlewareData.arrow?.y,
7851 left: middlewareData.arrow?.x
7852 }), [middlewareData.arrow]);
7853 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
7854 return React31.useMemo(() => ({
7855 positionerStyles: floatingStyles,
7856 arrowStyles,
7857 arrowRef,
7858 arrowUncentered,
7859 side: logicalRenderedSide,
7860 align: renderedAlign,
7861 physicalSide: renderedSide,
7862 anchorHidden,
7863 refs,
7864 context,
7865 isPositioned,
7866 update: update2
7867 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
7868 }
7869 function isRef(param) {
7870 return param != null && "current" in param;
7871 }
7872
7873 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js
7874 function getDisabledMountTransitionStyles(transitionStatus) {
7875 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
7876 }
7877
7878 // node_modules/@base-ui/react/esm/utils/usePositioner.js
7879 function usePositioner(componentProps, state, {
7880 styles,
7881 transitionStatus,
7882 props,
7883 refs,
7884 hidden,
7885 inert = false
7886 }) {
7887 const style = {
7888 ...styles
7889 };
7890 if (inert) {
7891 style.pointerEvents = "none";
7892 }
7893 return useRenderElement("div", componentProps, {
7894 state,
7895 ref: refs,
7896 props: [{
7897 role: "presentation",
7898 hidden,
7899 style
7900 }, getDisabledMountTransitionStyles(transitionStatus), props],
7901 stateAttributesMapping: popupStateMapping
7902 });
7903 }
7904
7905 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7906 var React34 = __toESM(require_react(), 1);
7907 var ReactDOM5 = __toESM(require_react_dom(), 1);
7908
7909 // node_modules/@base-ui/utils/esm/usePreviousValue.js
7910 var React32 = __toESM(require_react(), 1);
7911 function usePreviousValue(value) {
7912 const [state, setState] = React32.useState({
7913 current: value,
7914 previous: null
7915 });
7916 if (value !== state.current) {
7917 setState({
7918 current: value,
7919 previous: state.current
7920 });
7921 }
7922 return state.previous;
7923 }
7924
7925 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7926 var React33 = __toESM(require_react(), 1);
7927
7928 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js
7929 function getCssDimensions2(element) {
7930 const css = getComputedStyle2(element);
7931 let width = parseFloat(css.width) || 0;
7932 let height = parseFloat(css.height) || 0;
7933 const hasOffset = isHTMLElement(element);
7934 const offsetWidth = hasOffset ? element.offsetWidth : width;
7935 const offsetHeight = hasOffset ? element.offsetHeight : height;
7936 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
7937 if (shouldFallback) {
7938 width = offsetWidth;
7939 height = offsetHeight;
7940 }
7941 return {
7942 width,
7943 height
7944 };
7945 }
7946
7947 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7948 var DEFAULT_ENABLED = () => true;
7949 function usePopupAutoResize(parameters) {
7950 const {
7951 popupElement,
7952 positionerElement,
7953 content,
7954 mounted,
7955 enabled = DEFAULT_ENABLED,
7956 onMeasureLayout: onMeasureLayoutParam,
7957 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
7958 side,
7959 direction
7960 } = parameters;
7961 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
7962 const animationFrame = useAnimationFrame();
7963 const committedDimensionsRef = React33.useRef(null);
7964 const liveDimensionsRef = React33.useRef(null);
7965 const isInitialRenderRef = React33.useRef(true);
7966 const restoreAnchoringStylesRef = React33.useRef(NOOP);
7967 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
7968 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
7969 const anchoringStyles = React33.useMemo(() => {
7970 let isOriginSide = side === "top";
7971 let isPhysicalLeft = side === "left";
7972 if (direction === "rtl") {
7973 isOriginSide = isOriginSide || side === "inline-end";
7974 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
7975 } else {
7976 isOriginSide = isOriginSide || side === "inline-start";
7977 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
7978 }
7979 return isOriginSide ? {
7980 position: "absolute",
7981 [side === "top" ? "bottom" : "top"]: "0",
7982 [isPhysicalLeft ? "right" : "left"]: "0"
7983 } : EMPTY_OBJECT;
7984 }, [side, direction]);
7985 useIsoLayoutEffect(() => {
7986 if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
7987 restoreAnchoringStylesRef.current = NOOP;
7988 isInitialRenderRef.current = true;
7989 committedDimensionsRef.current = null;
7990 liveDimensionsRef.current = null;
7991 return void 0;
7992 }
7993 if (!popupElement || !positionerElement) {
7994 return void 0;
7995 }
7996 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
7997 const observer = new ResizeObserver((entries) => {
7998 const entry = entries[0];
7999 if (entry) {
8000 liveDimensionsRef.current = {
8001 width: Math.ceil(entry.borderBoxSize[0].inlineSize),
8002 height: Math.ceil(entry.borderBoxSize[0].blockSize)
8003 };
8004 }
8005 });
8006 observer.observe(popupElement);
8007 setPopupCssSize(popupElement, "auto");
8008 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
8009 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
8010 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
8011 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
8012 "--available-width": "max-content",
8013 "--available-height": "max-content"
8014 });
8015 function restoreMeasurementOverrides() {
8016 restorePopupPosition();
8017 restorePopupTransform();
8018 restorePositionerAvailableSize();
8019 }
8020 function restoreMeasurementOverridesIncludingScale() {
8021 restoreMeasurementOverrides();
8022 restorePopupScale();
8023 }
8024 onMeasureLayout?.();
8025 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
8026 setPositionerCssSize(positionerElement, "max-content");
8027 const dimensions = getCssDimensions2(popupElement);
8028 committedDimensionsRef.current = dimensions;
8029 setPositionerCssSize(positionerElement, dimensions);
8030 restoreMeasurementOverridesIncludingScale();
8031 onMeasureLayoutComplete?.(null, dimensions);
8032 isInitialRenderRef.current = false;
8033 return () => {
8034 observer.disconnect();
8035 restoreAnchoringStylesRef.current();
8036 restoreAnchoringStylesRef.current = NOOP;
8037 };
8038 }
8039 setPopupCssSize(popupElement, "auto");
8040 setPositionerCssSize(positionerElement, "max-content");
8041 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
8042 const newDimensions = getCssDimensions2(popupElement);
8043 committedDimensionsRef.current = newDimensions;
8044 if (!previousDimensions) {
8045 setPositionerCssSize(positionerElement, newDimensions);
8046 restoreMeasurementOverridesIncludingScale();
8047 onMeasureLayoutComplete?.(null, newDimensions);
8048 return () => {
8049 observer.disconnect();
8050 animationFrame.cancel();
8051 restoreAnchoringStylesRef.current();
8052 restoreAnchoringStylesRef.current = NOOP;
8053 };
8054 }
8055 setPopupCssSize(popupElement, previousDimensions);
8056 restoreMeasurementOverridesIncludingScale();
8057 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
8058 setPositionerCssSize(positionerElement, newDimensions);
8059 const abortController = new AbortController();
8060 animationFrame.request(() => {
8061 setPopupCssSize(popupElement, newDimensions);
8062 runOnceAnimationsFinish(() => {
8063 popupElement.style.setProperty("--popup-width", "auto");
8064 popupElement.style.setProperty("--popup-height", "auto");
8065 }, abortController.signal);
8066 });
8067 return () => {
8068 observer.disconnect();
8069 abortController.abort();
8070 animationFrame.cancel();
8071 restoreAnchoringStylesRef.current();
8072 restoreAnchoringStylesRef.current = NOOP;
8073 };
8074 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
8075 }
8076 function overrideElementStyle(element, property, value) {
8077 const originalValue = element.style.getPropertyValue(property);
8078 element.style.setProperty(property, value);
8079 return () => {
8080 element.style.setProperty(property, originalValue);
8081 };
8082 }
8083 function applyElementStyles(element, styles) {
8084 const restorers = [];
8085 for (const [key, value] of Object.entries(styles)) {
8086 restorers.push(overrideElementStyle(element, key, value));
8087 }
8088 return restorers.length ? () => {
8089 restorers.forEach((restore) => restore());
8090 } : NOOP;
8091 }
8092 function setPopupCssSize(popupElement, size4) {
8093 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
8094 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
8095 popupElement.style.setProperty("--popup-width", width);
8096 popupElement.style.setProperty("--popup-height", height);
8097 }
8098 function setPositionerCssSize(positionerElement, size4) {
8099 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
8100 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
8101 positionerElement.style.setProperty("--positioner-width", width);
8102 positionerElement.style.setProperty("--positioner-height", height);
8103 }
8104
8105 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
8106 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
8107 function usePopupViewport(parameters) {
8108 const {
8109 store,
8110 side,
8111 cssVars,
8112 children
8113 } = parameters;
8114 const direction = useDirection();
8115 const activeTrigger = store.useState("activeTriggerElement");
8116 const activeTriggerId = store.useState("activeTriggerId");
8117 const open = store.useState("open");
8118 const payload = store.useState("payload");
8119 const mounted = store.useState("mounted");
8120 const popupElement = store.useState("popupElement");
8121 const positionerElement = store.useState("positionerElement");
8122 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
8123 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
8124 const capturedNodeRef = React34.useRef(null);
8125 const [previousContentNode, setPreviousContentNode] = React34.useState(null);
8126 const [newTriggerOffset, setNewTriggerOffset] = React34.useState(null);
8127 const currentContainerRef = React34.useRef(null);
8128 const previousContainerRef = React34.useRef(null);
8129 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
8130 const cleanupFrame = useAnimationFrame();
8131 const [previousContentDimensions, setPreviousContentDimensions] = React34.useState(null);
8132 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React34.useState(false);
8133 useIsoLayoutEffect(() => {
8134 store.set("hasViewport", true);
8135 return () => {
8136 store.set("hasViewport", false);
8137 };
8138 }, [store]);
8139 const handleMeasureLayout = useStableCallback(() => {
8140 currentContainerRef.current?.style.setProperty("animation", "none");
8141 currentContainerRef.current?.style.setProperty("transition", "none");
8142 previousContainerRef.current?.style.setProperty("display", "none");
8143 });
8144 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
8145 currentContainerRef.current?.style.removeProperty("animation");
8146 currentContainerRef.current?.style.removeProperty("transition");
8147 previousContainerRef.current?.style.removeProperty("display");
8148 if (previousDimensions) {
8149 setPreviousContentDimensions(previousDimensions);
8150 }
8151 });
8152 const lastHandledTriggerRef = React34.useRef(null);
8153 useIsoLayoutEffect(() => {
8154 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
8155 setPreviousContentNode(capturedNodeRef.current);
8156 setShowStartingStyleAttribute(true);
8157 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
8158 setNewTriggerOffset(offset4);
8159 cleanupFrame.request(() => {
8160 ReactDOM5.flushSync(() => {
8161 setShowStartingStyleAttribute(false);
8162 });
8163 onAnimationsFinished(() => {
8164 setPreviousContentNode(null);
8165 setPreviousContentDimensions(null);
8166 capturedNodeRef.current = null;
8167 });
8168 });
8169 lastHandledTriggerRef.current = activeTrigger;
8170 }
8171 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
8172 useIsoLayoutEffect(() => {
8173 const source = currentContainerRef.current;
8174 if (!source) {
8175 return;
8176 }
8177 const wrapper = ownerDocument(source).createElement("div");
8178 for (const child of Array.from(source.childNodes)) {
8179 wrapper.appendChild(child.cloneNode(true));
8180 }
8181 capturedNodeRef.current = wrapper;
8182 });
8183 const isTransitioning = previousContentNode != null;
8184 let childrenToRender;
8185 if (!isTransitioning) {
8186 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
8187 "data-current": true,
8188 ref: currentContainerRef,
8189 children
8190 }, currentContentKey);
8191 } else {
8192 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(React34.Fragment, {
8193 children: [/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
8194 "data-previous": true,
8195 inert: inertValue(true),
8196 ref: previousContainerRef,
8197 style: {
8198 ...previousContentDimensions ? {
8199 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
8200 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
8201 } : null,
8202 position: "absolute"
8203 },
8204 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
8205 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
8206 "data-current": true,
8207 ref: currentContainerRef,
8208 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
8209 children
8210 }, currentContentKey)]
8211 });
8212 }
8213 useIsoLayoutEffect(() => {
8214 const container = previousContainerRef.current;
8215 if (!container || !previousContentNode) {
8216 return;
8217 }
8218 container.replaceChildren(...Array.from(previousContentNode.childNodes));
8219 }, [previousContentNode]);
8220 usePopupAutoResize({
8221 popupElement,
8222 positionerElement,
8223 mounted,
8224 content: payload,
8225 onMeasureLayout: handleMeasureLayout,
8226 onMeasureLayoutComplete: handleMeasureLayoutComplete,
8227 side,
8228 direction
8229 });
8230 const state = {
8231 activationDirection: getActivationDirection(newTriggerOffset),
8232 transitioning: isTransitioning
8233 };
8234 return {
8235 children: childrenToRender,
8236 state
8237 };
8238 }
8239 function getActivationDirection(offset4) {
8240 if (!offset4) {
8241 return void 0;
8242 }
8243 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
8244 }
8245 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
8246 if (value > tolerance) {
8247 return positiveLabel;
8248 }
8249 if (value < -tolerance) {
8250 return negativeLabel;
8251 }
8252 return "";
8253 }
8254 function calculateRelativePosition(from, to) {
8255 const fromRect = from.getBoundingClientRect();
8256 const toRect = to.getBoundingClientRect();
8257 const fromCenter = {
8258 x: fromRect.left + fromRect.width / 2,
8259 y: fromRect.top + fromRect.height / 2
8260 };
8261 const toCenter = {
8262 x: toRect.left + toRect.width / 2,
8263 y: toRect.top + toRect.height / 2
8264 };
8265 return {
8266 horizontal: toCenter.x - fromCenter.x,
8267 vertical: toCenter.y - fromCenter.y
8268 };
8269 }
8270 function usePopupContentKey(activeTriggerId, payload) {
8271 const [contentKey, setContentKey] = React34.useState(0);
8272 const previousActiveTriggerIdRef = React34.useRef(activeTriggerId);
8273 const previousPayloadRef = React34.useRef(payload);
8274 const pendingPayloadUpdateRef = React34.useRef(false);
8275 useIsoLayoutEffect(() => {
8276 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
8277 const previousPayload = previousPayloadRef.current;
8278 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
8279 const payloadChanged = payload !== previousPayload;
8280 if (triggerIdChanged) {
8281 setContentKey((value) => value + 1);
8282 pendingPayloadUpdateRef.current = !payloadChanged;
8283 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
8284 setContentKey((value) => value + 1);
8285 pendingPayloadUpdateRef.current = false;
8286 }
8287 previousActiveTriggerIdRef.current = activeTriggerId;
8288 previousPayloadRef.current = payload;
8289 }, [activeTriggerId, payload]);
8290 return `${activeTriggerId ?? "current"}-${contentKey}`;
8291 }
8292
8293 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js
8294 var React35 = __toESM(require_react(), 1);
8295 var ReactDOM6 = __toESM(require_react_dom(), 1);
8296 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
8297 var FloatingPortalLite = /* @__PURE__ */ React35.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
8298 const {
8299 children,
8300 container,
8301 className,
8302 render: render4,
8303 style,
8304 ...elementProps
8305 } = componentProps;
8306 const {
8307 portalNode,
8308 portalSubtree
8309 } = useFloatingPortalNode({
8310 container,
8311 ref: forwardedRef,
8312 componentProps,
8313 elementProps
8314 });
8315 if (!portalSubtree && !portalNode) {
8316 return null;
8317 }
8318 return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React35.Fragment, {
8319 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)]
8320 });
8321 });
8322 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
8323
8324 // node_modules/@base-ui/react/esm/tooltip/index.parts.js
8325 var index_parts_exports = {};
8326 __export(index_parts_exports, {
8327 Arrow: () => TooltipArrow,
8328 Handle: () => TooltipHandle,
8329 Popup: () => TooltipPopup,
8330 Portal: () => TooltipPortal,
8331 Positioner: () => TooltipPositioner,
8332 Provider: () => TooltipProvider,
8333 Root: () => TooltipRoot,
8334 Trigger: () => TooltipTrigger,
8335 Viewport: () => TooltipViewport,
8336 createHandle: () => createTooltipHandle
8337 });
8338
8339 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8340 var React38 = __toESM(require_react(), 1);
8341
8342 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js
8343 var React36 = __toESM(require_react(), 1);
8344 var TooltipRootContext = /* @__PURE__ */ React36.createContext(void 0);
8345 if (true) TooltipRootContext.displayName = "TooltipRootContext";
8346 function useTooltipRootContext(optional) {
8347 const context = React36.useContext(TooltipRootContext);
8348 if (context === void 0 && !optional) {
8349 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
8350 }
8351 return context;
8352 }
8353
8354 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js
8355 var React37 = __toESM(require_react(), 1);
8356 var ReactDOM7 = __toESM(require_react_dom(), 1);
8357 var selectors2 = {
8358 ...popupStoreSelectors,
8359 disabled: createSelector((state) => state.disabled),
8360 instantType: createSelector((state) => state.instantType),
8361 isInstantPhase: createSelector((state) => state.isInstantPhase),
8362 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
8363 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
8364 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
8365 closeOnClick: createSelector((state) => state.closeOnClick),
8366 closeDelay: createSelector((state) => state.closeDelay),
8367 hasViewport: createSelector((state) => state.hasViewport)
8368 };
8369 var TooltipStore = class _TooltipStore extends ReactStore {
8370 constructor(initialState) {
8371 super({
8372 ...createInitialState(),
8373 ...initialState
8374 }, {
8375 popupRef: /* @__PURE__ */ React37.createRef(),
8376 onOpenChange: void 0,
8377 onOpenChangeComplete: void 0,
8378 triggerElements: new PopupTriggerMap()
8379 }, selectors2);
8380 }
8381 setOpen = (nextOpen, eventDetails) => {
8382 const reason = eventDetails.reason;
8383 const isHover = reason === reason_parts_exports.triggerHover;
8384 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
8385 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
8386 eventDetails.preventUnmountOnClose = () => {
8387 this.set("preventUnmountingOnClose", true);
8388 };
8389 this.context.onOpenChange?.(nextOpen, eventDetails);
8390 if (eventDetails.isCanceled) {
8391 return;
8392 }
8393 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
8394 const changeState = () => {
8395 const updatedState = {
8396 open: nextOpen,
8397 openChangeReason: reason
8398 };
8399 if (isFocusOpen) {
8400 updatedState.instantType = "focus";
8401 } else if (isDismissClose) {
8402 updatedState.instantType = "dismiss";
8403 } else if (reason === reason_parts_exports.triggerHover) {
8404 updatedState.instantType = void 0;
8405 }
8406 const newTriggerId = eventDetails.trigger?.id ?? null;
8407 if (newTriggerId || nextOpen) {
8408 updatedState.activeTriggerId = newTriggerId;
8409 updatedState.activeTriggerElement = eventDetails.trigger ?? null;
8410 }
8411 this.update(updatedState);
8412 };
8413 if (isHover) {
8414 ReactDOM7.flushSync(changeState);
8415 } else {
8416 changeState();
8417 }
8418 };
8419 static useStore(externalStore, initialState) {
8420 const internalStore = useRefWithInit(() => {
8421 return new _TooltipStore(initialState);
8422 }).current;
8423 const store = externalStore ?? internalStore;
8424 const floatingRootContext = useSyncedFloatingRootContext({
8425 popupStore: store,
8426 onOpenChange: store.setOpen
8427 });
8428 store.state.floatingRootContext = floatingRootContext;
8429 return store;
8430 }
8431 };
8432 function createInitialState() {
8433 return {
8434 ...createInitialPopupStoreState(),
8435 disabled: false,
8436 instantType: void 0,
8437 isInstantPhase: false,
8438 trackCursorAxis: "none",
8439 disableHoverablePopup: false,
8440 openChangeReason: null,
8441 closeOnClick: true,
8442 closeDelay: 0,
8443 hasViewport: false
8444 };
8445 }
8446
8447 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8448 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
8449 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
8450 const {
8451 disabled: disabled2 = false,
8452 defaultOpen = false,
8453 open: openProp,
8454 disableHoverablePopup = false,
8455 trackCursorAxis = "none",
8456 actionsRef,
8457 onOpenChange,
8458 onOpenChangeComplete,
8459 handle,
8460 triggerId: triggerIdProp,
8461 defaultTriggerId: defaultTriggerIdProp = null,
8462 children
8463 } = props;
8464 const store = TooltipStore.useStore(handle?.store, {
8465 open: defaultOpen,
8466 openProp,
8467 activeTriggerId: defaultTriggerIdProp,
8468 triggerIdProp
8469 });
8470 useOnFirstRender(() => {
8471 if (openProp === void 0 && store.state.open === false && defaultOpen === true) {
8472 store.update({
8473 open: true,
8474 activeTriggerId: defaultTriggerIdProp
8475 });
8476 }
8477 });
8478 store.useControlledProp("openProp", openProp);
8479 store.useControlledProp("triggerIdProp", triggerIdProp);
8480 store.useContextCallback("onOpenChange", onOpenChange);
8481 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
8482 const openState = store.useState("open");
8483 const open = !disabled2 && openState;
8484 const activeTriggerId = store.useState("activeTriggerId");
8485 const payload = store.useState("payload");
8486 store.useSyncedValues({
8487 trackCursorAxis,
8488 disableHoverablePopup
8489 });
8490 useIsoLayoutEffect(() => {
8491 if (openState && disabled2) {
8492 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
8493 }
8494 }, [openState, disabled2, store]);
8495 store.useSyncedValue("disabled", disabled2);
8496 useImplicitActiveTrigger(store);
8497 const {
8498 forceUnmount,
8499 transitionStatus
8500 } = useOpenStateTransitions(open, store);
8501 const floatingRootContext = store.select("floatingRootContext");
8502 const isInstantPhase = store.useState("isInstantPhase");
8503 const instantType = store.useState("instantType");
8504 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
8505 const previousInstantTypeRef = React38.useRef(null);
8506 useIsoLayoutEffect(() => {
8507 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
8508 if (instantType !== "delay") {
8509 previousInstantTypeRef.current = instantType;
8510 }
8511 store.set("instantType", "delay");
8512 } else if (previousInstantTypeRef.current !== null) {
8513 store.set("instantType", previousInstantTypeRef.current);
8514 previousInstantTypeRef.current = null;
8515 }
8516 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
8517 useIsoLayoutEffect(() => {
8518 if (open) {
8519 if (activeTriggerId == null) {
8520 store.set("payload", void 0);
8521 }
8522 }
8523 }, [store, activeTriggerId, open]);
8524 const handleImperativeClose = React38.useCallback(() => {
8525 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
8526 }, [store]);
8527 React38.useImperativeHandle(actionsRef, () => ({
8528 unmount: forceUnmount,
8529 close: handleImperativeClose
8530 }), [forceUnmount, handleImperativeClose]);
8531 const dismiss = useDismiss(floatingRootContext, {
8532 enabled: !disabled2,
8533 referencePress: () => store.select("closeOnClick")
8534 });
8535 const clientPoint = useClientPoint(floatingRootContext, {
8536 enabled: !disabled2 && trackCursorAxis !== "none",
8537 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
8538 });
8539 const {
8540 getReferenceProps,
8541 getFloatingProps,
8542 getTriggerProps
8543 } = useInteractions([dismiss, clientPoint]);
8544 const activeTriggerProps = React38.useMemo(() => getReferenceProps(), [getReferenceProps]);
8545 const inactiveTriggerProps = React38.useMemo(() => getTriggerProps(), [getTriggerProps]);
8546 const popupProps = React38.useMemo(() => getFloatingProps(), [getFloatingProps]);
8547 store.useSyncedValues({
8548 activeTriggerProps,
8549 inactiveTriggerProps,
8550 popupProps
8551 });
8552 return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TooltipRootContext.Provider, {
8553 value: store,
8554 children: typeof children === "function" ? children({
8555 payload
8556 }) : children
8557 });
8558 });
8559 if (true) TooltipRoot.displayName = "TooltipRoot";
8560
8561 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8562 var React40 = __toESM(require_react(), 1);
8563
8564 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js
8565 var React39 = __toESM(require_react(), 1);
8566 var TooltipProviderContext = /* @__PURE__ */ React39.createContext(void 0);
8567 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
8568 function useTooltipProviderContext() {
8569 return React39.useContext(TooltipProviderContext);
8570 }
8571
8572 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js
8573 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
8574 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
8575 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
8576 return TooltipTriggerDataAttributes2;
8577 })({});
8578
8579 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js
8580 var OPEN_DELAY = 600;
8581
8582 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8583 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
8584 const {
8585 className,
8586 render: render4,
8587 handle,
8588 payload,
8589 disabled: disabledProp,
8590 delay,
8591 closeOnClick = true,
8592 closeDelay,
8593 id: idProp,
8594 style,
8595 ...elementProps
8596 } = componentProps;
8597 const rootContext = useTooltipRootContext(true);
8598 const store = handle?.store ?? rootContext;
8599 if (!store) {
8600 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));
8601 }
8602 const thisTriggerId = useBaseUiId(idProp);
8603 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
8604 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
8605 const floatingRootContext = store.useState("floatingRootContext");
8606 const triggerElementRef = React40.useRef(null);
8607 const delayWithDefault = delay ?? OPEN_DELAY;
8608 const closeDelayWithDefault = closeDelay ?? 0;
8609 const {
8610 registerTrigger,
8611 isMountedByThisTrigger
8612 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
8613 payload,
8614 closeOnClick,
8615 closeDelay: closeDelayWithDefault
8616 });
8617 const providerContext = useTooltipProviderContext();
8618 const {
8619 delayRef,
8620 isInstantPhase,
8621 hasProvider
8622 } = useDelayGroup(floatingRootContext, {
8623 open: isOpenedByThisTrigger
8624 });
8625 store.useSyncedValue("isInstantPhase", isInstantPhase);
8626 const rootDisabled = store.useState("disabled");
8627 const disabled2 = disabledProp ?? rootDisabled;
8628 const trackCursorAxis = store.useState("trackCursorAxis");
8629 const disableHoverablePopup = store.useState("disableHoverablePopup");
8630 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
8631 enabled: !disabled2,
8632 mouseOnly: true,
8633 move: false,
8634 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
8635 restMs() {
8636 const providerDelay = providerContext?.delay;
8637 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
8638 let computedRestMs = delayWithDefault;
8639 if (hasProvider) {
8640 if (groupOpenValue !== 0) {
8641 computedRestMs = delay ?? providerDelay ?? delayWithDefault;
8642 } else {
8643 computedRestMs = 0;
8644 }
8645 }
8646 return computedRestMs;
8647 },
8648 delay() {
8649 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
8650 let computedCloseDelay = closeDelayWithDefault;
8651 if (closeDelay == null && hasProvider) {
8652 computedCloseDelay = closeValue;
8653 }
8654 return {
8655 close: computedCloseDelay
8656 };
8657 },
8658 triggerElementRef,
8659 isActiveTrigger: isTriggerActive,
8660 isClosing: () => store.select("transitionStatus") === "ending"
8661 });
8662 const focusProps = useFocus(floatingRootContext, {
8663 enabled: !disabled2
8664 }).reference;
8665 const state = {
8666 open: isOpenedByThisTrigger
8667 };
8668 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
8669 const element = useRenderElement("button", componentProps, {
8670 state,
8671 ref: [forwardedRef, registerTrigger, triggerElementRef],
8672 props: [hoverProps, focusProps, rootTriggerProps, {
8673 onPointerDown() {
8674 store.set("closeOnClick", closeOnClick);
8675 },
8676 id: thisTriggerId,
8677 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0
8678 }, elementProps],
8679 stateAttributesMapping: triggerOpenStateMapping
8680 });
8681 return element;
8682 });
8683 if (true) TooltipTrigger.displayName = "TooltipTrigger";
8684
8685 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8686 var React42 = __toESM(require_react(), 1);
8687
8688 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js
8689 var React41 = __toESM(require_react(), 1);
8690 var TooltipPortalContext = /* @__PURE__ */ React41.createContext(void 0);
8691 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
8692 function useTooltipPortalContext() {
8693 const value = React41.useContext(TooltipPortalContext);
8694 if (value === void 0) {
8695 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
8696 }
8697 return value;
8698 }
8699
8700 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8701 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
8702 var TooltipPortal = /* @__PURE__ */ React42.forwardRef(function TooltipPortal2(props, forwardedRef) {
8703 const {
8704 keepMounted = false,
8705 ...portalProps
8706 } = props;
8707 const store = useTooltipRootContext();
8708 const mounted = store.useState("mounted");
8709 const shouldRender = mounted || keepMounted;
8710 if (!shouldRender) {
8711 return null;
8712 }
8713 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipPortalContext.Provider, {
8714 value: keepMounted,
8715 children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FloatingPortalLite, {
8716 ref: forwardedRef,
8717 ...portalProps
8718 })
8719 });
8720 });
8721 if (true) TooltipPortal.displayName = "TooltipPortal";
8722
8723 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8724 var React44 = __toESM(require_react(), 1);
8725
8726 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js
8727 var React43 = __toESM(require_react(), 1);
8728 var TooltipPositionerContext = /* @__PURE__ */ React43.createContext(void 0);
8729 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
8730 function useTooltipPositionerContext() {
8731 const context = React43.useContext(TooltipPositionerContext);
8732 if (context === void 0) {
8733 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
8734 }
8735 return context;
8736 }
8737
8738 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8739 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
8740 var TooltipPositioner = /* @__PURE__ */ React44.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
8741 const {
8742 render: render4,
8743 className,
8744 anchor,
8745 positionMethod = "absolute",
8746 side = "top",
8747 align = "center",
8748 sideOffset = 0,
8749 alignOffset = 0,
8750 collisionBoundary = "clipping-ancestors",
8751 collisionPadding = 5,
8752 arrowPadding = 5,
8753 sticky = false,
8754 disableAnchorTracking = false,
8755 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
8756 style,
8757 ...elementProps
8758 } = componentProps;
8759 const store = useTooltipRootContext();
8760 const keepMounted = useTooltipPortalContext();
8761 const open = store.useState("open");
8762 const mounted = store.useState("mounted");
8763 const trackCursorAxis = store.useState("trackCursorAxis");
8764 const disableHoverablePopup = store.useState("disableHoverablePopup");
8765 const floatingRootContext = store.useState("floatingRootContext");
8766 const instantType = store.useState("instantType");
8767 const transitionStatus = store.useState("transitionStatus");
8768 const hasViewport = store.useState("hasViewport");
8769 const positioning = useAnchorPositioning({
8770 anchor,
8771 positionMethod,
8772 floatingRootContext,
8773 mounted,
8774 side,
8775 sideOffset,
8776 align,
8777 alignOffset,
8778 collisionBoundary,
8779 collisionPadding,
8780 sticky,
8781 arrowPadding,
8782 disableAnchorTracking,
8783 keepMounted,
8784 collisionAvoidance,
8785 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
8786 });
8787 const state = React44.useMemo(() => ({
8788 open,
8789 side: positioning.side,
8790 align: positioning.align,
8791 anchorHidden: positioning.anchorHidden,
8792 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
8793 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
8794 const element = usePositioner(componentProps, state, {
8795 styles: positioning.positionerStyles,
8796 transitionStatus,
8797 props: elementProps,
8798 refs: [forwardedRef, store.useStateSetter("positionerElement")],
8799 hidden: !mounted,
8800 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
8801 });
8802 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPositionerContext.Provider, {
8803 value: positioning,
8804 children: element
8805 });
8806 });
8807 if (true) TooltipPositioner.displayName = "TooltipPositioner";
8808
8809 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js
8810 var React45 = __toESM(require_react(), 1);
8811 var stateAttributesMapping = {
8812 ...popupStateMapping,
8813 ...transitionStatusMapping
8814 };
8815 var TooltipPopup = /* @__PURE__ */ React45.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
8816 const {
8817 className,
8818 render: render4,
8819 style,
8820 ...elementProps
8821 } = componentProps;
8822 const store = useTooltipRootContext();
8823 const {
8824 side,
8825 align
8826 } = useTooltipPositionerContext();
8827 const open = store.useState("open");
8828 const instantType = store.useState("instantType");
8829 const transitionStatus = store.useState("transitionStatus");
8830 const popupProps = store.useState("popupProps");
8831 const floatingContext = store.useState("floatingRootContext");
8832 useOpenChangeComplete({
8833 open,
8834 ref: store.context.popupRef,
8835 onComplete() {
8836 if (open) {
8837 store.context.onOpenChangeComplete?.(true);
8838 }
8839 }
8840 });
8841 const disabled2 = store.useState("disabled");
8842 const closeDelay = store.useState("closeDelay");
8843 useHoverFloatingInteraction(floatingContext, {
8844 enabled: !disabled2,
8845 closeDelay
8846 });
8847 const state = {
8848 open,
8849 side,
8850 align,
8851 instant: instantType,
8852 transitionStatus
8853 };
8854 const element = useRenderElement("div", componentProps, {
8855 state,
8856 ref: [forwardedRef, store.context.popupRef, store.useStateSetter("popupElement")],
8857 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
8858 stateAttributesMapping
8859 });
8860 return element;
8861 });
8862 if (true) TooltipPopup.displayName = "TooltipPopup";
8863
8864 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js
8865 var React46 = __toESM(require_react(), 1);
8866 var TooltipArrow = /* @__PURE__ */ React46.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
8867 const {
8868 className,
8869 render: render4,
8870 style,
8871 ...elementProps
8872 } = componentProps;
8873 const store = useTooltipRootContext();
8874 const open = store.useState("open");
8875 const instantType = store.useState("instantType");
8876 const {
8877 arrowRef,
8878 side,
8879 align,
8880 arrowUncentered,
8881 arrowStyles
8882 } = useTooltipPositionerContext();
8883 const state = {
8884 open,
8885 side,
8886 align,
8887 uncentered: arrowUncentered,
8888 instant: instantType
8889 };
8890 const element = useRenderElement("div", componentProps, {
8891 state,
8892 ref: [forwardedRef, arrowRef],
8893 props: [{
8894 style: arrowStyles,
8895 "aria-hidden": true
8896 }, elementProps],
8897 stateAttributesMapping: popupStateMapping
8898 });
8899 return element;
8900 });
8901 if (true) TooltipArrow.displayName = "TooltipArrow";
8902
8903 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js
8904 var React47 = __toESM(require_react(), 1);
8905 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
8906 var TooltipProvider = function TooltipProvider2(props) {
8907 const {
8908 delay,
8909 closeDelay,
8910 timeout = 400
8911 } = props;
8912 const contextValue = React47.useMemo(() => ({
8913 delay,
8914 closeDelay
8915 }), [delay, closeDelay]);
8916 const delayValue = React47.useMemo(() => ({
8917 open: delay,
8918 close: closeDelay
8919 }), [delay, closeDelay]);
8920 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipProviderContext.Provider, {
8921 value: contextValue,
8922 children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FloatingDelayGroup, {
8923 delay: delayValue,
8924 timeoutMs: timeout,
8925 children: props.children
8926 })
8927 });
8928 };
8929 if (true) TooltipProvider.displayName = "TooltipProvider";
8930
8931 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8932 var React48 = __toESM(require_react(), 1);
8933
8934 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js
8935 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
8936 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
8937 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
8938 return TooltipViewportCssVars2;
8939 })({});
8940
8941 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8942 var stateAttributesMapping2 = {
8943 activationDirection: (value) => value ? {
8944 "data-activation-direction": value
8945 } : null
8946 };
8947 var TooltipViewport = /* @__PURE__ */ React48.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
8948 const {
8949 render: render4,
8950 className,
8951 style,
8952 children,
8953 ...elementProps
8954 } = componentProps;
8955 const store = useTooltipRootContext();
8956 const positioner = useTooltipPositionerContext();
8957 const instantType = store.useState("instantType");
8958 const {
8959 children: childrenToRender,
8960 state: viewportState
8961 } = usePopupViewport({
8962 store,
8963 side: positioner.side,
8964 cssVars: TooltipViewportCssVars,
8965 children
8966 });
8967 const state = {
8968 activationDirection: viewportState.activationDirection,
8969 transitioning: viewportState.transitioning,
8970 instant: instantType
8971 };
8972 return useRenderElement("div", componentProps, {
8973 state,
8974 ref: forwardedRef,
8975 props: [elementProps, {
8976 children: childrenToRender
8977 }],
8978 stateAttributesMapping: stateAttributesMapping2
8979 });
8980 });
8981 if (true) TooltipViewport.displayName = "TooltipViewport";
8982
8983 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
8984 var TooltipHandle = class {
8985 /**
8986 * Internal store holding the tooltip state.
8987 * @internal
8988 */
8989 constructor() {
8990 this.store = new TooltipStore();
8991 }
8992 /**
8993 * Opens the tooltip and associates it with the trigger with the given ID.
8994 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
8995 *
8996 * This method should only be called in an event handler or an effect (not during rendering).
8997 *
8998 * @param triggerId ID of the trigger to associate with the tooltip.
8999 */
9000 open(triggerId) {
9001 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
9002 if (triggerId && !triggerElement) {
9003 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
9004 }
9005 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
9006 }
9007 /**
9008 * Closes the tooltip.
9009 */
9010 close() {
9011 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
9012 }
9013 /**
9014 * Indicates whether the tooltip is currently open.
9015 */
9016 get isOpen() {
9017 return this.store.state.open;
9018 }
9019 };
9020 function createTooltipHandle() {
9021 return new TooltipHandle();
9022 }
9023
9024 // node_modules/@base-ui/react/esm/use-render/useRender.js
9025 function useRender(params) {
9026 return useRenderElement(params.defaultTagName ?? "div", params, params);
9027 }
9028
9029 // packages/ui/build-module/text/text.mjs
9030 var import_element9 = __toESM(require_element(), 1);
9031 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
9032 function getRuntime() {
9033 const globalScope = globalThis;
9034 if (globalScope.__wpStyleRuntime) {
9035 return globalScope.__wpStyleRuntime;
9036 }
9037 globalScope.__wpStyleRuntime = {
9038 documents: /* @__PURE__ */ new Map(),
9039 styles: /* @__PURE__ */ new Map(),
9040 injectedStyles: /* @__PURE__ */ new WeakMap()
9041 };
9042 if (typeof document !== "undefined") {
9043 registerDocument(document);
9044 }
9045 return globalScope.__wpStyleRuntime;
9046 }
9047 function documentContainsStyleHash(targetDocument, hash) {
9048 if (!targetDocument.head) {
9049 return false;
9050 }
9051 for (const style of targetDocument.head.querySelectorAll(
9052 `style[${STYLE_HASH_ATTRIBUTE}]`
9053 )) {
9054 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
9055 return true;
9056 }
9057 }
9058 return false;
9059 }
9060 function injectStyle(targetDocument, hash, css) {
9061 if (!targetDocument.head) {
9062 return;
9063 }
9064 const runtime = getRuntime();
9065 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9066 if (!injectedStyles) {
9067 injectedStyles = /* @__PURE__ */ new Set();
9068 runtime.injectedStyles.set(targetDocument, injectedStyles);
9069 }
9070 if (injectedStyles.has(hash)) {
9071 return;
9072 }
9073 if (documentContainsStyleHash(targetDocument, hash)) {
9074 injectedStyles.add(hash);
9075 return;
9076 }
9077 const style = targetDocument.createElement("style");
9078 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
9079 style.appendChild(targetDocument.createTextNode(css));
9080 targetDocument.head.appendChild(style);
9081 injectedStyles.add(hash);
9082 }
9083 function registerDocument(targetDocument) {
9084 const runtime = getRuntime();
9085 runtime.documents.set(
9086 targetDocument,
9087 (runtime.documents.get(targetDocument) ?? 0) + 1
9088 );
9089 for (const [hash, css] of runtime.styles) {
9090 injectStyle(targetDocument, hash, css);
9091 }
9092 return () => {
9093 const count = runtime.documents.get(targetDocument);
9094 if (count === void 0) {
9095 return;
9096 }
9097 if (count <= 1) {
9098 runtime.documents.delete(targetDocument);
9099 return;
9100 }
9101 runtime.documents.set(targetDocument, count - 1);
9102 };
9103 }
9104 function registerStyle(hash, css) {
9105 const runtime = getRuntime();
9106 runtime.styles.set(hash, css);
9107 for (const targetDocument of runtime.documents.keys()) {
9108 injectStyle(targetDocument, hash, css);
9109 }
9110 }
9111 if (typeof process === "undefined" || true) {
9112 registerStyle("0c8601dd83", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._83ed8a8da5dd50ea__text{margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-p-line-height:var(--wpds-typography-line-height-2xl,40px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}');
9113 }
9114 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" };
9115 if (typeof process === "undefined" || true) {
9116 registerStyle("1fb29d3a3c", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,#0000);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 #0000);color:var(--_gcd-input-color,var(--wpds-color-fg-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,#0000);border-color:var(--_gcd-input-border-color-disabled,#0000);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid #0000)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid #0000);transition:var(--_gcd-a-transition,none)}");
9117 }
9118 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" };
9119 var Text = (0, import_element9.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
9120 const element = useRender({
9121 render: render4,
9122 defaultTagName: "span",
9123 ref,
9124 props: mergeProps(props, {
9125 className: clsx_default(
9126 style_default.text,
9127 global_css_defense_default.heading,
9128 global_css_defense_default.p,
9129 style_default[variant],
9130 className
9131 )
9132 })
9133 });
9134 return element;
9135 });
9136
9137 // packages/icons/build-module/library/arrow-down.mjs
9138 var import_primitives = __toESM(require_primitives(), 1);
9139 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
9140 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives.Path, { d: "m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z" }) });
9141
9142 // packages/icons/build-module/library/arrow-left.mjs
9143 var import_primitives2 = __toESM(require_primitives(), 1);
9144 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
9145 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives2.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) });
9146
9147 // packages/icons/build-module/library/arrow-right.mjs
9148 var import_primitives3 = __toESM(require_primitives(), 1);
9149 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
9150 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives3.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) });
9151
9152 // packages/icons/build-module/library/arrow-up.mjs
9153 var import_primitives4 = __toESM(require_primitives(), 1);
9154 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
9155 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives4.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
9156
9157 // packages/icons/build-module/library/block-table.mjs
9158 var import_primitives5 = __toESM(require_primitives(), 1);
9159 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
9160 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives5.Path, { d: "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" }) });
9161
9162 // packages/icons/build-module/library/category.mjs
9163 var import_primitives6 = __toESM(require_primitives(), 1);
9164 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
9165 var category_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives6.Path, { 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" }) });
9166
9167 // packages/icons/build-module/library/check.mjs
9168 var import_primitives7 = __toESM(require_primitives(), 1);
9169 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
9170 var check_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives7.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
9171
9172 // packages/icons/build-module/library/close-small.mjs
9173 var import_primitives8 = __toESM(require_primitives(), 1);
9174 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
9175 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives8.Path, { d: "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" }) });
9176
9177 // packages/icons/build-module/library/cog.mjs
9178 var import_primitives9 = __toESM(require_primitives(), 1);
9179 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
9180 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives9.Path, { 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" }) });
9181
9182 // packages/icons/build-module/library/envelope.mjs
9183 var import_primitives10 = __toESM(require_primitives(), 1);
9184 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
9185 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives10.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "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" }) });
9186
9187 // packages/icons/build-module/library/error.mjs
9188 var import_primitives11 = __toESM(require_primitives(), 1);
9189 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
9190 var error_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives11.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "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" }) });
9191
9192 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
9193 var import_primitives12 = __toESM(require_primitives(), 1);
9194 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
9195 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives12.Path, { 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" }) });
9196
9197 // packages/icons/build-module/library/format-list-bullets.mjs
9198 var import_primitives13 = __toESM(require_primitives(), 1);
9199 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
9200 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives13.Path, { d: "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" }) });
9201
9202 // packages/icons/build-module/library/funnel.mjs
9203 var import_primitives14 = __toESM(require_primitives(), 1);
9204 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
9205 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives14.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
9206
9207 // packages/icons/build-module/library/link.mjs
9208 var import_primitives15 = __toESM(require_primitives(), 1);
9209 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
9210 var link_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives15.Path, { d: "M10 17.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" }) });
9211
9212 // packages/icons/build-module/library/mobile.mjs
9213 var import_primitives16 = __toESM(require_primitives(), 1);
9214 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
9215 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives16.Path, { d: "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" }) });
9216
9217 // packages/icons/build-module/library/more-vertical.mjs
9218 var import_primitives17 = __toESM(require_primitives(), 1);
9219 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
9220 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives17.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
9221
9222 // packages/icons/build-module/library/next.mjs
9223 var import_primitives18 = __toESM(require_primitives(), 1);
9224 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
9225 var next_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives18.Path, { d: "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" }) });
9226
9227 // packages/icons/build-module/library/previous.mjs
9228 var import_primitives19 = __toESM(require_primitives(), 1);
9229 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
9230 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives19.Path, { d: "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" }) });
9231
9232 // packages/icons/build-module/library/scheduled.mjs
9233 var import_primitives20 = __toESM(require_primitives(), 1);
9234 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
9235 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives20.Path, { 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" }) });
9236
9237 // packages/icons/build-module/library/search.mjs
9238 var import_primitives21 = __toESM(require_primitives(), 1);
9239 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
9240 var search_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives21.Path, { d: "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" }) });
9241
9242 // packages/icons/build-module/library/seen.mjs
9243 var import_primitives22 = __toESM(require_primitives(), 1);
9244 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
9245 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives22.Path, { d: "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" }) });
9246
9247 // packages/icons/build-module/library/unseen.mjs
9248 var import_primitives23 = __toESM(require_primitives(), 1);
9249 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
9250 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives23.Path, { 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" }) });
9251
9252 // packages/ui/build-module/utils/render-slot-with-children.mjs
9253 var import_element10 = __toESM(require_element(), 1);
9254 function renderSlotWithChildren(slot, defaultSlot, children) {
9255 return (0, import_element10.cloneElement)(
9256 slot ?? defaultSlot,
9257 { children }
9258 );
9259 }
9260
9261 // packages/ui/build-module/lock-unlock.mjs
9262 var import_private_apis2 = __toESM(require_private_apis(), 1);
9263 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
9264 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
9265 "@wordpress/ui"
9266 );
9267
9268 // packages/ui/build-module/stack/stack.mjs
9269 var import_element11 = __toESM(require_element(), 1);
9270 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
9271 function getRuntime2() {
9272 const globalScope = globalThis;
9273 if (globalScope.__wpStyleRuntime) {
9274 return globalScope.__wpStyleRuntime;
9275 }
9276 globalScope.__wpStyleRuntime = {
9277 documents: /* @__PURE__ */ new Map(),
9278 styles: /* @__PURE__ */ new Map(),
9279 injectedStyles: /* @__PURE__ */ new WeakMap()
9280 };
9281 if (typeof document !== "undefined") {
9282 registerDocument2(document);
9283 }
9284 return globalScope.__wpStyleRuntime;
9285 }
9286 function documentContainsStyleHash2(targetDocument, hash) {
9287 if (!targetDocument.head) {
9288 return false;
9289 }
9290 for (const style of targetDocument.head.querySelectorAll(
9291 `style[${STYLE_HASH_ATTRIBUTE2}]`
9292 )) {
9293 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
9294 return true;
9295 }
9296 }
9297 return false;
9298 }
9299 function injectStyle2(targetDocument, hash, css) {
9300 if (!targetDocument.head) {
9301 return;
9302 }
9303 const runtime = getRuntime2();
9304 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9305 if (!injectedStyles) {
9306 injectedStyles = /* @__PURE__ */ new Set();
9307 runtime.injectedStyles.set(targetDocument, injectedStyles);
9308 }
9309 if (injectedStyles.has(hash)) {
9310 return;
9311 }
9312 if (documentContainsStyleHash2(targetDocument, hash)) {
9313 injectedStyles.add(hash);
9314 return;
9315 }
9316 const style = targetDocument.createElement("style");
9317 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
9318 style.appendChild(targetDocument.createTextNode(css));
9319 targetDocument.head.appendChild(style);
9320 injectedStyles.add(hash);
9321 }
9322 function registerDocument2(targetDocument) {
9323 const runtime = getRuntime2();
9324 runtime.documents.set(
9325 targetDocument,
9326 (runtime.documents.get(targetDocument) ?? 0) + 1
9327 );
9328 for (const [hash, css] of runtime.styles) {
9329 injectStyle2(targetDocument, hash, css);
9330 }
9331 return () => {
9332 const count = runtime.documents.get(targetDocument);
9333 if (count === void 0) {
9334 return;
9335 }
9336 if (count <= 1) {
9337 runtime.documents.delete(targetDocument);
9338 return;
9339 }
9340 runtime.documents.set(targetDocument, count - 1);
9341 };
9342 }
9343 function registerStyle2(hash, css) {
9344 const runtime = getRuntime2();
9345 runtime.styles.set(hash, css);
9346 for (const targetDocument of runtime.documents.keys()) {
9347 injectStyle2(targetDocument, hash, css);
9348 }
9349 }
9350 if (typeof process === "undefined" || true) {
9351 registerStyle2("b51ff41489", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}");
9352 }
9353 var style_default2 = { "stack": "_19ce0419607e1896__stack" };
9354 var gapTokens = {
9355 xs: "var(--wpds-dimension-gap-xs, 4px)",
9356 sm: "var(--wpds-dimension-gap-sm, 8px)",
9357 md: "var(--wpds-dimension-gap-md, 12px)",
9358 lg: "var(--wpds-dimension-gap-lg, 16px)",
9359 xl: "var(--wpds-dimension-gap-xl, 24px)",
9360 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
9361 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
9362 };
9363 var Stack = (0, import_element11.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
9364 const style = {
9365 gap: gap && gapTokens[gap],
9366 alignItems: align,
9367 justifyContent: justify,
9368 flexDirection: direction,
9369 flexWrap: wrap
9370 };
9371 const element = useRender({
9372 render: render4,
9373 ref,
9374 props: mergeProps(props, { style, className: style_default2.stack })
9375 });
9376 return element;
9377 });
9378
9379 // packages/ui/build-module/tooltip/index.mjs
9380 var tooltip_exports = {};
9381 __export(tooltip_exports, {
9382 Popup: () => Popup,
9383 Portal: () => Portal,
9384 Positioner: () => Positioner,
9385 Provider: () => Provider,
9386 Root: () => Root,
9387 Trigger: () => Trigger
9388 });
9389
9390 // packages/ui/build-module/tooltip/popup.mjs
9391 var import_element14 = __toESM(require_element(), 1);
9392 var import_theme = __toESM(require_theme(), 1);
9393
9394 // packages/ui/build-module/tooltip/portal.mjs
9395 var import_element12 = __toESM(require_element(), 1);
9396
9397 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
9398 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
9399 function getRuntime3() {
9400 const globalScope = globalThis;
9401 if (globalScope.__wpStyleRuntime) {
9402 return globalScope.__wpStyleRuntime;
9403 }
9404 globalScope.__wpStyleRuntime = {
9405 documents: /* @__PURE__ */ new Map(),
9406 styles: /* @__PURE__ */ new Map(),
9407 injectedStyles: /* @__PURE__ */ new WeakMap()
9408 };
9409 if (typeof document !== "undefined") {
9410 registerDocument3(document);
9411 }
9412 return globalScope.__wpStyleRuntime;
9413 }
9414 function documentContainsStyleHash3(targetDocument, hash) {
9415 if (!targetDocument.head) {
9416 return false;
9417 }
9418 for (const style of targetDocument.head.querySelectorAll(
9419 `style[${STYLE_HASH_ATTRIBUTE3}]`
9420 )) {
9421 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
9422 return true;
9423 }
9424 }
9425 return false;
9426 }
9427 function injectStyle3(targetDocument, hash, css) {
9428 if (!targetDocument.head) {
9429 return;
9430 }
9431 const runtime = getRuntime3();
9432 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9433 if (!injectedStyles) {
9434 injectedStyles = /* @__PURE__ */ new Set();
9435 runtime.injectedStyles.set(targetDocument, injectedStyles);
9436 }
9437 if (injectedStyles.has(hash)) {
9438 return;
9439 }
9440 if (documentContainsStyleHash3(targetDocument, hash)) {
9441 injectedStyles.add(hash);
9442 return;
9443 }
9444 const style = targetDocument.createElement("style");
9445 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
9446 style.appendChild(targetDocument.createTextNode(css));
9447 targetDocument.head.appendChild(style);
9448 injectedStyles.add(hash);
9449 }
9450 function registerDocument3(targetDocument) {
9451 const runtime = getRuntime3();
9452 runtime.documents.set(
9453 targetDocument,
9454 (runtime.documents.get(targetDocument) ?? 0) + 1
9455 );
9456 for (const [hash, css] of runtime.styles) {
9457 injectStyle3(targetDocument, hash, css);
9458 }
9459 return () => {
9460 const count = runtime.documents.get(targetDocument);
9461 if (count === void 0) {
9462 return;
9463 }
9464 if (count <= 1) {
9465 runtime.documents.delete(targetDocument);
9466 return;
9467 }
9468 runtime.documents.set(targetDocument, count - 1);
9469 };
9470 }
9471 function registerStyle3(hash, css) {
9472 const runtime = getRuntime3();
9473 runtime.styles.set(hash, css);
9474 for (const targetDocument of runtime.documents.keys()) {
9475 injectStyle3(targetDocument, hash, css);
9476 }
9477 }
9478 if (typeof process === "undefined" || true) {
9479 registerStyle3("45eb1fe20f", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;._11fc52b637ff8a7e__slot{inset:0;isolation:isolate;pointer-events:none;position:fixed;z-index:1000000003}@layer wp-ui-utilities{._11fc52b637ff8a7e__slot>*{pointer-events:auto}}");
9480 }
9481 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
9482 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
9483 function resolveOwnerDocument() {
9484 return typeof document === "undefined" ? null : document;
9485 }
9486 function isInWordPressEnvironment() {
9487 let topWp;
9488 try {
9489 topWp = window.top?.wp;
9490 } catch {
9491 }
9492 const wp = topWp ?? window.wp;
9493 return typeof wp?.components === "object" && wp.components !== null;
9494 }
9495 var cachedSlot = null;
9496 function createSlot(ownerDocument2) {
9497 const element = ownerDocument2.createElement("div");
9498 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
9499 if (wp_compat_overlay_slot_default.slot) {
9500 element.classList.add(wp_compat_overlay_slot_default.slot);
9501 }
9502 ownerDocument2.body.appendChild(element);
9503 return element;
9504 }
9505 function getWpCompatOverlaySlot() {
9506 if (typeof window === "undefined") {
9507 return void 0;
9508 }
9509 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
9510 return void 0;
9511 }
9512 const ownerDocument2 = resolveOwnerDocument();
9513 if (!ownerDocument2 || !ownerDocument2.body) {
9514 return void 0;
9515 }
9516 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
9517 return cachedSlot;
9518 }
9519 const existing = ownerDocument2.querySelector(
9520 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
9521 );
9522 if (existing instanceof HTMLDivElement) {
9523 cachedSlot = existing;
9524 return existing;
9525 }
9526 if (cachedSlot?.isConnected) {
9527 cachedSlot.remove();
9528 }
9529 cachedSlot = createSlot(ownerDocument2);
9530 return cachedSlot;
9531 }
9532
9533 // packages/ui/build-module/tooltip/portal.mjs
9534 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
9535 var Portal = (0, import_element12.forwardRef)(
9536 function TooltipPortal3({ container, ...restProps }, ref) {
9537 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
9538 index_parts_exports.Portal,
9539 {
9540 container: container ?? getWpCompatOverlaySlot(),
9541 ...restProps,
9542 ref
9543 }
9544 );
9545 }
9546 );
9547
9548 // packages/ui/build-module/tooltip/positioner.mjs
9549 var import_element13 = __toESM(require_element(), 1);
9550 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
9551 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
9552 function getRuntime4() {
9553 const globalScope = globalThis;
9554 if (globalScope.__wpStyleRuntime) {
9555 return globalScope.__wpStyleRuntime;
9556 }
9557 globalScope.__wpStyleRuntime = {
9558 documents: /* @__PURE__ */ new Map(),
9559 styles: /* @__PURE__ */ new Map(),
9560 injectedStyles: /* @__PURE__ */ new WeakMap()
9561 };
9562 if (typeof document !== "undefined") {
9563 registerDocument4(document);
9564 }
9565 return globalScope.__wpStyleRuntime;
9566 }
9567 function documentContainsStyleHash4(targetDocument, hash) {
9568 if (!targetDocument.head) {
9569 return false;
9570 }
9571 for (const style of targetDocument.head.querySelectorAll(
9572 `style[${STYLE_HASH_ATTRIBUTE4}]`
9573 )) {
9574 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
9575 return true;
9576 }
9577 }
9578 return false;
9579 }
9580 function injectStyle4(targetDocument, hash, css) {
9581 if (!targetDocument.head) {
9582 return;
9583 }
9584 const runtime = getRuntime4();
9585 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9586 if (!injectedStyles) {
9587 injectedStyles = /* @__PURE__ */ new Set();
9588 runtime.injectedStyles.set(targetDocument, injectedStyles);
9589 }
9590 if (injectedStyles.has(hash)) {
9591 return;
9592 }
9593 if (documentContainsStyleHash4(targetDocument, hash)) {
9594 injectedStyles.add(hash);
9595 return;
9596 }
9597 const style = targetDocument.createElement("style");
9598 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
9599 style.appendChild(targetDocument.createTextNode(css));
9600 targetDocument.head.appendChild(style);
9601 injectedStyles.add(hash);
9602 }
9603 function registerDocument4(targetDocument) {
9604 const runtime = getRuntime4();
9605 runtime.documents.set(
9606 targetDocument,
9607 (runtime.documents.get(targetDocument) ?? 0) + 1
9608 );
9609 for (const [hash, css] of runtime.styles) {
9610 injectStyle4(targetDocument, hash, css);
9611 }
9612 return () => {
9613 const count = runtime.documents.get(targetDocument);
9614 if (count === void 0) {
9615 return;
9616 }
9617 if (count <= 1) {
9618 runtime.documents.delete(targetDocument);
9619 return;
9620 }
9621 runtime.documents.set(targetDocument, count - 1);
9622 };
9623 }
9624 function registerStyle4(hash, css) {
9625 const runtime = getRuntime4();
9626 runtime.styles.set(hash, css);
9627 for (const targetDocument of runtime.documents.keys()) {
9628 injectStyle4(targetDocument, hash, css);
9629 }
9630 }
9631 if (typeof process === "undefined" || true) {
9632 registerStyle4("e3ae230cea", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}");
9633 }
9634 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
9635 if (typeof process === "undefined" || true) {
9636 registerStyle4("8293efbb49", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-sm,2px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}');
9637 }
9638 var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9639 var Positioner = (0, import_element13.forwardRef)(
9640 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
9641 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
9642 index_parts_exports.Positioner,
9643 {
9644 ref,
9645 align,
9646 side,
9647 sideOffset,
9648 ...props,
9649 className: clsx_default(
9650 resets_default["box-sizing"],
9651 style_default3.positioner,
9652 className
9653 )
9654 }
9655 );
9656 }
9657 );
9658
9659 // packages/ui/build-module/tooltip/popup.mjs
9660 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
9661 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
9662 function getRuntime5() {
9663 const globalScope = globalThis;
9664 if (globalScope.__wpStyleRuntime) {
9665 return globalScope.__wpStyleRuntime;
9666 }
9667 globalScope.__wpStyleRuntime = {
9668 documents: /* @__PURE__ */ new Map(),
9669 styles: /* @__PURE__ */ new Map(),
9670 injectedStyles: /* @__PURE__ */ new WeakMap()
9671 };
9672 if (typeof document !== "undefined") {
9673 registerDocument5(document);
9674 }
9675 return globalScope.__wpStyleRuntime;
9676 }
9677 function documentContainsStyleHash5(targetDocument, hash) {
9678 if (!targetDocument.head) {
9679 return false;
9680 }
9681 for (const style of targetDocument.head.querySelectorAll(
9682 `style[${STYLE_HASH_ATTRIBUTE5}]`
9683 )) {
9684 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
9685 return true;
9686 }
9687 }
9688 return false;
9689 }
9690 function injectStyle5(targetDocument, hash, css) {
9691 if (!targetDocument.head) {
9692 return;
9693 }
9694 const runtime = getRuntime5();
9695 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9696 if (!injectedStyles) {
9697 injectedStyles = /* @__PURE__ */ new Set();
9698 runtime.injectedStyles.set(targetDocument, injectedStyles);
9699 }
9700 if (injectedStyles.has(hash)) {
9701 return;
9702 }
9703 if (documentContainsStyleHash5(targetDocument, hash)) {
9704 injectedStyles.add(hash);
9705 return;
9706 }
9707 const style = targetDocument.createElement("style");
9708 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
9709 style.appendChild(targetDocument.createTextNode(css));
9710 targetDocument.head.appendChild(style);
9711 injectedStyles.add(hash);
9712 }
9713 function registerDocument5(targetDocument) {
9714 const runtime = getRuntime5();
9715 runtime.documents.set(
9716 targetDocument,
9717 (runtime.documents.get(targetDocument) ?? 0) + 1
9718 );
9719 for (const [hash, css] of runtime.styles) {
9720 injectStyle5(targetDocument, hash, css);
9721 }
9722 return () => {
9723 const count = runtime.documents.get(targetDocument);
9724 if (count === void 0) {
9725 return;
9726 }
9727 if (count <= 1) {
9728 runtime.documents.delete(targetDocument);
9729 return;
9730 }
9731 runtime.documents.set(targetDocument, count - 1);
9732 };
9733 }
9734 function registerStyle5(hash, css) {
9735 const runtime = getRuntime5();
9736 runtime.styles.set(hash, css);
9737 for (const targetDocument of runtime.documents.keys()) {
9738 injectStyle5(targetDocument, hash, css);
9739 }
9740 }
9741 if (typeof process === "undefined" || true) {
9742 registerStyle5("8293efbb49", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-sm,2px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}');
9743 }
9744 var style_default4 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9745 var ThemeProvider = unlock2(import_theme.privateApis).ThemeProvider;
9746 var Popup = (0, import_element14.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
9747 const popupContent = (
9748 /* This should ideally use whatever dark color makes sense,
9749 * and not be hardcoded to #1e1e1e. The solutions would be to:
9750 * - review the design of the tooltip, in case we want to stop
9751 * hardcoding it to a dark background
9752 * - create new semantic tokens as needed (aliasing either the
9753 * "inverted bg" or "perma-dark bg" private tokens) and have
9754 * Tooltip.Popup use them;
9755 * - remove the hardcoded `bg` setting from the `ThemeProvider`
9756 * below
9757 */
9758 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ThemeProvider, { color: { bg: "#1e1e1e" }, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
9759 index_parts_exports.Popup,
9760 {
9761 ref,
9762 className: clsx_default(style_default4.popup, className),
9763 ...props,
9764 children
9765 }
9766 ) })
9767 );
9768 const positionedPopup = renderSlotWithChildren(
9769 positioner,
9770 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Positioner, {}),
9771 popupContent
9772 );
9773 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Portal, {}), positionedPopup);
9774 });
9775
9776 // packages/ui/build-module/tooltip/trigger.mjs
9777 var import_element15 = __toESM(require_element(), 1);
9778 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
9779 var Trigger = (0, import_element15.forwardRef)(
9780 function TooltipTrigger3(props, ref) {
9781 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(index_parts_exports.Trigger, { ref, ...props });
9782 }
9783 );
9784
9785 // packages/ui/build-module/tooltip/root.mjs
9786 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
9787 function Root(props) {
9788 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(index_parts_exports.Root, { ...props });
9789 }
9790
9791 // packages/ui/build-module/tooltip/provider.mjs
9792 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
9793 function Provider({ ...props }) {
9794 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(index_parts_exports.Provider, { ...props });
9795 }
9796
9797 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
9798 var import_element16 = __toESM(require_element(), 1);
9799 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
9800 function getRuntime6() {
9801 const globalScope = globalThis;
9802 if (globalScope.__wpStyleRuntime) {
9803 return globalScope.__wpStyleRuntime;
9804 }
9805 globalScope.__wpStyleRuntime = {
9806 documents: /* @__PURE__ */ new Map(),
9807 styles: /* @__PURE__ */ new Map(),
9808 injectedStyles: /* @__PURE__ */ new WeakMap()
9809 };
9810 if (typeof document !== "undefined") {
9811 registerDocument6(document);
9812 }
9813 return globalScope.__wpStyleRuntime;
9814 }
9815 function documentContainsStyleHash6(targetDocument, hash) {
9816 if (!targetDocument.head) {
9817 return false;
9818 }
9819 for (const style of targetDocument.head.querySelectorAll(
9820 `style[${STYLE_HASH_ATTRIBUTE6}]`
9821 )) {
9822 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
9823 return true;
9824 }
9825 }
9826 return false;
9827 }
9828 function injectStyle6(targetDocument, hash, css) {
9829 if (!targetDocument.head) {
9830 return;
9831 }
9832 const runtime = getRuntime6();
9833 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9834 if (!injectedStyles) {
9835 injectedStyles = /* @__PURE__ */ new Set();
9836 runtime.injectedStyles.set(targetDocument, injectedStyles);
9837 }
9838 if (injectedStyles.has(hash)) {
9839 return;
9840 }
9841 if (documentContainsStyleHash6(targetDocument, hash)) {
9842 injectedStyles.add(hash);
9843 return;
9844 }
9845 const style = targetDocument.createElement("style");
9846 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
9847 style.appendChild(targetDocument.createTextNode(css));
9848 targetDocument.head.appendChild(style);
9849 injectedStyles.add(hash);
9850 }
9851 function registerDocument6(targetDocument) {
9852 const runtime = getRuntime6();
9853 runtime.documents.set(
9854 targetDocument,
9855 (runtime.documents.get(targetDocument) ?? 0) + 1
9856 );
9857 for (const [hash, css] of runtime.styles) {
9858 injectStyle6(targetDocument, hash, css);
9859 }
9860 return () => {
9861 const count = runtime.documents.get(targetDocument);
9862 if (count === void 0) {
9863 return;
9864 }
9865 if (count <= 1) {
9866 runtime.documents.delete(targetDocument);
9867 return;
9868 }
9869 runtime.documents.set(targetDocument, count - 1);
9870 };
9871 }
9872 function registerStyle6(hash, css) {
9873 const runtime = getRuntime6();
9874 runtime.styles.set(hash, css);
9875 for (const targetDocument of runtime.documents.keys()) {
9876 injectStyle6(targetDocument, hash, css);
9877 }
9878 }
9879 if (typeof process === "undefined" || true) {
9880 registerStyle6("c46e8cb841", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.f37b9e2e191ebd66__visually-hidden{word-wrap:normal;border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-break:normal}}");
9881 }
9882 var style_default5 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
9883 var VisuallyHidden = (0, import_element16.forwardRef)(
9884 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
9885 const element = useRender({
9886 render: render4,
9887 ref,
9888 props: mergeProps(
9889 { className: style_default5["visually-hidden"] },
9890 restProps,
9891 {
9892 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
9893 "data-visually-hidden": ""
9894 }
9895 )
9896 });
9897 return element;
9898 }
9899 );
9900
9901 // packages/dataviews/build-module/components/dataviews-context/index.mjs
9902 var import_element17 = __toESM(require_element(), 1);
9903
9904 // packages/dataviews/build-module/constants.mjs
9905 var import_i18n = __toESM(require_i18n(), 1);
9906 var OPERATOR_IS_ANY = "isAny";
9907 var OPERATOR_IS_NONE = "isNone";
9908 var OPERATOR_IS_ALL = "isAll";
9909 var OPERATOR_IS_NOT_ALL = "isNotAll";
9910 var OPERATOR_BETWEEN = "between";
9911 var OPERATOR_IN_THE_PAST = "inThePast";
9912 var OPERATOR_OVER = "over";
9913 var OPERATOR_IS = "is";
9914 var OPERATOR_IS_NOT = "isNot";
9915 var OPERATOR_LESS_THAN = "lessThan";
9916 var OPERATOR_GREATER_THAN = "greaterThan";
9917 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
9918 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
9919 var OPERATOR_BEFORE = "before";
9920 var OPERATOR_AFTER = "after";
9921 var OPERATOR_BEFORE_INC = "beforeInc";
9922 var OPERATOR_AFTER_INC = "afterInc";
9923 var OPERATOR_CONTAINS = "contains";
9924 var OPERATOR_NOT_CONTAINS = "notContains";
9925 var OPERATOR_STARTS_WITH = "startsWith";
9926 var OPERATOR_ON = "on";
9927 var OPERATOR_NOT_ON = "notOn";
9928 var SORTING_DIRECTIONS = ["asc", "desc"];
9929 var sortArrows = { asc: "\u2191", desc: "\u2193" };
9930 var sortValues = { asc: "ascending", desc: "descending" };
9931 var sortLabels = {
9932 asc: (0, import_i18n.__)("Sort ascending"),
9933 desc: (0, import_i18n.__)("Sort descending")
9934 };
9935 var sortIcons = {
9936 asc: arrow_up_default,
9937 desc: arrow_down_default
9938 };
9939 var LAYOUT_TABLE = "table";
9940 var LAYOUT_GRID = "grid";
9941 var LAYOUT_LIST = "list";
9942 var LAYOUT_ACTIVITY = "activity";
9943 var LAYOUT_PICKER_GRID = "pickerGrid";
9944 var LAYOUT_PICKER_TABLE = "pickerTable";
9945
9946 // packages/dataviews/build-module/components/dataviews-context/index.mjs
9947 var DataViewsContext = (0, import_element17.createContext)({
9948 view: { type: LAYOUT_TABLE },
9949 onChangeView: () => {
9950 },
9951 fields: [],
9952 data: [],
9953 paginationInfo: {
9954 totalItems: 0,
9955 totalPages: 0
9956 },
9957 selection: [],
9958 onChangeSelection: () => {
9959 },
9960 setOpenedFilter: () => {
9961 },
9962 openedFilter: null,
9963 getItemId: (item) => item.id,
9964 isItemClickable: () => true,
9965 renderItemLink: void 0,
9966 containerWidth: 0,
9967 containerRef: (0, import_element17.createRef)(),
9968 resizeObserverRef: () => {
9969 },
9970 defaultLayouts: { list: {}, grid: {}, table: {} },
9971 filters: [],
9972 isShowingFilter: false,
9973 setIsShowingFilter: () => {
9974 },
9975 hasInitiallyLoaded: false,
9976 config: {
9977 perPageSizes: []
9978 },
9979 intersectionObserver: null
9980 });
9981 DataViewsContext.displayName = "DataViewsContext";
9982 var dataviews_context_default = DataViewsContext;
9983
9984 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
9985 var import_i18n21 = __toESM(require_i18n(), 1);
9986
9987 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
9988 var import_i18n9 = __toESM(require_i18n(), 1);
9989 var import_components6 = __toESM(require_components(), 1);
9990 var import_element25 = __toESM(require_element(), 1);
9991 var import_keycodes = __toESM(require_keycodes(), 1);
9992
9993 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
9994 var import_components = __toESM(require_components(), 1);
9995 var import_i18n2 = __toESM(require_i18n(), 1);
9996 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
9997 function DataViewsSelectionCheckbox({
9998 selection,
9999 onChangeSelection,
10000 item,
10001 getItemId,
10002 titleField,
10003 disabled: disabled2,
10004 ...extraProps
10005 }) {
10006 const id = getItemId(item);
10007 const isInSelectionArray = selection.includes(id);
10008 const checked = !disabled2 && isInSelectionArray;
10009 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n2.__)("(no title)");
10010 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
10011 import_components.CheckboxControl,
10012 {
10013 className: "dataviews-selection-checkbox",
10014 "aria-label": selectionLabel,
10015 "aria-disabled": disabled2,
10016 checked,
10017 onChange: () => {
10018 if (disabled2) {
10019 return;
10020 }
10021 onChangeSelection(
10022 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
10023 );
10024 },
10025 ...extraProps
10026 }
10027 );
10028 }
10029
10030 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10031 var import_components2 = __toESM(require_components(), 1);
10032 var import_i18n3 = __toESM(require_i18n(), 1);
10033 var import_element18 = __toESM(require_element(), 1);
10034 var import_data4 = __toESM(require_data(), 1);
10035 var import_compose = __toESM(require_compose(), 1);
10036
10037 // packages/dataviews/build-module/lock-unlock.mjs
10038 var import_private_apis3 = __toESM(require_private_apis(), 1);
10039 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
10040 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
10041 "@wordpress/dataviews"
10042 );
10043
10044 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10045 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
10046 var { Menu, kebabCase } = unlock3(import_components2.privateApis);
10047 function ButtonTrigger({
10048 action,
10049 onClick,
10050 items,
10051 variant
10052 }) {
10053 const label = typeof action.label === "string" ? action.label : action.label(items);
10054 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10055 import_components2.Button,
10056 {
10057 disabled: !!action.disabled,
10058 accessibleWhenDisabled: true,
10059 size: "compact",
10060 variant,
10061 onClick,
10062 children: label
10063 }
10064 );
10065 }
10066 function MenuItemTrigger({
10067 action,
10068 onClick,
10069 items
10070 }) {
10071 const label = typeof action.label === "string" ? action.label : action.label(items);
10072 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.ItemLabel, { children: label }) });
10073 }
10074 function ActionModal({
10075 action,
10076 items,
10077 closeModal
10078 }) {
10079 const label = typeof action.label === "string" ? action.label : action.label(items);
10080 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
10081 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10082 import_components2.Modal,
10083 {
10084 title: modalHeader || label,
10085 __experimentalHideHeader: !!action.hideModalHeader,
10086 onRequestClose: closeModal,
10087 focusOnMount: action.modalFocusOnMount ?? true,
10088 size: action.modalSize || "medium",
10089 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
10090 action.id
10091 )}`,
10092 children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(action.RenderModal, { items, closeModal })
10093 }
10094 );
10095 }
10096 function ActionsMenuGroup({
10097 actions,
10098 item,
10099 registry,
10100 setActiveModalAction
10101 }) {
10102 const { primaryActions, regularActions } = (0, import_element18.useMemo)(() => {
10103 return actions.reduce(
10104 (acc, action) => {
10105 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
10106 return acc;
10107 },
10108 {
10109 primaryActions: [],
10110 regularActions: []
10111 }
10112 );
10113 }, [actions]);
10114 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10115 MenuItemTrigger,
10116 {
10117 action,
10118 onClick: () => {
10119 if ("RenderModal" in action) {
10120 setActiveModalAction(action);
10121 return;
10122 }
10123 action.callback([item], { registry });
10124 },
10125 items: [item]
10126 },
10127 action.id
10128 ));
10129 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Menu.Group, { children: [
10130 renderActionGroup(primaryActions),
10131 renderActionGroup(regularActions)
10132 ] });
10133 }
10134 function ItemActions({
10135 item,
10136 actions,
10137 isCompact
10138 }) {
10139 const registry = (0, import_data4.useRegistry)();
10140 const { primaryActions, eligibleActions } = (0, import_element18.useMemo)(() => {
10141 const _eligibleActions = actions.filter(
10142 (action) => !action.isEligible || action.isEligible(item)
10143 );
10144 const _primaryActions = _eligibleActions.filter(
10145 (action) => action.isPrimary
10146 );
10147 return {
10148 primaryActions: _primaryActions,
10149 eligibleActions: _eligibleActions
10150 };
10151 }, [actions, item]);
10152 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10153 if (isCompact) {
10154 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10155 CompactItemActions,
10156 {
10157 item,
10158 actions: eligibleActions,
10159 isSmall: true,
10160 registry
10161 }
10162 );
10163 }
10164 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
10165 Stack,
10166 {
10167 direction: "row",
10168 justify: "flex-end",
10169 className: "dataviews-item-actions",
10170 style: {
10171 flexShrink: 0,
10172 width: "auto"
10173 },
10174 children: [
10175 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10176 PrimaryActions,
10177 {
10178 item,
10179 actions: primaryActions,
10180 registry
10181 }
10182 ),
10183 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
10184 // there if there are any actions at all.
10185 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10186 CompactItemActions,
10187 {
10188 item,
10189 actions: eligibleActions,
10190 registry
10191 }
10192 )
10193 ]
10194 }
10195 );
10196 }
10197 function CompactItemActions({
10198 item,
10199 actions,
10200 isSmall,
10201 registry
10202 }) {
10203 const [activeModalAction, setActiveModalAction] = (0, import_element18.useState)(
10204 null
10205 );
10206 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
10207 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Menu, { placement: "bottom-end", children: [
10208 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10209 Menu.TriggerButton,
10210 {
10211 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10212 import_components2.Button,
10213 {
10214 size: isSmall ? "small" : "compact",
10215 icon: more_vertical_default,
10216 label: (0, import_i18n3.__)("Actions"),
10217 accessibleWhenDisabled: true,
10218 disabled: !actions.length,
10219 className: "dataviews-all-actions-button"
10220 }
10221 )
10222 }
10223 ),
10224 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10225 ActionsMenuGroup,
10226 {
10227 actions,
10228 item,
10229 registry,
10230 setActiveModalAction
10231 }
10232 ) })
10233 ] }),
10234 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10235 ActionModal,
10236 {
10237 action: activeModalAction,
10238 items: [item],
10239 closeModal: () => setActiveModalAction(null)
10240 }
10241 )
10242 ] });
10243 }
10244 function PrimaryActions({
10245 item,
10246 actions,
10247 registry,
10248 buttonVariant
10249 }) {
10250 const [activeModalAction, setActiveModalAction] = (0, import_element18.useState)(null);
10251 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10252 if (isMobileViewport) {
10253 return null;
10254 }
10255 if (!Array.isArray(actions) || actions.length === 0) {
10256 return null;
10257 }
10258 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
10259 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10260 ButtonTrigger,
10261 {
10262 action,
10263 onClick: () => {
10264 if ("RenderModal" in action) {
10265 setActiveModalAction(action);
10266 return;
10267 }
10268 action.callback([item], { registry });
10269 },
10270 items: [item],
10271 variant: buttonVariant
10272 },
10273 action.id
10274 )),
10275 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10276 ActionModal,
10277 {
10278 action: activeModalAction,
10279 items: [item],
10280 closeModal: () => setActiveModalAction(null)
10281 }
10282 )
10283 ] });
10284 }
10285
10286 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10287 var import_components3 = __toESM(require_components(), 1);
10288 var import_i18n5 = __toESM(require_i18n(), 1);
10289 var import_element19 = __toESM(require_element(), 1);
10290 var import_data5 = __toESM(require_data(), 1);
10291 var import_compose2 = __toESM(require_compose(), 1);
10292
10293 // packages/dataviews/build-module/utils/get-footer-message.mjs
10294 var import_i18n4 = __toESM(require_i18n(), 1);
10295 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
10296 if (selectionCount > 0) {
10297 return (0, import_i18n4.sprintf)(
10298 /* translators: %d: number of items. */
10299 (0, import_i18n4._n)("%d Item selected", "%d Items selected", selectionCount),
10300 selectionCount
10301 );
10302 }
10303 if (onlyTotalCount || totalItems <= itemsCount) {
10304 return (0, import_i18n4.sprintf)(
10305 /* translators: %d: number of items. */
10306 (0, import_i18n4._n)("%d Item", "%d Items", totalItems),
10307 totalItems
10308 );
10309 }
10310 return (0, import_i18n4.sprintf)(
10311 /* translators: %1$d: number of items. %2$d: total number of items. */
10312 (0, import_i18n4._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
10313 itemsCount,
10314 totalItems
10315 );
10316 }
10317
10318 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10319 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
10320 function ActionWithModal({
10321 action,
10322 items,
10323 ActionTriggerComponent
10324 }) {
10325 const [isModalOpen, setIsModalOpen] = (0, import_element19.useState)(false);
10326 const actionTriggerProps = {
10327 action,
10328 onClick: () => {
10329 setIsModalOpen(true);
10330 },
10331 items
10332 };
10333 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
10334 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
10335 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10336 ActionModal,
10337 {
10338 action,
10339 items,
10340 closeModal: () => setIsModalOpen(false)
10341 }
10342 )
10343 ] });
10344 }
10345 function useHasAPossibleBulkAction(actions, item) {
10346 return (0, import_element19.useMemo)(() => {
10347 return actions.some((action) => {
10348 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10349 });
10350 }, [actions, item]);
10351 }
10352 function useSomeItemHasAPossibleBulkAction(actions, data) {
10353 return (0, import_element19.useMemo)(() => {
10354 return data.some((item) => {
10355 return actions.some((action) => {
10356 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10357 });
10358 });
10359 }, [actions, data]);
10360 }
10361 function BulkSelectionCheckbox({
10362 selection,
10363 onChangeSelection,
10364 data,
10365 actions,
10366 getItemId,
10367 disableSelectAll = false
10368 }) {
10369 const selectableItems = (0, import_element19.useMemo)(() => {
10370 return data.filter((item) => {
10371 return actions.some(
10372 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
10373 );
10374 });
10375 }, [data, actions]);
10376 const selectedItems = data.filter(
10377 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
10378 );
10379 const hasSelection = selection.length > 0;
10380 const areAllSelected = selectedItems.length === selectableItems.length;
10381 if (disableSelectAll) {
10382 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10383 import_components3.CheckboxControl,
10384 {
10385 className: "dataviews-view-table-selection-checkbox",
10386 checked: hasSelection,
10387 disabled: !hasSelection,
10388 onChange: () => {
10389 onChangeSelection([]);
10390 },
10391 "aria-label": (0, import_i18n5.__)("Deselect all")
10392 }
10393 );
10394 }
10395 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10396 import_components3.CheckboxControl,
10397 {
10398 className: "dataviews-view-table-selection-checkbox",
10399 checked: areAllSelected,
10400 indeterminate: !areAllSelected && !!selectedItems.length,
10401 onChange: () => {
10402 if (areAllSelected) {
10403 onChangeSelection([]);
10404 } else {
10405 onChangeSelection(
10406 selectableItems.map((item) => getItemId(item))
10407 );
10408 }
10409 },
10410 "aria-label": areAllSelected ? (0, import_i18n5.__)("Deselect all") : (0, import_i18n5.__)("Select all")
10411 }
10412 );
10413 }
10414 function ActionTrigger({
10415 action,
10416 onClick,
10417 isBusy,
10418 items
10419 }) {
10420 const label = typeof action.label === "string" ? action.label : action.label(items);
10421 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
10422 if (isMobile) {
10423 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10424 import_components3.Button,
10425 {
10426 disabled: isBusy,
10427 accessibleWhenDisabled: true,
10428 label,
10429 icon: action.icon,
10430 size: "compact",
10431 onClick,
10432 isBusy
10433 }
10434 );
10435 }
10436 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10437 import_components3.Button,
10438 {
10439 disabled: isBusy,
10440 accessibleWhenDisabled: true,
10441 size: "compact",
10442 onClick,
10443 isBusy,
10444 children: label
10445 }
10446 );
10447 }
10448 var EMPTY_ARRAY2 = [];
10449 function ActionButton({
10450 action,
10451 selectedItems,
10452 actionInProgress,
10453 setActionInProgress
10454 }) {
10455 const registry = (0, import_data5.useRegistry)();
10456 const selectedEligibleItems = (0, import_element19.useMemo)(() => {
10457 return selectedItems.filter((item) => {
10458 return !action.isEligible || action.isEligible(item);
10459 });
10460 }, [action, selectedItems]);
10461 if ("RenderModal" in action) {
10462 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10463 ActionWithModal,
10464 {
10465 action,
10466 items: selectedEligibleItems,
10467 ActionTriggerComponent: ActionTrigger
10468 },
10469 action.id
10470 );
10471 }
10472 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10473 ActionTrigger,
10474 {
10475 action,
10476 onClick: async () => {
10477 setActionInProgress(action.id);
10478 await action.callback(selectedItems, {
10479 registry
10480 });
10481 setActionInProgress(null);
10482 },
10483 items: selectedEligibleItems,
10484 isBusy: actionInProgress === action.id
10485 },
10486 action.id
10487 );
10488 }
10489 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
10490 const message2 = getFooterMessage(
10491 selection.length,
10492 data.length,
10493 paginationInfo.totalItems,
10494 isInfiniteScroll
10495 );
10496 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
10497 Stack,
10498 {
10499 direction: "row",
10500 className: "dataviews-bulk-actions-footer__container",
10501 gap: "md",
10502 align: "center",
10503 children: [
10504 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10505 BulkSelectionCheckbox,
10506 {
10507 selection,
10508 onChangeSelection,
10509 data,
10510 actions,
10511 getItemId,
10512 disableSelectAll: isInfiniteScroll
10513 }
10514 ),
10515 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
10516 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
10517 Stack,
10518 {
10519 direction: "row",
10520 className: "dataviews-bulk-actions-footer__action-buttons",
10521 gap: "xs",
10522 children: [
10523 actionsToShow.map((action) => {
10524 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10525 ActionButton,
10526 {
10527 action,
10528 selectedItems,
10529 actionInProgress,
10530 setActionInProgress
10531 },
10532 action.id
10533 );
10534 }),
10535 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10536 import_components3.Button,
10537 {
10538 icon: close_small_default,
10539 showTooltip: true,
10540 tooltipPosition: "top",
10541 size: "compact",
10542 label: (0, import_i18n5.__)("Cancel"),
10543 disabled: !!actionInProgress,
10544 accessibleWhenDisabled: false,
10545 onClick: () => {
10546 onChangeSelection(EMPTY_ARRAY2);
10547 }
10548 }
10549 )
10550 ]
10551 }
10552 )
10553 ]
10554 }
10555 );
10556 }
10557 function FooterContent({
10558 selection,
10559 actions,
10560 onChangeSelection,
10561 data,
10562 getItemId,
10563 isInfiniteScroll,
10564 paginationInfo
10565 }) {
10566 const [actionInProgress, setActionInProgress] = (0, import_element19.useState)(
10567 null
10568 );
10569 const footerContentRef = (0, import_element19.useRef)(void 0);
10570 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
10571 const bulkActions = (0, import_element19.useMemo)(
10572 () => actions.filter((action) => action.supportsBulk),
10573 [actions]
10574 );
10575 const selectableItems = (0, import_element19.useMemo)(() => {
10576 return data.filter((item) => {
10577 return bulkActions.some(
10578 (action) => !action.isEligible || action.isEligible(item)
10579 );
10580 });
10581 }, [data, bulkActions]);
10582 const selectedItems = (0, import_element19.useMemo)(() => {
10583 return data.filter(
10584 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
10585 );
10586 }, [selection, data, getItemId, selectableItems]);
10587 const actionsToShow = (0, import_element19.useMemo)(
10588 () => actions.filter((action) => {
10589 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
10590 (item) => !action.isEligible || action.isEligible(item)
10591 );
10592 }),
10593 [actions, selectedItems, isMobile]
10594 );
10595 if (!actionInProgress) {
10596 if (footerContentRef.current) {
10597 footerContentRef.current = void 0;
10598 }
10599 return renderFooterContent(
10600 data,
10601 actions,
10602 getItemId,
10603 isInfiniteScroll,
10604 selection,
10605 actionsToShow,
10606 selectedItems,
10607 actionInProgress,
10608 setActionInProgress,
10609 onChangeSelection,
10610 paginationInfo
10611 );
10612 } else if (!footerContentRef.current) {
10613 footerContentRef.current = renderFooterContent(
10614 data,
10615 actions,
10616 getItemId,
10617 isInfiniteScroll,
10618 selection,
10619 actionsToShow,
10620 selectedItems,
10621 actionInProgress,
10622 setActionInProgress,
10623 onChangeSelection,
10624 paginationInfo
10625 );
10626 }
10627 return footerContentRef.current;
10628 }
10629 function BulkActionsFooter() {
10630 const {
10631 data,
10632 selection,
10633 actions = EMPTY_ARRAY2,
10634 onChangeSelection,
10635 getItemId,
10636 paginationInfo,
10637 view
10638 } = (0, import_element19.useContext)(dataviews_context_default);
10639 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10640 FooterContent,
10641 {
10642 selection,
10643 onChangeSelection,
10644 data,
10645 actions,
10646 getItemId,
10647 isInfiniteScroll: !!view.infiniteScrollEnabled,
10648 paginationInfo
10649 }
10650 );
10651 }
10652
10653 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
10654 var import_i18n6 = __toESM(require_i18n(), 1);
10655 var import_components4 = __toESM(require_components(), 1);
10656 var import_element20 = __toESM(require_element(), 1);
10657
10658 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
10659 function getHideableFields(view, fields) {
10660 const togglableFields = [
10661 view?.titleField,
10662 view?.mediaField,
10663 view?.descriptionField
10664 ].filter(Boolean);
10665 return fields.filter(
10666 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
10667 );
10668 }
10669
10670 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
10671 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
10672 var { Menu: Menu2 } = unlock3(import_components4.privateApis);
10673 function WithMenuSeparators({ children }) {
10674 return import_element20.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_element20.Fragment, { children: [
10675 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Separator, {}),
10676 child
10677 ] }, i2));
10678 }
10679 var _HeaderMenu = (0, import_element20.forwardRef)(function HeaderMenu({
10680 fieldId,
10681 view,
10682 fields,
10683 onChangeView,
10684 onHide,
10685 setOpenedFilter,
10686 canMove = true,
10687 canInsertLeft = true,
10688 canInsertRight = true
10689 }, ref) {
10690 const visibleFieldIds = view.fields ?? [];
10691 const index2 = visibleFieldIds?.indexOf(fieldId);
10692 const isSorted = view.sort?.field === fieldId;
10693 let isHidable = false;
10694 let isSortable = false;
10695 let canAddFilter = false;
10696 let operators = [];
10697 const field = fields.find((f2) => f2.id === fieldId);
10698 const { setIsShowingFilter } = (0, import_element20.useContext)(dataviews_context_default);
10699 if (!field) {
10700 return null;
10701 }
10702 isHidable = field.enableHiding !== false;
10703 isSortable = field.enableSorting !== false;
10704 const header = field.header;
10705 operators = !!field.filterBy && field.filterBy?.operators || [];
10706 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
10707 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
10708 return header;
10709 }
10710 const hiddenFields = getHideableFields(view, fields).filter(
10711 (f2) => !visibleFieldIds.includes(f2.id)
10712 );
10713 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
10714 const isRtl = (0, import_i18n6.isRTL)();
10715 return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2, { children: [
10716 /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
10717 Menu2.TriggerButton,
10718 {
10719 render: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10720 import_components4.Button,
10721 {
10722 size: "compact",
10723 className: "dataviews-view-table-header-button",
10724 ref,
10725 variant: "tertiary"
10726 }
10727 ),
10728 children: [
10729 header,
10730 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
10731 ]
10732 }
10733 ),
10734 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(WithMenuSeparators, { children: [
10735 isSortable && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
10736 (direction) => {
10737 const isChecked = view.sort && isSorted && view.sort.direction === direction;
10738 const value = `${fieldId}-${direction}`;
10739 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10740 Menu2.RadioItem,
10741 {
10742 name: "view-table-sorting",
10743 value,
10744 checked: isChecked,
10745 onChange: () => {
10746 onChangeView({
10747 ...view,
10748 sort: {
10749 field: fieldId,
10750 direction
10751 },
10752 showLevels: false
10753 });
10754 },
10755 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
10756 },
10757 value
10758 );
10759 }
10760 ) }),
10761 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10762 Menu2.Item,
10763 {
10764 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: funnel_default }),
10765 onClick: () => {
10766 setOpenedFilter(fieldId);
10767 setIsShowingFilter(true);
10768 onChangeView({
10769 ...view,
10770 page: 1,
10771 filters: [
10772 ...view.filters || [],
10773 {
10774 field: fieldId,
10775 value: void 0,
10776 operator: operators[0]
10777 }
10778 ]
10779 });
10780 },
10781 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Add filter") })
10782 }
10783 ) }),
10784 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2.Group, { children: [
10785 canMove && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10786 Menu2.Item,
10787 {
10788 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: arrow_left_default }),
10789 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
10790 onClick: () => {
10791 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
10792 const newFields = [
10793 ...visibleFieldIds
10794 ];
10795 newFields.splice(index2, 1);
10796 newFields.splice(
10797 targetIndex,
10798 0,
10799 fieldId
10800 );
10801 onChangeView({
10802 ...view,
10803 fields: newFields
10804 });
10805 },
10806 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move left") })
10807 }
10808 ),
10809 canMove && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10810 Menu2.Item,
10811 {
10812 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: arrow_right_default }),
10813 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
10814 onClick: () => {
10815 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
10816 const newFields = [
10817 ...visibleFieldIds
10818 ];
10819 newFields.splice(index2, 1);
10820 newFields.splice(
10821 targetIndex,
10822 0,
10823 fieldId
10824 );
10825 onChangeView({
10826 ...view,
10827 fields: newFields
10828 });
10829 },
10830 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move right") })
10831 }
10832 ),
10833 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2, { children: [
10834 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert left") }) }),
10835 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
10836 const insertIndex = isRtl ? index2 + 1 : index2;
10837 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10838 Menu2.Item,
10839 {
10840 onClick: () => {
10841 onChangeView({
10842 ...view,
10843 fields: [
10844 ...visibleFieldIds.slice(
10845 0,
10846 insertIndex
10847 ),
10848 hiddenField.id,
10849 ...visibleFieldIds.slice(
10850 insertIndex
10851 )
10852 ]
10853 });
10854 },
10855 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
10856 },
10857 hiddenField.id
10858 );
10859 }) })
10860 ] }),
10861 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2, { children: [
10862 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert right") }) }),
10863 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
10864 const insertIndex = isRtl ? index2 : index2 + 1;
10865 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10866 Menu2.Item,
10867 {
10868 onClick: () => {
10869 onChangeView({
10870 ...view,
10871 fields: [
10872 ...visibleFieldIds.slice(
10873 0,
10874 insertIndex
10875 ),
10876 hiddenField.id,
10877 ...visibleFieldIds.slice(
10878 insertIndex
10879 )
10880 ]
10881 });
10882 },
10883 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
10884 },
10885 hiddenField.id
10886 );
10887 }) })
10888 ] }),
10889 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10890 Menu2.Item,
10891 {
10892 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: unseen_default }),
10893 onClick: () => {
10894 onHide(field);
10895 onChangeView({
10896 ...view,
10897 fields: visibleFieldIds.filter(
10898 (id) => id !== fieldId
10899 )
10900 });
10901 },
10902 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Hide column") })
10903 }
10904 )
10905 ] })
10906 ] }) })
10907 ] });
10908 });
10909 var ColumnHeaderMenu = _HeaderMenu;
10910 var column_header_menu_default = ColumnHeaderMenu;
10911
10912 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
10913 var import_element21 = __toESM(require_element(), 1);
10914 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
10915 function getClickableItemProps({
10916 item,
10917 isItemClickable,
10918 onClickItem,
10919 className
10920 }) {
10921 if (!isItemClickable(item) || !onClickItem) {
10922 return { className };
10923 }
10924 return {
10925 className: className ? `${className} ${className}--clickable` : void 0,
10926 role: "button",
10927 tabIndex: 0,
10928 onClick: (event) => {
10929 event.stopPropagation();
10930 onClickItem(item);
10931 },
10932 onKeyDown: (event) => {
10933 if (event.key === "Enter" || event.key === "" || event.key === " ") {
10934 event.stopPropagation();
10935 onClickItem(item);
10936 }
10937 }
10938 };
10939 }
10940 function ItemClickWrapper({
10941 item,
10942 isItemClickable,
10943 onClickItem,
10944 renderItemLink,
10945 className,
10946 children,
10947 ...extraProps
10948 }) {
10949 if (!isItemClickable(item)) {
10950 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className, ...extraProps, children });
10951 }
10952 if (renderItemLink) {
10953 const renderedElement = renderItemLink({
10954 item,
10955 className: `${className} ${className}--clickable`,
10956 ...extraProps,
10957 children
10958 });
10959 return (0, import_element21.cloneElement)(renderedElement, {
10960 onClick: (event) => {
10961 event.stopPropagation();
10962 if (renderedElement.props.onClick) {
10963 renderedElement.props.onClick(event);
10964 }
10965 },
10966 onKeyDown: (event) => {
10967 if (event.key === "Enter" || event.key === "" || event.key === " ") {
10968 event.stopPropagation();
10969 if (renderedElement.props.onKeyDown) {
10970 renderedElement.props.onKeyDown(event);
10971 }
10972 }
10973 }
10974 });
10975 }
10976 const clickProps = getClickableItemProps({
10977 item,
10978 isItemClickable,
10979 onClickItem,
10980 className
10981 });
10982 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { ...clickProps, ...extraProps, children });
10983 }
10984
10985 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
10986 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
10987 function ColumnPrimary({
10988 item,
10989 level,
10990 titleField,
10991 mediaField,
10992 descriptionField,
10993 onClickItem,
10994 renderItemLink,
10995 isItemClickable
10996 }) {
10997 return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
10998 mediaField && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
10999 ItemClickWrapper,
11000 {
11001 item,
11002 isItemClickable,
11003 onClickItem,
11004 renderItemLink,
11005 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
11006 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
11007 children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
11008 mediaField.render,
11009 {
11010 item,
11011 field: mediaField,
11012 config: { sizes: "32px" }
11013 }
11014 )
11015 }
11016 ),
11017 /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
11018 Stack,
11019 {
11020 direction: "column",
11021 align: "flex-start",
11022 className: "dataviews-view-table__primary-column-content",
11023 children: [
11024 titleField && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
11025 ItemClickWrapper,
11026 {
11027 item,
11028 isItemClickable,
11029 onClickItem,
11030 renderItemLink,
11031 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
11032 children: [
11033 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { className: "dataviews-view-table__level", children: [
11034 Array(level).fill("\u2014").join(" "),
11035 "\xA0"
11036 ] }),
11037 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(titleField.render, { item, field: titleField })
11038 ]
11039 }
11040 ),
11041 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
11042 descriptionField.render,
11043 {
11044 item,
11045 field: descriptionField
11046 }
11047 )
11048 ]
11049 }
11050 )
11051 ] });
11052 }
11053 var column_primary_default = ColumnPrimary;
11054
11055 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
11056 var import_element22 = __toESM(require_element(), 1);
11057 var import_i18n7 = __toESM(require_i18n(), 1);
11058 var isScrolledToEnd = (element) => {
11059 if ((0, import_i18n7.isRTL)()) {
11060 const scrollLeft = Math.abs(element.scrollLeft);
11061 return scrollLeft <= 1;
11062 }
11063 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
11064 };
11065 function useScrollState({
11066 scrollContainerRef,
11067 enabledHorizontal = false
11068 }) {
11069 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element22.useState)(false);
11070 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element22.useState)(false);
11071 const handleScroll = (0, import_element22.useCallback)(() => {
11072 const scrollContainer = scrollContainerRef.current;
11073 if (!scrollContainer) {
11074 return;
11075 }
11076 if (enabledHorizontal) {
11077 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
11078 }
11079 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
11080 }, [scrollContainerRef, enabledHorizontal]);
11081 (0, import_element22.useEffect)(() => {
11082 if (typeof window === "undefined" || !scrollContainerRef.current) {
11083 return () => {
11084 };
11085 }
11086 const scrollContainer = scrollContainerRef.current;
11087 handleScroll();
11088 scrollContainer.addEventListener("scroll", handleScroll);
11089 window.addEventListener("resize", handleScroll);
11090 return () => {
11091 scrollContainer.removeEventListener("scroll", handleScroll);
11092 window.removeEventListener("resize", handleScroll);
11093 };
11094 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
11095 return { isHorizontalScrollEnd, isVerticallyScrolled };
11096 }
11097
11098 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
11099 function getDataByGroup(data, groupByField) {
11100 return data.reduce((groups, item) => {
11101 const groupName = groupByField.getValue({ item });
11102 if (!groups.has(groupName)) {
11103 groups.set(groupName, []);
11104 }
11105 groups.get(groupName)?.push(item);
11106 return groups;
11107 }, /* @__PURE__ */ new Map());
11108 }
11109
11110 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
11111 var import_components5 = __toESM(require_components(), 1);
11112 var import_i18n8 = __toESM(require_i18n(), 1);
11113 var import_element23 = __toESM(require_element(), 1);
11114 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
11115 function FieldItem({
11116 field,
11117 isVisible: isVisible2,
11118 onToggleVisibility
11119 }) {
11120 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components5.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
11121 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components5.Icon, { icon: check_default }) }),
11122 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
11123 ] }) });
11124 }
11125 function isDefined(item) {
11126 return !!item;
11127 }
11128 function PropertiesSection({
11129 showLabel = true
11130 }) {
11131 const { view, fields, onChangeView } = (0, import_element23.useContext)(dataviews_context_default);
11132 const regularFields = getHideableFields(view, fields);
11133 if (!regularFields?.length) {
11134 return null;
11135 }
11136 const titleField = fields.find((f2) => f2.id === view.titleField);
11137 const previewField2 = fields.find((f2) => f2.id === view.mediaField);
11138 const descriptionField = fields.find(
11139 (f2) => f2.id === view.descriptionField
11140 );
11141 const lockedFields = [
11142 {
11143 field: titleField,
11144 isVisibleFlag: "showTitle"
11145 },
11146 {
11147 field: previewField2,
11148 isVisibleFlag: "showMedia"
11149 },
11150 {
11151 field: descriptionField,
11152 isVisibleFlag: "showDescription"
11153 }
11154 ].filter(({ field }) => isDefined(field));
11155 const visibleFieldIds = view.fields ?? [];
11156 const visibleRegularFieldsCount = regularFields.filter(
11157 (f2) => visibleFieldIds.includes(f2.id)
11158 ).length;
11159 const visibleLockedFields = lockedFields.filter(
11160 ({ isVisibleFlag }) => (
11161 // @ts-expect-error
11162 view[isVisibleFlag] ?? true
11163 )
11164 );
11165 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
11166 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
11167 return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
11168 showLabel && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n8.__)("Properties") }),
11169 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
11170 Stack,
11171 {
11172 direction: "column",
11173 className: "dataviews-view-config__properties",
11174 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
11175 lockedFields.map(({ field, isVisibleFlag }) => {
11176 const isVisible2 = view[isVisibleFlag] ?? true;
11177 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
11178 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
11179 FieldItem,
11180 {
11181 field: fieldToRender,
11182 isVisible: isVisible2,
11183 onToggleVisibility: () => {
11184 onChangeView({
11185 ...view,
11186 [isVisibleFlag]: !isVisible2
11187 });
11188 }
11189 },
11190 field.id
11191 );
11192 }),
11193 regularFields.map((field) => {
11194 const isVisible2 = visibleFieldIds.includes(field.id);
11195 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
11196 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
11197 FieldItem,
11198 {
11199 field: fieldToRender,
11200 isVisible: isVisible2,
11201 onToggleVisibility: () => {
11202 onChangeView({
11203 ...view,
11204 fields: isVisible2 ? visibleFieldIds.filter(
11205 (fieldId) => fieldId !== field.id
11206 ) : [...visibleFieldIds, field.id]
11207 });
11208 }
11209 },
11210 field.id
11211 );
11212 })
11213 ] })
11214 }
11215 )
11216 ] });
11217 }
11218
11219 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
11220 var import_element24 = __toESM(require_element(), 1);
11221 function useDelayedLoading(isLoading, options = { delay: 400 }) {
11222 const [showLoader, setShowLoader] = (0, import_element24.useState)(false);
11223 (0, import_element24.useEffect)(() => {
11224 if (!isLoading) {
11225 return;
11226 }
11227 const timeout = setTimeout(() => {
11228 setShowLoader(true);
11229 }, options.delay);
11230 return () => {
11231 clearTimeout(timeout);
11232 setShowLoader(false);
11233 };
11234 }, [isLoading, options.delay]);
11235 return showLoader;
11236 }
11237
11238 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
11239 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
11240 function getEffectiveAlign(explicitAlign, fieldType) {
11241 if (explicitAlign) {
11242 return explicitAlign;
11243 }
11244 if (fieldType === "integer" || fieldType === "number") {
11245 return "end";
11246 }
11247 return void 0;
11248 }
11249 function TableColumnField({
11250 item,
11251 fields,
11252 column,
11253 align
11254 }) {
11255 const field = fields.find((f2) => f2.id === column);
11256 if (!field) {
11257 return null;
11258 }
11259 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
11260 "dataviews-view-table__cell-align-end": align === "end",
11261 "dataviews-view-table__cell-align-center": align === "center"
11262 });
11263 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(field.render, { item, field }) });
11264 }
11265 function TableRow({
11266 hasBulkActions,
11267 item,
11268 level,
11269 actions,
11270 fields,
11271 id,
11272 view,
11273 titleField,
11274 mediaField,
11275 descriptionField,
11276 selection,
11277 getItemId,
11278 isItemClickable,
11279 onClickItem,
11280 renderItemLink,
11281 onChangeSelection,
11282 isActionsColumnSticky,
11283 posinset
11284 }) {
11285 const { paginationInfo } = (0, import_element25.useContext)(dataviews_context_default);
11286 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
11287 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
11288 const {
11289 showTitle = true,
11290 showMedia = true,
11291 showDescription = true,
11292 infiniteScrollEnabled
11293 } = view;
11294 const isTouchDeviceRef = (0, import_element25.useRef)(false);
11295 const columns = view.fields ?? [];
11296 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11297 return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
11298 "tr",
11299 {
11300 className: clsx_default("dataviews-view-table__row", {
11301 "is-selected": hasPossibleBulkAction && isSelected2,
11302 "has-bulk-actions": hasPossibleBulkAction
11303 }),
11304 onTouchStart: () => {
11305 isTouchDeviceRef.current = true;
11306 },
11307 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
11308 "aria-posinset": posinset,
11309 role: infiniteScrollEnabled ? "article" : void 0,
11310 onMouseDown: (event) => {
11311 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11312 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
11313 event?.preventDefault();
11314 }
11315 },
11316 onClick: (event) => {
11317 if (!hasPossibleBulkAction) {
11318 return;
11319 }
11320 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11321 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
11322 onChangeSelection(
11323 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
11324 );
11325 }
11326 },
11327 children: [
11328 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11329 DataViewsSelectionCheckbox,
11330 {
11331 item,
11332 selection,
11333 onChangeSelection,
11334 getItemId,
11335 titleField,
11336 disabled: !hasPossibleBulkAction
11337 }
11338 ) }) }),
11339 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11340 column_primary_default,
11341 {
11342 item,
11343 level,
11344 titleField: showTitle ? titleField : void 0,
11345 mediaField: showMedia ? mediaField : void 0,
11346 descriptionField: showDescription ? descriptionField : void 0,
11347 isItemClickable,
11348 onClickItem,
11349 renderItemLink
11350 }
11351 ) }),
11352 columns.map((column) => {
11353 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
11354 const field = fields.find((f2) => f2.id === column);
11355 const effectiveAlign = getEffectiveAlign(align, field?.type);
11356 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11357 "td",
11358 {
11359 style: {
11360 width,
11361 maxWidth,
11362 minWidth
11363 },
11364 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11365 TableColumnField,
11366 {
11367 fields,
11368 item,
11369 column,
11370 align: effectiveAlign
11371 }
11372 )
11373 },
11374 column
11375 );
11376 }),
11377 !!actions?.length && // Disable reason: we are not making the element interactive,
11378 // but preventing any click events from bubbling up to the
11379 // table row. This allows us to add a click handler to the row
11380 // itself (to toggle row selection) without erroneously
11381 // intercepting click events from ItemActions.
11382 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11383 "td",
11384 {
11385 className: clsx_default("dataviews-view-table__actions-column", {
11386 "dataviews-view-table__actions-column--sticky": true,
11387 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
11388 }),
11389 onClick: (e2) => e2.stopPropagation(),
11390 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ItemActions, { item, actions })
11391 }
11392 )
11393 ]
11394 }
11395 );
11396 }
11397 function ViewTable({
11398 actions,
11399 data,
11400 fields,
11401 getItemId,
11402 getItemLevel,
11403 isLoading = false,
11404 onChangeView,
11405 onChangeSelection,
11406 selection,
11407 setOpenedFilter,
11408 onClickItem,
11409 isItemClickable,
11410 renderItemLink,
11411 view,
11412 className,
11413 empty
11414 }) {
11415 const { containerRef } = (0, import_element25.useContext)(dataviews_context_default);
11416 const isDelayedLoading = useDelayedLoading(isLoading);
11417 const headerMenuRefs = (0, import_element25.useRef)(/* @__PURE__ */ new Map());
11418 const headerMenuToFocusRef = (0, import_element25.useRef)(void 0);
11419 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element25.useState)();
11420 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element25.useState)(null);
11421 (0, import_element25.useEffect)(() => {
11422 if (headerMenuToFocusRef.current) {
11423 headerMenuToFocusRef.current.focus();
11424 headerMenuToFocusRef.current = void 0;
11425 }
11426 });
11427 const tableNoticeId = (0, import_element25.useId)();
11428 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
11429 scrollContainerRef: containerRef,
11430 enabledHorizontal: !!actions?.length
11431 });
11432 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
11433 if (nextHeaderMenuToFocus) {
11434 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
11435 setNextHeaderMenuToFocus(void 0);
11436 return;
11437 }
11438 const onHide = (field) => {
11439 const hidden = headerMenuRefs.current.get(field.id);
11440 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
11441 setNextHeaderMenuToFocus(fallback?.node);
11442 };
11443 const handleHeaderContextMenu = (event) => {
11444 event.preventDefault();
11445 event.stopPropagation();
11446 const virtualAnchor = {
11447 getBoundingClientRect: () => ({
11448 x: event.clientX,
11449 y: event.clientY,
11450 top: event.clientY,
11451 left: event.clientX,
11452 right: event.clientX,
11453 bottom: event.clientY,
11454 width: 0,
11455 height: 0,
11456 toJSON: () => ({})
11457 })
11458 };
11459 window.requestAnimationFrame(() => {
11460 setContextMenuAnchor(virtualAnchor);
11461 });
11462 };
11463 const hasData = !!data?.length;
11464 const titleField = fields.find((field) => field.id === view.titleField);
11465 const mediaField = fields.find((field) => field.id === view.mediaField);
11466 const descriptionField = fields.find(
11467 (field) => field.id === view.descriptionField
11468 );
11469 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
11470 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
11471 const { showTitle = true, showMedia = true, showDescription = true } = view;
11472 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11473 const columns = view.fields ?? [];
11474 const headerMenuRef = (column, index2) => (node) => {
11475 if (node) {
11476 headerMenuRefs.current.set(column, {
11477 node,
11478 fallback: columns[index2 > 0 ? index2 - 1 : 1]
11479 });
11480 } else {
11481 headerMenuRefs.current.delete(column);
11482 }
11483 };
11484 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
11485 const isRtl = (0, import_i18n9.isRTL)();
11486 if (!hasData) {
11487 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11488 "div",
11489 {
11490 className: clsx_default("dataviews-no-results", {
11491 "is-refreshing": isDelayedLoading
11492 }),
11493 id: tableNoticeId,
11494 children: empty
11495 }
11496 );
11497 }
11498 return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
11499 /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
11500 "table",
11501 {
11502 className: clsx_default("dataviews-view-table", className, {
11503 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
11504 view.layout.density
11505 ),
11506 "has-bulk-actions": hasBulkActions,
11507 "is-refreshing": !isInfiniteScroll && isDelayedLoading
11508 }),
11509 "aria-busy": isLoading,
11510 "aria-describedby": tableNoticeId,
11511 role: isInfiniteScroll ? "feed" : void 0,
11512 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
11513 children: [
11514 /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("colgroup", { children: [
11515 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
11516 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
11517 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11518 "col",
11519 {
11520 className: clsx_default(
11521 `dataviews-view-table__col-${column}`,
11522 {
11523 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
11524 }
11525 )
11526 },
11527 `col-${column}`
11528 )),
11529 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("col", { className: "dataviews-view-table__col-actions" })
11530 ] }),
11531 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11532 import_components6.Popover,
11533 {
11534 anchor: contextMenuAnchor,
11535 onClose: () => setContextMenuAnchor(null),
11536 placement: "bottom-start",
11537 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(PropertiesSection, { showLabel: false })
11538 }
11539 ),
11540 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11541 "thead",
11542 {
11543 className: clsx_default({
11544 "dataviews-view-table__thead--stuck": isVerticallyScrolled
11545 }),
11546 onContextMenu: handleHeaderContextMenu,
11547 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("tr", { className: "dataviews-view-table__row", children: [
11548 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11549 "th",
11550 {
11551 className: "dataviews-view-table__checkbox-column",
11552 scope: "col",
11553 onContextMenu: handleHeaderContextMenu,
11554 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11555 BulkSelectionCheckbox,
11556 {
11557 selection,
11558 onChangeSelection,
11559 data,
11560 actions,
11561 getItemId
11562 }
11563 )
11564 }
11565 ),
11566 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11567 column_header_menu_default,
11568 {
11569 ref: headerMenuRef(
11570 titleField.id,
11571 0
11572 ),
11573 fieldId: titleField.id,
11574 view,
11575 fields,
11576 onChangeView,
11577 onHide,
11578 setOpenedFilter,
11579 canMove: false,
11580 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
11581 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
11582 }
11583 ) }),
11584 columns.map((column, index2) => {
11585 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
11586 const field = fields.find(
11587 (f2) => f2.id === column
11588 );
11589 const effectiveAlign = getEffectiveAlign(
11590 align,
11591 field?.type
11592 );
11593 const canInsertOrMove = view.layout?.enableMoving ?? true;
11594 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11595 "th",
11596 {
11597 style: {
11598 width,
11599 maxWidth,
11600 minWidth,
11601 textAlign: effectiveAlign
11602 },
11603 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
11604 scope: "col",
11605 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11606 column_header_menu_default,
11607 {
11608 ref: headerMenuRef(column, index2),
11609 fieldId: column,
11610 view,
11611 fields,
11612 onChangeView,
11613 onHide,
11614 setOpenedFilter,
11615 canMove: canInsertOrMove,
11616 canInsertLeft: canInsertOrMove,
11617 canInsertRight: canInsertOrMove
11618 }
11619 )
11620 },
11621 column
11622 );
11623 }),
11624 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11625 "th",
11626 {
11627 className: clsx_default(
11628 "dataviews-view-table__actions-column",
11629 {
11630 "dataviews-view-table__actions-column--sticky": true,
11631 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
11632 }
11633 ),
11634 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n9.__)("Actions") })
11635 }
11636 )
11637 ] })
11638 }
11639 ),
11640 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
11641 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("tbody", { children: [
11642 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11643 "td",
11644 {
11645 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
11646 className: "dataviews-view-table__group-header-cell",
11647 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n9.sprintf)(
11648 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
11649 (0, import_i18n9.__)("%1$s: %2$s"),
11650 groupField.label,
11651 groupName
11652 )
11653 }
11654 ) }),
11655 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11656 TableRow,
11657 {
11658 item,
11659 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
11660 hasBulkActions,
11661 actions,
11662 fields,
11663 id: getItemId(item) || index2.toString(),
11664 view,
11665 titleField,
11666 mediaField,
11667 descriptionField,
11668 selection,
11669 getItemId,
11670 onChangeSelection,
11671 onClickItem,
11672 renderItemLink,
11673 isItemClickable,
11674 isActionsColumnSticky: !isHorizontalScrollEnd
11675 },
11676 getItemId(item)
11677 ))
11678 ] }, `group-${groupName}`)
11679 ) : /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("tbody", { children: hasData && data.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11680 TableRow,
11681 {
11682 item,
11683 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
11684 hasBulkActions,
11685 actions,
11686 fields,
11687 id: getItemId(item) || index2.toString(),
11688 view,
11689 titleField,
11690 mediaField,
11691 descriptionField,
11692 selection,
11693 getItemId,
11694 onChangeSelection,
11695 onClickItem,
11696 renderItemLink,
11697 isItemClickable,
11698 isActionsColumnSticky: !isHorizontalScrollEnd,
11699 posinset: isInfiniteScroll ? index2 + 1 : void 0
11700 },
11701 getItemId(item)
11702 )) })
11703 ]
11704 }
11705 ),
11706 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_components6.Spinner, {}) }) })
11707 ] });
11708 }
11709 var table_default = ViewTable;
11710
11711 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
11712 var import_components9 = __toESM(require_components(), 1);
11713 var import_i18n12 = __toESM(require_i18n(), 1);
11714
11715 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
11716 var import_components8 = __toESM(require_components(), 1);
11717 var import_i18n11 = __toESM(require_i18n(), 1);
11718 var import_compose3 = __toESM(require_compose(), 1);
11719 var import_keycodes2 = __toESM(require_keycodes(), 1);
11720 var import_element29 = __toESM(require_element(), 1);
11721
11722 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
11723 var import_components7 = __toESM(require_components(), 1);
11724 var import_i18n10 = __toESM(require_i18n(), 1);
11725 var import_element26 = __toESM(require_element(), 1);
11726 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
11727 var imageSizes = [
11728 {
11729 value: 120,
11730 breakpoint: 1
11731 },
11732 {
11733 value: 170,
11734 breakpoint: 1
11735 },
11736 {
11737 value: 230,
11738 breakpoint: 1
11739 },
11740 {
11741 value: 290,
11742 breakpoint: 1112
11743 // at minimum image width, 4 images display at this container size
11744 },
11745 {
11746 value: 350,
11747 breakpoint: 1636
11748 // at minimum image width, 6 images display at this container size
11749 },
11750 {
11751 value: 430,
11752 breakpoint: 588
11753 // at minimum image width, 2 images display at this container size
11754 }
11755 ];
11756 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
11757 function useGridColumns() {
11758 const context = (0, import_element26.useContext)(dataviews_context_default);
11759 const view = context.view;
11760 return (0, import_element26.useMemo)(() => {
11761 const containerWidth = context.containerWidth;
11762 const gap = 32;
11763 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
11764 const columns = Math.floor(
11765 (containerWidth + gap) / (previewSize + gap)
11766 );
11767 return Math.max(1, columns);
11768 }, [context.containerWidth, view.layout?.previewSize]);
11769 }
11770
11771 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
11772 var import_element27 = __toESM(require_element(), 1);
11773 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
11774 var GridItems = (0, import_element27.forwardRef)(({ className, previewSize, ...props }, ref) => {
11775 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11776 "div",
11777 {
11778 ref,
11779 className: clsx_default("dataviews-view-grid-items", className),
11780 style: {
11781 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
11782 },
11783 ...props
11784 }
11785 );
11786 });
11787
11788 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
11789 var import_element28 = __toESM(require_element(), 1);
11790 function useIntersectionObserver(elementRef, posinset) {
11791 const { intersectionObserver } = (0, import_element28.useContext)(dataviews_context_default);
11792 (0, import_element28.useEffect)(() => {
11793 const element = elementRef.current;
11794 if (!element || posinset === void 0 || !intersectionObserver) {
11795 return;
11796 }
11797 intersectionObserver.observe(element);
11798 return () => {
11799 intersectionObserver.unobserve(element);
11800 };
11801 }, [elementRef, intersectionObserver, posinset]);
11802 }
11803 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
11804 const hasData = !!data?.length;
11805 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
11806 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
11807 }
11808
11809 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
11810 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
11811 var { Badge: WCBadge } = unlock3(import_components8.privateApis);
11812 function chunk(array, size4) {
11813 const chunks = [];
11814 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
11815 chunks.push(array.slice(i2, i2 + size4));
11816 }
11817 return chunks;
11818 }
11819 var GridItem = (0, import_element29.forwardRef)(
11820 function GridItem2({
11821 view,
11822 selection,
11823 onChangeSelection,
11824 onClickItem,
11825 isItemClickable,
11826 renderItemLink,
11827 getItemId,
11828 item,
11829 actions,
11830 mediaField,
11831 titleField,
11832 descriptionField,
11833 regularFields,
11834 badgeFields,
11835 hasBulkActions,
11836 config,
11837 posinset,
11838 setsize,
11839 ...props
11840 }, forwardedRef) {
11841 const {
11842 showTitle = true,
11843 showMedia = true,
11844 showDescription = true
11845 } = view;
11846 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
11847 const id = getItemId(item);
11848 const elementRef = (0, import_element29.useRef)(null);
11849 const setRefs = (0, import_element29.useCallback)(
11850 (node) => {
11851 elementRef.current = node;
11852 if (typeof forwardedRef === "function") {
11853 forwardedRef(node);
11854 } else if (forwardedRef) {
11855 forwardedRef.current = node;
11856 }
11857 },
11858 [forwardedRef]
11859 );
11860 useIntersectionObserver(elementRef, posinset);
11861 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
11862 const isSelected2 = selection.includes(id);
11863 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
11864 const rendersMediaField = showMedia && mediaField?.render;
11865 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11866 mediaField.render,
11867 {
11868 item,
11869 field: mediaField,
11870 config
11871 }
11872 ) : mediaPlaceholder;
11873 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(titleField.render, { item, field: titleField }) : null;
11874 let mediaA11yProps;
11875 let titleA11yProps;
11876 if (isItemClickable(item) && onClickItem) {
11877 if (renderedTitleField) {
11878 mediaA11yProps = {
11879 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
11880 };
11881 titleA11yProps = {
11882 id: `dataviews-view-grid__title-field-${instanceId}`
11883 };
11884 } else {
11885 mediaA11yProps = {
11886 "aria-label": (0, import_i18n11.__)("Navigate to item")
11887 };
11888 }
11889 }
11890 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
11891 Stack,
11892 {
11893 direction: "column",
11894 ...props,
11895 ref: setRefs,
11896 "aria-setsize": setsize,
11897 "aria-posinset": posinset,
11898 className: clsx_default(
11899 props.className,
11900 "dataviews-view-grid__row__gridcell",
11901 "dataviews-view-grid__card",
11902 {
11903 "is-selected": hasBulkAction && isSelected2
11904 }
11905 ),
11906 onClickCapture: (event) => {
11907 props.onClickCapture?.(event);
11908 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
11909 event.stopPropagation();
11910 event.preventDefault();
11911 if (!hasBulkAction) {
11912 return;
11913 }
11914 onChangeSelection(
11915 isSelected2 ? selection.filter(
11916 (itemId) => id !== itemId
11917 ) : [...selection, id]
11918 );
11919 }
11920 },
11921 children: [
11922 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11923 ItemClickWrapper,
11924 {
11925 item,
11926 isItemClickable,
11927 onClickItem,
11928 renderItemLink,
11929 className: clsx_default("dataviews-view-grid__media", {
11930 "dataviews-view-grid__media--placeholder": !rendersMediaField
11931 }),
11932 ...mediaA11yProps,
11933 children: renderedMediaField
11934 }
11935 ),
11936 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11937 DataViewsSelectionCheckbox,
11938 {
11939 item,
11940 selection,
11941 onChangeSelection,
11942 getItemId,
11943 titleField,
11944 disabled: !hasBulkAction
11945 }
11946 ),
11947 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11948 ItemActions,
11949 {
11950 item,
11951 actions,
11952 isCompact: true
11953 }
11954 ) }),
11955 showTitle && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11956 ItemClickWrapper,
11957 {
11958 item,
11959 isItemClickable,
11960 onClickItem,
11961 renderItemLink,
11962 className: "dataviews-view-grid__title-field dataviews-title-field",
11963 ...titleA11yProps,
11964 title: titleField?.getValueFormatted({
11965 item,
11966 field: titleField
11967 }) || void 0,
11968 children: renderedTitleField
11969 }
11970 ) }),
11971 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Stack, { direction: "column", gap: "xs", children: [
11972 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11973 descriptionField.render,
11974 {
11975 item,
11976 field: descriptionField
11977 }
11978 ),
11979 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11980 Stack,
11981 {
11982 direction: "row",
11983 className: "dataviews-view-grid__badge-fields",
11984 gap: "sm",
11985 wrap: "wrap",
11986 align: "top",
11987 justify: "flex-start",
11988 children: badgeFields.map((field) => {
11989 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11990 WCBadge,
11991 {
11992 className: "dataviews-view-grid__field-value",
11993 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11994 field.render,
11995 {
11996 item,
11997 field
11998 }
11999 )
12000 },
12001 field.id
12002 );
12003 })
12004 }
12005 ),
12006 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12007 Stack,
12008 {
12009 direction: "column",
12010 className: "dataviews-view-grid__fields",
12011 gap: "xs",
12012 children: regularFields.map((field) => {
12013 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12014 import_components8.Flex,
12015 {
12016 className: "dataviews-view-grid__field",
12017 gap: 1,
12018 justify: "flex-start",
12019 expanded: true,
12020 style: { height: "auto" },
12021 direction: "row",
12022 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
12023 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(tooltip_exports.Root, { children: [
12024 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12025 tooltip_exports.Trigger,
12026 {
12027 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
12028 }
12029 ),
12030 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(tooltip_exports.Popup, { children: field.label })
12031 ] }),
12032 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12033 import_components8.FlexItem,
12034 {
12035 className: "dataviews-view-grid__field-value",
12036 style: { maxHeight: "none" },
12037 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12038 field.render,
12039 {
12040 item,
12041 field
12042 }
12043 )
12044 }
12045 )
12046 ] })
12047 },
12048 field.id
12049 );
12050 })
12051 }
12052 )
12053 ] })
12054 ]
12055 }
12056 );
12057 }
12058 );
12059 function CompositeGrid({
12060 data,
12061 isInfiniteScroll,
12062 className,
12063 inert,
12064 isLoading,
12065 view,
12066 fields,
12067 selection,
12068 onChangeSelection,
12069 onClickItem,
12070 isItemClickable,
12071 renderItemLink,
12072 getItemId,
12073 actions
12074 }) {
12075 const { paginationInfo, resizeObserverRef } = (0, import_element29.useContext)(dataviews_context_default);
12076 const gridColumns = useGridColumns();
12077 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12078 const titleField = fields.find(
12079 (field) => field.id === view?.titleField
12080 );
12081 const mediaField = fields.find(
12082 (field) => field.id === view?.mediaField
12083 );
12084 const descriptionField = fields.find(
12085 (field) => field.id === view?.descriptionField
12086 );
12087 const otherFields = view.fields ?? [];
12088 const { regularFields, badgeFields } = otherFields.reduce(
12089 (accumulator, fieldId) => {
12090 const field = fields.find((f2) => f2.id === fieldId);
12091 if (!field) {
12092 return accumulator;
12093 }
12094 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
12095 accumulator[key].push(field);
12096 return accumulator;
12097 },
12098 { regularFields: [], badgeFields: [] }
12099 );
12100 const size4 = "900px";
12101 const totalRows = Math.ceil(data.length / gridColumns);
12102 const placeholdersNeeded = usePlaceholdersNeeded(
12103 data,
12104 isInfiniteScroll,
12105 gridColumns
12106 );
12107 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, {
12108 // Render infinite scroll layout (no rows, feed semantics)
12109 children: [
12110 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
12111 import_components8.Composite,
12112 {
12113 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12114 GridItems,
12115 {
12116 className: clsx_default(
12117 "dataviews-view-grid-infinite-scroll",
12118 className,
12119 {
12120 [`has-${view.layout?.density}-density`]: view.layout?.density && [
12121 "compact",
12122 "comfortable"
12123 ].includes(view.layout.density)
12124 }
12125 ),
12126 previewSize: view.layout?.previewSize,
12127 "aria-busy": isLoading,
12128 ref: resizeObserverRef
12129 }
12130 ),
12131 role: "feed",
12132 focusWrap: true,
12133 inert,
12134 children: [
12135 Array.from({ length: placeholdersNeeded }).map(
12136 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12137 import_components8.Composite.Item,
12138 {
12139 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12140 Stack,
12141 {
12142 ...props,
12143 direction: "column",
12144 role: "article",
12145 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
12146 }
12147 ),
12148 "aria-hidden": true,
12149 tabIndex: -1
12150 },
12151 `placeholder-${index2}`
12152 )
12153 ),
12154 data.map((item) => {
12155 const itemId = getItemId(item);
12156 const stablePosition = item.position;
12157 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12158 import_components8.Composite.Item,
12159 {
12160 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12161 GridItem,
12162 {
12163 ...props,
12164 id: itemId,
12165 role: "article",
12166 view,
12167 selection,
12168 onChangeSelection,
12169 onClickItem,
12170 isItemClickable,
12171 renderItemLink,
12172 getItemId,
12173 item,
12174 actions,
12175 mediaField,
12176 titleField,
12177 descriptionField,
12178 regularFields,
12179 badgeFields,
12180 hasBulkActions,
12181 posinset: stablePosition,
12182 setsize: paginationInfo.totalItems,
12183 config: {
12184 sizes: size4
12185 }
12186 }
12187 )
12188 },
12189 itemId
12190 );
12191 })
12192 ]
12193 }
12194 ),
12195 // Render standard grid layout (with rows, grid semantics)
12196 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12197 import_components8.Composite,
12198 {
12199 role: "grid",
12200 className: clsx_default("dataviews-view-grid", className, {
12201 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12202 view.layout.density
12203 )
12204 }),
12205 focusWrap: true,
12206 "aria-busy": isLoading,
12207 "aria-rowcount": totalRows,
12208 ref: resizeObserverRef,
12209 inert,
12210 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12211 import_components8.Composite.Row,
12212 {
12213 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12214 "div",
12215 {
12216 role: "row",
12217 "aria-rowindex": i2 + 1,
12218 "aria-label": (0, import_i18n11.sprintf)(
12219 /* translators: %d: The row number in the grid */
12220 (0, import_i18n11.__)("Row %d"),
12221 i2 + 1
12222 ),
12223 className: "dataviews-view-grid__row",
12224 style: {
12225 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
12226 }
12227 }
12228 ),
12229 children: row.map((item) => {
12230 const itemId = getItemId(item);
12231 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12232 import_components8.Composite.Item,
12233 {
12234 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12235 GridItem,
12236 {
12237 ...props,
12238 id: itemId,
12239 role: "gridcell",
12240 view,
12241 selection,
12242 onChangeSelection,
12243 onClickItem,
12244 isItemClickable,
12245 renderItemLink,
12246 getItemId,
12247 item,
12248 actions,
12249 mediaField,
12250 titleField,
12251 descriptionField,
12252 regularFields,
12253 badgeFields,
12254 hasBulkActions,
12255 config: {
12256 sizes: size4
12257 }
12258 }
12259 )
12260 },
12261 itemId
12262 );
12263 })
12264 },
12265 i2
12266 ))
12267 }
12268 )
12269 ]
12270 });
12271 }
12272
12273 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12274 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
12275 function ViewGrid({
12276 actions,
12277 data,
12278 fields,
12279 getItemId,
12280 isLoading,
12281 onChangeSelection,
12282 onClickItem,
12283 isItemClickable,
12284 renderItemLink,
12285 selection,
12286 view,
12287 className,
12288 empty
12289 }) {
12290 const isDelayedLoading = useDelayedLoading(!!isLoading);
12291 const hasData = !!data?.length;
12292 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12293 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12294 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12295 if (!hasData) {
12296 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
12297 "div",
12298 {
12299 className: clsx_default("dataviews-no-results", {
12300 "is-refreshing": isDelayedLoading
12301 }),
12302 children: empty
12303 }
12304 );
12305 }
12306 const gridProps = {
12307 className: clsx_default(className, {
12308 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12309 }),
12310 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
12311 isLoading,
12312 view,
12313 fields,
12314 selection,
12315 onChangeSelection,
12316 onClickItem,
12317 isItemClickable,
12318 renderItemLink,
12319 getItemId,
12320 actions
12321 };
12322 return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_jsx_runtime51.Fragment, {
12323 // Render multiple groups.
12324 children: [
12325 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
12326 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
12327 Stack,
12328 {
12329 direction: "column",
12330 gap: "sm",
12331 children: [
12332 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n12.sprintf)(
12333 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12334 (0, import_i18n12.__)("%1$s: %2$s"),
12335 groupField.label,
12336 groupName
12337 ) }),
12338 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
12339 CompositeGrid,
12340 {
12341 ...gridProps,
12342 data: groupItems,
12343 isInfiniteScroll: false
12344 }
12345 )
12346 ]
12347 },
12348 groupName
12349 )
12350 ) }),
12351 // Render a single grid with all data.
12352 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
12353 CompositeGrid,
12354 {
12355 ...gridProps,
12356 data,
12357 isInfiniteScroll: !!isInfiniteScroll
12358 }
12359 ),
12360 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components9.Spinner, {}) })
12361 ]
12362 });
12363 }
12364 var grid_default = ViewGrid;
12365
12366 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
12367 var import_compose4 = __toESM(require_compose(), 1);
12368 var import_components10 = __toESM(require_components(), 1);
12369 var import_element30 = __toESM(require_element(), 1);
12370 var import_i18n13 = __toESM(require_i18n(), 1);
12371 var import_data6 = __toESM(require_data(), 1);
12372 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
12373 var { Menu: Menu3 } = unlock3(import_components10.privateApis);
12374 function generateItemWrapperCompositeId(idPrefix) {
12375 return `${idPrefix}-item-wrapper`;
12376 }
12377 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
12378 return `${idPrefix}-primary-action-${primaryActionId}`;
12379 }
12380 function generateDropdownTriggerCompositeId(idPrefix) {
12381 return `${idPrefix}-dropdown`;
12382 }
12383 function PrimaryActionGridCell({
12384 idPrefix,
12385 primaryAction,
12386 item
12387 }) {
12388 const registry = (0, import_data6.useRegistry)();
12389 const [isModalOpen, setIsModalOpen] = (0, import_element30.useState)(false);
12390 const compositeItemId = generatePrimaryActionCompositeId(
12391 idPrefix,
12392 primaryAction.id
12393 );
12394 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
12395 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12396 import_components10.Composite.Item,
12397 {
12398 id: compositeItemId,
12399 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12400 import_components10.Button,
12401 {
12402 disabled: !!primaryAction.disabled,
12403 accessibleWhenDisabled: true,
12404 text: label,
12405 size: "small",
12406 onClick: () => setIsModalOpen(true)
12407 }
12408 ),
12409 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12410 ActionModal,
12411 {
12412 action: primaryAction,
12413 items: [item],
12414 closeModal: () => setIsModalOpen(false)
12415 }
12416 )
12417 }
12418 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12419 import_components10.Composite.Item,
12420 {
12421 id: compositeItemId,
12422 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12423 import_components10.Button,
12424 {
12425 disabled: !!primaryAction.disabled,
12426 accessibleWhenDisabled: true,
12427 size: "small",
12428 onClick: () => {
12429 primaryAction.callback([item], { registry });
12430 },
12431 children: label
12432 }
12433 )
12434 }
12435 ) }, primaryAction.id);
12436 }
12437 function ListItem({
12438 view,
12439 actions,
12440 idPrefix,
12441 isSelected: isSelected2,
12442 item,
12443 titleField,
12444 mediaField,
12445 descriptionField,
12446 onSelect,
12447 otherFields,
12448 onDropdownTriggerKeyDown,
12449 posinset
12450 }) {
12451 const {
12452 showTitle = true,
12453 showMedia = true,
12454 showDescription = true,
12455 infiniteScrollEnabled
12456 } = view;
12457 const itemRef = (0, import_element30.useRef)(null);
12458 const labelId = `${idPrefix}-label`;
12459 const descriptionId = `${idPrefix}-description`;
12460 const registry = (0, import_data6.useRegistry)();
12461 const [isHovered, setIsHovered] = (0, import_element30.useState)(false);
12462 const [activeModalAction, setActiveModalAction] = (0, import_element30.useState)(
12463 null
12464 );
12465 const handleHover = ({ type }) => {
12466 const isHover = type === "mouseenter";
12467 setIsHovered(isHover);
12468 };
12469 const { paginationInfo } = (0, import_element30.useContext)(dataviews_context_default);
12470 (0, import_element30.useEffect)(() => {
12471 if (isSelected2) {
12472 itemRef.current?.scrollIntoView({
12473 behavior: "auto",
12474 block: "nearest",
12475 inline: "nearest"
12476 });
12477 }
12478 }, [isSelected2]);
12479 const { primaryAction, eligibleActions } = (0, import_element30.useMemo)(() => {
12480 const _eligibleActions = actions.filter(
12481 (action) => !action.isEligible || action.isEligible(item)
12482 );
12483 const _primaryActions = _eligibleActions.filter(
12484 (action) => action.isPrimary
12485 );
12486 return {
12487 primaryAction: _primaryActions[0],
12488 eligibleActions: _eligibleActions
12489 };
12490 }, [actions, item]);
12491 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
12492 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12493 mediaField.render,
12494 {
12495 item,
12496 field: mediaField,
12497 config: { sizes: "52px" }
12498 }
12499 ) }) : null;
12500 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(titleField.render, { item, field: titleField }) : null;
12501 const renderDescription = showDescription && descriptionField?.render;
12502 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
12503 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12504 Stack,
12505 {
12506 direction: "row",
12507 gap: "md",
12508 className: "dataviews-view-list__item-actions",
12509 children: [
12510 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12511 PrimaryActionGridCell,
12512 {
12513 idPrefix,
12514 primaryAction,
12515 item
12516 }
12517 ),
12518 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { role: "gridcell", children: [
12519 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Menu3, { placement: "bottom-end", children: [
12520 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12521 Menu3.TriggerButton,
12522 {
12523 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12524 import_components10.Composite.Item,
12525 {
12526 id: generateDropdownTriggerCompositeId(
12527 idPrefix
12528 ),
12529 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12530 import_components10.Button,
12531 {
12532 size: "small",
12533 icon: more_vertical_default,
12534 label: (0, import_i18n13.__)("Actions"),
12535 accessibleWhenDisabled: true,
12536 disabled: !actions.length,
12537 onKeyDown: onDropdownTriggerKeyDown
12538 }
12539 )
12540 }
12541 )
12542 }
12543 ),
12544 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12545 ActionsMenuGroup,
12546 {
12547 actions: eligibleActions,
12548 item,
12549 registry,
12550 setActiveModalAction
12551 }
12552 ) })
12553 ] }),
12554 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12555 ActionModal,
12556 {
12557 action: activeModalAction,
12558 items: [item],
12559 closeModal: () => setActiveModalAction(null)
12560 }
12561 )
12562 ] })
12563 ]
12564 }
12565 );
12566 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12567 import_components10.Composite.Row,
12568 {
12569 ref: itemRef,
12570 render: (
12571 /* aria-posinset breaks Composite.Row if passed to it directly. */
12572 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12573 "div",
12574 {
12575 "aria-posinset": posinset,
12576 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
12577 }
12578 )
12579 ),
12580 role: infiniteScrollEnabled ? "article" : "row",
12581 className: clsx_default({
12582 "is-selected": isSelected2,
12583 "is-hovered": isHovered
12584 }),
12585 onMouseEnter: handleHover,
12586 onMouseLeave: handleHover,
12587 children: /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12588 Stack,
12589 {
12590 direction: "row",
12591 className: "dataviews-view-list__item-wrapper",
12592 children: [
12593 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12594 import_components10.Composite.Item,
12595 {
12596 id: generateItemWrapperCompositeId(idPrefix),
12597 "aria-pressed": isSelected2,
12598 "aria-labelledby": labelId,
12599 "aria-describedby": descriptionId,
12600 className: "dataviews-view-list__item",
12601 onClick: () => onSelect(item)
12602 }
12603 ) }),
12604 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12605 Stack,
12606 {
12607 direction: "row",
12608 gap: "md",
12609 justify: "start",
12610 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
12611 style: { flex: 1, minWidth: 0 },
12612 children: [
12613 renderedMediaField,
12614 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12615 Stack,
12616 {
12617 direction: "column",
12618 gap: "xs",
12619 className: "dataviews-view-list__field-wrapper",
12620 children: [
12621 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Stack, { direction: "row", align: "center", children: [
12622 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12623 "div",
12624 {
12625 className: "dataviews-title-field dataviews-view-list__title-field",
12626 id: labelId,
12627 children: renderedTitleField
12628 }
12629 ),
12630 usedActions
12631 ] }),
12632 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12633 descriptionField.render,
12634 {
12635 item,
12636 field: descriptionField
12637 }
12638 ) }),
12639 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12640 "div",
12641 {
12642 className: "dataviews-view-list__fields",
12643 id: descriptionId,
12644 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12645 "div",
12646 {
12647 className: "dataviews-view-list__field",
12648 children: [
12649 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12650 VisuallyHidden,
12651 {
12652 className: "dataviews-view-list__field-label",
12653 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", {}),
12654 children: field.label
12655 }
12656 ),
12657 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12658 field.render,
12659 {
12660 item,
12661 field
12662 }
12663 ) })
12664 ]
12665 },
12666 field.id
12667 ))
12668 }
12669 )
12670 ]
12671 }
12672 )
12673 ]
12674 }
12675 )
12676 ]
12677 }
12678 )
12679 }
12680 );
12681 }
12682 function isDefined2(item) {
12683 return !!item;
12684 }
12685 function ViewList(props) {
12686 const {
12687 actions,
12688 data,
12689 fields,
12690 getItemId,
12691 isLoading,
12692 onChangeSelection,
12693 selection,
12694 view,
12695 className,
12696 empty
12697 } = props;
12698 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
12699 const isDelayedLoading = useDelayedLoading(!!isLoading);
12700 const selectedItem = data?.findLast(
12701 (item) => selection.includes(getItemId(item))
12702 );
12703 const titleField = fields.find((field) => field.id === view.titleField);
12704 const mediaField = fields.find((field) => field.id === view.mediaField);
12705 const descriptionField = fields.find(
12706 (field) => field.id === view.descriptionField
12707 );
12708 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
12709 const onSelect = (item) => onChangeSelection([getItemId(item)]);
12710 const generateCompositeItemIdPrefix = (0, import_element30.useCallback)(
12711 (item) => `${baseId}-${getItemId(item)}`,
12712 [baseId, getItemId]
12713 );
12714 const isActiveCompositeItem = (0, import_element30.useCallback)(
12715 (item, idToCheck) => {
12716 return idToCheck.startsWith(
12717 generateCompositeItemIdPrefix(item)
12718 );
12719 },
12720 [generateCompositeItemIdPrefix]
12721 );
12722 const [activeCompositeId, setActiveCompositeId] = (0, import_element30.useState)(void 0);
12723 const compositeRef = (0, import_element30.useRef)(null);
12724 (0, import_element30.useEffect)(() => {
12725 if (selectedItem) {
12726 setActiveCompositeId(
12727 generateItemWrapperCompositeId(
12728 generateCompositeItemIdPrefix(selectedItem)
12729 )
12730 );
12731 }
12732 }, [selectedItem, generateCompositeItemIdPrefix]);
12733 const activeItemIndex = data.findIndex(
12734 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
12735 );
12736 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
12737 const isActiveIdInList = activeItemIndex !== -1;
12738 const selectCompositeItem = (0, import_element30.useCallback)(
12739 (targetIndex, generateCompositeId) => {
12740 const clampedIndex = Math.min(
12741 data.length - 1,
12742 Math.max(0, targetIndex)
12743 );
12744 if (!data[clampedIndex]) {
12745 return;
12746 }
12747 const itemIdPrefix = generateCompositeItemIdPrefix(
12748 data[clampedIndex]
12749 );
12750 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
12751 setActiveCompositeId(targetCompositeItemId);
12752 if (compositeRef.current?.contains(
12753 compositeRef.current.ownerDocument.activeElement
12754 )) {
12755 document.getElementById(targetCompositeItemId)?.focus();
12756 }
12757 },
12758 [data, generateCompositeItemIdPrefix]
12759 );
12760 (0, import_element30.useEffect)(() => {
12761 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
12762 if (!isActiveIdInList && wasActiveIdInList) {
12763 selectCompositeItem(
12764 previousActiveItemIndex,
12765 generateItemWrapperCompositeId
12766 );
12767 }
12768 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
12769 const onDropdownTriggerKeyDown = (0, import_element30.useCallback)(
12770 (event) => {
12771 if (event.key === "ArrowDown") {
12772 event.preventDefault();
12773 selectCompositeItem(
12774 activeItemIndex + 1,
12775 generateDropdownTriggerCompositeId
12776 );
12777 }
12778 if (event.key === "ArrowUp") {
12779 event.preventDefault();
12780 selectCompositeItem(
12781 activeItemIndex - 1,
12782 generateDropdownTriggerCompositeId
12783 );
12784 }
12785 },
12786 [selectCompositeItem, activeItemIndex]
12787 );
12788 const hasData = !!data?.length;
12789 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
12790 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
12791 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12792 if (!hasData) {
12793 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12794 "div",
12795 {
12796 className: clsx_default("dataviews-no-results", {
12797 "is-refreshing": isDelayedLoading
12798 }),
12799 children: empty
12800 }
12801 );
12802 }
12803 if (hasData && groupField && dataByGroup) {
12804 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12805 import_components10.Composite,
12806 {
12807 ref: compositeRef,
12808 id: `${baseId}`,
12809 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", {}),
12810 className: "dataviews-view-list__group",
12811 role: "grid",
12812 activeId: activeCompositeId,
12813 setActiveId: setActiveCompositeId,
12814 children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12815 Stack,
12816 {
12817 direction: "column",
12818 gap: "lg",
12819 className: clsx_default("dataviews-view-list", className),
12820 children: Array.from(dataByGroup.entries()).map(
12821 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12822 Stack,
12823 {
12824 direction: "column",
12825 gap: "sm",
12826 children: [
12827 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)(
12828 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12829 (0, import_i18n13.__)("%1$s: %2$s"),
12830 groupField.label,
12831 groupName
12832 ) }),
12833 groupItems.map((item) => {
12834 const id = generateCompositeItemIdPrefix(item);
12835 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12836 ListItem,
12837 {
12838 view,
12839 idPrefix: id,
12840 actions,
12841 item,
12842 isSelected: item === selectedItem,
12843 onSelect,
12844 mediaField,
12845 titleField,
12846 descriptionField,
12847 otherFields,
12848 onDropdownTriggerKeyDown
12849 },
12850 id
12851 );
12852 })
12853 ]
12854 },
12855 groupName
12856 )
12857 )
12858 }
12859 )
12860 }
12861 );
12862 }
12863 return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_jsx_runtime52.Fragment, { children: [
12864 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12865 import_components10.Composite,
12866 {
12867 ref: compositeRef,
12868 id: baseId,
12869 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", {}),
12870 className: clsx_default("dataviews-view-list", className, {
12871 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12872 view.layout.density
12873 ),
12874 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12875 }),
12876 role: view.infiniteScrollEnabled ? "feed" : "grid",
12877 activeId: activeCompositeId,
12878 setActiveId: setActiveCompositeId,
12879 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
12880 children: data.map((item, index2) => {
12881 const id = generateCompositeItemIdPrefix(item);
12882 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12883 ListItem,
12884 {
12885 view,
12886 idPrefix: id,
12887 actions,
12888 item,
12889 isSelected: item === selectedItem,
12890 onSelect,
12891 mediaField,
12892 titleField,
12893 descriptionField,
12894 otherFields,
12895 onDropdownTriggerKeyDown,
12896 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
12897 },
12898 id
12899 );
12900 })
12901 }
12902 ),
12903 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_components10.Spinner, {}) })
12904 ] });
12905 }
12906
12907 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
12908 var import_components11 = __toESM(require_components(), 1);
12909
12910 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
12911 var import_i18n14 = __toESM(require_i18n(), 1);
12912 var import_element31 = __toESM(require_element(), 1);
12913 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
12914 function ActivityGroup({
12915 groupName,
12916 groupData,
12917 groupField,
12918 showLabel = true,
12919 children
12920 }) {
12921 const groupHeader = showLabel ? (0, import_element31.createInterpolateElement)(
12922 // translators: %s: The label of the field e.g. "Status".
12923 (0, import_i18n14.sprintf)((0, import_i18n14.__)("%s: <groupName />"), groupField.label).trim(),
12924 {
12925 groupName: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
12926 groupField.render,
12927 {
12928 item: groupData[0],
12929 field: groupField
12930 }
12931 )
12932 }
12933 ) : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(groupField.render, { item: groupData[0], field: groupField });
12934 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
12935 Stack,
12936 {
12937 direction: "column",
12938 className: "dataviews-view-activity__group",
12939 children: [
12940 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
12941 children
12942 ]
12943 },
12944 groupName
12945 );
12946 }
12947
12948 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
12949 var import_element32 = __toESM(require_element(), 1);
12950 var import_data7 = __toESM(require_data(), 1);
12951 var import_compose5 = __toESM(require_compose(), 1);
12952 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
12953 function ActivityItem(props) {
12954 const {
12955 view,
12956 actions,
12957 item,
12958 titleField,
12959 mediaField,
12960 descriptionField,
12961 otherFields,
12962 posinset,
12963 onClickItem,
12964 renderItemLink,
12965 isItemClickable
12966 } = props;
12967 const {
12968 showTitle = true,
12969 showMedia = true,
12970 showDescription = true,
12971 infiniteScrollEnabled
12972 } = view;
12973 const itemRef = (0, import_element32.useRef)(null);
12974 const registry = (0, import_data7.useRegistry)();
12975 const { paginationInfo } = (0, import_element32.useContext)(dataviews_context_default);
12976 const { primaryActions, eligibleActions } = (0, import_element32.useMemo)(() => {
12977 const _eligibleActions = actions.filter(
12978 (action) => !action.isEligible || action.isEligible(item)
12979 );
12980 const _primaryActions = _eligibleActions.filter(
12981 (action) => action.isPrimary
12982 );
12983 return {
12984 primaryActions: _primaryActions,
12985 eligibleActions: _eligibleActions
12986 };
12987 }, [actions, item]);
12988 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
12989 const density = view.layout?.density ?? "balanced";
12990 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12991 mediaField.render,
12992 {
12993 item,
12994 field: mediaField,
12995 config: {
12996 sizes: density === "comfortable" ? "32px" : "24px"
12997 }
12998 }
12999 ) : null;
13000 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13001 "span",
13002 {
13003 className: "dataviews-view-activity__item-bullet",
13004 "aria-hidden": "true"
13005 }
13006 ) });
13007 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(titleField.render, { item, field: titleField }) : null;
13008 const verticalGap = (0, import_element32.useMemo)(() => {
13009 switch (density) {
13010 case "comfortable":
13011 return "md";
13012 default:
13013 return "sm";
13014 }
13015 }, [density]);
13016 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13017 "div",
13018 {
13019 ref: itemRef,
13020 role: infiniteScrollEnabled ? "article" : void 0,
13021 "aria-posinset": posinset,
13022 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
13023 className: clsx_default(
13024 "dataviews-view-activity__item",
13025 density === "compact" && "is-compact",
13026 density === "balanced" && "is-balanced",
13027 density === "comfortable" && "is-comfortable"
13028 ),
13029 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
13030 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13031 Stack,
13032 {
13033 direction: "column",
13034 gap: "xs",
13035 align: "center",
13036 className: "dataviews-view-activity__item-type",
13037 children: renderedMediaField
13038 }
13039 ),
13040 /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
13041 Stack,
13042 {
13043 direction: "column",
13044 gap: verticalGap,
13045 align: "flex-start",
13046 className: "dataviews-view-activity__item-content",
13047 children: [
13048 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13049 ItemClickWrapper,
13050 {
13051 item,
13052 isItemClickable,
13053 onClickItem,
13054 renderItemLink,
13055 className: "dataviews-view-activity__item-title",
13056 children: renderedTitleField
13057 }
13058 ),
13059 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13060 descriptionField.render,
13061 {
13062 item,
13063 field: descriptionField
13064 }
13065 ) }),
13066 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
13067 "div",
13068 {
13069 className: "dataviews-view-activity__item-field",
13070 children: [
13071 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13072 VisuallyHidden,
13073 {
13074 className: "dataviews-view-activity__item-field-label",
13075 render: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", {}),
13076 children: field.label
13077 }
13078 ),
13079 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13080 field.render,
13081 {
13082 item,
13083 field
13084 }
13085 ) })
13086 ]
13087 },
13088 field.id
13089 )) }),
13090 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13091 PrimaryActions,
13092 {
13093 item,
13094 actions: primaryActions,
13095 registry,
13096 buttonVariant: "secondary"
13097 }
13098 )
13099 ]
13100 }
13101 ),
13102 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13103 // there if there are any actions at all.
13104 isMobileViewport && // At the same time, only show the menu if there are actions to show.
13105 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13106 ItemActions,
13107 {
13108 item,
13109 actions: eligibleActions,
13110 isCompact: true
13111 }
13112 ) })
13113 ] })
13114 }
13115 );
13116 }
13117 var activity_item_default = ActivityItem;
13118
13119 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
13120 var import_react6 = __toESM(require_react(), 1);
13121 function isDefined3(item) {
13122 return !!item;
13123 }
13124 function ActivityItems(props) {
13125 const { data, fields, getItemId, view } = props;
13126 const titleField = fields.find((field) => field.id === view.titleField);
13127 const mediaField = fields.find((field) => field.id === view.mediaField);
13128 const descriptionField = fields.find(
13129 (field) => field.id === view.descriptionField
13130 );
13131 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
13132 return data.map((item, index2) => {
13133 return /* @__PURE__ */ (0, import_react6.createElement)(
13134 activity_item_default,
13135 {
13136 ...props,
13137 key: getItemId(item),
13138 item,
13139 mediaField,
13140 titleField,
13141 descriptionField,
13142 otherFields,
13143 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13144 }
13145 );
13146 });
13147 }
13148
13149 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13150 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
13151 function ViewActivity(props) {
13152 const { empty, data, fields, isLoading, view, className } = props;
13153 const isDelayedLoading = useDelayedLoading(!!isLoading);
13154 const hasData = !!data?.length;
13155 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13156 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13157 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13158 if (!hasData) {
13159 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13160 "div",
13161 {
13162 className: clsx_default("dataviews-no-results", {
13163 "is-refreshing": isDelayedLoading
13164 }),
13165 children: empty
13166 }
13167 );
13168 }
13169 const isInert = !isInfiniteScroll && !!isLoading;
13170 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
13171 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13172 });
13173 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
13174 if (hasData && groupField && dataByGroup) {
13175 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13176 Stack,
13177 {
13178 direction: "column",
13179 gap: "sm",
13180 className: wrapperClassName,
13181 inert: isInert ? "true" : void 0,
13182 children: groupedEntries.map(
13183 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13184 ActivityGroup,
13185 {
13186 groupName,
13187 groupData,
13188 groupField,
13189 showLabel: view.groupBy?.showLabel !== false,
13190 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13191 ActivityItems,
13192 {
13193 ...props,
13194 data: groupData
13195 }
13196 )
13197 },
13198 groupName
13199 )
13200 )
13201 }
13202 );
13203 }
13204 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
13205 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13206 "div",
13207 {
13208 className: wrapperClassName,
13209 role: view.infiniteScrollEnabled ? "feed" : void 0,
13210 inert: isInert ? "true" : void 0,
13211 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ActivityItems, { ...props })
13212 }
13213 ),
13214 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components11.Spinner, {}) })
13215 ] });
13216 }
13217
13218 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13219 var import_components14 = __toESM(require_components(), 1);
13220 var import_i18n17 = __toESM(require_i18n(), 1);
13221 var import_compose6 = __toESM(require_compose(), 1);
13222 var import_element35 = __toESM(require_element(), 1);
13223
13224 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13225 var import_components13 = __toESM(require_components(), 1);
13226 var import_data8 = __toESM(require_data(), 1);
13227 var import_element34 = __toESM(require_element(), 1);
13228 var import_i18n16 = __toESM(require_i18n(), 1);
13229
13230 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
13231 var import_components12 = __toESM(require_components(), 1);
13232 var import_element33 = __toESM(require_element(), 1);
13233 var import_i18n15 = __toESM(require_i18n(), 1);
13234 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
13235 function DataViewsPagination() {
13236 const {
13237 view,
13238 onChangeView,
13239 paginationInfo: { totalItems = 0, totalPages }
13240 } = (0, import_element33.useContext)(dataviews_context_default);
13241 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
13242 return null;
13243 }
13244 const currentPage = view.page ?? 1;
13245 const pageSelectOptions = Array.from(Array(totalPages)).map(
13246 (_, i2) => {
13247 const page = i2 + 1;
13248 return {
13249 value: page.toString(),
13250 label: page.toString(),
13251 "aria-label": currentPage === page ? (0, import_i18n15.sprintf)(
13252 // translators: 1: current page number. 2: total number of pages.
13253 (0, import_i18n15.__)("Page %1$d of %2$d"),
13254 currentPage,
13255 totalPages
13256 ) : page.toString()
13257 };
13258 }
13259 );
13260 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
13261 Stack,
13262 {
13263 direction: "row",
13264 className: "dataviews-pagination",
13265 justify: "end",
13266 align: "center",
13267 gap: "xl",
13268 children: [
13269 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13270 Stack,
13271 {
13272 direction: "row",
13273 justify: "flex-start",
13274 align: "center",
13275 gap: "xs",
13276 className: "dataviews-pagination__page-select",
13277 children: (0, import_element33.createInterpolateElement)(
13278 (0, import_i18n15.sprintf)(
13279 // translators: 1: Current page number, 2: Total number of pages.
13280 (0, import_i18n15._x)(
13281 "<div>Page</div>%1$s<div>of %2$d</div>",
13282 "paging"
13283 ),
13284 "<CurrentPage />",
13285 totalPages
13286 ),
13287 {
13288 div: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { "aria-hidden": true }),
13289 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
13290 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13291 import_components12.SelectControl,
13292 {
13293 "aria-label": (0, import_i18n15.__)("Current page"),
13294 value: currentPage.toString(),
13295 options: pageSelectOptions,
13296 onChange: (newValue) => {
13297 onChangeView({
13298 ...view,
13299 page: +newValue
13300 });
13301 },
13302 size: "small",
13303 variant: "minimal"
13304 }
13305 )
13306 }
13307 )
13308 }
13309 ),
13310 /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
13311 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13312 import_components12.Button,
13313 {
13314 onClick: () => onChangeView({
13315 ...view,
13316 page: currentPage - 1
13317 }),
13318 disabled: currentPage === 1,
13319 accessibleWhenDisabled: true,
13320 label: (0, import_i18n15.__)("Previous page"),
13321 icon: (0, import_i18n15.isRTL)() ? next_default : previous_default,
13322 showTooltip: true,
13323 size: "compact",
13324 tooltipPosition: "top"
13325 }
13326 ),
13327 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13328 import_components12.Button,
13329 {
13330 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
13331 disabled: currentPage >= totalPages,
13332 accessibleWhenDisabled: true,
13333 label: (0, import_i18n15.__)("Next page"),
13334 icon: (0, import_i18n15.isRTL)() ? previous_default : next_default,
13335 showTooltip: true,
13336 size: "compact",
13337 tooltipPosition: "top"
13338 }
13339 )
13340 ] })
13341 ]
13342 }
13343 );
13344 }
13345 var dataviews_pagination_default = (0, import_element33.memo)(DataViewsPagination);
13346
13347 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13348 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
13349 function useIsMultiselectPicker(actions) {
13350 return (0, import_element34.useMemo)(() => {
13351 return actions?.every((action) => action.supportsBulk);
13352 }, [actions]);
13353 }
13354
13355 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13356 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
13357 var { Badge: WCBadge2 } = unlock3(import_components14.privateApis);
13358 function GridItem3({
13359 view,
13360 multiselect,
13361 selection,
13362 onChangeSelection,
13363 getItemId,
13364 item,
13365 mediaField,
13366 titleField,
13367 descriptionField,
13368 regularFields,
13369 badgeFields,
13370 config,
13371 posinset,
13372 setsize
13373 }) {
13374 const { showTitle = true, showMedia = true, showDescription = true } = view;
13375 const id = getItemId(item);
13376 const elementRef = (0, import_element35.useRef)(null);
13377 const isSelected2 = selection.includes(id);
13378 useIntersectionObserver(elementRef, posinset);
13379 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13380 mediaField.render,
13381 {
13382 item,
13383 field: mediaField,
13384 config
13385 }
13386 ) : null;
13387 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(titleField.render, { item, field: titleField }) : null;
13388 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
13389 import_components14.Composite.Item,
13390 {
13391 ref: elementRef,
13392 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n17.__)("(no title)") : void 0,
13393 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Stack, { direction: "column", children, ...props }),
13394 role: "option",
13395 "aria-posinset": posinset,
13396 "aria-setsize": setsize,
13397 className: clsx_default("dataviews-view-picker-grid__card", {
13398 "is-selected": isSelected2
13399 }),
13400 "aria-selected": isSelected2,
13401 onClick: () => {
13402 if (isSelected2) {
13403 onChangeSelection(
13404 selection.filter((itemId) => id !== itemId)
13405 );
13406 } else {
13407 const newSelection = multiselect ? [...selection, id] : [id];
13408 onChangeSelection(newSelection);
13409 }
13410 },
13411 children: [
13412 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
13413 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13414 DataViewsSelectionCheckbox,
13415 {
13416 item,
13417 selection,
13418 onChangeSelection,
13419 getItemId,
13420 titleField,
13421 disabled: false,
13422 "aria-hidden": true,
13423 tabIndex: -1
13424 }
13425 ),
13426 showTitle && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13427 Stack,
13428 {
13429 direction: "row",
13430 justify: "space-between",
13431 className: "dataviews-view-picker-grid__title-actions",
13432 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
13433 }
13434 ),
13435 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(Stack, { direction: "column", gap: "xs", children: [
13436 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13437 descriptionField.render,
13438 {
13439 item,
13440 field: descriptionField
13441 }
13442 ),
13443 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13444 Stack,
13445 {
13446 direction: "row",
13447 className: "dataviews-view-picker-grid__badge-fields",
13448 gap: "sm",
13449 wrap: "wrap",
13450 align: "top",
13451 justify: "flex-start",
13452 children: badgeFields.map((field) => {
13453 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13454 WCBadge2,
13455 {
13456 className: "dataviews-view-picker-grid__field-value",
13457 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13458 field.render,
13459 {
13460 item,
13461 field
13462 }
13463 )
13464 },
13465 field.id
13466 );
13467 })
13468 }
13469 ),
13470 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13471 Stack,
13472 {
13473 direction: "column",
13474 className: "dataviews-view-picker-grid__fields",
13475 gap: "xs",
13476 children: regularFields.map((field) => {
13477 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13478 import_components14.Flex,
13479 {
13480 className: "dataviews-view-picker-grid__field",
13481 gap: 1,
13482 justify: "flex-start",
13483 expanded: true,
13484 style: { height: "auto" },
13485 direction: "row",
13486 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
13487 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
13488 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13489 import_components14.FlexItem,
13490 {
13491 className: "dataviews-view-picker-grid__field-value",
13492 style: { maxHeight: "none" },
13493 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13494 field.render,
13495 {
13496 item,
13497 field
13498 }
13499 )
13500 }
13501 )
13502 ] })
13503 },
13504 field.id
13505 );
13506 })
13507 }
13508 )
13509 ] })
13510 ]
13511 },
13512 id
13513 );
13514 }
13515 function GridGroup({
13516 groupName,
13517 groupField,
13518 showLabel = true,
13519 children
13520 }) {
13521 const headerId = (0, import_compose6.useInstanceId)(
13522 GridGroup,
13523 "dataviews-view-picker-grid-group__header"
13524 );
13525 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
13526 Stack,
13527 {
13528 direction: "column",
13529 gap: "sm",
13530 role: "group",
13531 "aria-labelledby": headerId,
13532 children: [
13533 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13534 "h3",
13535 {
13536 className: "dataviews-view-picker-grid-group__header",
13537 id: headerId,
13538 children: showLabel ? (0, import_i18n17.sprintf)(
13539 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13540 (0, import_i18n17.__)("%1$s: %2$s"),
13541 groupField.label,
13542 groupName
13543 ) : groupName
13544 }
13545 ),
13546 children
13547 ]
13548 },
13549 groupName
13550 );
13551 }
13552 function ViewPickerGrid({
13553 actions,
13554 data,
13555 fields,
13556 getItemId,
13557 isLoading,
13558 onChangeSelection,
13559 selection,
13560 view,
13561 className,
13562 empty
13563 }) {
13564 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element35.useContext)(dataviews_context_default);
13565 const titleField = fields.find(
13566 (field) => field.id === view?.titleField
13567 );
13568 const mediaField = fields.find(
13569 (field) => field.id === view?.mediaField
13570 );
13571 const descriptionField = fields.find(
13572 (field) => field.id === view?.descriptionField
13573 );
13574 const otherFields = view.fields ?? [];
13575 const { regularFields, badgeFields } = otherFields.reduce(
13576 (accumulator, fieldId) => {
13577 const field = fields.find((f2) => f2.id === fieldId);
13578 if (!field) {
13579 return accumulator;
13580 }
13581 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
13582 accumulator[key].push(field);
13583 return accumulator;
13584 },
13585 { regularFields: [], badgeFields: [] }
13586 );
13587 const hasData = !!data?.length;
13588 const usedPreviewSize = view.layout?.previewSize;
13589 const isMultiselect = useIsMultiselectPicker(actions);
13590 const size4 = "900px";
13591 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
13592 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
13593 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
13594 const currentPage = view?.page ?? 1;
13595 const perPage = view?.perPage ?? 0;
13596 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
13597 const gridColumns = useGridColumns();
13598 const placeholdersNeeded = usePlaceholdersNeeded(
13599 data,
13600 isInfiniteScroll,
13601 gridColumns
13602 );
13603 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, {
13604 // Render multiple groups.
13605 children: [
13606 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13607 import_components14.Composite,
13608 {
13609 virtualFocus: true,
13610 orientation: "horizontal",
13611 role: "listbox",
13612 "aria-multiselectable": isMultiselect,
13613 className: clsx_default(
13614 "dataviews-view-picker-grid",
13615 className,
13616 {
13617 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
13618 view.layout.density
13619 )
13620 }
13621 ),
13622 "aria-label": itemListLabel,
13623 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13624 Stack,
13625 {
13626 direction: "column",
13627 gap: "lg",
13628 children,
13629 ...props
13630 }
13631 ),
13632 children: Array.from(dataByGroup.entries()).map(
13633 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13634 GridGroup,
13635 {
13636 groupName,
13637 groupField,
13638 showLabel: view.groupBy?.showLabel !== false,
13639 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13640 GridItems,
13641 {
13642 previewSize: usedPreviewSize,
13643 style: {
13644 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
13645 },
13646 "aria-busy": isLoading,
13647 ref: resizeObserverRef,
13648 children: groupItems.map((item) => {
13649 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
13650 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13651 GridItem3,
13652 {
13653 view,
13654 multiselect: isMultiselect,
13655 selection,
13656 onChangeSelection,
13657 getItemId,
13658 item,
13659 mediaField,
13660 titleField,
13661 descriptionField,
13662 regularFields,
13663 badgeFields,
13664 config: {
13665 sizes: size4
13666 },
13667 posinset: posInSet,
13668 setsize: setSize
13669 },
13670 getItemId(item)
13671 );
13672 })
13673 }
13674 )
13675 },
13676 groupName
13677 )
13678 )
13679 }
13680 ),
13681 // Render a single grid with all data.
13682 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
13683 import_components14.Composite,
13684 {
13685 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13686 GridItems,
13687 {
13688 className: clsx_default(
13689 "dataviews-view-picker-grid",
13690 className,
13691 {
13692 [`has-${view.layout?.density}-density`]: view.layout?.density && [
13693 "compact",
13694 "comfortable"
13695 ].includes(view.layout.density)
13696 }
13697 ),
13698 previewSize: usedPreviewSize,
13699 "aria-busy": isLoading,
13700 ref: resizeObserverRef
13701 }
13702 ),
13703 virtualFocus: true,
13704 orientation: "horizontal",
13705 role: "listbox",
13706 "aria-multiselectable": isMultiselect,
13707 "aria-label": itemListLabel,
13708 children: [
13709 Array.from({ length: placeholdersNeeded }).map(
13710 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13711 import_components14.Composite.Item,
13712 {
13713 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13714 Stack,
13715 {
13716 direction: "column",
13717 children,
13718 ...props
13719 }
13720 ),
13721 role: "option",
13722 "aria-hidden": true,
13723 tabIndex: -1,
13724 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
13725 },
13726 `placeholder-${index2}`
13727 )
13728 ),
13729 data.map((item) => {
13730 const posinset = item.position;
13731 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13732 GridItem3,
13733 {
13734 view,
13735 multiselect: isMultiselect,
13736 selection,
13737 onChangeSelection,
13738 getItemId,
13739 item,
13740 mediaField,
13741 titleField,
13742 descriptionField,
13743 regularFields,
13744 badgeFields,
13745 config: {
13746 sizes: size4
13747 },
13748 posinset,
13749 setsize: setSize
13750 },
13751 getItemId(item)
13752 );
13753 })
13754 ]
13755 }
13756 ),
13757 // Render empty state.
13758 !hasData && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13759 "div",
13760 {
13761 className: clsx_default({
13762 "dataviews-loading": isLoading,
13763 "dataviews-no-results": !isLoading
13764 }),
13765 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components14.Spinner, {}) }) : empty
13766 }
13767 ),
13768 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components14.Spinner, {}) })
13769 ]
13770 });
13771 }
13772 var picker_grid_default = ViewPickerGrid;
13773
13774 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
13775 var import_i18n18 = __toESM(require_i18n(), 1);
13776 var import_components15 = __toESM(require_components(), 1);
13777 var import_element36 = __toESM(require_element(), 1);
13778 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
13779 function TableColumnField2({
13780 item,
13781 fields,
13782 column,
13783 align
13784 }) {
13785 const field = fields.find((f2) => f2.id === column);
13786 if (!field) {
13787 return null;
13788 }
13789 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
13790 "dataviews-view-table__cell-align-end": align === "end",
13791 "dataviews-view-table__cell-align-center": align === "center"
13792 });
13793 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(field.render, { item, field }) });
13794 }
13795 function TableRow2({
13796 item,
13797 fields,
13798 id,
13799 view,
13800 titleField,
13801 mediaField,
13802 descriptionField,
13803 selection,
13804 getItemId,
13805 onChangeSelection,
13806 multiselect,
13807 posinset
13808 }) {
13809 const { paginationInfo } = (0, import_element36.useContext)(dataviews_context_default);
13810 const isSelected2 = selection.includes(id);
13811 const [isHovered, setIsHovered] = (0, import_element36.useState)(false);
13812 const elementRef = (0, import_element36.useRef)(null);
13813 useIntersectionObserver(elementRef, posinset);
13814 const {
13815 showTitle = true,
13816 showMedia = true,
13817 showDescription = true,
13818 infiniteScrollEnabled
13819 } = view;
13820 const handleMouseEnter = () => {
13821 setIsHovered(true);
13822 };
13823 const handleMouseLeave = () => {
13824 setIsHovered(false);
13825 };
13826 const columns = view.fields ?? [];
13827 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
13828 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13829 import_components15.Composite.Item,
13830 {
13831 ref: elementRef,
13832 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13833 "tr",
13834 {
13835 className: clsx_default("dataviews-view-table__row", {
13836 "is-selected": isSelected2,
13837 "is-hovered": isHovered
13838 }),
13839 onMouseEnter: handleMouseEnter,
13840 onMouseLeave: handleMouseLeave,
13841 children,
13842 ...props
13843 }
13844 ),
13845 "aria-selected": isSelected2,
13846 "aria-setsize": paginationInfo.totalItems || void 0,
13847 "aria-posinset": posinset,
13848 role: infiniteScrollEnabled ? "article" : "option",
13849 onMouseDown: (event) => {
13850 if (event.button !== 0) {
13851 return;
13852 }
13853 event.currentTarget.parentElement?.focus({
13854 preventScroll: true
13855 });
13856 },
13857 onClick: () => {
13858 if (isSelected2) {
13859 onChangeSelection(
13860 selection.filter((itemId) => id !== itemId)
13861 );
13862 } else {
13863 const newSelection = multiselect ? [...selection, id] : [id];
13864 onChangeSelection(newSelection);
13865 }
13866 },
13867 children: [
13868 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13869 "td",
13870 {
13871 className: "dataviews-view-table__checkbox-column",
13872 role: "presentation",
13873 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13874 DataViewsSelectionCheckbox,
13875 {
13876 item,
13877 selection,
13878 onChangeSelection,
13879 getItemId,
13880 titleField,
13881 disabled: false,
13882 "aria-hidden": true,
13883 tabIndex: -1
13884 }
13885 ) })
13886 }
13887 ),
13888 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13889 "td",
13890 {
13891 role: "presentation",
13892 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13893 column_primary_default,
13894 {
13895 item,
13896 titleField: showTitle ? titleField : void 0,
13897 mediaField: showMedia ? mediaField : void 0,
13898 descriptionField: showDescription ? descriptionField : void 0,
13899 isItemClickable: () => false
13900 }
13901 )
13902 }
13903 ),
13904 columns.map((column) => {
13905 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
13906 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13907 "td",
13908 {
13909 style: {
13910 width,
13911 maxWidth,
13912 minWidth
13913 },
13914 role: "presentation",
13915 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13916 TableColumnField2,
13917 {
13918 fields,
13919 item,
13920 column,
13921 align
13922 }
13923 )
13924 },
13925 column
13926 );
13927 })
13928 ]
13929 },
13930 id
13931 );
13932 }
13933 function ViewPickerTable({
13934 actions,
13935 data,
13936 fields,
13937 getItemId,
13938 isLoading = false,
13939 onChangeView,
13940 onChangeSelection,
13941 selection,
13942 setOpenedFilter,
13943 view,
13944 className,
13945 empty
13946 }) {
13947 const headerMenuRefs = (0, import_element36.useRef)(/* @__PURE__ */ new Map());
13948 const headerMenuToFocusRef = (0, import_element36.useRef)(void 0);
13949 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element36.useState)();
13950 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
13951 (0, import_element36.useEffect)(() => {
13952 if (headerMenuToFocusRef.current) {
13953 headerMenuToFocusRef.current.focus();
13954 headerMenuToFocusRef.current = void 0;
13955 }
13956 });
13957 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
13958 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
13959 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13960 const tableNoticeId = (0, import_element36.useId)();
13961 if (nextHeaderMenuToFocus) {
13962 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
13963 setNextHeaderMenuToFocus(void 0);
13964 return;
13965 }
13966 const onHide = (field) => {
13967 const hidden = headerMenuRefs.current.get(field.id);
13968 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
13969 setNextHeaderMenuToFocus(fallback?.node);
13970 };
13971 const hasData = !!data?.length;
13972 const titleField = fields.find((field) => field.id === view.titleField);
13973 const mediaField = fields.find((field) => field.id === view.mediaField);
13974 const descriptionField = fields.find(
13975 (field) => field.id === view.descriptionField
13976 );
13977 const { showTitle = true, showMedia = true, showDescription = true } = view;
13978 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
13979 const columns = view.fields ?? [];
13980 const headerMenuRef = (column, index2) => (node) => {
13981 if (node) {
13982 headerMenuRefs.current.set(column, {
13983 node,
13984 fallback: columns[index2 > 0 ? index2 - 1 : 1]
13985 });
13986 } else {
13987 headerMenuRefs.current.delete(column);
13988 }
13989 };
13990 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, { children: [
13991 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13992 "table",
13993 {
13994 className: clsx_default(
13995 "dataviews-view-table",
13996 "dataviews-view-picker-table",
13997 className,
13998 {
13999 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14000 view.layout.density
14001 )
14002 }
14003 ),
14004 "aria-busy": isLoading,
14005 "aria-describedby": tableNoticeId,
14006 role: isInfiniteScroll ? "feed" : "listbox",
14007 children: [
14008 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14009 "tr",
14010 {
14011 className: "dataviews-view-table__row",
14012 role: "presentation",
14013 children: [
14014 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14015 BulkSelectionCheckbox,
14016 {
14017 selection,
14018 onChangeSelection,
14019 data,
14020 actions,
14021 getItemId,
14022 disableSelectAll: isInfiniteScroll
14023 }
14024 ) }),
14025 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14026 column_header_menu_default,
14027 {
14028 ref: headerMenuRef(
14029 titleField.id,
14030 0
14031 ),
14032 fieldId: titleField.id,
14033 view,
14034 fields,
14035 onChangeView,
14036 onHide,
14037 setOpenedFilter,
14038 canMove: false
14039 }
14040 ) }),
14041 columns.map((column, index2) => {
14042 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14043 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14044 "th",
14045 {
14046 style: {
14047 width,
14048 maxWidth,
14049 minWidth,
14050 textAlign: align
14051 },
14052 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14053 scope: "col",
14054 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14055 column_header_menu_default,
14056 {
14057 ref: headerMenuRef(column, index2),
14058 fieldId: column,
14059 view,
14060 fields,
14061 onChangeView,
14062 onHide,
14063 setOpenedFilter,
14064 canMove: view.layout?.enableMoving ?? true
14065 }
14066 )
14067 },
14068 column
14069 );
14070 })
14071 ]
14072 }
14073 ) }),
14074 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14075 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14076 import_components15.Composite,
14077 {
14078 virtualFocus: true,
14079 orientation: "vertical",
14080 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("tbody", { role: "group" }),
14081 children: [
14082 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14083 "tr",
14084 {
14085 className: "dataviews-view-table__group-header-row",
14086 role: "presentation",
14087 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14088 "td",
14089 {
14090 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
14091 className: "dataviews-view-table__group-header-cell",
14092 role: "presentation",
14093 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n18.sprintf)(
14094 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14095 (0, import_i18n18.__)("%1$s: %2$s"),
14096 groupField.label,
14097 groupName
14098 )
14099 }
14100 )
14101 }
14102 ),
14103 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14104 TableRow2,
14105 {
14106 item,
14107 fields,
14108 id: getItemId(item) || index2.toString(),
14109 view,
14110 titleField,
14111 mediaField,
14112 descriptionField,
14113 selection,
14114 getItemId,
14115 onChangeSelection,
14116 multiselect: isMultiselect
14117 },
14118 getItemId(item)
14119 ))
14120 ]
14121 },
14122 `group-${groupName}`
14123 )
14124 ) : /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14125 import_components15.Composite,
14126 {
14127 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("tbody", { role: "presentation" }),
14128 virtualFocus: true,
14129 orientation: "vertical",
14130 children: hasData && data.map((item, index2) => {
14131 const itemId = getItemId(item);
14132 const posinset = item.position;
14133 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14134 TableRow2,
14135 {
14136 item,
14137 fields,
14138 id: itemId || index2.toString(),
14139 view,
14140 titleField,
14141 mediaField,
14142 descriptionField,
14143 selection,
14144 getItemId,
14145 onChangeSelection,
14146 multiselect: isMultiselect,
14147 posinset
14148 },
14149 itemId
14150 );
14151 })
14152 }
14153 )
14154 ]
14155 }
14156 ),
14157 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14158 "div",
14159 {
14160 className: clsx_default({
14161 "dataviews-loading": isLoading,
14162 "dataviews-no-results": !hasData && !isLoading
14163 }),
14164 id: tableNoticeId,
14165 children: [
14166 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components15.Spinner, {}) }) : empty),
14167 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components15.Spinner, {}) })
14168 ]
14169 }
14170 )
14171 ] });
14172 }
14173 var picker_table_default = ViewPickerTable;
14174
14175 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
14176 var import_components16 = __toESM(require_components(), 1);
14177 var import_i18n19 = __toESM(require_i18n(), 1);
14178 var import_element37 = __toESM(require_element(), 1);
14179 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
14180 function DensityPicker() {
14181 const context = (0, import_element37.useContext)(dataviews_context_default);
14182 const view = context.view;
14183 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
14184 import_components16.__experimentalToggleGroupControl,
14185 {
14186 size: "__unstable-large",
14187 label: (0, import_i18n19.__)("Density"),
14188 value: view.layout?.density || "balanced",
14189 onChange: (value) => {
14190 context.onChangeView({
14191 ...view,
14192 layout: {
14193 ...view.layout,
14194 density: value
14195 }
14196 });
14197 },
14198 isBlock: true,
14199 children: [
14200 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14201 import_components16.__experimentalToggleGroupControlOption,
14202 {
14203 value: "comfortable",
14204 label: (0, import_i18n19._x)(
14205 "Comfortable",
14206 "Density option for DataView layout"
14207 )
14208 },
14209 "comfortable"
14210 ),
14211 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14212 import_components16.__experimentalToggleGroupControlOption,
14213 {
14214 value: "balanced",
14215 label: (0, import_i18n19._x)("Balanced", "Density option for DataView layout")
14216 },
14217 "balanced"
14218 ),
14219 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14220 import_components16.__experimentalToggleGroupControlOption,
14221 {
14222 value: "compact",
14223 label: (0, import_i18n19._x)("Compact", "Density option for DataView layout")
14224 },
14225 "compact"
14226 )
14227 ]
14228 }
14229 );
14230 }
14231
14232 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
14233 var import_components17 = __toESM(require_components(), 1);
14234 var import_i18n20 = __toESM(require_i18n(), 1);
14235 var import_element38 = __toESM(require_element(), 1);
14236 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
14237 var imageSizes2 = [
14238 {
14239 value: 120,
14240 breakpoint: 1
14241 },
14242 {
14243 value: 170,
14244 breakpoint: 1
14245 },
14246 {
14247 value: 230,
14248 breakpoint: 1
14249 },
14250 {
14251 value: 290,
14252 breakpoint: 1112
14253 // at minimum image width, 4 images display at this container size
14254 },
14255 {
14256 value: 350,
14257 breakpoint: 1636
14258 // at minimum image width, 6 images display at this container size
14259 },
14260 {
14261 value: 430,
14262 breakpoint: 588
14263 // at minimum image width, 2 images display at this container size
14264 }
14265 ];
14266 function PreviewSizePicker() {
14267 const context = (0, import_element38.useContext)(dataviews_context_default);
14268 const view = context.view;
14269 const breakValues = imageSizes2.filter((size4) => {
14270 return context.containerWidth >= size4.breakpoint;
14271 });
14272 const layoutPreviewSize = view.layout?.previewSize ?? 230;
14273 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
14274 const marks = breakValues.map((size4, index2) => {
14275 return {
14276 value: index2
14277 };
14278 });
14279 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
14280 import_components17.RangeControl,
14281 {
14282 __next40pxDefaultSize: true,
14283 showTooltip: false,
14284 label: (0, import_i18n20.__)("Preview size"),
14285 value: previewSizeToUse,
14286 min: 0,
14287 max: breakValues.length - 1,
14288 withInputField: false,
14289 onChange: (value = 0) => {
14290 context.onChangeView({
14291 ...view,
14292 layout: {
14293 ...view.layout,
14294 previewSize: breakValues[value].value
14295 }
14296 });
14297 },
14298 step: 1,
14299 marks
14300 }
14301 );
14302 }
14303
14304 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
14305 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
14306 function GridConfigOptions() {
14307 return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_jsx_runtime62.Fragment, { children: [
14308 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(DensityPicker, {}),
14309 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(PreviewSizePicker, {})
14310 ] });
14311 }
14312
14313 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
14314 var VIEW_LAYOUTS = [
14315 {
14316 type: LAYOUT_TABLE,
14317 label: (0, import_i18n21.__)("Table"),
14318 component: table_default,
14319 icon: block_table_default,
14320 viewConfigOptions: DensityPicker
14321 },
14322 {
14323 type: LAYOUT_GRID,
14324 label: (0, import_i18n21.__)("Grid"),
14325 component: grid_default,
14326 icon: category_default,
14327 viewConfigOptions: GridConfigOptions
14328 },
14329 {
14330 type: LAYOUT_LIST,
14331 label: (0, import_i18n21.__)("List"),
14332 component: ViewList,
14333 icon: (0, import_i18n21.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
14334 viewConfigOptions: DensityPicker
14335 },
14336 {
14337 type: LAYOUT_ACTIVITY,
14338 label: (0, import_i18n21.__)("Activity"),
14339 component: ViewActivity,
14340 icon: scheduled_default,
14341 viewConfigOptions: DensityPicker
14342 },
14343 {
14344 type: LAYOUT_PICKER_GRID,
14345 label: (0, import_i18n21.__)("Grid"),
14346 component: picker_grid_default,
14347 icon: category_default,
14348 viewConfigOptions: GridConfigOptions,
14349 isPicker: true
14350 },
14351 {
14352 type: LAYOUT_PICKER_TABLE,
14353 label: (0, import_i18n21.__)("Table"),
14354 component: picker_table_default,
14355 icon: block_table_default,
14356 viewConfigOptions: DensityPicker,
14357 isPicker: true
14358 }
14359 ];
14360
14361 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
14362 var import_element46 = __toESM(require_element(), 1);
14363
14364 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
14365 var import_components20 = __toESM(require_components(), 1);
14366 var import_i18n24 = __toESM(require_i18n(), 1);
14367 var import_element43 = __toESM(require_element(), 1);
14368
14369 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
14370 function noop4(..._) {
14371 }
14372 function applyState(argument, currentValue) {
14373 if (isUpdater(argument)) {
14374 const value = isLazyValue(currentValue) ? currentValue() : currentValue;
14375 return argument(value);
14376 }
14377 return argument;
14378 }
14379 function isUpdater(argument) {
14380 return typeof argument === "function";
14381 }
14382 function isLazyValue(value) {
14383 return typeof value === "function";
14384 }
14385 function hasOwnProperty(object, prop) {
14386 if (typeof Object.hasOwn === "function") {
14387 return Object.hasOwn(object, prop);
14388 }
14389 return Object.prototype.hasOwnProperty.call(object, prop);
14390 }
14391 function chain(...fns) {
14392 return (...args) => {
14393 for (const fn of fns) {
14394 if (typeof fn === "function") {
14395 fn(...args);
14396 }
14397 }
14398 };
14399 }
14400 function normalizeString(str) {
14401 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
14402 }
14403 function omit2(object, keys) {
14404 const result = { ...object };
14405 for (const key of keys) {
14406 if (hasOwnProperty(result, key)) {
14407 delete result[key];
14408 }
14409 }
14410 return result;
14411 }
14412 function pick(object, paths) {
14413 const result = {};
14414 for (const key of paths) {
14415 if (hasOwnProperty(object, key)) {
14416 result[key] = object[key];
14417 }
14418 }
14419 return result;
14420 }
14421 function identity(value) {
14422 return value;
14423 }
14424 function invariant(condition, message2) {
14425 if (condition) return;
14426 if (typeof message2 !== "string") throw new Error("Invariant failed");
14427 throw new Error(message2);
14428 }
14429 function getKeys(obj) {
14430 return Object.keys(obj);
14431 }
14432 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
14433 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
14434 if (result == null) return false;
14435 return !result;
14436 }
14437 function disabledFromProps(props) {
14438 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
14439 }
14440 function removeUndefinedValues(obj) {
14441 const result = {};
14442 for (const key in obj) {
14443 if (obj[key] !== void 0) {
14444 result[key] = obj[key];
14445 }
14446 }
14447 return result;
14448 }
14449 function defaultValue(...values) {
14450 for (const value of values) {
14451 if (value !== void 0) return value;
14452 }
14453 return void 0;
14454 }
14455
14456 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
14457 var import_react7 = __toESM(require_react(), 1);
14458 function setRef(ref, value) {
14459 if (typeof ref === "function") {
14460 ref(value);
14461 } else if (ref) {
14462 ref.current = value;
14463 }
14464 }
14465 function isValidElementWithRef(element) {
14466 if (!element) return false;
14467 if (!(0, import_react7.isValidElement)(element)) return false;
14468 if ("ref" in element.props) return true;
14469 if ("ref" in element) return true;
14470 return false;
14471 }
14472 function getRefProperty(element) {
14473 if (!isValidElementWithRef(element)) return null;
14474 const props = { ...element.props };
14475 return props.ref || element.ref;
14476 }
14477 function mergeProps3(base, overrides) {
14478 const props = { ...base };
14479 for (const key in overrides) {
14480 if (!hasOwnProperty(overrides, key)) continue;
14481 if (key === "className") {
14482 const prop = "className";
14483 props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
14484 continue;
14485 }
14486 if (key === "style") {
14487 const prop = "style";
14488 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
14489 continue;
14490 }
14491 const overrideValue = overrides[key];
14492 if (typeof overrideValue === "function" && key.startsWith("on")) {
14493 const baseValue = base[key];
14494 if (typeof baseValue === "function") {
14495 props[key] = (...args) => {
14496 overrideValue(...args);
14497 baseValue(...args);
14498 };
14499 continue;
14500 }
14501 }
14502 props[key] = overrideValue;
14503 }
14504 return props;
14505 }
14506
14507 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
14508 var canUseDOM = checkIsBrowser();
14509 function checkIsBrowser() {
14510 var _a;
14511 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
14512 }
14513 function getDocument(node) {
14514 if (!node) return document;
14515 if ("self" in node) return node.document;
14516 return node.ownerDocument || document;
14517 }
14518 function getActiveElement(node, activeDescendant = false) {
14519 var _a;
14520 const { activeElement: activeElement2 } = getDocument(node);
14521 if (!(activeElement2 == null ? void 0 : activeElement2.nodeName)) {
14522 return null;
14523 }
14524 if (isFrame(activeElement2) && ((_a = activeElement2.contentDocument) == null ? void 0 : _a.body)) {
14525 return getActiveElement(
14526 activeElement2.contentDocument.body,
14527 activeDescendant
14528 );
14529 }
14530 if (activeDescendant) {
14531 const id = activeElement2.getAttribute("aria-activedescendant");
14532 if (id) {
14533 const element = getDocument(activeElement2).getElementById(id);
14534 if (element) {
14535 return element;
14536 }
14537 }
14538 }
14539 return activeElement2;
14540 }
14541 function contains2(parent, child) {
14542 return parent === child || parent.contains(child);
14543 }
14544 function isFrame(element) {
14545 return element.tagName === "IFRAME";
14546 }
14547 function isButton(element) {
14548 const tagName = element.tagName.toLowerCase();
14549 if (tagName === "button") return true;
14550 if (tagName === "input" && element.type) {
14551 return buttonInputTypes.indexOf(element.type) !== -1;
14552 }
14553 return false;
14554 }
14555 var buttonInputTypes = [
14556 "button",
14557 "color",
14558 "file",
14559 "image",
14560 "reset",
14561 "submit"
14562 ];
14563 function isVisible(element) {
14564 if (typeof element.checkVisibility === "function") {
14565 return element.checkVisibility();
14566 }
14567 const htmlElement = element;
14568 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
14569 }
14570 function isTextField(element) {
14571 try {
14572 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
14573 const isTextArea = element.tagName === "TEXTAREA";
14574 return isTextInput || isTextArea || false;
14575 } catch (_error) {
14576 return false;
14577 }
14578 }
14579 function isTextbox(element) {
14580 return element.isContentEditable || isTextField(element);
14581 }
14582 function getTextboxValue(element) {
14583 if (isTextField(element)) {
14584 return element.value;
14585 }
14586 if (element.isContentEditable) {
14587 const range = getDocument(element).createRange();
14588 range.selectNodeContents(element);
14589 return range.toString();
14590 }
14591 return "";
14592 }
14593 function getTextboxSelection(element) {
14594 let start = 0;
14595 let end = 0;
14596 if (isTextField(element)) {
14597 start = element.selectionStart || 0;
14598 end = element.selectionEnd || 0;
14599 } else if (element.isContentEditable) {
14600 const selection = getDocument(element).getSelection();
14601 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
14602 const range = selection.getRangeAt(0);
14603 const nextRange = range.cloneRange();
14604 nextRange.selectNodeContents(element);
14605 nextRange.setEnd(range.startContainer, range.startOffset);
14606 start = nextRange.toString().length;
14607 nextRange.setEnd(range.endContainer, range.endOffset);
14608 end = nextRange.toString().length;
14609 }
14610 }
14611 return { start, end };
14612 }
14613 function getPopupRole(element, fallback) {
14614 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
14615 const role = element == null ? void 0 : element.getAttribute("role");
14616 if (role && allowedPopupRoles.indexOf(role) !== -1) {
14617 return role;
14618 }
14619 return fallback;
14620 }
14621 function getScrollingElement(element) {
14622 if (!element) return null;
14623 const isScrollableOverflow = (overflow) => {
14624 if (overflow === "auto") return true;
14625 if (overflow === "scroll") return true;
14626 return false;
14627 };
14628 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
14629 const { overflowY } = getComputedStyle(element);
14630 if (isScrollableOverflow(overflowY)) return element;
14631 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
14632 const { overflowX } = getComputedStyle(element);
14633 if (isScrollableOverflow(overflowX)) return element;
14634 }
14635 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
14636 }
14637 function setSelectionRange(element, ...args) {
14638 if (/text|search|password|tel|url/i.test(element.type)) {
14639 element.setSelectionRange(...args);
14640 }
14641 }
14642 function sortBasedOnDOMPosition(items, getElement) {
14643 const pairs = items.map((item, index2) => [index2, item]);
14644 let isOrderDifferent = false;
14645 pairs.sort(([indexA, a2], [indexB, b2]) => {
14646 const elementA = getElement(a2);
14647 const elementB = getElement(b2);
14648 if (elementA === elementB) return 0;
14649 if (!elementA || !elementB) return 0;
14650 if (isElementPreceding(elementA, elementB)) {
14651 if (indexA > indexB) {
14652 isOrderDifferent = true;
14653 }
14654 return -1;
14655 }
14656 if (indexA < indexB) {
14657 isOrderDifferent = true;
14658 }
14659 return 1;
14660 });
14661 if (isOrderDifferent) {
14662 return pairs.map(([_, item]) => item);
14663 }
14664 return items;
14665 }
14666 function isElementPreceding(a2, b2) {
14667 return Boolean(
14668 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING
14669 );
14670 }
14671
14672 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
14673 function isTouchDevice() {
14674 return canUseDOM && !!navigator.maxTouchPoints;
14675 }
14676 function isApple() {
14677 if (!canUseDOM) return false;
14678 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
14679 }
14680 function isSafari2() {
14681 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
14682 }
14683 function isFirefox2() {
14684 return canUseDOM && /firefox\//i.test(navigator.userAgent);
14685 }
14686
14687 // node_modules/@ariakit/core/esm/utils/events.js
14688 function isPortalEvent(event) {
14689 return Boolean(
14690 event.currentTarget && !contains2(event.currentTarget, event.target)
14691 );
14692 }
14693 function isSelfTarget(event) {
14694 return event.target === event.currentTarget;
14695 }
14696 function isOpeningInNewTab(event) {
14697 const element = event.currentTarget;
14698 if (!element) return false;
14699 const isAppleDevice = isApple();
14700 if (isAppleDevice && !event.metaKey) return false;
14701 if (!isAppleDevice && !event.ctrlKey) return false;
14702 const tagName = element.tagName.toLowerCase();
14703 if (tagName === "a") return true;
14704 if (tagName === "button" && element.type === "submit") return true;
14705 if (tagName === "input" && element.type === "submit") return true;
14706 return false;
14707 }
14708 function isDownloading(event) {
14709 const element = event.currentTarget;
14710 if (!element) return false;
14711 const tagName = element.tagName.toLowerCase();
14712 if (!event.altKey) return false;
14713 if (tagName === "a") return true;
14714 if (tagName === "button" && element.type === "submit") return true;
14715 if (tagName === "input" && element.type === "submit") return true;
14716 return false;
14717 }
14718 function fireBlurEvent(element, eventInit) {
14719 const event = new FocusEvent("blur", eventInit);
14720 const defaultAllowed = element.dispatchEvent(event);
14721 const bubbleInit = { ...eventInit, bubbles: true };
14722 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
14723 return defaultAllowed;
14724 }
14725 function fireKeyboardEvent(element, type, eventInit) {
14726 const event = new KeyboardEvent(type, eventInit);
14727 return element.dispatchEvent(event);
14728 }
14729 function fireClickEvent(element, eventInit) {
14730 const event = new MouseEvent("click", eventInit);
14731 return element.dispatchEvent(event);
14732 }
14733 function isFocusEventOutside(event, container) {
14734 const containerElement = container || event.currentTarget;
14735 const relatedTarget = event.relatedTarget;
14736 return !relatedTarget || !contains2(containerElement, relatedTarget);
14737 }
14738 function queueBeforeEvent(element, type, callback, timeout) {
14739 const createTimer = (callback2) => {
14740 if (timeout) {
14741 const timerId2 = setTimeout(callback2, timeout);
14742 return () => clearTimeout(timerId2);
14743 }
14744 const timerId = requestAnimationFrame(callback2);
14745 return () => cancelAnimationFrame(timerId);
14746 };
14747 const cancelTimer = createTimer(() => {
14748 element.removeEventListener(type, callSync, true);
14749 callback();
14750 });
14751 const callSync = () => {
14752 cancelTimer();
14753 callback();
14754 };
14755 element.addEventListener(type, callSync, { once: true, capture: true });
14756 return cancelTimer;
14757 }
14758 function addGlobalEventListener(type, listener, options, scope = window) {
14759 const children = [];
14760 try {
14761 scope.document.addEventListener(type, listener, options);
14762 for (const frame of Array.from(scope.frames)) {
14763 children.push(addGlobalEventListener(type, listener, options, frame));
14764 }
14765 } catch (e2) {
14766 }
14767 const removeEventListener = () => {
14768 try {
14769 scope.document.removeEventListener(type, listener, options);
14770 } catch (e2) {
14771 }
14772 for (const remove of children) {
14773 remove();
14774 }
14775 };
14776 return removeEventListener;
14777 }
14778
14779 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
14780 var React49 = __toESM(require_react(), 1);
14781 var import_react8 = __toESM(require_react(), 1);
14782 var _React = { ...React49 };
14783 var useReactId = _React.useId;
14784 var useReactDeferredValue = _React.useDeferredValue;
14785 var useReactInsertionEffect = _React.useInsertionEffect;
14786 var useSafeLayoutEffect = canUseDOM ? import_react8.useLayoutEffect : import_react8.useEffect;
14787 function useInitialValue(value) {
14788 const [initialValue] = (0, import_react8.useState)(value);
14789 return initialValue;
14790 }
14791 function useLiveRef(value) {
14792 const ref = (0, import_react8.useRef)(value);
14793 useSafeLayoutEffect(() => {
14794 ref.current = value;
14795 });
14796 return ref;
14797 }
14798 function useEvent(callback) {
14799 const ref = (0, import_react8.useRef)(() => {
14800 throw new Error("Cannot call an event handler while rendering.");
14801 });
14802 if (useReactInsertionEffect) {
14803 useReactInsertionEffect(() => {
14804 ref.current = callback;
14805 });
14806 } else {
14807 ref.current = callback;
14808 }
14809 return (0, import_react8.useCallback)((...args) => {
14810 var _a;
14811 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
14812 }, []);
14813 }
14814 function useTransactionState(callback) {
14815 const [state, setState] = (0, import_react8.useState)(null);
14816 useSafeLayoutEffect(() => {
14817 if (state == null) return;
14818 if (!callback) return;
14819 let prevState = null;
14820 callback((prev) => {
14821 prevState = prev;
14822 return state;
14823 });
14824 return () => {
14825 callback(prevState);
14826 };
14827 }, [state, callback]);
14828 return [state, setState];
14829 }
14830 function useMergeRefs(...refs) {
14831 return (0, import_react8.useMemo)(() => {
14832 if (!refs.some(Boolean)) return;
14833 return (value) => {
14834 for (const ref of refs) {
14835 setRef(ref, value);
14836 }
14837 };
14838 }, refs);
14839 }
14840 function useId4(defaultId) {
14841 if (useReactId) {
14842 const reactId = useReactId();
14843 if (defaultId) return defaultId;
14844 return reactId;
14845 }
14846 const [id, setId] = (0, import_react8.useState)(defaultId);
14847 useSafeLayoutEffect(() => {
14848 if (defaultId || id) return;
14849 const random = Math.random().toString(36).slice(2, 8);
14850 setId(`id-${random}`);
14851 }, [defaultId, id]);
14852 return defaultId || id;
14853 }
14854 function useTagName(refOrElement, type) {
14855 const stringOrUndefined = (type2) => {
14856 if (typeof type2 !== "string") return;
14857 return type2;
14858 };
14859 const [tagName, setTagName] = (0, import_react8.useState)(() => stringOrUndefined(type));
14860 useSafeLayoutEffect(() => {
14861 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
14862 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
14863 }, [refOrElement, type]);
14864 return tagName;
14865 }
14866 function useAttribute(refOrElement, attributeName, defaultValue2) {
14867 const initialValue = useInitialValue(defaultValue2);
14868 const [attribute, setAttribute] = (0, import_react8.useState)(initialValue);
14869 (0, import_react8.useEffect)(() => {
14870 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
14871 if (!element) return;
14872 const callback = () => {
14873 const value = element.getAttribute(attributeName);
14874 setAttribute(value == null ? initialValue : value);
14875 };
14876 const observer = new MutationObserver(callback);
14877 observer.observe(element, { attributeFilter: [attributeName] });
14878 callback();
14879 return () => observer.disconnect();
14880 }, [refOrElement, attributeName, initialValue]);
14881 return attribute;
14882 }
14883 function useUpdateEffect(effect, deps) {
14884 const mounted = (0, import_react8.useRef)(false);
14885 (0, import_react8.useEffect)(() => {
14886 if (mounted.current) {
14887 return effect();
14888 }
14889 mounted.current = true;
14890 }, deps);
14891 (0, import_react8.useEffect)(
14892 () => () => {
14893 mounted.current = false;
14894 },
14895 []
14896 );
14897 }
14898 function useUpdateLayoutEffect(effect, deps) {
14899 const mounted = (0, import_react8.useRef)(false);
14900 useSafeLayoutEffect(() => {
14901 if (mounted.current) {
14902 return effect();
14903 }
14904 mounted.current = true;
14905 }, deps);
14906 useSafeLayoutEffect(
14907 () => () => {
14908 mounted.current = false;
14909 },
14910 []
14911 );
14912 }
14913 function useForceUpdate() {
14914 return (0, import_react8.useReducer)(() => [], []);
14915 }
14916 function useBooleanEvent(booleanOrCallback) {
14917 return useEvent(
14918 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
14919 );
14920 }
14921 function useWrapElement(props, callback, deps = []) {
14922 const wrapElement = (0, import_react8.useCallback)(
14923 (element) => {
14924 if (props.wrapElement) {
14925 element = props.wrapElement(element);
14926 }
14927 return callback(element);
14928 },
14929 [...deps, props.wrapElement]
14930 );
14931 return { ...props, wrapElement };
14932 }
14933 function useMetadataProps(props, key, value) {
14934 const parent = props.onLoadedMetadataCapture;
14935 const onLoadedMetadataCapture = (0, import_react8.useMemo)(() => {
14936 return Object.assign(() => {
14937 }, { ...parent, [key]: value });
14938 }, [parent, key, value]);
14939 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }];
14940 }
14941 var hasInstalledGlobalEventListeners = false;
14942 function useIsMouseMoving() {
14943 (0, import_react8.useEffect)(() => {
14944 if (hasInstalledGlobalEventListeners) return;
14945 addGlobalEventListener("mousemove", setMouseMoving, true);
14946 addGlobalEventListener("mousedown", resetMouseMoving, true);
14947 addGlobalEventListener("mouseup", resetMouseMoving, true);
14948 addGlobalEventListener("keydown", resetMouseMoving, true);
14949 addGlobalEventListener("scroll", resetMouseMoving, true);
14950 hasInstalledGlobalEventListeners = true;
14951 }, []);
14952 const isMouseMoving = useEvent(() => mouseMoving);
14953 return isMouseMoving;
14954 }
14955 var mouseMoving = false;
14956 var previousScreenX = 0;
14957 var previousScreenY = 0;
14958 function hasMouseMovement(event) {
14959 const movementX = event.movementX || event.screenX - previousScreenX;
14960 const movementY = event.movementY || event.screenY - previousScreenY;
14961 previousScreenX = event.screenX;
14962 previousScreenY = event.screenY;
14963 return movementX || movementY || false;
14964 }
14965 function setMouseMoving(event) {
14966 if (!hasMouseMovement(event)) return;
14967 mouseMoving = true;
14968 }
14969 function resetMouseMoving() {
14970 mouseMoving = false;
14971 }
14972
14973 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
14974 var React50 = __toESM(require_react(), 1);
14975 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
14976 function forwardRef22(render4) {
14977 const Role = React50.forwardRef(
14978 // @ts-ignore Incompatible with React 19 types. Ignore for now.
14979 (props, ref) => render4({ ...props, ref })
14980 );
14981 Role.displayName = render4.displayName || render4.name;
14982 return Role;
14983 }
14984 function memo22(Component, propsAreEqual) {
14985 return React50.memo(Component, propsAreEqual);
14986 }
14987 function createElement3(Type, props) {
14988 const { wrapElement, render: render4, ...rest } = props;
14989 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
14990 let element;
14991 if (React50.isValidElement(render4)) {
14992 const renderProps = {
14993 // @ts-ignore Incompatible with React 19 types. Ignore for now.
14994 ...render4.props,
14995 ref: mergedRef
14996 };
14997 element = React50.cloneElement(render4, mergeProps3(rest, renderProps));
14998 } else if (render4) {
14999 element = render4(rest);
15000 } else {
15001 element = /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(Type, { ...rest });
15002 }
15003 if (wrapElement) {
15004 return wrapElement(element);
15005 }
15006 return element;
15007 }
15008 function createHook(useProps) {
15009 const useRole = (props = {}) => {
15010 return useProps(props);
15011 };
15012 useRole.displayName = useProps.name;
15013 return useRole;
15014 }
15015 function createStoreContext(providers = [], scopedProviders = []) {
15016 const context = React50.createContext(void 0);
15017 const scopedContext = React50.createContext(void 0);
15018 const useContext210 = () => React50.useContext(context);
15019 const useScopedContext = (onlyScoped = false) => {
15020 const scoped = React50.useContext(scopedContext);
15021 const store = useContext210();
15022 if (onlyScoped) return scoped;
15023 return scoped || store;
15024 };
15025 const useProviderContext = () => {
15026 const scoped = React50.useContext(scopedContext);
15027 const store = useContext210();
15028 if (scoped && scoped === store) return;
15029 return store;
15030 };
15031 const ContextProvider = (props) => {
15032 return providers.reduceRight(
15033 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(Provider2, { ...props, children }),
15034 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(context.Provider, { ...props })
15035 );
15036 };
15037 const ScopedContextProvider = (props) => {
15038 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
15039 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(Provider2, { ...props, children }),
15040 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(scopedContext.Provider, { ...props })
15041 ) });
15042 };
15043 return {
15044 context,
15045 scopedContext,
15046 useContext: useContext210,
15047 useScopedContext,
15048 useProviderContext,
15049 ContextProvider,
15050 ScopedContextProvider
15051 };
15052 }
15053
15054 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
15055 var ctx = createStoreContext();
15056 var useCollectionContext = ctx.useContext;
15057 var useCollectionScopedContext = ctx.useScopedContext;
15058 var useCollectionProviderContext = ctx.useProviderContext;
15059 var CollectionContextProvider = ctx.ContextProvider;
15060 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
15061
15062 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
15063 var import_react9 = __toESM(require_react(), 1);
15064 var ctx2 = createStoreContext(
15065 [CollectionContextProvider],
15066 [CollectionScopedContextProvider]
15067 );
15068 var useCompositeContext = ctx2.useContext;
15069 var useCompositeScopedContext = ctx2.useScopedContext;
15070 var useCompositeProviderContext = ctx2.useProviderContext;
15071 var CompositeContextProvider = ctx2.ContextProvider;
15072 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
15073 var CompositeItemContext = (0, import_react9.createContext)(
15074 void 0
15075 );
15076 var CompositeRowContext = (0, import_react9.createContext)(
15077 void 0
15078 );
15079
15080 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
15081 function findFirstEnabledItem(items, excludeId) {
15082 return items.find((item) => {
15083 if (excludeId) {
15084 return !item.disabled && item.id !== excludeId;
15085 }
15086 return !item.disabled;
15087 });
15088 }
15089 function getEnabledItem(store, id) {
15090 if (!id) return null;
15091 return store.item(id) || null;
15092 }
15093 function groupItemsByRows(items) {
15094 const rows = [];
15095 for (const item of items) {
15096 const row = rows.find((currentRow) => {
15097 var _a;
15098 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
15099 });
15100 if (row) {
15101 row.push(item);
15102 } else {
15103 rows.push([item]);
15104 }
15105 }
15106 return rows;
15107 }
15108 function selectTextField(element, collapseToEnd = false) {
15109 if (isTextField(element)) {
15110 element.setSelectionRange(
15111 collapseToEnd ? element.value.length : 0,
15112 element.value.length
15113 );
15114 } else if (element.isContentEditable) {
15115 const selection = getDocument(element).getSelection();
15116 selection == null ? void 0 : selection.selectAllChildren(element);
15117 if (collapseToEnd) {
15118 selection == null ? void 0 : selection.collapseToEnd();
15119 }
15120 }
15121 }
15122 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
15123 function focusSilently(element) {
15124 element[FOCUS_SILENTLY] = true;
15125 element.focus({ preventScroll: true });
15126 }
15127 function silentlyFocused(element) {
15128 const isSilentlyFocused = element[FOCUS_SILENTLY];
15129 delete element[FOCUS_SILENTLY];
15130 return isSilentlyFocused;
15131 }
15132 function isItem(store, element, exclude) {
15133 if (!element) return false;
15134 if (element === exclude) return false;
15135 const item = store.item(element.id);
15136 if (!item) return false;
15137 if (exclude && item.element === exclude) return false;
15138 return true;
15139 }
15140
15141 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
15142 var import_react10 = __toESM(require_react(), 1);
15143 var TagName = "div";
15144 var useCollectionItem = createHook(
15145 function useCollectionItem2({
15146 store,
15147 shouldRegisterItem = true,
15148 getItem = identity,
15149 // @ts-expect-error This prop may come from a collection renderer.
15150 element,
15151 ...props
15152 }) {
15153 const context = useCollectionContext();
15154 store = store || context;
15155 const id = useId4(props.id);
15156 const ref = (0, import_react10.useRef)(element);
15157 (0, import_react10.useEffect)(() => {
15158 const element2 = ref.current;
15159 if (!id) return;
15160 if (!element2) return;
15161 if (!shouldRegisterItem) return;
15162 const item = getItem({ id, element: element2 });
15163 return store == null ? void 0 : store.renderItem(item);
15164 }, [id, shouldRegisterItem, getItem, store]);
15165 props = {
15166 ...props,
15167 ref: useMergeRefs(ref, props.ref)
15168 };
15169 return removeUndefinedValues(props);
15170 }
15171 );
15172 var CollectionItem = forwardRef22(function CollectionItem2(props) {
15173 const htmlProps = useCollectionItem(props);
15174 return createElement3(TagName, htmlProps);
15175 });
15176
15177 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
15178 var import_react11 = __toESM(require_react(), 1);
15179 var FocusableContext = (0, import_react11.createContext)(true);
15180
15181 // node_modules/@ariakit/core/esm/utils/focus.js
15182 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'])";
15183 function isFocusable(element) {
15184 if (!element.matches(selector)) return false;
15185 if (!isVisible(element)) return false;
15186 if (element.closest("[inert]")) return false;
15187 return true;
15188 }
15189 function getClosestFocusable(element) {
15190 while (element && !isFocusable(element)) {
15191 element = element.closest(selector);
15192 }
15193 return element || null;
15194 }
15195 function hasFocus(element) {
15196 const activeElement2 = getActiveElement(element);
15197 if (!activeElement2) return false;
15198 if (activeElement2 === element) return true;
15199 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15200 if (!activeDescendant) return false;
15201 return activeDescendant === element.id;
15202 }
15203 function hasFocusWithin(element) {
15204 const activeElement2 = getActiveElement(element);
15205 if (!activeElement2) return false;
15206 if (contains2(element, activeElement2)) return true;
15207 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15208 if (!activeDescendant) return false;
15209 if (!("id" in element)) return false;
15210 if (activeDescendant === element.id) return true;
15211 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
15212 }
15213 function focusIfNeeded(element) {
15214 if (!hasFocusWithin(element) && isFocusable(element)) {
15215 element.focus();
15216 }
15217 }
15218 function focusIntoView(element, options) {
15219 if (!("scrollIntoView" in element)) {
15220 element.focus();
15221 } else {
15222 element.focus({ preventScroll: true });
15223 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
15224 }
15225 }
15226
15227 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
15228 var import_react12 = __toESM(require_react(), 1);
15229 var TagName2 = "div";
15230 var isSafariBrowser = isSafari2();
15231 var alwaysFocusVisibleInputTypes = [
15232 "text",
15233 "search",
15234 "url",
15235 "tel",
15236 "email",
15237 "password",
15238 "number",
15239 "date",
15240 "month",
15241 "week",
15242 "time",
15243 "datetime",
15244 "datetime-local"
15245 ];
15246 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
15247 function markSafariFocusAncestor(element, value) {
15248 if (!element) return;
15249 element[safariFocusAncestorSymbol] = value;
15250 }
15251 function isAlwaysFocusVisible(element) {
15252 const { tagName, readOnly, type } = element;
15253 if (tagName === "TEXTAREA" && !readOnly) return true;
15254 if (tagName === "SELECT" && !readOnly) return true;
15255 if (tagName === "INPUT" && !readOnly) {
15256 return alwaysFocusVisibleInputTypes.includes(type);
15257 }
15258 if (element.isContentEditable) return true;
15259 const role = element.getAttribute("role");
15260 if (role === "combobox" && element.dataset.name) {
15261 return true;
15262 }
15263 return false;
15264 }
15265 function getLabels(element) {
15266 if ("labels" in element) {
15267 return element.labels;
15268 }
15269 return null;
15270 }
15271 function isNativeCheckboxOrRadio(element) {
15272 const tagName = element.tagName.toLowerCase();
15273 if (tagName === "input" && element.type) {
15274 return element.type === "radio" || element.type === "checkbox";
15275 }
15276 return false;
15277 }
15278 function isNativeTabbable(tagName) {
15279 if (!tagName) return true;
15280 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
15281 }
15282 function supportsDisabledAttribute(tagName) {
15283 if (!tagName) return true;
15284 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
15285 }
15286 function getTabIndex2(focusable2, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
15287 if (!focusable2) {
15288 return tabIndexProp;
15289 }
15290 if (trulyDisabled) {
15291 if (nativeTabbable && !supportsDisabled) {
15292 return -1;
15293 }
15294 return;
15295 }
15296 if (nativeTabbable) {
15297 return tabIndexProp;
15298 }
15299 return tabIndexProp || 0;
15300 }
15301 function useDisableEvent(onEvent, disabled2) {
15302 return useEvent((event) => {
15303 onEvent == null ? void 0 : onEvent(event);
15304 if (event.defaultPrevented) return;
15305 if (disabled2) {
15306 event.stopPropagation();
15307 event.preventDefault();
15308 }
15309 });
15310 }
15311 var hasInstalledGlobalEventListeners2 = false;
15312 var isKeyboardModality = true;
15313 function onGlobalMouseDown(event) {
15314 const target = event.target;
15315 if (target && "hasAttribute" in target) {
15316 if (!target.hasAttribute("data-focus-visible")) {
15317 isKeyboardModality = false;
15318 }
15319 }
15320 }
15321 function onGlobalKeyDown(event) {
15322 if (event.metaKey) return;
15323 if (event.ctrlKey) return;
15324 if (event.altKey) return;
15325 isKeyboardModality = true;
15326 }
15327 var useFocusable = createHook(
15328 function useFocusable2({
15329 focusable: focusable2 = true,
15330 accessibleWhenDisabled,
15331 autoFocus,
15332 onFocusVisible,
15333 ...props
15334 }) {
15335 const ref = (0, import_react12.useRef)(null);
15336 (0, import_react12.useEffect)(() => {
15337 if (!focusable2) return;
15338 if (hasInstalledGlobalEventListeners2) return;
15339 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
15340 addGlobalEventListener("keydown", onGlobalKeyDown, true);
15341 hasInstalledGlobalEventListeners2 = true;
15342 }, [focusable2]);
15343 if (isSafariBrowser) {
15344 (0, import_react12.useEffect)(() => {
15345 if (!focusable2) return;
15346 const element = ref.current;
15347 if (!element) return;
15348 if (!isNativeCheckboxOrRadio(element)) return;
15349 const labels = getLabels(element);
15350 if (!labels) return;
15351 const onMouseUp = () => queueMicrotask(() => element.focus());
15352 for (const label of labels) {
15353 label.addEventListener("mouseup", onMouseUp);
15354 }
15355 return () => {
15356 for (const label of labels) {
15357 label.removeEventListener("mouseup", onMouseUp);
15358 }
15359 };
15360 }, [focusable2]);
15361 }
15362 const disabled2 = focusable2 && disabledFromProps(props);
15363 const trulyDisabled = !!disabled2 && !accessibleWhenDisabled;
15364 const [focusVisible, setFocusVisible] = (0, import_react12.useState)(false);
15365 (0, import_react12.useEffect)(() => {
15366 if (!focusable2) return;
15367 if (trulyDisabled && focusVisible) {
15368 setFocusVisible(false);
15369 }
15370 }, [focusable2, trulyDisabled, focusVisible]);
15371 (0, import_react12.useEffect)(() => {
15372 if (!focusable2) return;
15373 if (!focusVisible) return;
15374 const element = ref.current;
15375 if (!element) return;
15376 if (typeof IntersectionObserver === "undefined") return;
15377 const observer = new IntersectionObserver(() => {
15378 if (!isFocusable(element)) {
15379 setFocusVisible(false);
15380 }
15381 });
15382 observer.observe(element);
15383 return () => observer.disconnect();
15384 }, [focusable2, focusVisible]);
15385 const onKeyPressCapture = useDisableEvent(
15386 props.onKeyPressCapture,
15387 disabled2
15388 );
15389 const onMouseDownCapture = useDisableEvent(
15390 props.onMouseDownCapture,
15391 disabled2
15392 );
15393 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
15394 const onMouseDownProp = props.onMouseDown;
15395 const onMouseDown = useEvent((event) => {
15396 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
15397 if (event.defaultPrevented) return;
15398 if (!focusable2) return;
15399 const element = event.currentTarget;
15400 if (!isSafariBrowser) return;
15401 if (isPortalEvent(event)) return;
15402 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
15403 let receivedFocus = false;
15404 const onFocus = () => {
15405 receivedFocus = true;
15406 };
15407 const options = { capture: true, once: true };
15408 element.addEventListener("focusin", onFocus, options);
15409 const focusableContainer = getClosestFocusable(element.parentElement);
15410 markSafariFocusAncestor(focusableContainer, true);
15411 queueBeforeEvent(element, "mouseup", () => {
15412 element.removeEventListener("focusin", onFocus, true);
15413 markSafariFocusAncestor(focusableContainer, false);
15414 if (receivedFocus) return;
15415 focusIfNeeded(element);
15416 });
15417 });
15418 const handleFocusVisible = (event, currentTarget) => {
15419 if (currentTarget) {
15420 event.currentTarget = currentTarget;
15421 }
15422 if (!focusable2) return;
15423 const element = event.currentTarget;
15424 if (!element) return;
15425 if (!hasFocus(element)) return;
15426 onFocusVisible == null ? void 0 : onFocusVisible(event);
15427 if (event.defaultPrevented) return;
15428 element.dataset.focusVisible = "true";
15429 setFocusVisible(true);
15430 };
15431 const onKeyDownCaptureProp = props.onKeyDownCapture;
15432 const onKeyDownCapture = useEvent((event) => {
15433 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
15434 if (event.defaultPrevented) return;
15435 if (!focusable2) return;
15436 if (focusVisible) return;
15437 if (event.metaKey) return;
15438 if (event.altKey) return;
15439 if (event.ctrlKey) return;
15440 if (!isSelfTarget(event)) return;
15441 const element = event.currentTarget;
15442 const applyFocusVisible = () => handleFocusVisible(event, element);
15443 queueBeforeEvent(element, "focusout", applyFocusVisible);
15444 });
15445 const onFocusCaptureProp = props.onFocusCapture;
15446 const onFocusCapture = useEvent((event) => {
15447 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
15448 if (event.defaultPrevented) return;
15449 if (!focusable2) return;
15450 if (!isSelfTarget(event)) {
15451 setFocusVisible(false);
15452 return;
15453 }
15454 const element = event.currentTarget;
15455 const applyFocusVisible = () => handleFocusVisible(event, element);
15456 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
15457 queueBeforeEvent(event.target, "focusout", applyFocusVisible);
15458 } else {
15459 setFocusVisible(false);
15460 }
15461 });
15462 const onBlurProp = props.onBlur;
15463 const onBlur = useEvent((event) => {
15464 onBlurProp == null ? void 0 : onBlurProp(event);
15465 if (!focusable2) return;
15466 if (!isFocusEventOutside(event)) return;
15467 event.currentTarget.removeAttribute("data-focus-visible");
15468 setFocusVisible(false);
15469 });
15470 const autoFocusOnShow = (0, import_react12.useContext)(FocusableContext);
15471 const autoFocusRef = useEvent((element) => {
15472 if (!focusable2) return;
15473 if (!autoFocus) return;
15474 if (!element) return;
15475 if (!autoFocusOnShow) return;
15476 queueMicrotask(() => {
15477 if (hasFocus(element)) return;
15478 if (!isFocusable(element)) return;
15479 element.focus();
15480 });
15481 });
15482 const tagName = useTagName(ref);
15483 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
15484 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
15485 const styleProp = props.style;
15486 const style = (0, import_react12.useMemo)(() => {
15487 if (trulyDisabled) {
15488 return { pointerEvents: "none", ...styleProp };
15489 }
15490 return styleProp;
15491 }, [trulyDisabled, styleProp]);
15492 props = {
15493 "data-focus-visible": focusable2 && focusVisible || void 0,
15494 "data-autofocus": autoFocus || void 0,
15495 "aria-disabled": disabled2 || void 0,
15496 ...props,
15497 ref: useMergeRefs(ref, autoFocusRef, props.ref),
15498 style,
15499 tabIndex: getTabIndex2(
15500 focusable2,
15501 trulyDisabled,
15502 nativeTabbable,
15503 supportsDisabled,
15504 props.tabIndex
15505 ),
15506 disabled: supportsDisabled && trulyDisabled ? true : void 0,
15507 // TODO: Test Focusable contentEditable.
15508 contentEditable: disabled2 ? void 0 : props.contentEditable,
15509 onKeyPressCapture,
15510 onClickCapture,
15511 onMouseDownCapture,
15512 onMouseDown,
15513 onKeyDownCapture,
15514 onFocusCapture,
15515 onBlur
15516 };
15517 return removeUndefinedValues(props);
15518 }
15519 );
15520 var Focusable = forwardRef22(function Focusable2(props) {
15521 const htmlProps = useFocusable(props);
15522 return createElement3(TagName2, htmlProps);
15523 });
15524
15525 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
15526 var import_react13 = __toESM(require_react(), 1);
15527 var TagName3 = "button";
15528 function isNativeClick(event) {
15529 if (!event.isTrusted) return false;
15530 const element = event.currentTarget;
15531 if (event.key === "Enter") {
15532 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
15533 }
15534 if (event.key === " ") {
15535 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
15536 }
15537 return false;
15538 }
15539 var symbol = /* @__PURE__ */ Symbol("command");
15540 var useCommand = createHook(
15541 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
15542 const ref = (0, import_react13.useRef)(null);
15543 const [isNativeButton, setIsNativeButton] = (0, import_react13.useState)(false);
15544 (0, import_react13.useEffect)(() => {
15545 if (!ref.current) return;
15546 setIsNativeButton(isButton(ref.current));
15547 }, []);
15548 const [active, setActive] = (0, import_react13.useState)(false);
15549 const activeRef = (0, import_react13.useRef)(false);
15550 const disabled2 = disabledFromProps(props);
15551 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
15552 const onKeyDownProp = props.onKeyDown;
15553 const onKeyDown = useEvent((event) => {
15554 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
15555 const element = event.currentTarget;
15556 if (event.defaultPrevented) return;
15557 if (isDuplicate) return;
15558 if (disabled2) return;
15559 if (!isSelfTarget(event)) return;
15560 if (isTextField(element)) return;
15561 if (element.isContentEditable) return;
15562 const isEnter = clickOnEnter && event.key === "Enter";
15563 const isSpace = clickOnSpace && event.key === " ";
15564 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
15565 const shouldPreventSpace = event.key === " " && !clickOnSpace;
15566 if (shouldPreventEnter || shouldPreventSpace) {
15567 event.preventDefault();
15568 return;
15569 }
15570 if (isEnter || isSpace) {
15571 const nativeClick = isNativeClick(event);
15572 if (isEnter) {
15573 if (!nativeClick) {
15574 event.preventDefault();
15575 const { view, ...eventInit } = event;
15576 const click = () => fireClickEvent(element, eventInit);
15577 if (isFirefox2()) {
15578 queueBeforeEvent(element, "keyup", click);
15579 } else {
15580 queueMicrotask(click);
15581 }
15582 }
15583 } else if (isSpace) {
15584 activeRef.current = true;
15585 if (!nativeClick) {
15586 event.preventDefault();
15587 setActive(true);
15588 }
15589 }
15590 }
15591 });
15592 const onKeyUpProp = props.onKeyUp;
15593 const onKeyUp = useEvent((event) => {
15594 onKeyUpProp == null ? void 0 : onKeyUpProp(event);
15595 if (event.defaultPrevented) return;
15596 if (isDuplicate) return;
15597 if (disabled2) return;
15598 if (event.metaKey) return;
15599 const isSpace = clickOnSpace && event.key === " ";
15600 if (activeRef.current && isSpace) {
15601 activeRef.current = false;
15602 if (!isNativeClick(event)) {
15603 event.preventDefault();
15604 setActive(false);
15605 const element = event.currentTarget;
15606 const { view, ...eventInit } = event;
15607 queueMicrotask(() => fireClickEvent(element, eventInit));
15608 }
15609 }
15610 });
15611 props = {
15612 "data-active": active || void 0,
15613 type: isNativeButton ? "button" : void 0,
15614 ...metadataProps,
15615 ...props,
15616 ref: useMergeRefs(ref, props.ref),
15617 onKeyDown,
15618 onKeyUp
15619 };
15620 props = useFocusable(props);
15621 return props;
15622 }
15623 );
15624 var Command = forwardRef22(function Command2(props) {
15625 const htmlProps = useCommand(props);
15626 return createElement3(TagName3, htmlProps);
15627 });
15628
15629 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
15630 function getInternal(store, key) {
15631 const internals = store.__unstableInternals;
15632 invariant(internals, "Invalid store");
15633 return internals[key];
15634 }
15635 function createStore(initialState, ...stores) {
15636 let state = initialState;
15637 let prevStateBatch = state;
15638 let lastUpdate = /* @__PURE__ */ Symbol();
15639 let destroy = noop4;
15640 const instances = /* @__PURE__ */ new Set();
15641 const updatedKeys = /* @__PURE__ */ new Set();
15642 const setups = /* @__PURE__ */ new Set();
15643 const listeners = /* @__PURE__ */ new Set();
15644 const batchListeners = /* @__PURE__ */ new Set();
15645 const disposables = /* @__PURE__ */ new WeakMap();
15646 const listenerKeys = /* @__PURE__ */ new WeakMap();
15647 const storeSetup = (callback) => {
15648 setups.add(callback);
15649 return () => setups.delete(callback);
15650 };
15651 const storeInit = () => {
15652 const initialized = instances.size;
15653 const instance = /* @__PURE__ */ Symbol();
15654 instances.add(instance);
15655 const maybeDestroy = () => {
15656 instances.delete(instance);
15657 if (instances.size) return;
15658 destroy();
15659 };
15660 if (initialized) return maybeDestroy;
15661 const desyncs = getKeys(state).map(
15662 (key) => chain(
15663 ...stores.map((store) => {
15664 var _a;
15665 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store);
15666 if (!storeState) return;
15667 if (!hasOwnProperty(storeState, key)) return;
15668 return sync(store, [key], (state2) => {
15669 setState(
15670 key,
15671 state2[key],
15672 // @ts-expect-error - Not public API. This is just to prevent
15673 // infinite loops.
15674 true
15675 );
15676 });
15677 })
15678 )
15679 );
15680 const teardowns = [];
15681 for (const setup2 of setups) {
15682 teardowns.push(setup2());
15683 }
15684 const cleanups = stores.map(init);
15685 destroy = chain(...desyncs, ...teardowns, ...cleanups);
15686 return maybeDestroy;
15687 };
15688 const sub = (keys, listener, set2 = listeners) => {
15689 set2.add(listener);
15690 listenerKeys.set(listener, keys);
15691 return () => {
15692 var _a;
15693 (_a = disposables.get(listener)) == null ? void 0 : _a();
15694 disposables.delete(listener);
15695 listenerKeys.delete(listener);
15696 set2.delete(listener);
15697 };
15698 };
15699 const storeSubscribe = (keys, listener) => sub(keys, listener);
15700 const storeSync = (keys, listener) => {
15701 disposables.set(listener, listener(state, state));
15702 return sub(keys, listener);
15703 };
15704 const storeBatch = (keys, listener) => {
15705 disposables.set(listener, listener(state, prevStateBatch));
15706 return sub(keys, listener, batchListeners);
15707 };
15708 const storePick = (keys) => createStore(pick(state, keys), finalStore);
15709 const storeOmit = (keys) => createStore(omit2(state, keys), finalStore);
15710 const getState = () => state;
15711 const setState = (key, value, fromStores = false) => {
15712 var _a;
15713 if (!hasOwnProperty(state, key)) return;
15714 const nextValue = applyState(value, state[key]);
15715 if (nextValue === state[key]) return;
15716 if (!fromStores) {
15717 for (const store of stores) {
15718 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue);
15719 }
15720 }
15721 const prevState = state;
15722 state = { ...state, [key]: nextValue };
15723 const thisUpdate = /* @__PURE__ */ Symbol();
15724 lastUpdate = thisUpdate;
15725 updatedKeys.add(key);
15726 const run = (listener, prev, uKeys) => {
15727 var _a2;
15728 const keys = listenerKeys.get(listener);
15729 const updated = (k) => uKeys ? uKeys.has(k) : k === key;
15730 if (!keys || keys.some(updated)) {
15731 (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
15732 disposables.set(listener, listener(state, prev));
15733 }
15734 };
15735 for (const listener of listeners) {
15736 run(listener, prevState);
15737 }
15738 queueMicrotask(() => {
15739 if (lastUpdate !== thisUpdate) return;
15740 const snapshot = state;
15741 for (const listener of batchListeners) {
15742 run(listener, prevStateBatch, updatedKeys);
15743 }
15744 prevStateBatch = snapshot;
15745 updatedKeys.clear();
15746 });
15747 };
15748 const finalStore = {
15749 getState,
15750 setState,
15751 __unstableInternals: {
15752 setup: storeSetup,
15753 init: storeInit,
15754 subscribe: storeSubscribe,
15755 sync: storeSync,
15756 batch: storeBatch,
15757 pick: storePick,
15758 omit: storeOmit
15759 }
15760 };
15761 return finalStore;
15762 }
15763 function setup(store, ...args) {
15764 if (!store) return;
15765 return getInternal(store, "setup")(...args);
15766 }
15767 function init(store, ...args) {
15768 if (!store) return;
15769 return getInternal(store, "init")(...args);
15770 }
15771 function subscribe(store, ...args) {
15772 if (!store) return;
15773 return getInternal(store, "subscribe")(...args);
15774 }
15775 function sync(store, ...args) {
15776 if (!store) return;
15777 return getInternal(store, "sync")(...args);
15778 }
15779 function batch(store, ...args) {
15780 if (!store) return;
15781 return getInternal(store, "batch")(...args);
15782 }
15783 function omit22(store, ...args) {
15784 if (!store) return;
15785 return getInternal(store, "omit")(...args);
15786 }
15787 function pick2(store, ...args) {
15788 if (!store) return;
15789 return getInternal(store, "pick")(...args);
15790 }
15791 function mergeStore(...stores) {
15792 var _a;
15793 const initialState = {};
15794 for (const store2 of stores) {
15795 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
15796 if (nextState) {
15797 Object.assign(initialState, nextState);
15798 }
15799 }
15800 const store = createStore(initialState, ...stores);
15801 return Object.assign({}, ...stores, store);
15802 }
15803 function throwOnConflictingProps(props, store) {
15804 if (false) return;
15805 if (!store) return;
15806 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
15807 var _a;
15808 const stateKey = key.replace("default", "");
15809 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
15810 });
15811 if (!defaultKeys.length) return;
15812 const storeState = store.getState();
15813 const conflictingProps = defaultKeys.filter(
15814 (key) => hasOwnProperty(storeState, key)
15815 );
15816 if (!conflictingProps.length) return;
15817 throw new Error(
15818 `Passing a store prop in conjunction with a default state is not supported.
15819
15820 const store = useSelectStore();
15821 <SelectProvider store={store} defaultValue="Apple" />
15822 ^ ^
15823
15824 Instead, pass the default state to the topmost store:
15825
15826 const store = useSelectStore({ defaultValue: "Apple" });
15827 <SelectProvider store={store} />
15828
15829 See https://github.com/ariakit/ariakit/pull/2745 for more details.
15830
15831 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
15832 `
15833 );
15834 }
15835
15836 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
15837 var React51 = __toESM(require_react(), 1);
15838 var import_shim2 = __toESM(require_shim(), 1);
15839 var { useSyncExternalStore: useSyncExternalStore2 } = import_shim2.default;
15840 var noopSubscribe = () => () => {
15841 };
15842 function useStoreState(store, keyOrSelector = identity) {
15843 const storeSubscribe = React51.useCallback(
15844 (callback) => {
15845 if (!store) return noopSubscribe();
15846 return subscribe(store, null, callback);
15847 },
15848 [store]
15849 );
15850 const getSnapshot = () => {
15851 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
15852 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
15853 const state = store == null ? void 0 : store.getState();
15854 if (selector2) return selector2(state);
15855 if (!state) return;
15856 if (!key) return;
15857 if (!hasOwnProperty(state, key)) return;
15858 return state[key];
15859 };
15860 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
15861 }
15862 function useStoreStateObject(store, object) {
15863 const objRef = React51.useRef(
15864 {}
15865 );
15866 const storeSubscribe = React51.useCallback(
15867 (callback) => {
15868 if (!store) return noopSubscribe();
15869 return subscribe(store, null, callback);
15870 },
15871 [store]
15872 );
15873 const getSnapshot = () => {
15874 const state = store == null ? void 0 : store.getState();
15875 let updated = false;
15876 const obj = objRef.current;
15877 for (const prop in object) {
15878 const keyOrSelector = object[prop];
15879 if (typeof keyOrSelector === "function") {
15880 const value = keyOrSelector(state);
15881 if (value !== obj[prop]) {
15882 obj[prop] = value;
15883 updated = true;
15884 }
15885 }
15886 if (typeof keyOrSelector === "string") {
15887 if (!state) continue;
15888 if (!hasOwnProperty(state, keyOrSelector)) continue;
15889 const value = state[keyOrSelector];
15890 if (value !== obj[prop]) {
15891 obj[prop] = value;
15892 updated = true;
15893 }
15894 }
15895 }
15896 if (updated) {
15897 objRef.current = { ...obj };
15898 }
15899 return objRef.current;
15900 };
15901 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
15902 }
15903 function useStoreProps(store, props, key, setKey) {
15904 const value = hasOwnProperty(props, key) ? props[key] : void 0;
15905 const setValue = setKey ? props[setKey] : void 0;
15906 const propsRef = useLiveRef({ value, setValue });
15907 useSafeLayoutEffect(() => {
15908 return sync(store, [key], (state, prev) => {
15909 const { value: value2, setValue: setValue2 } = propsRef.current;
15910 if (!setValue2) return;
15911 if (state[key] === prev[key]) return;
15912 if (state[key] === value2) return;
15913 setValue2(state[key]);
15914 });
15915 }, [store, key]);
15916 useSafeLayoutEffect(() => {
15917 if (value === void 0) return;
15918 store.setState(key, value);
15919 return batch(store, [key], () => {
15920 if (value === void 0) return;
15921 store.setState(key, value);
15922 });
15923 });
15924 }
15925 function useStore2(createStore2, props) {
15926 const [store, setStore] = React51.useState(() => createStore2(props));
15927 useSafeLayoutEffect(() => init(store), [store]);
15928 const useState210 = React51.useCallback(
15929 (keyOrSelector) => useStoreState(store, keyOrSelector),
15930 [store]
15931 );
15932 const memoizedStore = React51.useMemo(
15933 () => ({ ...store, useState: useState210 }),
15934 [store, useState210]
15935 );
15936 const updateStore = useEvent(() => {
15937 setStore((store2) => createStore2({ ...props, ...store2.getState() }));
15938 });
15939 return [memoizedStore, updateStore];
15940 }
15941
15942 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
15943 var import_react14 = __toESM(require_react(), 1);
15944 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
15945 var TagName4 = "button";
15946 function isEditableElement(element) {
15947 if (isTextbox(element)) return true;
15948 return element.tagName === "INPUT" && !isButton(element);
15949 }
15950 function getNextPageOffset(scrollingElement, pageUp = false) {
15951 const height = scrollingElement.clientHeight;
15952 const { top } = scrollingElement.getBoundingClientRect();
15953 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
15954 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
15955 if (scrollingElement.tagName === "HTML") {
15956 return pageOffset + scrollingElement.scrollTop;
15957 }
15958 return pageOffset;
15959 }
15960 function getItemOffset(itemElement, pageUp = false) {
15961 const { top } = itemElement.getBoundingClientRect();
15962 if (pageUp) {
15963 return top + itemElement.clientHeight;
15964 }
15965 return top;
15966 }
15967 function findNextPageItemId(element, store, next, pageUp = false) {
15968 var _a;
15969 if (!store) return;
15970 if (!next) return;
15971 const { renderedItems } = store.getState();
15972 const scrollingElement = getScrollingElement(element);
15973 if (!scrollingElement) return;
15974 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
15975 let id;
15976 let prevDifference;
15977 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
15978 const previousId = id;
15979 id = next(i2);
15980 if (!id) break;
15981 if (id === previousId) continue;
15982 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element;
15983 if (!itemElement) continue;
15984 const itemOffset = getItemOffset(itemElement, pageUp);
15985 const difference = itemOffset - nextPageOffset;
15986 const absDifference = Math.abs(difference);
15987 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
15988 if (prevDifference !== void 0 && prevDifference < absDifference) {
15989 id = previousId;
15990 }
15991 break;
15992 }
15993 prevDifference = absDifference;
15994 }
15995 return id;
15996 }
15997 function targetIsAnotherItem(event, store) {
15998 if (isSelfTarget(event)) return false;
15999 return isItem(store, event.target);
16000 }
16001 var useCompositeItem = createHook(
16002 function useCompositeItem2({
16003 store,
16004 rowId: rowIdProp,
16005 preventScrollOnKeyDown = false,
16006 moveOnKeyPress = true,
16007 tabbable: tabbable2 = false,
16008 getItem: getItemProp,
16009 "aria-setsize": ariaSetSizeProp,
16010 "aria-posinset": ariaPosInSetProp,
16011 ...props
16012 }) {
16013 const context = useCompositeContext();
16014 store = store || context;
16015 const id = useId4(props.id);
16016 const ref = (0, import_react14.useRef)(null);
16017 const row = (0, import_react14.useContext)(CompositeRowContext);
16018 const disabled2 = disabledFromProps(props);
16019 const trulyDisabled = disabled2 && !props.accessibleWhenDisabled;
16020 const {
16021 rowId,
16022 baseElement,
16023 isActiveItem,
16024 ariaSetSize,
16025 ariaPosInSet,
16026 isTabbable
16027 } = useStoreStateObject(store, {
16028 rowId(state) {
16029 if (rowIdProp) return rowIdProp;
16030 if (!state) return;
16031 if (!(row == null ? void 0 : row.baseElement)) return;
16032 if (row.baseElement !== state.baseElement) return;
16033 return row.id;
16034 },
16035 baseElement(state) {
16036 return (state == null ? void 0 : state.baseElement) || void 0;
16037 },
16038 isActiveItem(state) {
16039 return !!state && state.activeId === id;
16040 },
16041 ariaSetSize(state) {
16042 if (ariaSetSizeProp != null) return ariaSetSizeProp;
16043 if (!state) return;
16044 if (!(row == null ? void 0 : row.ariaSetSize)) return;
16045 if (row.baseElement !== state.baseElement) return;
16046 return row.ariaSetSize;
16047 },
16048 ariaPosInSet(state) {
16049 if (ariaPosInSetProp != null) return ariaPosInSetProp;
16050 if (!state) return;
16051 if (!(row == null ? void 0 : row.ariaPosInSet)) return;
16052 if (row.baseElement !== state.baseElement) return;
16053 const itemsInRow = state.renderedItems.filter(
16054 (item) => item.rowId === rowId
16055 );
16056 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
16057 },
16058 isTabbable(state) {
16059 if (!(state == null ? void 0 : state.renderedItems.length)) return true;
16060 if (state.virtualFocus) return false;
16061 if (tabbable2) return true;
16062 if (state.activeId === null) return false;
16063 const item = store == null ? void 0 : store.item(state.activeId);
16064 if (item == null ? void 0 : item.disabled) return true;
16065 if (!(item == null ? void 0 : item.element)) return true;
16066 return state.activeId === id;
16067 }
16068 });
16069 const getItem = (0, import_react14.useCallback)(
16070 (item) => {
16071 var _a;
16072 const nextItem = {
16073 ...item,
16074 id: id || item.id,
16075 rowId,
16076 disabled: !!trulyDisabled,
16077 children: (_a = item.element) == null ? void 0 : _a.textContent
16078 };
16079 if (getItemProp) {
16080 return getItemProp(nextItem);
16081 }
16082 return nextItem;
16083 },
16084 [id, rowId, trulyDisabled, getItemProp]
16085 );
16086 const onFocusProp = props.onFocus;
16087 const hasFocusedComposite = (0, import_react14.useRef)(false);
16088 const onFocus = useEvent((event) => {
16089 onFocusProp == null ? void 0 : onFocusProp(event);
16090 if (event.defaultPrevented) return;
16091 if (isPortalEvent(event)) return;
16092 if (!id) return;
16093 if (!store) return;
16094 if (targetIsAnotherItem(event, store)) return;
16095 const { virtualFocus, baseElement: baseElement2 } = store.getState();
16096 store.setActiveId(id);
16097 if (isTextbox(event.currentTarget)) {
16098 selectTextField(event.currentTarget);
16099 }
16100 if (!virtualFocus) return;
16101 if (!isSelfTarget(event)) return;
16102 if (isEditableElement(event.currentTarget)) return;
16103 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
16104 if (isSafari2() && event.currentTarget.hasAttribute("data-autofocus")) {
16105 event.currentTarget.scrollIntoView({
16106 block: "nearest",
16107 inline: "nearest"
16108 });
16109 }
16110 hasFocusedComposite.current = true;
16111 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget);
16112 if (fromComposite) {
16113 focusSilently(baseElement2);
16114 } else {
16115 baseElement2.focus();
16116 }
16117 });
16118 const onBlurCaptureProp = props.onBlurCapture;
16119 const onBlurCapture = useEvent((event) => {
16120 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
16121 if (event.defaultPrevented) return;
16122 const state = store == null ? void 0 : store.getState();
16123 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
16124 hasFocusedComposite.current = false;
16125 event.preventDefault();
16126 event.stopPropagation();
16127 }
16128 });
16129 const onKeyDownProp = props.onKeyDown;
16130 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
16131 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
16132 const onKeyDown = useEvent((event) => {
16133 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
16134 if (event.defaultPrevented) return;
16135 if (!isSelfTarget(event)) return;
16136 if (!store) return;
16137 const { currentTarget } = event;
16138 const state = store.getState();
16139 const item = store.item(id);
16140 const isGrid2 = !!(item == null ? void 0 : item.rowId);
16141 const isVertical = state.orientation !== "horizontal";
16142 const isHorizontal = state.orientation !== "vertical";
16143 const canHomeEnd = () => {
16144 if (isGrid2) return true;
16145 if (isHorizontal) return true;
16146 if (!state.baseElement) return true;
16147 if (!isTextField(state.baseElement)) return true;
16148 return false;
16149 };
16150 const keyMap = {
16151 ArrowUp: (isGrid2 || isVertical) && store.up,
16152 ArrowRight: (isGrid2 || isHorizontal) && store.next,
16153 ArrowDown: (isGrid2 || isVertical) && store.down,
16154 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
16155 Home: () => {
16156 if (!canHomeEnd()) return;
16157 if (!isGrid2 || event.ctrlKey) {
16158 return store == null ? void 0 : store.first();
16159 }
16160 return store == null ? void 0 : store.previous(-1);
16161 },
16162 End: () => {
16163 if (!canHomeEnd()) return;
16164 if (!isGrid2 || event.ctrlKey) {
16165 return store == null ? void 0 : store.last();
16166 }
16167 return store == null ? void 0 : store.next(-1);
16168 },
16169 PageUp: () => {
16170 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true);
16171 },
16172 PageDown: () => {
16173 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down);
16174 }
16175 };
16176 const action = keyMap[event.key];
16177 if (action) {
16178 if (isTextbox(currentTarget)) {
16179 const selection = getTextboxSelection(currentTarget);
16180 const isLeft = isHorizontal && event.key === "ArrowLeft";
16181 const isRight = isHorizontal && event.key === "ArrowRight";
16182 const isUp = isVertical && event.key === "ArrowUp";
16183 const isDown = isVertical && event.key === "ArrowDown";
16184 if (isRight || isDown) {
16185 const { length: valueLength } = getTextboxValue(currentTarget);
16186 if (selection.end !== valueLength) return;
16187 } else if ((isLeft || isUp) && selection.start !== 0) return;
16188 }
16189 const nextId = action();
16190 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
16191 if (!moveOnKeyPressProp(event)) return;
16192 event.preventDefault();
16193 store.move(nextId);
16194 }
16195 }
16196 });
16197 const providerValue = (0, import_react14.useMemo)(
16198 () => ({ id, baseElement }),
16199 [id, baseElement]
16200 );
16201 props = useWrapElement(
16202 props,
16203 (element) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
16204 [providerValue]
16205 );
16206 props = {
16207 id,
16208 "data-active-item": isActiveItem || void 0,
16209 ...props,
16210 ref: useMergeRefs(ref, props.ref),
16211 tabIndex: isTabbable ? props.tabIndex : -1,
16212 onFocus,
16213 onBlurCapture,
16214 onKeyDown
16215 };
16216 props = useCommand(props);
16217 props = useCollectionItem({
16218 store,
16219 ...props,
16220 getItem,
16221 shouldRegisterItem: id ? props.shouldRegisterItem : false
16222 });
16223 return removeUndefinedValues({
16224 ...props,
16225 "aria-setsize": ariaSetSize,
16226 "aria-posinset": ariaPosInSet
16227 });
16228 }
16229 );
16230 var CompositeItem = memo22(
16231 forwardRef22(function CompositeItem2(props) {
16232 const htmlProps = useCompositeItem(props);
16233 return createElement3(TagName4, htmlProps);
16234 })
16235 );
16236
16237 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
16238 function toArray(arg) {
16239 if (Array.isArray(arg)) {
16240 return arg;
16241 }
16242 return typeof arg !== "undefined" ? [arg] : [];
16243 }
16244 function flatten2DArray(array) {
16245 const flattened = [];
16246 for (const row of array) {
16247 flattened.push(...row);
16248 }
16249 return flattened;
16250 }
16251 function reverseArray(array) {
16252 return array.slice().reverse();
16253 }
16254
16255 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
16256 var import_react15 = __toESM(require_react(), 1);
16257 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
16258 var TagName5 = "div";
16259 function isGrid(items) {
16260 return items.some((item) => !!item.rowId);
16261 }
16262 function isPrintableKey(event) {
16263 const target = event.target;
16264 if (target && !isTextField(target)) return false;
16265 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
16266 }
16267 function isModifierKey(event) {
16268 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
16269 }
16270 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
16271 return useEvent((event) => {
16272 var _a;
16273 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
16274 if (event.defaultPrevented) return;
16275 if (event.isPropagationStopped()) return;
16276 if (!isSelfTarget(event)) return;
16277 if (isModifierKey(event)) return;
16278 if (isPrintableKey(event)) return;
16279 const state = store.getState();
16280 const activeElement2 = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element;
16281 if (!activeElement2) return;
16282 const { view, ...eventInit } = event;
16283 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
16284 if (activeElement2 !== previousElement) {
16285 activeElement2.focus();
16286 }
16287 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) {
16288 event.preventDefault();
16289 }
16290 if (event.currentTarget.contains(activeElement2)) {
16291 event.stopPropagation();
16292 }
16293 });
16294 }
16295 function findFirstEnabledItemInTheLastRow(items) {
16296 return findFirstEnabledItem(
16297 flatten2DArray(reverseArray(groupItemsByRows(items)))
16298 );
16299 }
16300 function useScheduleFocus(store) {
16301 const [scheduled, setScheduled] = (0, import_react15.useState)(false);
16302 const schedule = (0, import_react15.useCallback)(() => setScheduled(true), []);
16303 const activeItem = store.useState(
16304 (state) => getEnabledItem(store, state.activeId)
16305 );
16306 (0, import_react15.useEffect)(() => {
16307 const activeElement2 = activeItem == null ? void 0 : activeItem.element;
16308 if (!scheduled) return;
16309 if (!activeElement2) return;
16310 setScheduled(false);
16311 activeElement2.focus({ preventScroll: true });
16312 }, [activeItem, scheduled]);
16313 return schedule;
16314 }
16315 var useComposite = createHook(
16316 function useComposite2({
16317 store,
16318 composite = true,
16319 focusOnMove = composite,
16320 moveOnKeyPress = true,
16321 ...props
16322 }) {
16323 const context = useCompositeProviderContext();
16324 store = store || context;
16325 invariant(
16326 store,
16327 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
16328 );
16329 const ref = (0, import_react15.useRef)(null);
16330 const previousElementRef = (0, import_react15.useRef)(null);
16331 const scheduleFocus = useScheduleFocus(store);
16332 const moves = store.useState("moves");
16333 const [, setBaseElement] = useTransactionState(
16334 composite ? store.setBaseElement : null
16335 );
16336 (0, import_react15.useEffect)(() => {
16337 var _a;
16338 if (!store) return;
16339 if (!moves) return;
16340 if (!composite) return;
16341 if (!focusOnMove) return;
16342 const { activeId: activeId2 } = store.getState();
16343 const itemElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
16344 if (!itemElement) return;
16345 focusIntoView(itemElement);
16346 }, [store, moves, composite, focusOnMove]);
16347 useSafeLayoutEffect(() => {
16348 if (!store) return;
16349 if (!moves) return;
16350 if (!composite) return;
16351 const { baseElement, activeId: activeId2 } = store.getState();
16352 const isSelfAcive = activeId2 === null;
16353 if (!isSelfAcive) return;
16354 if (!baseElement) return;
16355 const previousElement = previousElementRef.current;
16356 previousElementRef.current = null;
16357 if (previousElement) {
16358 fireBlurEvent(previousElement, { relatedTarget: baseElement });
16359 }
16360 if (!hasFocus(baseElement)) {
16361 baseElement.focus();
16362 }
16363 }, [store, moves, composite]);
16364 const activeId = store.useState("activeId");
16365 const virtualFocus = store.useState("virtualFocus");
16366 useSafeLayoutEffect(() => {
16367 var _a;
16368 if (!store) return;
16369 if (!composite) return;
16370 if (!virtualFocus) return;
16371 const previousElement = previousElementRef.current;
16372 previousElementRef.current = null;
16373 if (!previousElement) return;
16374 const activeElement2 = (_a = getEnabledItem(store, activeId)) == null ? void 0 : _a.element;
16375 const relatedTarget = activeElement2 || getActiveElement(previousElement);
16376 if (relatedTarget === previousElement) return;
16377 fireBlurEvent(previousElement, { relatedTarget });
16378 }, [store, activeId, virtualFocus, composite]);
16379 const onKeyDownCapture = useKeyboardEventProxy(
16380 store,
16381 props.onKeyDownCapture,
16382 previousElementRef
16383 );
16384 const onKeyUpCapture = useKeyboardEventProxy(
16385 store,
16386 props.onKeyUpCapture,
16387 previousElementRef
16388 );
16389 const onFocusCaptureProp = props.onFocusCapture;
16390 const onFocusCapture = useEvent((event) => {
16391 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
16392 if (event.defaultPrevented) return;
16393 if (!store) return;
16394 const { virtualFocus: virtualFocus2 } = store.getState();
16395 if (!virtualFocus2) return;
16396 const previousActiveElement = event.relatedTarget;
16397 const isSilentlyFocused = silentlyFocused(event.currentTarget);
16398 if (isSelfTarget(event) && isSilentlyFocused) {
16399 event.stopPropagation();
16400 previousElementRef.current = previousActiveElement;
16401 }
16402 });
16403 const onFocusProp = props.onFocus;
16404 const onFocus = useEvent((event) => {
16405 onFocusProp == null ? void 0 : onFocusProp(event);
16406 if (event.defaultPrevented) return;
16407 if (!composite) return;
16408 if (!store) return;
16409 const { relatedTarget } = event;
16410 const { virtualFocus: virtualFocus2 } = store.getState();
16411 if (virtualFocus2) {
16412 if (isSelfTarget(event) && !isItem(store, relatedTarget)) {
16413 queueMicrotask(scheduleFocus);
16414 }
16415 } else if (isSelfTarget(event)) {
16416 store.setActiveId(null);
16417 }
16418 });
16419 const onBlurCaptureProp = props.onBlurCapture;
16420 const onBlurCapture = useEvent((event) => {
16421 var _a;
16422 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
16423 if (event.defaultPrevented) return;
16424 if (!store) return;
16425 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
16426 if (!virtualFocus2) return;
16427 const activeElement2 = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
16428 const nextActiveElement = event.relatedTarget;
16429 const nextActiveElementIsItem = isItem(store, nextActiveElement);
16430 const previousElement = previousElementRef.current;
16431 previousElementRef.current = null;
16432 if (isSelfTarget(event) && nextActiveElementIsItem) {
16433 if (nextActiveElement === activeElement2) {
16434 if (previousElement && previousElement !== nextActiveElement) {
16435 fireBlurEvent(previousElement, event);
16436 }
16437 } else if (activeElement2) {
16438 fireBlurEvent(activeElement2, event);
16439 } else if (previousElement) {
16440 fireBlurEvent(previousElement, event);
16441 }
16442 event.stopPropagation();
16443 } else {
16444 const targetIsItem = isItem(store, event.target);
16445 if (!targetIsItem && activeElement2) {
16446 fireBlurEvent(activeElement2, event);
16447 }
16448 }
16449 });
16450 const onKeyDownProp = props.onKeyDown;
16451 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
16452 const onKeyDown = useEvent((event) => {
16453 var _a;
16454 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
16455 if (event.nativeEvent.isComposing) return;
16456 if (event.defaultPrevented) return;
16457 if (!store) return;
16458 if (!isSelfTarget(event)) return;
16459 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
16460 const activeItem = getEnabledItem(store, activeId2);
16461 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
16462 const isVertical = orientation !== "horizontal";
16463 const isHorizontal = orientation !== "vertical";
16464 const grid = isGrid(renderedItems);
16465 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
16466 if (isHorizontalKey && isTextField(event.currentTarget)) return;
16467 const up = () => {
16468 if (grid) {
16469 const item = findFirstEnabledItemInTheLastRow(renderedItems);
16470 return item == null ? void 0 : item.id;
16471 }
16472 return store == null ? void 0 : store.last();
16473 };
16474 const keyMap = {
16475 ArrowUp: (grid || isVertical) && up,
16476 ArrowRight: (grid || isHorizontal) && store.first,
16477 ArrowDown: (grid || isVertical) && store.first,
16478 ArrowLeft: (grid || isHorizontal) && store.last,
16479 Home: store.first,
16480 End: store.last,
16481 PageUp: store.first,
16482 PageDown: store.last
16483 };
16484 const action = keyMap[event.key];
16485 if (action) {
16486 const id = action();
16487 if (id !== void 0) {
16488 if (!moveOnKeyPressProp(event)) return;
16489 event.preventDefault();
16490 store.move(id);
16491 }
16492 }
16493 });
16494 props = useWrapElement(
16495 props,
16496 (element) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(CompositeContextProvider, { value: store, children: element }),
16497 [store]
16498 );
16499 const activeDescendant = store.useState((state) => {
16500 var _a;
16501 if (!store) return;
16502 if (!composite) return;
16503 if (!state.virtualFocus) return;
16504 return (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.id;
16505 });
16506 props = {
16507 "aria-activedescendant": activeDescendant,
16508 ...props,
16509 ref: useMergeRefs(ref, setBaseElement, props.ref),
16510 onKeyDownCapture,
16511 onKeyUpCapture,
16512 onFocusCapture,
16513 onFocus,
16514 onBlurCapture,
16515 onKeyDown
16516 };
16517 const focusable2 = store.useState(
16518 (state) => composite && (state.virtualFocus || state.activeId === null)
16519 );
16520 props = useFocusable({ focusable: focusable2, ...props });
16521 return props;
16522 }
16523 );
16524 var Composite5 = forwardRef22(function Composite22(props) {
16525 const htmlProps = useComposite(props);
16526 return createElement3(TagName5, htmlProps);
16527 });
16528
16529 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
16530 var ctx3 = createStoreContext();
16531 var useDisclosureContext = ctx3.useContext;
16532 var useDisclosureScopedContext = ctx3.useScopedContext;
16533 var useDisclosureProviderContext = ctx3.useProviderContext;
16534 var DisclosureContextProvider = ctx3.ContextProvider;
16535 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
16536
16537 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
16538 var import_react16 = __toESM(require_react(), 1);
16539 var ctx4 = createStoreContext(
16540 [DisclosureContextProvider],
16541 [DisclosureScopedContextProvider]
16542 );
16543 var useDialogContext = ctx4.useContext;
16544 var useDialogScopedContext = ctx4.useScopedContext;
16545 var useDialogProviderContext = ctx4.useProviderContext;
16546 var DialogContextProvider = ctx4.ContextProvider;
16547 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
16548 var DialogHeadingContext = (0, import_react16.createContext)(void 0);
16549 var DialogDescriptionContext = (0, import_react16.createContext)(void 0);
16550
16551 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
16552 var import_react17 = __toESM(require_react(), 1);
16553 var import_react_dom4 = __toESM(require_react_dom(), 1);
16554 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
16555 var TagName6 = "div";
16556 function afterTimeout(timeoutMs, cb) {
16557 const timeoutId = setTimeout(cb, timeoutMs);
16558 return () => clearTimeout(timeoutId);
16559 }
16560 function afterPaint2(cb) {
16561 let raf = requestAnimationFrame(() => {
16562 raf = requestAnimationFrame(cb);
16563 });
16564 return () => cancelAnimationFrame(raf);
16565 }
16566 function parseCSSTime(...times) {
16567 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
16568 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
16569 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
16570 if (currentTime > longestTime) return currentTime;
16571 return longestTime;
16572 }, 0);
16573 }
16574 function isHidden(mounted, hidden, alwaysVisible) {
16575 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
16576 }
16577 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) {
16578 const context = useDisclosureProviderContext();
16579 store = store || context;
16580 invariant(
16581 store,
16582 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
16583 );
16584 const ref = (0, import_react17.useRef)(null);
16585 const id = useId4(props.id);
16586 const [transition, setTransition] = (0, import_react17.useState)(null);
16587 const open = store.useState("open");
16588 const mounted = store.useState("mounted");
16589 const animated = store.useState("animated");
16590 const contentElement = store.useState("contentElement");
16591 const otherElement = useStoreState(store.disclosure, "contentElement");
16592 useSafeLayoutEffect(() => {
16593 if (!ref.current) return;
16594 store == null ? void 0 : store.setContentElement(ref.current);
16595 }, [store]);
16596 useSafeLayoutEffect(() => {
16597 let previousAnimated;
16598 store == null ? void 0 : store.setState("animated", (animated2) => {
16599 previousAnimated = animated2;
16600 return true;
16601 });
16602 return () => {
16603 if (previousAnimated === void 0) return;
16604 store == null ? void 0 : store.setState("animated", previousAnimated);
16605 };
16606 }, [store]);
16607 useSafeLayoutEffect(() => {
16608 if (!animated) return;
16609 if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
16610 setTransition(null);
16611 return;
16612 }
16613 return afterPaint2(() => {
16614 setTransition(open ? "enter" : mounted ? "leave" : null);
16615 });
16616 }, [animated, contentElement, open, mounted]);
16617 useSafeLayoutEffect(() => {
16618 if (!store) return;
16619 if (!animated) return;
16620 if (!transition) return;
16621 if (!contentElement) return;
16622 const stopAnimation = () => store == null ? void 0 : store.setState("animating", false);
16623 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
16624 if (transition === "leave" && open) return;
16625 if (transition === "enter" && !open) return;
16626 if (typeof animated === "number") {
16627 const timeout2 = animated;
16628 return afterTimeout(timeout2, stopAnimationSync);
16629 }
16630 const {
16631 transitionDuration,
16632 animationDuration,
16633 transitionDelay,
16634 animationDelay
16635 } = getComputedStyle(contentElement);
16636 const {
16637 transitionDuration: transitionDuration2 = "0",
16638 animationDuration: animationDuration2 = "0",
16639 transitionDelay: transitionDelay2 = "0",
16640 animationDelay: animationDelay2 = "0"
16641 } = otherElement ? getComputedStyle(otherElement) : {};
16642 const delay = parseCSSTime(
16643 transitionDelay,
16644 animationDelay,
16645 transitionDelay2,
16646 animationDelay2
16647 );
16648 const duration = parseCSSTime(
16649 transitionDuration,
16650 animationDuration,
16651 transitionDuration2,
16652 animationDuration2
16653 );
16654 const timeout = delay + duration;
16655 if (!timeout) {
16656 if (transition === "enter") {
16657 store.setState("animated", false);
16658 }
16659 stopAnimation();
16660 return;
16661 }
16662 const frameRate = 1e3 / 60;
16663 const maxTimeout = Math.max(timeout - frameRate, 0);
16664 return afterTimeout(maxTimeout, stopAnimationSync);
16665 }, [store, animated, contentElement, otherElement, open, transition]);
16666 props = useWrapElement(
16667 props,
16668 (element) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(DialogScopedContextProvider, { value: store, children: element }),
16669 [store]
16670 );
16671 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
16672 const styleProp = props.style;
16673 const style = (0, import_react17.useMemo)(() => {
16674 if (hidden) {
16675 return { ...styleProp, display: "none" };
16676 }
16677 return styleProp;
16678 }, [hidden, styleProp]);
16679 props = {
16680 id,
16681 "data-open": open || void 0,
16682 "data-enter": transition === "enter" || void 0,
16683 "data-leave": transition === "leave" || void 0,
16684 hidden,
16685 ...props,
16686 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
16687 style
16688 };
16689 return removeUndefinedValues(props);
16690 });
16691 var DisclosureContentImpl = forwardRef22(function DisclosureContentImpl2(props) {
16692 const htmlProps = useDisclosureContent(props);
16693 return createElement3(TagName6, htmlProps);
16694 });
16695 var DisclosureContent = forwardRef22(function DisclosureContent2({
16696 unmountOnHide,
16697 ...props
16698 }) {
16699 const context = useDisclosureProviderContext();
16700 const store = props.store || context;
16701 const mounted = useStoreState(
16702 store,
16703 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
16704 );
16705 if (mounted === false) return null;
16706 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(DisclosureContentImpl, { ...props });
16707 });
16708
16709 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
16710 function createDisclosureStore(props = {}) {
16711 const store = mergeStore(
16712 props.store,
16713 omit22(props.disclosure, ["contentElement", "disclosureElement"])
16714 );
16715 throwOnConflictingProps(props, store);
16716 const syncState = store == null ? void 0 : store.getState();
16717 const open = defaultValue(
16718 props.open,
16719 syncState == null ? void 0 : syncState.open,
16720 props.defaultOpen,
16721 false
16722 );
16723 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
16724 const initialState = {
16725 open,
16726 animated,
16727 animating: !!animated && open,
16728 mounted: open,
16729 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
16730 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
16731 };
16732 const disclosure = createStore(initialState, store);
16733 setup(
16734 disclosure,
16735 () => sync(disclosure, ["animated", "animating"], (state) => {
16736 if (state.animated) return;
16737 disclosure.setState("animating", false);
16738 })
16739 );
16740 setup(
16741 disclosure,
16742 () => subscribe(disclosure, ["open"], () => {
16743 if (!disclosure.getState().animated) return;
16744 disclosure.setState("animating", true);
16745 })
16746 );
16747 setup(
16748 disclosure,
16749 () => sync(disclosure, ["open", "animating"], (state) => {
16750 disclosure.setState("mounted", state.open || state.animating);
16751 })
16752 );
16753 return {
16754 ...disclosure,
16755 disclosure: props.disclosure,
16756 setOpen: (value) => disclosure.setState("open", value),
16757 show: () => disclosure.setState("open", true),
16758 hide: () => disclosure.setState("open", false),
16759 toggle: () => disclosure.setState("open", (open2) => !open2),
16760 stopAnimation: () => disclosure.setState("animating", false),
16761 setContentElement: (value) => disclosure.setState("contentElement", value),
16762 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
16763 };
16764 }
16765
16766 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
16767 function useDisclosureStoreProps(store, update2, props) {
16768 useUpdateEffect(update2, [props.store, props.disclosure]);
16769 useStoreProps(store, props, "open", "setOpen");
16770 useStoreProps(store, props, "mounted", "setMounted");
16771 useStoreProps(store, props, "animated");
16772 return Object.assign(store, { disclosure: props.disclosure });
16773 }
16774
16775 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
16776 var ctx5 = createStoreContext(
16777 [DialogContextProvider],
16778 [DialogScopedContextProvider]
16779 );
16780 var usePopoverContext = ctx5.useContext;
16781 var usePopoverScopedContext = ctx5.useScopedContext;
16782 var usePopoverProviderContext = ctx5.useProviderContext;
16783 var PopoverContextProvider = ctx5.ContextProvider;
16784 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
16785
16786 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
16787 function getCommonParent(items) {
16788 var _a;
16789 const firstItem = items.find((item) => !!item.element);
16790 const lastItem = [...items].reverse().find((item) => !!item.element);
16791 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
16792 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
16793 const parent = parentElement;
16794 if (lastItem && parent.contains(lastItem.element)) {
16795 return parentElement;
16796 }
16797 parentElement = parentElement.parentElement;
16798 }
16799 return getDocument(parentElement).body;
16800 }
16801 function getPrivateStore(store) {
16802 return store == null ? void 0 : store.__unstablePrivateStore;
16803 }
16804 function createCollectionStore(props = {}) {
16805 var _a;
16806 throwOnConflictingProps(props, props.store);
16807 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
16808 const items = defaultValue(
16809 props.items,
16810 syncState == null ? void 0 : syncState.items,
16811 props.defaultItems,
16812 []
16813 );
16814 const itemsMap = new Map(items.map((item) => [item.id, item]));
16815 const initialState = {
16816 items,
16817 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
16818 };
16819 const syncPrivateStore = getPrivateStore(props.store);
16820 const privateStore = createStore(
16821 { items, renderedItems: initialState.renderedItems },
16822 syncPrivateStore
16823 );
16824 const collection = createStore(initialState, props.store);
16825 const sortItems = (renderedItems) => {
16826 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
16827 privateStore.setState("renderedItems", sortedItems);
16828 collection.setState("renderedItems", sortedItems);
16829 };
16830 setup(collection, () => init(privateStore));
16831 setup(privateStore, () => {
16832 return batch(privateStore, ["items"], (state) => {
16833 collection.setState("items", state.items);
16834 });
16835 });
16836 setup(privateStore, () => {
16837 return batch(privateStore, ["renderedItems"], (state) => {
16838 let firstRun = true;
16839 let raf = requestAnimationFrame(() => {
16840 const { renderedItems } = collection.getState();
16841 if (state.renderedItems === renderedItems) return;
16842 sortItems(state.renderedItems);
16843 });
16844 if (typeof IntersectionObserver !== "function") {
16845 return () => cancelAnimationFrame(raf);
16846 }
16847 const ioCallback = () => {
16848 if (firstRun) {
16849 firstRun = false;
16850 return;
16851 }
16852 cancelAnimationFrame(raf);
16853 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
16854 };
16855 const root = getCommonParent(state.renderedItems);
16856 const observer = new IntersectionObserver(ioCallback, { root });
16857 for (const item of state.renderedItems) {
16858 if (!item.element) continue;
16859 observer.observe(item.element);
16860 }
16861 return () => {
16862 cancelAnimationFrame(raf);
16863 observer.disconnect();
16864 };
16865 });
16866 });
16867 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
16868 let prevItem;
16869 setItems((items2) => {
16870 const index2 = items2.findIndex(({ id }) => id === item.id);
16871 const nextItems = items2.slice();
16872 if (index2 !== -1) {
16873 prevItem = items2[index2];
16874 const nextItem = { ...prevItem, ...item };
16875 nextItems[index2] = nextItem;
16876 itemsMap.set(item.id, nextItem);
16877 } else {
16878 nextItems.push(item);
16879 itemsMap.set(item.id, item);
16880 }
16881 return nextItems;
16882 });
16883 const unmergeItem = () => {
16884 setItems((items2) => {
16885 if (!prevItem) {
16886 if (canDeleteFromMap) {
16887 itemsMap.delete(item.id);
16888 }
16889 return items2.filter(({ id }) => id !== item.id);
16890 }
16891 const index2 = items2.findIndex(({ id }) => id === item.id);
16892 if (index2 === -1) return items2;
16893 const nextItems = items2.slice();
16894 nextItems[index2] = prevItem;
16895 itemsMap.set(item.id, prevItem);
16896 return nextItems;
16897 });
16898 };
16899 return unmergeItem;
16900 };
16901 const registerItem = (item) => mergeItem(
16902 item,
16903 (getItems) => privateStore.setState("items", getItems),
16904 true
16905 );
16906 return {
16907 ...collection,
16908 registerItem,
16909 renderItem: (item) => chain(
16910 registerItem(item),
16911 mergeItem(
16912 item,
16913 (getItems) => privateStore.setState("renderedItems", getItems)
16914 )
16915 ),
16916 item: (id) => {
16917 if (!id) return null;
16918 let item = itemsMap.get(id);
16919 if (!item) {
16920 const { items: items2 } = privateStore.getState();
16921 item = items2.find((item2) => item2.id === id);
16922 if (item) {
16923 itemsMap.set(id, item);
16924 }
16925 }
16926 return item || null;
16927 },
16928 // @ts-expect-error Internal
16929 __unstablePrivateStore: privateStore
16930 };
16931 }
16932
16933 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
16934 function useCollectionStoreProps(store, update2, props) {
16935 useUpdateEffect(update2, [props.store]);
16936 useStoreProps(store, props, "items", "setItems");
16937 return store;
16938 }
16939
16940 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
16941 var NULL_ITEM = { id: null };
16942 function findFirstEnabledItem2(items, excludeId) {
16943 return items.find((item) => {
16944 if (excludeId) {
16945 return !item.disabled && item.id !== excludeId;
16946 }
16947 return !item.disabled;
16948 });
16949 }
16950 function getEnabledItems(items, excludeId) {
16951 return items.filter((item) => {
16952 if (excludeId) {
16953 return !item.disabled && item.id !== excludeId;
16954 }
16955 return !item.disabled;
16956 });
16957 }
16958 function getItemsInRow(items, rowId) {
16959 return items.filter((item) => item.rowId === rowId);
16960 }
16961 function flipItems(items, activeId, shouldInsertNullItem = false) {
16962 const index2 = items.findIndex((item) => item.id === activeId);
16963 return [
16964 ...items.slice(index2 + 1),
16965 ...shouldInsertNullItem ? [NULL_ITEM] : [],
16966 ...items.slice(0, index2)
16967 ];
16968 }
16969 function groupItemsByRows2(items) {
16970 const rows = [];
16971 for (const item of items) {
16972 const row = rows.find((currentRow) => {
16973 var _a;
16974 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
16975 });
16976 if (row) {
16977 row.push(item);
16978 } else {
16979 rows.push([item]);
16980 }
16981 }
16982 return rows;
16983 }
16984 function getMaxRowLength(array) {
16985 let maxLength = 0;
16986 for (const { length } of array) {
16987 if (length > maxLength) {
16988 maxLength = length;
16989 }
16990 }
16991 return maxLength;
16992 }
16993 function createEmptyItem(rowId) {
16994 return {
16995 id: "__EMPTY_ITEM__",
16996 disabled: true,
16997 rowId
16998 };
16999 }
17000 function normalizeRows(rows, activeId, focusShift) {
17001 const maxLength = getMaxRowLength(rows);
17002 for (const row of rows) {
17003 for (let i2 = 0; i2 < maxLength; i2 += 1) {
17004 const item = row[i2];
17005 if (!item || focusShift && item.disabled) {
17006 const isFirst = i2 === 0;
17007 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
17008 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
17009 }
17010 }
17011 }
17012 return rows;
17013 }
17014 function verticalizeItems(items) {
17015 const rows = groupItemsByRows2(items);
17016 const maxLength = getMaxRowLength(rows);
17017 const verticalized = [];
17018 for (let i2 = 0; i2 < maxLength; i2 += 1) {
17019 for (const row of rows) {
17020 const item = row[i2];
17021 if (item) {
17022 verticalized.push({
17023 ...item,
17024 // If there's no rowId, it means that it's not a grid composite, but
17025 // a single row instead. So, instead of verticalizing it, that is,
17026 // assigning a different rowId based on the column index, we keep it
17027 // undefined so they will be part of the same row. This is useful
17028 // when using up/down on one-dimensional composites.
17029 rowId: item.rowId ? `${i2}` : void 0
17030 });
17031 }
17032 }
17033 }
17034 return verticalized;
17035 }
17036 function createCompositeStore(props = {}) {
17037 var _a;
17038 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
17039 const collection = createCollectionStore(props);
17040 const activeId = defaultValue(
17041 props.activeId,
17042 syncState == null ? void 0 : syncState.activeId,
17043 props.defaultActiveId
17044 );
17045 const initialState = {
17046 ...collection.getState(),
17047 id: defaultValue(
17048 props.id,
17049 syncState == null ? void 0 : syncState.id,
17050 `id-${Math.random().toString(36).slice(2, 8)}`
17051 ),
17052 activeId,
17053 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
17054 includesBaseElement: defaultValue(
17055 props.includesBaseElement,
17056 syncState == null ? void 0 : syncState.includesBaseElement,
17057 activeId === null
17058 ),
17059 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
17060 orientation: defaultValue(
17061 props.orientation,
17062 syncState == null ? void 0 : syncState.orientation,
17063 "both"
17064 ),
17065 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
17066 virtualFocus: defaultValue(
17067 props.virtualFocus,
17068 syncState == null ? void 0 : syncState.virtualFocus,
17069 false
17070 ),
17071 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
17072 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
17073 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
17074 };
17075 const composite = createStore(initialState, collection, props.store);
17076 setup(
17077 composite,
17078 () => sync(composite, ["renderedItems", "activeId"], (state) => {
17079 composite.setState("activeId", (activeId2) => {
17080 var _a2;
17081 if (activeId2 !== void 0) return activeId2;
17082 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
17083 });
17084 })
17085 );
17086 const getNextId = (direction = "next", options = {}) => {
17087 var _a2, _b;
17088 const defaultState = composite.getState();
17089 const {
17090 skip = 0,
17091 activeId: activeId2 = defaultState.activeId,
17092 focusShift = defaultState.focusShift,
17093 focusLoop = defaultState.focusLoop,
17094 focusWrap = defaultState.focusWrap,
17095 includesBaseElement = defaultState.includesBaseElement,
17096 renderedItems = defaultState.renderedItems,
17097 rtl = defaultState.rtl
17098 } = options;
17099 const isVerticalDirection = direction === "up" || direction === "down";
17100 const isNextDirection = direction === "next" || direction === "down";
17101 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
17102 const canShift = focusShift && !skip;
17103 let items = !isVerticalDirection ? renderedItems : flatten2DArray(
17104 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
17105 );
17106 items = canReverse ? reverseArray(items) : items;
17107 items = isVerticalDirection ? verticalizeItems(items) : items;
17108 if (activeId2 == null) {
17109 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
17110 }
17111 const activeItem = items.find((item) => item.id === activeId2);
17112 if (!activeItem) {
17113 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
17114 }
17115 const isGrid2 = items.some((item) => item.rowId);
17116 const activeIndex = items.indexOf(activeItem);
17117 const nextItems = items.slice(activeIndex + 1);
17118 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
17119 if (skip) {
17120 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
17121 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
17122 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
17123 return nextItem2 == null ? void 0 : nextItem2.id;
17124 }
17125 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
17126 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
17127 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
17128 if (canLoop) {
17129 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
17130 const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
17131 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
17132 return nextItem2 == null ? void 0 : nextItem2.id;
17133 }
17134 if (canWrap) {
17135 const nextItem2 = findFirstEnabledItem2(
17136 // We can use nextItems, which contains all the next items, including
17137 // items from other rows, to wrap between rows. However, if there is a
17138 // null item (the composite container), we'll only use the next items in
17139 // the row. So moving next from the last item will focus on the
17140 // composite container. On grid composites, horizontal navigation never
17141 // focuses on the composite container, only vertical.
17142 hasNullItem ? nextItemsInRow : nextItems,
17143 activeId2
17144 );
17145 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
17146 return nextId;
17147 }
17148 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
17149 if (!nextItem && hasNullItem) {
17150 return null;
17151 }
17152 return nextItem == null ? void 0 : nextItem.id;
17153 };
17154 return {
17155 ...collection,
17156 ...composite,
17157 setBaseElement: (element) => composite.setState("baseElement", element),
17158 setActiveId: (id) => composite.setState("activeId", id),
17159 move: (id) => {
17160 if (id === void 0) return;
17161 composite.setState("activeId", id);
17162 composite.setState("moves", (moves) => moves + 1);
17163 },
17164 first: () => {
17165 var _a2;
17166 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
17167 },
17168 last: () => {
17169 var _a2;
17170 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
17171 },
17172 next: (options) => {
17173 if (options !== void 0 && typeof options === "number") {
17174 options = { skip: options };
17175 }
17176 return getNextId("next", options);
17177 },
17178 previous: (options) => {
17179 if (options !== void 0 && typeof options === "number") {
17180 options = { skip: options };
17181 }
17182 return getNextId("previous", options);
17183 },
17184 down: (options) => {
17185 if (options !== void 0 && typeof options === "number") {
17186 options = { skip: options };
17187 }
17188 return getNextId("down", options);
17189 },
17190 up: (options) => {
17191 if (options !== void 0 && typeof options === "number") {
17192 options = { skip: options };
17193 }
17194 return getNextId("up", options);
17195 }
17196 };
17197 }
17198
17199 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
17200 function useCompositeStoreOptions(props) {
17201 const id = useId4(props.id);
17202 return { id, ...props };
17203 }
17204 function useCompositeStoreProps(store, update2, props) {
17205 store = useCollectionStoreProps(store, update2, props);
17206 useStoreProps(store, props, "activeId", "setActiveId");
17207 useStoreProps(store, props, "includesBaseElement");
17208 useStoreProps(store, props, "virtualFocus");
17209 useStoreProps(store, props, "orientation");
17210 useStoreProps(store, props, "rtl");
17211 useStoreProps(store, props, "focusLoop");
17212 useStoreProps(store, props, "focusWrap");
17213 useStoreProps(store, props, "focusShift");
17214 return store;
17215 }
17216
17217 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
17218 var import_react18 = __toESM(require_react(), 1);
17219 var ComboboxListRoleContext = (0, import_react18.createContext)(
17220 void 0
17221 );
17222 var ctx6 = createStoreContext(
17223 [PopoverContextProvider, CompositeContextProvider],
17224 [PopoverScopedContextProvider, CompositeScopedContextProvider]
17225 );
17226 var useComboboxContext = ctx6.useContext;
17227 var useComboboxScopedContext = ctx6.useScopedContext;
17228 var useComboboxProviderContext = ctx6.useProviderContext;
17229 var ComboboxContextProvider = ctx6.ContextProvider;
17230 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
17231 var ComboboxItemValueContext = (0, import_react18.createContext)(
17232 void 0
17233 );
17234 var ComboboxItemCheckedContext = (0, import_react18.createContext)(false);
17235
17236 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
17237 function createDialogStore(props = {}) {
17238 return createDisclosureStore(props);
17239 }
17240
17241 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
17242 function useDialogStoreProps(store, update2, props) {
17243 return useDisclosureStoreProps(store, update2, props);
17244 }
17245
17246 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
17247 function createPopoverStore({
17248 popover: otherPopover,
17249 ...props
17250 } = {}) {
17251 const store = mergeStore(
17252 props.store,
17253 omit22(otherPopover, [
17254 "arrowElement",
17255 "anchorElement",
17256 "contentElement",
17257 "popoverElement",
17258 "disclosureElement"
17259 ])
17260 );
17261 throwOnConflictingProps(props, store);
17262 const syncState = store == null ? void 0 : store.getState();
17263 const dialog = createDialogStore({ ...props, store });
17264 const placement = defaultValue(
17265 props.placement,
17266 syncState == null ? void 0 : syncState.placement,
17267 "bottom"
17268 );
17269 const initialState = {
17270 ...dialog.getState(),
17271 placement,
17272 currentPlacement: placement,
17273 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
17274 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
17275 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
17276 rendered: /* @__PURE__ */ Symbol("rendered")
17277 };
17278 const popover = createStore(initialState, dialog, store);
17279 return {
17280 ...dialog,
17281 ...popover,
17282 setAnchorElement: (element) => popover.setState("anchorElement", element),
17283 setPopoverElement: (element) => popover.setState("popoverElement", element),
17284 setArrowElement: (element) => popover.setState("arrowElement", element),
17285 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
17286 };
17287 }
17288
17289 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
17290 function usePopoverStoreProps(store, update2, props) {
17291 useUpdateEffect(update2, [props.popover]);
17292 useStoreProps(store, props, "placement");
17293 return useDialogStoreProps(store, update2, props);
17294 }
17295
17296 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
17297 var TagName7 = "div";
17298 var usePopoverAnchor = createHook(
17299 function usePopoverAnchor2({ store, ...props }) {
17300 const context = usePopoverProviderContext();
17301 store = store || context;
17302 props = {
17303 ...props,
17304 ref: useMergeRefs(store == null ? void 0 : store.setAnchorElement, props.ref)
17305 };
17306 return props;
17307 }
17308 );
17309 var PopoverAnchor = forwardRef22(function PopoverAnchor2(props) {
17310 const htmlProps = usePopoverAnchor(props);
17311 return createElement3(TagName7, htmlProps);
17312 });
17313
17314 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
17315 var import_react19 = __toESM(require_react(), 1);
17316 var TagName8 = "div";
17317 function getMouseDestination(event) {
17318 const relatedTarget = event.relatedTarget;
17319 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
17320 return relatedTarget;
17321 }
17322 return null;
17323 }
17324 function hoveringInside(event) {
17325 const nextElement = getMouseDestination(event);
17326 if (!nextElement) return false;
17327 return contains2(event.currentTarget, nextElement);
17328 }
17329 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
17330 function movingToAnotherItem(event) {
17331 let dest = getMouseDestination(event);
17332 if (!dest) return false;
17333 do {
17334 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
17335 dest = dest.parentElement;
17336 } while (dest);
17337 return false;
17338 }
17339 var useCompositeHover = createHook(
17340 function useCompositeHover2({
17341 store,
17342 focusOnHover = true,
17343 blurOnHoverEnd = !!focusOnHover,
17344 ...props
17345 }) {
17346 const context = useCompositeContext();
17347 store = store || context;
17348 invariant(
17349 store,
17350 "CompositeHover must be wrapped in a Composite component."
17351 );
17352 const isMouseMoving = useIsMouseMoving();
17353 const onMouseMoveProp = props.onMouseMove;
17354 const focusOnHoverProp = useBooleanEvent(focusOnHover);
17355 const onMouseMove = useEvent((event) => {
17356 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
17357 if (event.defaultPrevented) return;
17358 if (!isMouseMoving()) return;
17359 if (!focusOnHoverProp(event)) return;
17360 if (!hasFocusWithin(event.currentTarget)) {
17361 const baseElement = store == null ? void 0 : store.getState().baseElement;
17362 if (baseElement && !hasFocus(baseElement)) {
17363 baseElement.focus();
17364 }
17365 }
17366 store == null ? void 0 : store.setActiveId(event.currentTarget.id);
17367 });
17368 const onMouseLeaveProp = props.onMouseLeave;
17369 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
17370 const onMouseLeave = useEvent((event) => {
17371 var _a;
17372 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
17373 if (event.defaultPrevented) return;
17374 if (!isMouseMoving()) return;
17375 if (hoveringInside(event)) return;
17376 if (movingToAnotherItem(event)) return;
17377 if (!focusOnHoverProp(event)) return;
17378 if (!blurOnHoverEndProp(event)) return;
17379 store == null ? void 0 : store.setActiveId(null);
17380 (_a = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a.focus();
17381 });
17382 const ref = (0, import_react19.useCallback)((element) => {
17383 if (!element) return;
17384 element[symbol2] = true;
17385 }, []);
17386 props = {
17387 ...props,
17388 ref: useMergeRefs(ref, props.ref),
17389 onMouseMove,
17390 onMouseLeave
17391 };
17392 return removeUndefinedValues(props);
17393 }
17394 );
17395 var CompositeHover = memo22(
17396 forwardRef22(function CompositeHover2(props) {
17397 const htmlProps = useCompositeHover(props);
17398 return createElement3(TagName8, htmlProps);
17399 })
17400 );
17401
17402 // node_modules/@ariakit/react-core/esm/combobox/combobox.js
17403 var import_react20 = __toESM(require_react(), 1);
17404 var TagName9 = "input";
17405 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
17406 if (!autoSelect) return false;
17407 const firstItem = items.find((item) => !item.disabled && item.value);
17408 return (firstItem == null ? void 0 : firstItem.value) === activeValue;
17409 }
17410 function hasCompletionString(value, activeValue) {
17411 if (!activeValue) return false;
17412 if (value == null) return false;
17413 value = normalizeString(value);
17414 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
17415 }
17416 function isInputEvent(event) {
17417 return event.type === "input";
17418 }
17419 function isAriaAutoCompleteValue(value) {
17420 return value === "inline" || value === "list" || value === "both" || value === "none";
17421 }
17422 function getDefaultAutoSelectId(items) {
17423 const item = items.find((item2) => {
17424 var _a;
17425 if (item2.disabled) return false;
17426 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
17427 });
17428 return item == null ? void 0 : item.id;
17429 }
17430 var useCombobox = createHook(
17431 function useCombobox2({
17432 store,
17433 focusable: focusable2 = true,
17434 autoSelect: autoSelectProp = false,
17435 getAutoSelectId,
17436 setValueOnChange,
17437 showMinLength = 0,
17438 showOnChange,
17439 showOnMouseDown,
17440 showOnClick = showOnMouseDown,
17441 showOnKeyDown,
17442 showOnKeyPress = showOnKeyDown,
17443 blurActiveItemOnClick,
17444 setValueOnClick = true,
17445 moveOnKeyPress = true,
17446 autoComplete = "list",
17447 ...props
17448 }) {
17449 const context = useComboboxProviderContext();
17450 store = store || context;
17451 invariant(
17452 store,
17453 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
17454 );
17455 const ref = (0, import_react20.useRef)(null);
17456 const [valueUpdated, forceValueUpdate] = useForceUpdate();
17457 const canAutoSelectRef = (0, import_react20.useRef)(false);
17458 const composingRef = (0, import_react20.useRef)(false);
17459 const autoSelect = store.useState(
17460 (state) => state.virtualFocus && autoSelectProp
17461 );
17462 const inline4 = autoComplete === "inline" || autoComplete === "both";
17463 const [canInline, setCanInline] = (0, import_react20.useState)(inline4);
17464 useUpdateLayoutEffect(() => {
17465 if (!inline4) return;
17466 setCanInline(true);
17467 }, [inline4]);
17468 const storeValue = store.useState("value");
17469 const prevSelectedValueRef = (0, import_react20.useRef)(void 0);
17470 (0, import_react20.useEffect)(() => {
17471 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
17472 prevSelectedValueRef.current = prev.selectedValue;
17473 });
17474 }, []);
17475 const inlineActiveValue = store.useState((state) => {
17476 var _a;
17477 if (!inline4) return;
17478 if (!canInline) return;
17479 if (state.activeValue && Array.isArray(state.selectedValue)) {
17480 if (state.selectedValue.includes(state.activeValue)) return;
17481 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
17482 }
17483 return state.activeValue;
17484 });
17485 const items = store.useState("renderedItems");
17486 const open = store.useState("open");
17487 const contentElement = store.useState("contentElement");
17488 const value = (0, import_react20.useMemo)(() => {
17489 if (!inline4) return storeValue;
17490 if (!canInline) return storeValue;
17491 const firstItemAutoSelected = isFirstItemAutoSelected(
17492 items,
17493 inlineActiveValue,
17494 autoSelect
17495 );
17496 if (firstItemAutoSelected) {
17497 if (hasCompletionString(storeValue, inlineActiveValue)) {
17498 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
17499 return storeValue + slice;
17500 }
17501 return storeValue;
17502 }
17503 return inlineActiveValue || storeValue;
17504 }, [inline4, canInline, items, inlineActiveValue, autoSelect, storeValue]);
17505 (0, import_react20.useEffect)(() => {
17506 const element = ref.current;
17507 if (!element) return;
17508 const onCompositeItemMove = () => setCanInline(true);
17509 element.addEventListener("combobox-item-move", onCompositeItemMove);
17510 return () => {
17511 element.removeEventListener("combobox-item-move", onCompositeItemMove);
17512 };
17513 }, []);
17514 (0, import_react20.useEffect)(() => {
17515 if (!inline4) return;
17516 if (!canInline) return;
17517 if (!inlineActiveValue) return;
17518 const firstItemAutoSelected = isFirstItemAutoSelected(
17519 items,
17520 inlineActiveValue,
17521 autoSelect
17522 );
17523 if (!firstItemAutoSelected) return;
17524 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
17525 let cleanup = noop4;
17526 queueMicrotask(() => {
17527 const element = ref.current;
17528 if (!element) return;
17529 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
17530 const nextStart = storeValue.length;
17531 const nextEnd = inlineActiveValue.length;
17532 setSelectionRange(element, nextStart, nextEnd);
17533 cleanup = () => {
17534 if (!hasFocus(element)) return;
17535 const { start, end } = getTextboxSelection(element);
17536 if (start !== nextStart) return;
17537 if (end !== nextEnd) return;
17538 setSelectionRange(element, prevStart, prevEnd);
17539 };
17540 });
17541 return () => cleanup();
17542 }, [
17543 valueUpdated,
17544 inline4,
17545 canInline,
17546 inlineActiveValue,
17547 items,
17548 autoSelect,
17549 storeValue
17550 ]);
17551 const scrollingElementRef = (0, import_react20.useRef)(null);
17552 const getAutoSelectIdProp = useEvent(getAutoSelectId);
17553 const autoSelectIdRef = (0, import_react20.useRef)(null);
17554 (0, import_react20.useEffect)(() => {
17555 if (!open) return;
17556 if (!contentElement) return;
17557 const scrollingElement = getScrollingElement(contentElement);
17558 if (!scrollingElement) return;
17559 scrollingElementRef.current = scrollingElement;
17560 const onUserScroll = () => {
17561 canAutoSelectRef.current = false;
17562 };
17563 const onScroll = () => {
17564 if (!store) return;
17565 if (!canAutoSelectRef.current) return;
17566 const { activeId } = store.getState();
17567 if (activeId === null) return;
17568 if (activeId === autoSelectIdRef.current) return;
17569 canAutoSelectRef.current = false;
17570 };
17571 const options = { passive: true, capture: true };
17572 scrollingElement.addEventListener("wheel", onUserScroll, options);
17573 scrollingElement.addEventListener("touchmove", onUserScroll, options);
17574 scrollingElement.addEventListener("scroll", onScroll, options);
17575 return () => {
17576 scrollingElement.removeEventListener("wheel", onUserScroll, true);
17577 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
17578 scrollingElement.removeEventListener("scroll", onScroll, true);
17579 };
17580 }, [open, contentElement, store]);
17581 useSafeLayoutEffect(() => {
17582 if (!storeValue) return;
17583 if (composingRef.current) return;
17584 canAutoSelectRef.current = true;
17585 }, [storeValue]);
17586 useSafeLayoutEffect(() => {
17587 if (autoSelect !== "always" && open) return;
17588 canAutoSelectRef.current = open;
17589 }, [autoSelect, open]);
17590 const resetValueOnSelect = store.useState("resetValueOnSelect");
17591 useUpdateEffect(() => {
17592 var _a, _b;
17593 const canAutoSelect = canAutoSelectRef.current;
17594 if (!store) return;
17595 if (!open) return;
17596 if (!canAutoSelect && !resetValueOnSelect) return;
17597 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
17598 if (baseElement && !hasFocus(baseElement)) return;
17599 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
17600 const observer = new MutationObserver(forceValueUpdate);
17601 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
17602 return () => observer.disconnect();
17603 }
17604 if (autoSelect && canAutoSelect) {
17605 const userAutoSelectId = getAutoSelectIdProp(items);
17606 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store.first();
17607 autoSelectIdRef.current = autoSelectId;
17608 store.move(autoSelectId != null ? autoSelectId : null);
17609 } else {
17610 const element = (_b = store.item(activeId || store.first())) == null ? void 0 : _b.element;
17611 if (element && "scrollIntoView" in element) {
17612 element.scrollIntoView({ block: "nearest", inline: "nearest" });
17613 }
17614 }
17615 return;
17616 }, [
17617 store,
17618 open,
17619 valueUpdated,
17620 storeValue,
17621 autoSelect,
17622 resetValueOnSelect,
17623 getAutoSelectIdProp,
17624 items
17625 ]);
17626 (0, import_react20.useEffect)(() => {
17627 if (!inline4) return;
17628 const combobox = ref.current;
17629 if (!combobox) return;
17630 const elements = [combobox, contentElement].filter(
17631 (value2) => !!value2
17632 );
17633 const onBlur2 = (event) => {
17634 if (elements.every((el) => isFocusEventOutside(event, el))) {
17635 store == null ? void 0 : store.setValue(value);
17636 }
17637 };
17638 for (const element of elements) {
17639 element.addEventListener("focusout", onBlur2);
17640 }
17641 return () => {
17642 for (const element of elements) {
17643 element.removeEventListener("focusout", onBlur2);
17644 }
17645 };
17646 }, [inline4, contentElement, store, value]);
17647 const canShow = (event) => {
17648 const currentTarget = event.currentTarget;
17649 return currentTarget.value.length >= showMinLength;
17650 };
17651 const onChangeProp = props.onChange;
17652 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
17653 const setValueOnChangeProp = useBooleanEvent(
17654 // If the combobox is combined with tags, the value will be set by the tag
17655 // input component.
17656 setValueOnChange != null ? setValueOnChange : !store.tag
17657 );
17658 const onChange = useEvent((event) => {
17659 onChangeProp == null ? void 0 : onChangeProp(event);
17660 if (event.defaultPrevented) return;
17661 if (!store) return;
17662 const currentTarget = event.currentTarget;
17663 const { value: value2, selectionStart, selectionEnd } = currentTarget;
17664 const nativeEvent = event.nativeEvent;
17665 canAutoSelectRef.current = true;
17666 if (isInputEvent(nativeEvent)) {
17667 if (nativeEvent.isComposing) {
17668 canAutoSelectRef.current = false;
17669 composingRef.current = true;
17670 }
17671 if (inline4) {
17672 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
17673 const caretAtEnd = selectionStart === value2.length;
17674 setCanInline(textInserted && caretAtEnd);
17675 }
17676 }
17677 if (setValueOnChangeProp(event)) {
17678 const isSameValue = value2 === store.getState().value;
17679 store.setValue(value2);
17680 queueMicrotask(() => {
17681 setSelectionRange(currentTarget, selectionStart, selectionEnd);
17682 });
17683 if (inline4 && autoSelect && isSameValue) {
17684 forceValueUpdate();
17685 }
17686 }
17687 if (showOnChangeProp(event)) {
17688 store.show();
17689 }
17690 if (!autoSelect || !canAutoSelectRef.current) {
17691 store.setActiveId(null);
17692 }
17693 });
17694 const onCompositionEndProp = props.onCompositionEnd;
17695 const onCompositionEnd = useEvent((event) => {
17696 canAutoSelectRef.current = true;
17697 composingRef.current = false;
17698 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
17699 if (event.defaultPrevented) return;
17700 if (!autoSelect) return;
17701 forceValueUpdate();
17702 });
17703 const onMouseDownProp = props.onMouseDown;
17704 const blurActiveItemOnClickProp = useBooleanEvent(
17705 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store == null ? void 0 : store.getState().includesBaseElement))
17706 );
17707 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
17708 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
17709 const onMouseDown = useEvent((event) => {
17710 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
17711 if (event.defaultPrevented) return;
17712 if (event.button) return;
17713 if (event.ctrlKey) return;
17714 if (!store) return;
17715 if (blurActiveItemOnClickProp(event)) {
17716 store.setActiveId(null);
17717 }
17718 if (setValueOnClickProp(event)) {
17719 store.setValue(value);
17720 }
17721 if (showOnClickProp(event)) {
17722 queueBeforeEvent(event.currentTarget, "mouseup", store.show);
17723 }
17724 });
17725 const onKeyDownProp = props.onKeyDown;
17726 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
17727 const onKeyDown = useEvent((event) => {
17728 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
17729 if (!event.repeat) {
17730 canAutoSelectRef.current = false;
17731 }
17732 if (event.defaultPrevented) return;
17733 if (event.ctrlKey) return;
17734 if (event.altKey) return;
17735 if (event.shiftKey) return;
17736 if (event.metaKey) return;
17737 if (!store) return;
17738 const { open: open2 } = store.getState();
17739 if (open2) return;
17740 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
17741 if (showOnKeyPressProp(event)) {
17742 event.preventDefault();
17743 store.show();
17744 }
17745 }
17746 });
17747 const onBlurProp = props.onBlur;
17748 const onBlur = useEvent((event) => {
17749 canAutoSelectRef.current = false;
17750 onBlurProp == null ? void 0 : onBlurProp(event);
17751 if (event.defaultPrevented) return;
17752 });
17753 const id = useId4(props.id);
17754 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
17755 const isActiveItem = store.useState((state) => state.activeId === null);
17756 props = {
17757 id,
17758 role: "combobox",
17759 "aria-autocomplete": ariaAutoComplete,
17760 "aria-haspopup": getPopupRole(contentElement, "listbox"),
17761 "aria-expanded": open,
17762 "aria-controls": contentElement == null ? void 0 : contentElement.id,
17763 "data-active-item": isActiveItem || void 0,
17764 value,
17765 ...props,
17766 ref: useMergeRefs(ref, props.ref),
17767 onChange,
17768 onCompositionEnd,
17769 onMouseDown,
17770 onKeyDown,
17771 onBlur
17772 };
17773 props = useComposite({
17774 store,
17775 focusable: focusable2,
17776 ...props,
17777 // Enable inline autocomplete when the user moves from the combobox input
17778 // to an item.
17779 moveOnKeyPress: (event) => {
17780 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
17781 if (inline4) setCanInline(true);
17782 return true;
17783 }
17784 });
17785 props = usePopoverAnchor({ store, ...props });
17786 return { autoComplete: "off", ...props };
17787 }
17788 );
17789 var Combobox = forwardRef22(function Combobox2(props) {
17790 const htmlProps = useCombobox(props);
17791 return createElement3(TagName9, htmlProps);
17792 });
17793
17794 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
17795 var import_react21 = __toESM(require_react(), 1);
17796 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
17797 var TagName10 = "div";
17798 function isSelected(storeValue, itemValue) {
17799 if (itemValue == null) return;
17800 if (storeValue == null) return false;
17801 if (Array.isArray(storeValue)) {
17802 return storeValue.includes(itemValue);
17803 }
17804 return storeValue === itemValue;
17805 }
17806 function getItemRole(popupRole) {
17807 var _a;
17808 const itemRoleByPopupRole = {
17809 menu: "menuitem",
17810 listbox: "option",
17811 tree: "treeitem"
17812 };
17813 const key = popupRole;
17814 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
17815 }
17816 var useComboboxItem = createHook(
17817 function useComboboxItem2({
17818 store,
17819 value,
17820 hideOnClick,
17821 setValueOnClick,
17822 selectValueOnClick = true,
17823 resetValueOnSelect,
17824 focusOnHover = false,
17825 moveOnKeyPress = true,
17826 getItem: getItemProp,
17827 ...props
17828 }) {
17829 var _a;
17830 const context = useComboboxScopedContext();
17831 store = store || context;
17832 invariant(
17833 store,
17834 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
17835 );
17836 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
17837 resetValueOnSelectState: "resetValueOnSelect",
17838 multiSelectable(state) {
17839 return Array.isArray(state.selectedValue);
17840 },
17841 selected(state) {
17842 return isSelected(state.selectedValue, value);
17843 }
17844 });
17845 const getItem = (0, import_react21.useCallback)(
17846 (item) => {
17847 const nextItem = { ...item, value };
17848 if (getItemProp) {
17849 return getItemProp(nextItem);
17850 }
17851 return nextItem;
17852 },
17853 [value, getItemProp]
17854 );
17855 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
17856 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
17857 const onClickProp = props.onClick;
17858 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
17859 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
17860 const resetValueOnSelectProp = useBooleanEvent(
17861 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
17862 );
17863 const hideOnClickProp = useBooleanEvent(hideOnClick);
17864 const onClick = useEvent((event) => {
17865 onClickProp == null ? void 0 : onClickProp(event);
17866 if (event.defaultPrevented) return;
17867 if (isDownloading(event)) return;
17868 if (isOpeningInNewTab(event)) return;
17869 if (value != null) {
17870 if (selectValueOnClickProp(event)) {
17871 if (resetValueOnSelectProp(event)) {
17872 store == null ? void 0 : store.resetValue();
17873 }
17874 store == null ? void 0 : store.setSelectedValue((prevValue) => {
17875 if (!Array.isArray(prevValue)) return value;
17876 if (prevValue.includes(value)) {
17877 return prevValue.filter((v2) => v2 !== value);
17878 }
17879 return [...prevValue, value];
17880 });
17881 }
17882 if (setValueOnClickProp(event)) {
17883 store == null ? void 0 : store.setValue(value);
17884 }
17885 }
17886 if (hideOnClickProp(event)) {
17887 store == null ? void 0 : store.hide();
17888 }
17889 });
17890 const onKeyDownProp = props.onKeyDown;
17891 const onKeyDown = useEvent((event) => {
17892 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
17893 if (event.defaultPrevented) return;
17894 const baseElement = store == null ? void 0 : store.getState().baseElement;
17895 if (!baseElement) return;
17896 if (hasFocus(baseElement)) return;
17897 const printable = event.key.length === 1;
17898 if (printable || event.key === "Backspace" || event.key === "Delete") {
17899 queueMicrotask(() => baseElement.focus());
17900 if (isTextField(baseElement)) {
17901 store == null ? void 0 : store.setValue(baseElement.value);
17902 }
17903 }
17904 });
17905 if (multiSelectable && selected != null) {
17906 props = {
17907 "aria-selected": selected,
17908 ...props
17909 };
17910 }
17911 props = useWrapElement(
17912 props,
17913 (element) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }),
17914 [value, selected]
17915 );
17916 const popupRole = (0, import_react21.useContext)(ComboboxListRoleContext);
17917 props = {
17918 role: getItemRole(popupRole),
17919 children: value,
17920 ...props,
17921 onClick,
17922 onKeyDown
17923 };
17924 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
17925 props = useCompositeItem({
17926 store,
17927 ...props,
17928 getItem,
17929 // Dispatch a custom event on the combobox input when moving to an item
17930 // with the keyboard so the Combobox component can enable inline
17931 // autocompletion.
17932 moveOnKeyPress: (event) => {
17933 if (!moveOnKeyPressProp(event)) return false;
17934 const moveEvent = new Event("combobox-item-move");
17935 const baseElement = store == null ? void 0 : store.getState().baseElement;
17936 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
17937 return true;
17938 }
17939 });
17940 props = useCompositeHover({ store, focusOnHover, ...props });
17941 return props;
17942 }
17943 );
17944 var ComboboxItem = memo22(
17945 forwardRef22(function ComboboxItem2(props) {
17946 const htmlProps = useComboboxItem(props);
17947 return createElement3(TagName10, htmlProps);
17948 })
17949 );
17950
17951 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
17952 var import_react22 = __toESM(require_react(), 1);
17953 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
17954 var TagName11 = "span";
17955 function normalizeValue(value) {
17956 return normalizeString(value).toLowerCase();
17957 }
17958 function getOffsets(string, values) {
17959 const offsets = [];
17960 for (const value of values) {
17961 let pos = 0;
17962 const length = value.length;
17963 while (string.indexOf(value, pos) !== -1) {
17964 const index2 = string.indexOf(value, pos);
17965 if (index2 !== -1) {
17966 offsets.push([index2, length]);
17967 }
17968 pos = index2 + 1;
17969 }
17970 }
17971 return offsets;
17972 }
17973 function filterOverlappingOffsets(offsets) {
17974 return offsets.filter(([offset4, length], i2, arr) => {
17975 return !arr.some(
17976 ([o2, l2], j2) => j2 !== i2 && o2 <= offset4 && o2 + l2 >= offset4 + length
17977 );
17978 });
17979 }
17980 function sortOffsets(offsets) {
17981 return offsets.sort(([a2], [b2]) => a2 - b2);
17982 }
17983 function splitValue(itemValue, userValue) {
17984 if (!itemValue) return itemValue;
17985 if (!userValue) return itemValue;
17986 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
17987 const parts = [];
17988 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
17989 "span",
17990 {
17991 "data-autocomplete-value": autocomplete ? "" : void 0,
17992 "data-user-value": autocomplete ? void 0 : "",
17993 children: value
17994 },
17995 parts.length
17996 );
17997 const offsets = sortOffsets(
17998 filterOverlappingOffsets(
17999 // Convert userValues into a set to avoid duplicates
18000 getOffsets(normalizeValue(itemValue), new Set(userValues))
18001 )
18002 );
18003 if (!offsets.length) {
18004 parts.push(span(itemValue, true));
18005 return parts;
18006 }
18007 const [firstOffset] = offsets[0];
18008 const values = [
18009 itemValue.slice(0, firstOffset),
18010 ...offsets.flatMap(([offset4, length], i2) => {
18011 var _a;
18012 const value = itemValue.slice(offset4, offset4 + length);
18013 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0];
18014 const nextValue = itemValue.slice(offset4 + length, nextOffset);
18015 return [value, nextValue];
18016 })
18017 ];
18018 values.forEach((value, i2) => {
18019 if (!value) return;
18020 parts.push(span(value, i2 % 2 === 0));
18021 });
18022 return parts;
18023 }
18024 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
18025 const context = useComboboxScopedContext();
18026 store = store || context;
18027 const itemContext = (0, import_react22.useContext)(ComboboxItemValueContext);
18028 const itemValue = value != null ? value : itemContext;
18029 const inputValue = useStoreState(store, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
18030 const children = (0, import_react22.useMemo)(() => {
18031 if (!itemValue) return;
18032 if (!inputValue) return itemValue;
18033 return splitValue(itemValue, inputValue);
18034 }, [itemValue, inputValue]);
18035 props = {
18036 children,
18037 ...props
18038 };
18039 return removeUndefinedValues(props);
18040 });
18041 var ComboboxItemValue = forwardRef22(function ComboboxItemValue2(props) {
18042 const htmlProps = useComboboxItemValue(props);
18043 return createElement3(TagName11, htmlProps);
18044 });
18045
18046 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
18047 var TagName12 = "label";
18048 var useComboboxLabel = createHook(
18049 function useComboboxLabel2({ store, ...props }) {
18050 const context = useComboboxProviderContext();
18051 store = store || context;
18052 invariant(
18053 store,
18054 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
18055 );
18056 const comboboxId = store.useState((state) => {
18057 var _a;
18058 return (_a = state.baseElement) == null ? void 0 : _a.id;
18059 });
18060 props = {
18061 htmlFor: comboboxId,
18062 ...props
18063 };
18064 return removeUndefinedValues(props);
18065 }
18066 );
18067 var ComboboxLabel = memo22(
18068 forwardRef22(function ComboboxLabel2(props) {
18069 const htmlProps = useComboboxLabel(props);
18070 return createElement3(TagName12, htmlProps);
18071 })
18072 );
18073
18074 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
18075 var import_react23 = __toESM(require_react(), 1);
18076 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
18077 var TagName13 = "div";
18078 var useComboboxList = createHook(
18079 function useComboboxList2({ store, alwaysVisible, ...props }) {
18080 const scopedContext = useComboboxScopedContext(true);
18081 const context = useComboboxContext();
18082 store = store || context;
18083 const scopedContextSameStore = !!store && store === scopedContext;
18084 invariant(
18085 store,
18086 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
18087 );
18088 const ref = (0, import_react23.useRef)(null);
18089 const id = useId4(props.id);
18090 const mounted = store.useState("mounted");
18091 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
18092 const style = hidden ? { ...props.style, display: "none" } : props.style;
18093 const multiSelectable = store.useState(
18094 (state) => Array.isArray(state.selectedValue)
18095 );
18096 const role = useAttribute(ref, "role", props.role);
18097 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
18098 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
18099 const [hasListboxInside, setHasListboxInside] = (0, import_react23.useState)(false);
18100 const contentElement = store.useState("contentElement");
18101 useSafeLayoutEffect(() => {
18102 if (!mounted) return;
18103 const element = ref.current;
18104 if (!element) return;
18105 if (contentElement !== element) return;
18106 const callback = () => {
18107 setHasListboxInside(!!element.querySelector("[role='listbox']"));
18108 };
18109 const observer = new MutationObserver(callback);
18110 observer.observe(element, {
18111 subtree: true,
18112 childList: true,
18113 attributeFilter: ["role"]
18114 });
18115 callback();
18116 return () => observer.disconnect();
18117 }, [mounted, contentElement]);
18118 if (!hasListboxInside) {
18119 props = {
18120 role: "listbox",
18121 "aria-multiselectable": ariaMultiSelectable,
18122 ...props
18123 };
18124 }
18125 props = useWrapElement(
18126 props,
18127 (element) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(ComboboxScopedContextProvider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
18128 [store, role]
18129 );
18130 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
18131 props = {
18132 id,
18133 hidden,
18134 ...props,
18135 ref: useMergeRefs(setContentElement, ref, props.ref),
18136 style
18137 };
18138 return removeUndefinedValues(props);
18139 }
18140 );
18141 var ComboboxList = forwardRef22(function ComboboxList2(props) {
18142 const htmlProps = useComboboxList(props);
18143 return createElement3(TagName13, htmlProps);
18144 });
18145
18146 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
18147 var import_react24 = __toESM(require_react(), 1);
18148 var TagValueContext = (0, import_react24.createContext)(null);
18149 var TagRemoveIdContext = (0, import_react24.createContext)(
18150 null
18151 );
18152 var ctx7 = createStoreContext(
18153 [CompositeContextProvider],
18154 [CompositeScopedContextProvider]
18155 );
18156 var useTagContext = ctx7.useContext;
18157 var useTagScopedContext = ctx7.useScopedContext;
18158 var useTagProviderContext = ctx7.useProviderContext;
18159 var TagContextProvider = ctx7.ContextProvider;
18160 var TagScopedContextProvider = ctx7.ScopedContextProvider;
18161
18162 // node_modules/@ariakit/core/esm/combobox/combobox-store.js
18163 var isTouchSafari = isSafari2() && isTouchDevice();
18164 function createComboboxStore({
18165 tag,
18166 ...props
18167 } = {}) {
18168 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
18169 throwOnConflictingProps(props, store);
18170 const tagState = tag == null ? void 0 : tag.getState();
18171 const syncState = store == null ? void 0 : store.getState();
18172 const activeId = defaultValue(
18173 props.activeId,
18174 syncState == null ? void 0 : syncState.activeId,
18175 props.defaultActiveId,
18176 null
18177 );
18178 const composite = createCompositeStore({
18179 ...props,
18180 activeId,
18181 includesBaseElement: defaultValue(
18182 props.includesBaseElement,
18183 syncState == null ? void 0 : syncState.includesBaseElement,
18184 true
18185 ),
18186 orientation: defaultValue(
18187 props.orientation,
18188 syncState == null ? void 0 : syncState.orientation,
18189 "vertical"
18190 ),
18191 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
18192 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
18193 virtualFocus: defaultValue(
18194 props.virtualFocus,
18195 syncState == null ? void 0 : syncState.virtualFocus,
18196 true
18197 )
18198 });
18199 const popover = createPopoverStore({
18200 ...props,
18201 placement: defaultValue(
18202 props.placement,
18203 syncState == null ? void 0 : syncState.placement,
18204 "bottom-start"
18205 )
18206 });
18207 const value = defaultValue(
18208 props.value,
18209 syncState == null ? void 0 : syncState.value,
18210 props.defaultValue,
18211 ""
18212 );
18213 const selectedValue = defaultValue(
18214 props.selectedValue,
18215 syncState == null ? void 0 : syncState.selectedValue,
18216 tagState == null ? void 0 : tagState.values,
18217 props.defaultSelectedValue,
18218 ""
18219 );
18220 const multiSelectable = Array.isArray(selectedValue);
18221 const initialState = {
18222 ...composite.getState(),
18223 ...popover.getState(),
18224 value,
18225 selectedValue,
18226 resetValueOnSelect: defaultValue(
18227 props.resetValueOnSelect,
18228 syncState == null ? void 0 : syncState.resetValueOnSelect,
18229 multiSelectable
18230 ),
18231 resetValueOnHide: defaultValue(
18232 props.resetValueOnHide,
18233 syncState == null ? void 0 : syncState.resetValueOnHide,
18234 multiSelectable && !tag
18235 ),
18236 activeValue: syncState == null ? void 0 : syncState.activeValue
18237 };
18238 const combobox = createStore(initialState, composite, popover, store);
18239 if (isTouchSafari) {
18240 setup(
18241 combobox,
18242 () => sync(combobox, ["virtualFocus"], () => {
18243 combobox.setState("virtualFocus", false);
18244 })
18245 );
18246 }
18247 setup(combobox, () => {
18248 if (!tag) return;
18249 return chain(
18250 sync(combobox, ["selectedValue"], (state) => {
18251 if (!Array.isArray(state.selectedValue)) return;
18252 tag.setValues(state.selectedValue);
18253 }),
18254 sync(tag, ["values"], (state) => {
18255 combobox.setState("selectedValue", state.values);
18256 })
18257 );
18258 });
18259 setup(
18260 combobox,
18261 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
18262 if (!state.resetValueOnHide) return;
18263 if (state.mounted) return;
18264 combobox.setState("value", value);
18265 })
18266 );
18267 setup(
18268 combobox,
18269 () => sync(combobox, ["open"], (state) => {
18270 if (state.open) return;
18271 combobox.setState("activeId", activeId);
18272 combobox.setState("moves", 0);
18273 })
18274 );
18275 setup(
18276 combobox,
18277 () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
18278 if (state.moves === prevState.moves) {
18279 combobox.setState("activeValue", void 0);
18280 }
18281 })
18282 );
18283 setup(
18284 combobox,
18285 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
18286 if (state.moves === prev.moves) return;
18287 const { activeId: activeId2 } = combobox.getState();
18288 const activeItem = composite.item(activeId2);
18289 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
18290 })
18291 );
18292 return {
18293 ...popover,
18294 ...composite,
18295 ...combobox,
18296 tag,
18297 setValue: (value2) => combobox.setState("value", value2),
18298 resetValue: () => combobox.setState("value", initialState.value),
18299 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
18300 };
18301 }
18302
18303 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
18304 function useComboboxStoreOptions(props) {
18305 const tag = useTagContext();
18306 props = {
18307 ...props,
18308 tag: props.tag !== void 0 ? props.tag : tag
18309 };
18310 return useCompositeStoreOptions(props);
18311 }
18312 function useComboboxStoreProps(store, update2, props) {
18313 useUpdateEffect(update2, [props.tag]);
18314 useStoreProps(store, props, "value", "setValue");
18315 useStoreProps(store, props, "selectedValue", "setSelectedValue");
18316 useStoreProps(store, props, "resetValueOnHide");
18317 useStoreProps(store, props, "resetValueOnSelect");
18318 return Object.assign(
18319 useCompositeStoreProps(
18320 usePopoverStoreProps(store, update2, props),
18321 update2,
18322 props
18323 ),
18324 { tag: props.tag }
18325 );
18326 }
18327 function useComboboxStore(props = {}) {
18328 props = useComboboxStoreOptions(props);
18329 const [store, update2] = useStore2(createComboboxStore, props);
18330 return useComboboxStoreProps(store, update2, props);
18331 }
18332
18333 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
18334 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
18335 function ComboboxProvider(props = {}) {
18336 const store = useComboboxStore(props);
18337 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ComboboxContextProvider, { value: store, children: props.children });
18338 }
18339
18340 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18341 var import_remove_accents = __toESM(require_remove_accents(), 1);
18342 var import_compose7 = __toESM(require_compose(), 1);
18343 var import_i18n22 = __toESM(require_i18n(), 1);
18344 var import_element40 = __toESM(require_element(), 1);
18345 var import_components18 = __toESM(require_components(), 1);
18346
18347 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
18348 var EMPTY_ARRAY3 = [];
18349 var getCurrentValue = (filterDefinition, currentFilter) => {
18350 if (filterDefinition.singleSelection) {
18351 return currentFilter?.value;
18352 }
18353 if (Array.isArray(currentFilter?.value)) {
18354 return currentFilter.value;
18355 }
18356 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
18357 return [currentFilter.value];
18358 }
18359 return EMPTY_ARRAY3;
18360 };
18361
18362 // packages/dataviews/build-module/hooks/use-elements.mjs
18363 var import_element39 = __toESM(require_element(), 1);
18364 var EMPTY_ARRAY4 = [];
18365 function useElements({
18366 elements,
18367 getElements
18368 }) {
18369 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
18370 const [records, setRecords] = (0, import_element39.useState)(staticElements);
18371 const [isLoading, setIsLoading] = (0, import_element39.useState)(false);
18372 (0, import_element39.useEffect)(() => {
18373 if (!getElements) {
18374 setRecords(staticElements);
18375 return;
18376 }
18377 let cancelled = false;
18378 setIsLoading(true);
18379 getElements().then((fetchedElements) => {
18380 if (!cancelled) {
18381 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
18382 setRecords(dynamicElements);
18383 }
18384 }).catch(() => {
18385 if (!cancelled) {
18386 setRecords(staticElements);
18387 }
18388 }).finally(() => {
18389 if (!cancelled) {
18390 setIsLoading(false);
18391 }
18392 });
18393 return () => {
18394 cancelled = true;
18395 };
18396 }, [getElements, staticElements]);
18397 return {
18398 elements: records,
18399 isLoading
18400 };
18401 }
18402
18403 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18404 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
18405 function normalizeSearchInput(input = "") {
18406 return (0, import_remove_accents.default)(input.trim().toLowerCase());
18407 }
18408 var getNewValue = (filterDefinition, currentFilter, value) => {
18409 if (filterDefinition.singleSelection) {
18410 return value;
18411 }
18412 if (Array.isArray(currentFilter?.value)) {
18413 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
18414 }
18415 return [value];
18416 };
18417 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
18418 return `${prefix}-${filterElementValue}`;
18419 }
18420 var MultiSelectionOption = ({ selected }) => {
18421 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18422 "span",
18423 {
18424 className: clsx_default(
18425 "dataviews-filters__search-widget-listitem-multi-selection",
18426 { "is-selected": selected }
18427 ),
18428 children: selected && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_components18.Icon, { icon: check_default })
18429 }
18430 );
18431 };
18432 var SingleSelectionOption = ({ selected }) => {
18433 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18434 "span",
18435 {
18436 className: clsx_default(
18437 "dataviews-filters__search-widget-listitem-single-selection",
18438 { "is-selected": selected }
18439 )
18440 }
18441 );
18442 };
18443 function ListBox({ view, filter, onChangeView }) {
18444 const baseId = (0, import_compose7.useInstanceId)(ListBox, "dataviews-filter-list-box");
18445 const [activeCompositeId, setActiveCompositeId] = (0, import_element40.useState)(
18446 // When there are one or less operators, the first item is set as active
18447 // (by setting the initial `activeId` to `undefined`).
18448 // With 2 or more operators, the focus is moved on the operators control
18449 // (by setting the initial `activeId` to `null`), meaning that there won't
18450 // be an active item initially. Focus is then managed via the
18451 // `onFocusVisible` callback.
18452 filter.operators?.length === 1 ? void 0 : null
18453 );
18454 const currentFilter = view.filters?.find(
18455 (f2) => f2.field === filter.field
18456 );
18457 const currentValue = getCurrentValue(filter, currentFilter);
18458 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18459 import_components18.Composite,
18460 {
18461 virtualFocus: true,
18462 focusLoop: true,
18463 activeId: activeCompositeId,
18464 setActiveId: setActiveCompositeId,
18465 role: "listbox",
18466 className: "dataviews-filters__search-widget-listbox",
18467 "aria-label": (0, import_i18n22.sprintf)(
18468 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
18469 (0, import_i18n22.__)("List of: %1$s"),
18470 filter.name
18471 ),
18472 onFocusVisible: () => {
18473 if (!activeCompositeId && filter.elements.length) {
18474 setActiveCompositeId(
18475 generateFilterElementCompositeItemId(
18476 baseId,
18477 filter.elements[0].value
18478 )
18479 );
18480 }
18481 },
18482 render: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_components18.Composite.Typeahead, {}),
18483 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
18484 import_components18.Composite.Hover,
18485 {
18486 render: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18487 import_components18.Composite.Item,
18488 {
18489 id: generateFilterElementCompositeItemId(
18490 baseId,
18491 element.value
18492 ),
18493 render: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18494 "div",
18495 {
18496 "aria-label": element.label,
18497 role: "option",
18498 className: "dataviews-filters__search-widget-listitem"
18499 }
18500 ),
18501 onClick: () => {
18502 const newFilters = currentFilter ? [
18503 ...(view.filters ?? []).map(
18504 (_filter) => {
18505 if (_filter.field === filter.field) {
18506 return {
18507 ..._filter,
18508 operator: currentFilter.operator || filter.operators[0],
18509 value: getNewValue(
18510 filter,
18511 currentFilter,
18512 element.value
18513 )
18514 };
18515 }
18516 return _filter;
18517 }
18518 )
18519 ] : [
18520 ...view.filters ?? [],
18521 {
18522 field: filter.field,
18523 operator: filter.operators[0],
18524 value: getNewValue(
18525 filter,
18526 currentFilter,
18527 element.value
18528 )
18529 }
18530 ];
18531 onChangeView({
18532 ...view,
18533 page: 1,
18534 filters: newFilters
18535 });
18536 }
18537 }
18538 ),
18539 children: [
18540 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18541 SingleSelectionOption,
18542 {
18543 selected: currentValue === element.value
18544 }
18545 ),
18546 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18547 MultiSelectionOption,
18548 {
18549 selected: currentValue.includes(element.value)
18550 }
18551 ),
18552 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18553 "span",
18554 {
18555 className: "dataviews-filters__search-widget-listitem-value",
18556 title: element.label,
18557 children: element.label
18558 }
18559 )
18560 ]
18561 },
18562 element.value
18563 ))
18564 }
18565 );
18566 }
18567 function ComboboxList22({ view, filter, onChangeView }) {
18568 const [searchValue, setSearchValue] = (0, import_element40.useState)("");
18569 const deferredSearchValue = (0, import_element40.useDeferredValue)(searchValue);
18570 const currentFilter = view.filters?.find(
18571 (_filter) => _filter.field === filter.field
18572 );
18573 const currentValue = getCurrentValue(filter, currentFilter);
18574 const matches = (0, import_element40.useMemo)(() => {
18575 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
18576 return filter.elements.filter(
18577 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
18578 );
18579 }, [filter.elements, deferredSearchValue]);
18580 return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
18581 ComboboxProvider,
18582 {
18583 selectedValue: currentValue,
18584 setSelectedValue: (value) => {
18585 const newFilters = currentFilter ? [
18586 ...(view.filters ?? []).map((_filter) => {
18587 if (_filter.field === filter.field) {
18588 return {
18589 ..._filter,
18590 operator: currentFilter.operator || filter.operators[0],
18591 value
18592 };
18593 }
18594 return _filter;
18595 })
18596 ] : [
18597 ...view.filters ?? [],
18598 {
18599 field: filter.field,
18600 operator: filter.operators[0],
18601 value
18602 }
18603 ];
18604 onChangeView({
18605 ...view,
18606 page: 1,
18607 filters: newFilters
18608 });
18609 },
18610 setValue: setSearchValue,
18611 children: [
18612 /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
18613 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ComboboxLabel, {}), children: (0, import_i18n22.__)("Search items") }),
18614 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18615 Combobox,
18616 {
18617 autoSelect: "always",
18618 placeholder: (0, import_i18n22.__)("Search"),
18619 className: "dataviews-filters__search-widget-filter-combobox__input"
18620 }
18621 ),
18622 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_components18.Icon, { icon: search_default }) })
18623 ] }),
18624 /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
18625 ComboboxList,
18626 {
18627 className: "dataviews-filters__search-widget-filter-combobox-list",
18628 alwaysVisible: true,
18629 children: [
18630 matches.map((element) => {
18631 return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
18632 ComboboxItem,
18633 {
18634 resetValueOnSelect: false,
18635 value: element.value,
18636 className: "dataviews-filters__search-widget-listitem",
18637 hideOnClick: false,
18638 setValueOnClick: false,
18639 focusOnHover: true,
18640 children: [
18641 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18642 SingleSelectionOption,
18643 {
18644 selected: currentValue === element.value
18645 }
18646 ),
18647 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18648 MultiSelectionOption,
18649 {
18650 selected: currentValue.includes(
18651 element.value
18652 )
18653 }
18654 ),
18655 /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
18656 "span",
18657 {
18658 className: "dataviews-filters__search-widget-listitem-value",
18659 title: element.label,
18660 children: [
18661 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18662 ComboboxItemValue,
18663 {
18664 className: "dataviews-filters__search-widget-filter-combobox-item-value",
18665 value: element.label
18666 }
18667 ),
18668 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
18669 ]
18670 }
18671 )
18672 ]
18673 },
18674 element.value
18675 );
18676 }),
18677 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("p", { children: (0, import_i18n22.__)("No results found") })
18678 ]
18679 }
18680 )
18681 ]
18682 }
18683 );
18684 }
18685 function SearchWidget(props) {
18686 const { elements, isLoading } = useElements({
18687 elements: props.filter.elements,
18688 getElements: props.filter.getElements
18689 });
18690 if (isLoading) {
18691 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_components18.Spinner, {}) });
18692 }
18693 if (elements.length === 0) {
18694 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n22.__)("No elements found") });
18695 }
18696 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
18697 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
18698 }
18699
18700 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
18701 var import_es6 = __toESM(require_es6(), 1);
18702 var import_compose8 = __toESM(require_compose(), 1);
18703 var import_element41 = __toESM(require_element(), 1);
18704 var import_components19 = __toESM(require_components(), 1);
18705 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
18706 function InputWidget({
18707 filter,
18708 view,
18709 onChangeView,
18710 fields
18711 }) {
18712 const currentFilter = view.filters?.find(
18713 (f2) => f2.field === filter.field
18714 );
18715 const currentValue = getCurrentValue(filter, currentFilter);
18716 const field = (0, import_element41.useMemo)(() => {
18717 const currentField = fields.find((f2) => f2.id === filter.field);
18718 if (currentField) {
18719 return {
18720 ...currentField,
18721 // Deactivate validation for filters.
18722 isValid: {},
18723 // Filter controls are always enabled.
18724 isDisabled: () => false,
18725 // Filter controls are always visible.
18726 isVisible: () => true,
18727 // Configure getValue/setValue as if Item was a plain object.
18728 getValue: ({ item }) => item[currentField.id],
18729 setValue: ({ value }) => ({
18730 [currentField.id]: value
18731 })
18732 };
18733 }
18734 return currentField;
18735 }, [fields, filter.field]);
18736 const data = (0, import_element41.useMemo)(() => {
18737 return (view.filters ?? []).reduce(
18738 (acc, activeFilter) => {
18739 acc[activeFilter.field] = activeFilter.value;
18740 return acc;
18741 },
18742 {}
18743 );
18744 }, [view.filters]);
18745 const handleChange = (0, import_compose8.useEvent)((updatedData) => {
18746 if (!field || !currentFilter) {
18747 return;
18748 }
18749 const nextValue = field.getValue({ item: updatedData });
18750 if ((0, import_es6.default)(nextValue, currentValue)) {
18751 return;
18752 }
18753 onChangeView({
18754 ...view,
18755 filters: (view.filters ?? []).map(
18756 (_filter) => _filter.field === filter.field ? {
18757 ..._filter,
18758 operator: currentFilter.operator || filter.operators[0],
18759 // Consider empty strings as undefined:
18760 //
18761 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
18762 // - empty string as value means "search empty string": returns only the records that have an empty string as value
18763 //
18764 // In practice, this means the filter will not be able to find an empty string as the value.
18765 value: nextValue === "" ? void 0 : nextValue
18766 } : _filter
18767 )
18768 });
18769 });
18770 if (!field || !field.Edit || !currentFilter) {
18771 return null;
18772 }
18773 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18774 import_components19.Flex,
18775 {
18776 className: "dataviews-filters__user-input-widget",
18777 gap: 2.5,
18778 direction: "column",
18779 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18780 field.Edit,
18781 {
18782 hideLabelFromVision: true,
18783 data,
18784 field,
18785 operator: currentFilter.operator,
18786 onChange: handleChange
18787 }
18788 )
18789 }
18790 );
18791 }
18792
18793 // node_modules/date-fns/constants.js
18794 var daysInYear = 365.2425;
18795 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
18796 var minTime = -maxTime;
18797 var millisecondsInWeek = 6048e5;
18798 var millisecondsInDay = 864e5;
18799 var secondsInHour = 3600;
18800 var secondsInDay = secondsInHour * 24;
18801 var secondsInWeek = secondsInDay * 7;
18802 var secondsInYear = secondsInDay * daysInYear;
18803 var secondsInMonth = secondsInYear / 12;
18804 var secondsInQuarter = secondsInMonth * 3;
18805 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
18806
18807 // node_modules/date-fns/constructFrom.js
18808 function constructFrom(date, value) {
18809 if (typeof date === "function") return date(value);
18810 if (date && typeof date === "object" && constructFromSymbol in date)
18811 return date[constructFromSymbol](value);
18812 if (date instanceof Date) return new date.constructor(value);
18813 return new Date(value);
18814 }
18815
18816 // node_modules/date-fns/toDate.js
18817 function toDate(argument, context) {
18818 return constructFrom(context || argument, argument);
18819 }
18820
18821 // node_modules/date-fns/addDays.js
18822 function addDays(date, amount, options) {
18823 const _date = toDate(date, options?.in);
18824 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
18825 if (!amount) return _date;
18826 _date.setDate(_date.getDate() + amount);
18827 return _date;
18828 }
18829
18830 // node_modules/date-fns/addMonths.js
18831 function addMonths(date, amount, options) {
18832 const _date = toDate(date, options?.in);
18833 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
18834 if (!amount) {
18835 return _date;
18836 }
18837 const dayOfMonth = _date.getDate();
18838 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
18839 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
18840 const daysInMonth = endOfDesiredMonth.getDate();
18841 if (dayOfMonth >= daysInMonth) {
18842 return endOfDesiredMonth;
18843 } else {
18844 _date.setFullYear(
18845 endOfDesiredMonth.getFullYear(),
18846 endOfDesiredMonth.getMonth(),
18847 dayOfMonth
18848 );
18849 return _date;
18850 }
18851 }
18852
18853 // node_modules/date-fns/_lib/defaultOptions.js
18854 var defaultOptions = {};
18855 function getDefaultOptions() {
18856 return defaultOptions;
18857 }
18858
18859 // node_modules/date-fns/startOfWeek.js
18860 function startOfWeek(date, options) {
18861 const defaultOptions2 = getDefaultOptions();
18862 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
18863 const _date = toDate(date, options?.in);
18864 const day = _date.getDay();
18865 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
18866 _date.setDate(_date.getDate() - diff);
18867 _date.setHours(0, 0, 0, 0);
18868 return _date;
18869 }
18870
18871 // node_modules/date-fns/startOfISOWeek.js
18872 function startOfISOWeek(date, options) {
18873 return startOfWeek(date, { ...options, weekStartsOn: 1 });
18874 }
18875
18876 // node_modules/date-fns/getISOWeekYear.js
18877 function getISOWeekYear(date, options) {
18878 const _date = toDate(date, options?.in);
18879 const year = _date.getFullYear();
18880 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
18881 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
18882 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
18883 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
18884 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
18885 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
18886 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
18887 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
18888 if (_date.getTime() >= startOfNextYear.getTime()) {
18889 return year + 1;
18890 } else if (_date.getTime() >= startOfThisYear.getTime()) {
18891 return year;
18892 } else {
18893 return year - 1;
18894 }
18895 }
18896
18897 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
18898 function getTimezoneOffsetInMilliseconds(date) {
18899 const _date = toDate(date);
18900 const utcDate = new Date(
18901 Date.UTC(
18902 _date.getFullYear(),
18903 _date.getMonth(),
18904 _date.getDate(),
18905 _date.getHours(),
18906 _date.getMinutes(),
18907 _date.getSeconds(),
18908 _date.getMilliseconds()
18909 )
18910 );
18911 utcDate.setUTCFullYear(_date.getFullYear());
18912 return +date - +utcDate;
18913 }
18914
18915 // node_modules/date-fns/_lib/normalizeDates.js
18916 function normalizeDates(context, ...dates) {
18917 const normalize = constructFrom.bind(
18918 null,
18919 context || dates.find((date) => typeof date === "object")
18920 );
18921 return dates.map(normalize);
18922 }
18923
18924 // node_modules/date-fns/startOfDay.js
18925 function startOfDay(date, options) {
18926 const _date = toDate(date, options?.in);
18927 _date.setHours(0, 0, 0, 0);
18928 return _date;
18929 }
18930
18931 // node_modules/date-fns/differenceInCalendarDays.js
18932 function differenceInCalendarDays(laterDate, earlierDate, options) {
18933 const [laterDate_, earlierDate_] = normalizeDates(
18934 options?.in,
18935 laterDate,
18936 earlierDate
18937 );
18938 const laterStartOfDay = startOfDay(laterDate_);
18939 const earlierStartOfDay = startOfDay(earlierDate_);
18940 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
18941 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
18942 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
18943 }
18944
18945 // node_modules/date-fns/startOfISOWeekYear.js
18946 function startOfISOWeekYear(date, options) {
18947 const year = getISOWeekYear(date, options);
18948 const fourthOfJanuary = constructFrom(options?.in || date, 0);
18949 fourthOfJanuary.setFullYear(year, 0, 4);
18950 fourthOfJanuary.setHours(0, 0, 0, 0);
18951 return startOfISOWeek(fourthOfJanuary);
18952 }
18953
18954 // node_modules/date-fns/addWeeks.js
18955 function addWeeks(date, amount, options) {
18956 return addDays(date, amount * 7, options);
18957 }
18958
18959 // node_modules/date-fns/addYears.js
18960 function addYears(date, amount, options) {
18961 return addMonths(date, amount * 12, options);
18962 }
18963
18964 // node_modules/date-fns/isDate.js
18965 function isDate(value) {
18966 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
18967 }
18968
18969 // node_modules/date-fns/isValid.js
18970 function isValid(date) {
18971 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
18972 }
18973
18974 // node_modules/date-fns/startOfMonth.js
18975 function startOfMonth(date, options) {
18976 const _date = toDate(date, options?.in);
18977 _date.setDate(1);
18978 _date.setHours(0, 0, 0, 0);
18979 return _date;
18980 }
18981
18982 // node_modules/date-fns/startOfYear.js
18983 function startOfYear(date, options) {
18984 const date_ = toDate(date, options?.in);
18985 date_.setFullYear(date_.getFullYear(), 0, 1);
18986 date_.setHours(0, 0, 0, 0);
18987 return date_;
18988 }
18989
18990 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
18991 var formatDistanceLocale = {
18992 lessThanXSeconds: {
18993 one: "less than a second",
18994 other: "less than {{count}} seconds"
18995 },
18996 xSeconds: {
18997 one: "1 second",
18998 other: "{{count}} seconds"
18999 },
19000 halfAMinute: "half a minute",
19001 lessThanXMinutes: {
19002 one: "less than a minute",
19003 other: "less than {{count}} minutes"
19004 },
19005 xMinutes: {
19006 one: "1 minute",
19007 other: "{{count}} minutes"
19008 },
19009 aboutXHours: {
19010 one: "about 1 hour",
19011 other: "about {{count}} hours"
19012 },
19013 xHours: {
19014 one: "1 hour",
19015 other: "{{count}} hours"
19016 },
19017 xDays: {
19018 one: "1 day",
19019 other: "{{count}} days"
19020 },
19021 aboutXWeeks: {
19022 one: "about 1 week",
19023 other: "about {{count}} weeks"
19024 },
19025 xWeeks: {
19026 one: "1 week",
19027 other: "{{count}} weeks"
19028 },
19029 aboutXMonths: {
19030 one: "about 1 month",
19031 other: "about {{count}} months"
19032 },
19033 xMonths: {
19034 one: "1 month",
19035 other: "{{count}} months"
19036 },
19037 aboutXYears: {
19038 one: "about 1 year",
19039 other: "about {{count}} years"
19040 },
19041 xYears: {
19042 one: "1 year",
19043 other: "{{count}} years"
19044 },
19045 overXYears: {
19046 one: "over 1 year",
19047 other: "over {{count}} years"
19048 },
19049 almostXYears: {
19050 one: "almost 1 year",
19051 other: "almost {{count}} years"
19052 }
19053 };
19054 var formatDistance = (token, count, options) => {
19055 let result;
19056 const tokenValue = formatDistanceLocale[token];
19057 if (typeof tokenValue === "string") {
19058 result = tokenValue;
19059 } else if (count === 1) {
19060 result = tokenValue.one;
19061 } else {
19062 result = tokenValue.other.replace("{{count}}", count.toString());
19063 }
19064 if (options?.addSuffix) {
19065 if (options.comparison && options.comparison > 0) {
19066 return "in " + result;
19067 } else {
19068 return result + " ago";
19069 }
19070 }
19071 return result;
19072 };
19073
19074 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
19075 function buildFormatLongFn(args) {
19076 return (options = {}) => {
19077 const width = options.width ? String(options.width) : args.defaultWidth;
19078 const format6 = args.formats[width] || args.formats[args.defaultWidth];
19079 return format6;
19080 };
19081 }
19082
19083 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
19084 var dateFormats = {
19085 full: "EEEE, MMMM do, y",
19086 long: "MMMM do, y",
19087 medium: "MMM d, y",
19088 short: "MM/dd/yyyy"
19089 };
19090 var timeFormats = {
19091 full: "h:mm:ss a zzzz",
19092 long: "h:mm:ss a z",
19093 medium: "h:mm:ss a",
19094 short: "h:mm a"
19095 };
19096 var dateTimeFormats = {
19097 full: "{{date}} 'at' {{time}}",
19098 long: "{{date}} 'at' {{time}}",
19099 medium: "{{date}}, {{time}}",
19100 short: "{{date}}, {{time}}"
19101 };
19102 var formatLong = {
19103 date: buildFormatLongFn({
19104 formats: dateFormats,
19105 defaultWidth: "full"
19106 }),
19107 time: buildFormatLongFn({
19108 formats: timeFormats,
19109 defaultWidth: "full"
19110 }),
19111 dateTime: buildFormatLongFn({
19112 formats: dateTimeFormats,
19113 defaultWidth: "full"
19114 })
19115 };
19116
19117 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
19118 var formatRelativeLocale = {
19119 lastWeek: "'last' eeee 'at' p",
19120 yesterday: "'yesterday at' p",
19121 today: "'today at' p",
19122 tomorrow: "'tomorrow at' p",
19123 nextWeek: "eeee 'at' p",
19124 other: "P"
19125 };
19126 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
19127
19128 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
19129 function buildLocalizeFn(args) {
19130 return (value, options) => {
19131 const context = options?.context ? String(options.context) : "standalone";
19132 let valuesArray;
19133 if (context === "formatting" && args.formattingValues) {
19134 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
19135 const width = options?.width ? String(options.width) : defaultWidth;
19136 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
19137 } else {
19138 const defaultWidth = args.defaultWidth;
19139 const width = options?.width ? String(options.width) : args.defaultWidth;
19140 valuesArray = args.values[width] || args.values[defaultWidth];
19141 }
19142 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
19143 return valuesArray[index2];
19144 };
19145 }
19146
19147 // node_modules/date-fns/locale/en-US/_lib/localize.js
19148 var eraValues = {
19149 narrow: ["B", "A"],
19150 abbreviated: ["BC", "AD"],
19151 wide: ["Before Christ", "Anno Domini"]
19152 };
19153 var quarterValues = {
19154 narrow: ["1", "2", "3", "4"],
19155 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
19156 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
19157 };
19158 var monthValues = {
19159 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
19160 abbreviated: [
19161 "Jan",
19162 "Feb",
19163 "Mar",
19164 "Apr",
19165 "May",
19166 "Jun",
19167 "Jul",
19168 "Aug",
19169 "Sep",
19170 "Oct",
19171 "Nov",
19172 "Dec"
19173 ],
19174 wide: [
19175 "January",
19176 "February",
19177 "March",
19178 "April",
19179 "May",
19180 "June",
19181 "July",
19182 "August",
19183 "September",
19184 "October",
19185 "November",
19186 "December"
19187 ]
19188 };
19189 var dayValues = {
19190 narrow: ["S", "M", "T", "W", "T", "F", "S"],
19191 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
19192 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
19193 wide: [
19194 "Sunday",
19195 "Monday",
19196 "Tuesday",
19197 "Wednesday",
19198 "Thursday",
19199 "Friday",
19200 "Saturday"
19201 ]
19202 };
19203 var dayPeriodValues = {
19204 narrow: {
19205 am: "a",
19206 pm: "p",
19207 midnight: "mi",
19208 noon: "n",
19209 morning: "morning",
19210 afternoon: "afternoon",
19211 evening: "evening",
19212 night: "night"
19213 },
19214 abbreviated: {
19215 am: "AM",
19216 pm: "PM",
19217 midnight: "midnight",
19218 noon: "noon",
19219 morning: "morning",
19220 afternoon: "afternoon",
19221 evening: "evening",
19222 night: "night"
19223 },
19224 wide: {
19225 am: "a.m.",
19226 pm: "p.m.",
19227 midnight: "midnight",
19228 noon: "noon",
19229 morning: "morning",
19230 afternoon: "afternoon",
19231 evening: "evening",
19232 night: "night"
19233 }
19234 };
19235 var formattingDayPeriodValues = {
19236 narrow: {
19237 am: "a",
19238 pm: "p",
19239 midnight: "mi",
19240 noon: "n",
19241 morning: "in the morning",
19242 afternoon: "in the afternoon",
19243 evening: "in the evening",
19244 night: "at night"
19245 },
19246 abbreviated: {
19247 am: "AM",
19248 pm: "PM",
19249 midnight: "midnight",
19250 noon: "noon",
19251 morning: "in the morning",
19252 afternoon: "in the afternoon",
19253 evening: "in the evening",
19254 night: "at night"
19255 },
19256 wide: {
19257 am: "a.m.",
19258 pm: "p.m.",
19259 midnight: "midnight",
19260 noon: "noon",
19261 morning: "in the morning",
19262 afternoon: "in the afternoon",
19263 evening: "in the evening",
19264 night: "at night"
19265 }
19266 };
19267 var ordinalNumber = (dirtyNumber, _options) => {
19268 const number = Number(dirtyNumber);
19269 const rem100 = number % 100;
19270 if (rem100 > 20 || rem100 < 10) {
19271 switch (rem100 % 10) {
19272 case 1:
19273 return number + "st";
19274 case 2:
19275 return number + "nd";
19276 case 3:
19277 return number + "rd";
19278 }
19279 }
19280 return number + "th";
19281 };
19282 var localize = {
19283 ordinalNumber,
19284 era: buildLocalizeFn({
19285 values: eraValues,
19286 defaultWidth: "wide"
19287 }),
19288 quarter: buildLocalizeFn({
19289 values: quarterValues,
19290 defaultWidth: "wide",
19291 argumentCallback: (quarter) => quarter - 1
19292 }),
19293 month: buildLocalizeFn({
19294 values: monthValues,
19295 defaultWidth: "wide"
19296 }),
19297 day: buildLocalizeFn({
19298 values: dayValues,
19299 defaultWidth: "wide"
19300 }),
19301 dayPeriod: buildLocalizeFn({
19302 values: dayPeriodValues,
19303 defaultWidth: "wide",
19304 formattingValues: formattingDayPeriodValues,
19305 defaultFormattingWidth: "wide"
19306 })
19307 };
19308
19309 // node_modules/date-fns/locale/_lib/buildMatchFn.js
19310 function buildMatchFn(args) {
19311 return (string, options = {}) => {
19312 const width = options.width;
19313 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
19314 const matchResult = string.match(matchPattern);
19315 if (!matchResult) {
19316 return null;
19317 }
19318 const matchedString = matchResult[0];
19319 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
19320 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
19321 // [TODO] -- I challenge you to fix the type
19322 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
19323 );
19324 let value;
19325 value = args.valueCallback ? args.valueCallback(key) : key;
19326 value = options.valueCallback ? (
19327 // [TODO] -- I challenge you to fix the type
19328 options.valueCallback(value)
19329 ) : value;
19330 const rest = string.slice(matchedString.length);
19331 return { value, rest };
19332 };
19333 }
19334 function findKey(object, predicate) {
19335 for (const key in object) {
19336 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
19337 return key;
19338 }
19339 }
19340 return void 0;
19341 }
19342 function findIndex(array, predicate) {
19343 for (let key = 0; key < array.length; key++) {
19344 if (predicate(array[key])) {
19345 return key;
19346 }
19347 }
19348 return void 0;
19349 }
19350
19351 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
19352 function buildMatchPatternFn(args) {
19353 return (string, options = {}) => {
19354 const matchResult = string.match(args.matchPattern);
19355 if (!matchResult) return null;
19356 const matchedString = matchResult[0];
19357 const parseResult = string.match(args.parsePattern);
19358 if (!parseResult) return null;
19359 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
19360 value = options.valueCallback ? options.valueCallback(value) : value;
19361 const rest = string.slice(matchedString.length);
19362 return { value, rest };
19363 };
19364 }
19365
19366 // node_modules/date-fns/locale/en-US/_lib/match.js
19367 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
19368 var parseOrdinalNumberPattern = /\d+/i;
19369 var matchEraPatterns = {
19370 narrow: /^(b|a)/i,
19371 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
19372 wide: /^(before christ|before common era|anno domini|common era)/i
19373 };
19374 var parseEraPatterns = {
19375 any: [/^b/i, /^(a|c)/i]
19376 };
19377 var matchQuarterPatterns = {
19378 narrow: /^[1234]/i,
19379 abbreviated: /^q[1234]/i,
19380 wide: /^[1234](th|st|nd|rd)? quarter/i
19381 };
19382 var parseQuarterPatterns = {
19383 any: [/1/i, /2/i, /3/i, /4/i]
19384 };
19385 var matchMonthPatterns = {
19386 narrow: /^[jfmasond]/i,
19387 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
19388 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
19389 };
19390 var parseMonthPatterns = {
19391 narrow: [
19392 /^j/i,
19393 /^f/i,
19394 /^m/i,
19395 /^a/i,
19396 /^m/i,
19397 /^j/i,
19398 /^j/i,
19399 /^a/i,
19400 /^s/i,
19401 /^o/i,
19402 /^n/i,
19403 /^d/i
19404 ],
19405 any: [
19406 /^ja/i,
19407 /^f/i,
19408 /^mar/i,
19409 /^ap/i,
19410 /^may/i,
19411 /^jun/i,
19412 /^jul/i,
19413 /^au/i,
19414 /^s/i,
19415 /^o/i,
19416 /^n/i,
19417 /^d/i
19418 ]
19419 };
19420 var matchDayPatterns = {
19421 narrow: /^[smtwf]/i,
19422 short: /^(su|mo|tu|we|th|fr|sa)/i,
19423 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
19424 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
19425 };
19426 var parseDayPatterns = {
19427 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
19428 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
19429 };
19430 var matchDayPeriodPatterns = {
19431 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
19432 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
19433 };
19434 var parseDayPeriodPatterns = {
19435 any: {
19436 am: /^a/i,
19437 pm: /^p/i,
19438 midnight: /^mi/i,
19439 noon: /^no/i,
19440 morning: /morning/i,
19441 afternoon: /afternoon/i,
19442 evening: /evening/i,
19443 night: /night/i
19444 }
19445 };
19446 var match = {
19447 ordinalNumber: buildMatchPatternFn({
19448 matchPattern: matchOrdinalNumberPattern,
19449 parsePattern: parseOrdinalNumberPattern,
19450 valueCallback: (value) => parseInt(value, 10)
19451 }),
19452 era: buildMatchFn({
19453 matchPatterns: matchEraPatterns,
19454 defaultMatchWidth: "wide",
19455 parsePatterns: parseEraPatterns,
19456 defaultParseWidth: "any"
19457 }),
19458 quarter: buildMatchFn({
19459 matchPatterns: matchQuarterPatterns,
19460 defaultMatchWidth: "wide",
19461 parsePatterns: parseQuarterPatterns,
19462 defaultParseWidth: "any",
19463 valueCallback: (index2) => index2 + 1
19464 }),
19465 month: buildMatchFn({
19466 matchPatterns: matchMonthPatterns,
19467 defaultMatchWidth: "wide",
19468 parsePatterns: parseMonthPatterns,
19469 defaultParseWidth: "any"
19470 }),
19471 day: buildMatchFn({
19472 matchPatterns: matchDayPatterns,
19473 defaultMatchWidth: "wide",
19474 parsePatterns: parseDayPatterns,
19475 defaultParseWidth: "any"
19476 }),
19477 dayPeriod: buildMatchFn({
19478 matchPatterns: matchDayPeriodPatterns,
19479 defaultMatchWidth: "any",
19480 parsePatterns: parseDayPeriodPatterns,
19481 defaultParseWidth: "any"
19482 })
19483 };
19484
19485 // node_modules/date-fns/locale/en-US.js
19486 var enUS = {
19487 code: "en-US",
19488 formatDistance,
19489 formatLong,
19490 formatRelative,
19491 localize,
19492 match,
19493 options: {
19494 weekStartsOn: 0,
19495 firstWeekContainsDate: 1
19496 }
19497 };
19498
19499 // node_modules/date-fns/getDayOfYear.js
19500 function getDayOfYear(date, options) {
19501 const _date = toDate(date, options?.in);
19502 const diff = differenceInCalendarDays(_date, startOfYear(_date));
19503 const dayOfYear = diff + 1;
19504 return dayOfYear;
19505 }
19506
19507 // node_modules/date-fns/getISOWeek.js
19508 function getISOWeek(date, options) {
19509 const _date = toDate(date, options?.in);
19510 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
19511 return Math.round(diff / millisecondsInWeek) + 1;
19512 }
19513
19514 // node_modules/date-fns/getWeekYear.js
19515 function getWeekYear(date, options) {
19516 const _date = toDate(date, options?.in);
19517 const year = _date.getFullYear();
19518 const defaultOptions2 = getDefaultOptions();
19519 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
19520 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
19521 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
19522 firstWeekOfNextYear.setHours(0, 0, 0, 0);
19523 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
19524 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
19525 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
19526 firstWeekOfThisYear.setHours(0, 0, 0, 0);
19527 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
19528 if (+_date >= +startOfNextYear) {
19529 return year + 1;
19530 } else if (+_date >= +startOfThisYear) {
19531 return year;
19532 } else {
19533 return year - 1;
19534 }
19535 }
19536
19537 // node_modules/date-fns/startOfWeekYear.js
19538 function startOfWeekYear(date, options) {
19539 const defaultOptions2 = getDefaultOptions();
19540 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
19541 const year = getWeekYear(date, options);
19542 const firstWeek = constructFrom(options?.in || date, 0);
19543 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
19544 firstWeek.setHours(0, 0, 0, 0);
19545 const _date = startOfWeek(firstWeek, options);
19546 return _date;
19547 }
19548
19549 // node_modules/date-fns/getWeek.js
19550 function getWeek(date, options) {
19551 const _date = toDate(date, options?.in);
19552 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
19553 return Math.round(diff / millisecondsInWeek) + 1;
19554 }
19555
19556 // node_modules/date-fns/_lib/addLeadingZeros.js
19557 function addLeadingZeros(number, targetLength) {
19558 const sign = number < 0 ? "-" : "";
19559 const output = Math.abs(number).toString().padStart(targetLength, "0");
19560 return sign + output;
19561 }
19562
19563 // node_modules/date-fns/_lib/format/lightFormatters.js
19564 var lightFormatters = {
19565 // Year
19566 y(date, token) {
19567 const signedYear = date.getFullYear();
19568 const year = signedYear > 0 ? signedYear : 1 - signedYear;
19569 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
19570 },
19571 // Month
19572 M(date, token) {
19573 const month = date.getMonth();
19574 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
19575 },
19576 // Day of the month
19577 d(date, token) {
19578 return addLeadingZeros(date.getDate(), token.length);
19579 },
19580 // AM or PM
19581 a(date, token) {
19582 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
19583 switch (token) {
19584 case "a":
19585 case "aa":
19586 return dayPeriodEnumValue.toUpperCase();
19587 case "aaa":
19588 return dayPeriodEnumValue;
19589 case "aaaaa":
19590 return dayPeriodEnumValue[0];
19591 case "aaaa":
19592 default:
19593 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
19594 }
19595 },
19596 // Hour [1-12]
19597 h(date, token) {
19598 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
19599 },
19600 // Hour [0-23]
19601 H(date, token) {
19602 return addLeadingZeros(date.getHours(), token.length);
19603 },
19604 // Minute
19605 m(date, token) {
19606 return addLeadingZeros(date.getMinutes(), token.length);
19607 },
19608 // Second
19609 s(date, token) {
19610 return addLeadingZeros(date.getSeconds(), token.length);
19611 },
19612 // Fraction of second
19613 S(date, token) {
19614 const numberOfDigits = token.length;
19615 const milliseconds = date.getMilliseconds();
19616 const fractionalSeconds = Math.trunc(
19617 milliseconds * Math.pow(10, numberOfDigits - 3)
19618 );
19619 return addLeadingZeros(fractionalSeconds, token.length);
19620 }
19621 };
19622
19623 // node_modules/date-fns/_lib/format/formatters.js
19624 var dayPeriodEnum = {
19625 am: "am",
19626 pm: "pm",
19627 midnight: "midnight",
19628 noon: "noon",
19629 morning: "morning",
19630 afternoon: "afternoon",
19631 evening: "evening",
19632 night: "night"
19633 };
19634 var formatters = {
19635 // Era
19636 G: function(date, token, localize2) {
19637 const era = date.getFullYear() > 0 ? 1 : 0;
19638 switch (token) {
19639 // AD, BC
19640 case "G":
19641 case "GG":
19642 case "GGG":
19643 return localize2.era(era, { width: "abbreviated" });
19644 // A, B
19645 case "GGGGG":
19646 return localize2.era(era, { width: "narrow" });
19647 // Anno Domini, Before Christ
19648 case "GGGG":
19649 default:
19650 return localize2.era(era, { width: "wide" });
19651 }
19652 },
19653 // Year
19654 y: function(date, token, localize2) {
19655 if (token === "yo") {
19656 const signedYear = date.getFullYear();
19657 const year = signedYear > 0 ? signedYear : 1 - signedYear;
19658 return localize2.ordinalNumber(year, { unit: "year" });
19659 }
19660 return lightFormatters.y(date, token);
19661 },
19662 // Local week-numbering year
19663 Y: function(date, token, localize2, options) {
19664 const signedWeekYear = getWeekYear(date, options);
19665 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
19666 if (token === "YY") {
19667 const twoDigitYear = weekYear % 100;
19668 return addLeadingZeros(twoDigitYear, 2);
19669 }
19670 if (token === "Yo") {
19671 return localize2.ordinalNumber(weekYear, { unit: "year" });
19672 }
19673 return addLeadingZeros(weekYear, token.length);
19674 },
19675 // ISO week-numbering year
19676 R: function(date, token) {
19677 const isoWeekYear = getISOWeekYear(date);
19678 return addLeadingZeros(isoWeekYear, token.length);
19679 },
19680 // Extended year. This is a single number designating the year of this calendar system.
19681 // The main difference between `y` and `u` localizers are B.C. years:
19682 // | Year | `y` | `u` |
19683 // |------|-----|-----|
19684 // | AC 1 | 1 | 1 |
19685 // | BC 1 | 1 | 0 |
19686 // | BC 2 | 2 | -1 |
19687 // Also `yy` always returns the last two digits of a year,
19688 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
19689 u: function(date, token) {
19690 const year = date.getFullYear();
19691 return addLeadingZeros(year, token.length);
19692 },
19693 // Quarter
19694 Q: function(date, token, localize2) {
19695 const quarter = Math.ceil((date.getMonth() + 1) / 3);
19696 switch (token) {
19697 // 1, 2, 3, 4
19698 case "Q":
19699 return String(quarter);
19700 // 01, 02, 03, 04
19701 case "QQ":
19702 return addLeadingZeros(quarter, 2);
19703 // 1st, 2nd, 3rd, 4th
19704 case "Qo":
19705 return localize2.ordinalNumber(quarter, { unit: "quarter" });
19706 // Q1, Q2, Q3, Q4
19707 case "QQQ":
19708 return localize2.quarter(quarter, {
19709 width: "abbreviated",
19710 context: "formatting"
19711 });
19712 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
19713 case "QQQQQ":
19714 return localize2.quarter(quarter, {
19715 width: "narrow",
19716 context: "formatting"
19717 });
19718 // 1st quarter, 2nd quarter, ...
19719 case "QQQQ":
19720 default:
19721 return localize2.quarter(quarter, {
19722 width: "wide",
19723 context: "formatting"
19724 });
19725 }
19726 },
19727 // Stand-alone quarter
19728 q: function(date, token, localize2) {
19729 const quarter = Math.ceil((date.getMonth() + 1) / 3);
19730 switch (token) {
19731 // 1, 2, 3, 4
19732 case "q":
19733 return String(quarter);
19734 // 01, 02, 03, 04
19735 case "qq":
19736 return addLeadingZeros(quarter, 2);
19737 // 1st, 2nd, 3rd, 4th
19738 case "qo":
19739 return localize2.ordinalNumber(quarter, { unit: "quarter" });
19740 // Q1, Q2, Q3, Q4
19741 case "qqq":
19742 return localize2.quarter(quarter, {
19743 width: "abbreviated",
19744 context: "standalone"
19745 });
19746 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
19747 case "qqqqq":
19748 return localize2.quarter(quarter, {
19749 width: "narrow",
19750 context: "standalone"
19751 });
19752 // 1st quarter, 2nd quarter, ...
19753 case "qqqq":
19754 default:
19755 return localize2.quarter(quarter, {
19756 width: "wide",
19757 context: "standalone"
19758 });
19759 }
19760 },
19761 // Month
19762 M: function(date, token, localize2) {
19763 const month = date.getMonth();
19764 switch (token) {
19765 case "M":
19766 case "MM":
19767 return lightFormatters.M(date, token);
19768 // 1st, 2nd, ..., 12th
19769 case "Mo":
19770 return localize2.ordinalNumber(month + 1, { unit: "month" });
19771 // Jan, Feb, ..., Dec
19772 case "MMM":
19773 return localize2.month(month, {
19774 width: "abbreviated",
19775 context: "formatting"
19776 });
19777 // J, F, ..., D
19778 case "MMMMM":
19779 return localize2.month(month, {
19780 width: "narrow",
19781 context: "formatting"
19782 });
19783 // January, February, ..., December
19784 case "MMMM":
19785 default:
19786 return localize2.month(month, { width: "wide", context: "formatting" });
19787 }
19788 },
19789 // Stand-alone month
19790 L: function(date, token, localize2) {
19791 const month = date.getMonth();
19792 switch (token) {
19793 // 1, 2, ..., 12
19794 case "L":
19795 return String(month + 1);
19796 // 01, 02, ..., 12
19797 case "LL":
19798 return addLeadingZeros(month + 1, 2);
19799 // 1st, 2nd, ..., 12th
19800 case "Lo":
19801 return localize2.ordinalNumber(month + 1, { unit: "month" });
19802 // Jan, Feb, ..., Dec
19803 case "LLL":
19804 return localize2.month(month, {
19805 width: "abbreviated",
19806 context: "standalone"
19807 });
19808 // J, F, ..., D
19809 case "LLLLL":
19810 return localize2.month(month, {
19811 width: "narrow",
19812 context: "standalone"
19813 });
19814 // January, February, ..., December
19815 case "LLLL":
19816 default:
19817 return localize2.month(month, { width: "wide", context: "standalone" });
19818 }
19819 },
19820 // Local week of year
19821 w: function(date, token, localize2, options) {
19822 const week = getWeek(date, options);
19823 if (token === "wo") {
19824 return localize2.ordinalNumber(week, { unit: "week" });
19825 }
19826 return addLeadingZeros(week, token.length);
19827 },
19828 // ISO week of year
19829 I: function(date, token, localize2) {
19830 const isoWeek = getISOWeek(date);
19831 if (token === "Io") {
19832 return localize2.ordinalNumber(isoWeek, { unit: "week" });
19833 }
19834 return addLeadingZeros(isoWeek, token.length);
19835 },
19836 // Day of the month
19837 d: function(date, token, localize2) {
19838 if (token === "do") {
19839 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
19840 }
19841 return lightFormatters.d(date, token);
19842 },
19843 // Day of year
19844 D: function(date, token, localize2) {
19845 const dayOfYear = getDayOfYear(date);
19846 if (token === "Do") {
19847 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
19848 }
19849 return addLeadingZeros(dayOfYear, token.length);
19850 },
19851 // Day of week
19852 E: function(date, token, localize2) {
19853 const dayOfWeek = date.getDay();
19854 switch (token) {
19855 // Tue
19856 case "E":
19857 case "EE":
19858 case "EEE":
19859 return localize2.day(dayOfWeek, {
19860 width: "abbreviated",
19861 context: "formatting"
19862 });
19863 // T
19864 case "EEEEE":
19865 return localize2.day(dayOfWeek, {
19866 width: "narrow",
19867 context: "formatting"
19868 });
19869 // Tu
19870 case "EEEEEE":
19871 return localize2.day(dayOfWeek, {
19872 width: "short",
19873 context: "formatting"
19874 });
19875 // Tuesday
19876 case "EEEE":
19877 default:
19878 return localize2.day(dayOfWeek, {
19879 width: "wide",
19880 context: "formatting"
19881 });
19882 }
19883 },
19884 // Local day of week
19885 e: function(date, token, localize2, options) {
19886 const dayOfWeek = date.getDay();
19887 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
19888 switch (token) {
19889 // Numerical value (Nth day of week with current locale or weekStartsOn)
19890 case "e":
19891 return String(localDayOfWeek);
19892 // Padded numerical value
19893 case "ee":
19894 return addLeadingZeros(localDayOfWeek, 2);
19895 // 1st, 2nd, ..., 7th
19896 case "eo":
19897 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
19898 case "eee":
19899 return localize2.day(dayOfWeek, {
19900 width: "abbreviated",
19901 context: "formatting"
19902 });
19903 // T
19904 case "eeeee":
19905 return localize2.day(dayOfWeek, {
19906 width: "narrow",
19907 context: "formatting"
19908 });
19909 // Tu
19910 case "eeeeee":
19911 return localize2.day(dayOfWeek, {
19912 width: "short",
19913 context: "formatting"
19914 });
19915 // Tuesday
19916 case "eeee":
19917 default:
19918 return localize2.day(dayOfWeek, {
19919 width: "wide",
19920 context: "formatting"
19921 });
19922 }
19923 },
19924 // Stand-alone local day of week
19925 c: function(date, token, localize2, options) {
19926 const dayOfWeek = date.getDay();
19927 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
19928 switch (token) {
19929 // Numerical value (same as in `e`)
19930 case "c":
19931 return String(localDayOfWeek);
19932 // Padded numerical value
19933 case "cc":
19934 return addLeadingZeros(localDayOfWeek, token.length);
19935 // 1st, 2nd, ..., 7th
19936 case "co":
19937 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
19938 case "ccc":
19939 return localize2.day(dayOfWeek, {
19940 width: "abbreviated",
19941 context: "standalone"
19942 });
19943 // T
19944 case "ccccc":
19945 return localize2.day(dayOfWeek, {
19946 width: "narrow",
19947 context: "standalone"
19948 });
19949 // Tu
19950 case "cccccc":
19951 return localize2.day(dayOfWeek, {
19952 width: "short",
19953 context: "standalone"
19954 });
19955 // Tuesday
19956 case "cccc":
19957 default:
19958 return localize2.day(dayOfWeek, {
19959 width: "wide",
19960 context: "standalone"
19961 });
19962 }
19963 },
19964 // ISO day of week
19965 i: function(date, token, localize2) {
19966 const dayOfWeek = date.getDay();
19967 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
19968 switch (token) {
19969 // 2
19970 case "i":
19971 return String(isoDayOfWeek);
19972 // 02
19973 case "ii":
19974 return addLeadingZeros(isoDayOfWeek, token.length);
19975 // 2nd
19976 case "io":
19977 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
19978 // Tue
19979 case "iii":
19980 return localize2.day(dayOfWeek, {
19981 width: "abbreviated",
19982 context: "formatting"
19983 });
19984 // T
19985 case "iiiii":
19986 return localize2.day(dayOfWeek, {
19987 width: "narrow",
19988 context: "formatting"
19989 });
19990 // Tu
19991 case "iiiiii":
19992 return localize2.day(dayOfWeek, {
19993 width: "short",
19994 context: "formatting"
19995 });
19996 // Tuesday
19997 case "iiii":
19998 default:
19999 return localize2.day(dayOfWeek, {
20000 width: "wide",
20001 context: "formatting"
20002 });
20003 }
20004 },
20005 // AM or PM
20006 a: function(date, token, localize2) {
20007 const hours = date.getHours();
20008 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20009 switch (token) {
20010 case "a":
20011 case "aa":
20012 return localize2.dayPeriod(dayPeriodEnumValue, {
20013 width: "abbreviated",
20014 context: "formatting"
20015 });
20016 case "aaa":
20017 return localize2.dayPeriod(dayPeriodEnumValue, {
20018 width: "abbreviated",
20019 context: "formatting"
20020 }).toLowerCase();
20021 case "aaaaa":
20022 return localize2.dayPeriod(dayPeriodEnumValue, {
20023 width: "narrow",
20024 context: "formatting"
20025 });
20026 case "aaaa":
20027 default:
20028 return localize2.dayPeriod(dayPeriodEnumValue, {
20029 width: "wide",
20030 context: "formatting"
20031 });
20032 }
20033 },
20034 // AM, PM, midnight, noon
20035 b: function(date, token, localize2) {
20036 const hours = date.getHours();
20037 let dayPeriodEnumValue;
20038 if (hours === 12) {
20039 dayPeriodEnumValue = dayPeriodEnum.noon;
20040 } else if (hours === 0) {
20041 dayPeriodEnumValue = dayPeriodEnum.midnight;
20042 } else {
20043 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20044 }
20045 switch (token) {
20046 case "b":
20047 case "bb":
20048 return localize2.dayPeriod(dayPeriodEnumValue, {
20049 width: "abbreviated",
20050 context: "formatting"
20051 });
20052 case "bbb":
20053 return localize2.dayPeriod(dayPeriodEnumValue, {
20054 width: "abbreviated",
20055 context: "formatting"
20056 }).toLowerCase();
20057 case "bbbbb":
20058 return localize2.dayPeriod(dayPeriodEnumValue, {
20059 width: "narrow",
20060 context: "formatting"
20061 });
20062 case "bbbb":
20063 default:
20064 return localize2.dayPeriod(dayPeriodEnumValue, {
20065 width: "wide",
20066 context: "formatting"
20067 });
20068 }
20069 },
20070 // in the morning, in the afternoon, in the evening, at night
20071 B: function(date, token, localize2) {
20072 const hours = date.getHours();
20073 let dayPeriodEnumValue;
20074 if (hours >= 17) {
20075 dayPeriodEnumValue = dayPeriodEnum.evening;
20076 } else if (hours >= 12) {
20077 dayPeriodEnumValue = dayPeriodEnum.afternoon;
20078 } else if (hours >= 4) {
20079 dayPeriodEnumValue = dayPeriodEnum.morning;
20080 } else {
20081 dayPeriodEnumValue = dayPeriodEnum.night;
20082 }
20083 switch (token) {
20084 case "B":
20085 case "BB":
20086 case "BBB":
20087 return localize2.dayPeriod(dayPeriodEnumValue, {
20088 width: "abbreviated",
20089 context: "formatting"
20090 });
20091 case "BBBBB":
20092 return localize2.dayPeriod(dayPeriodEnumValue, {
20093 width: "narrow",
20094 context: "formatting"
20095 });
20096 case "BBBB":
20097 default:
20098 return localize2.dayPeriod(dayPeriodEnumValue, {
20099 width: "wide",
20100 context: "formatting"
20101 });
20102 }
20103 },
20104 // Hour [1-12]
20105 h: function(date, token, localize2) {
20106 if (token === "ho") {
20107 let hours = date.getHours() % 12;
20108 if (hours === 0) hours = 12;
20109 return localize2.ordinalNumber(hours, { unit: "hour" });
20110 }
20111 return lightFormatters.h(date, token);
20112 },
20113 // Hour [0-23]
20114 H: function(date, token, localize2) {
20115 if (token === "Ho") {
20116 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
20117 }
20118 return lightFormatters.H(date, token);
20119 },
20120 // Hour [0-11]
20121 K: function(date, token, localize2) {
20122 const hours = date.getHours() % 12;
20123 if (token === "Ko") {
20124 return localize2.ordinalNumber(hours, { unit: "hour" });
20125 }
20126 return addLeadingZeros(hours, token.length);
20127 },
20128 // Hour [1-24]
20129 k: function(date, token, localize2) {
20130 let hours = date.getHours();
20131 if (hours === 0) hours = 24;
20132 if (token === "ko") {
20133 return localize2.ordinalNumber(hours, { unit: "hour" });
20134 }
20135 return addLeadingZeros(hours, token.length);
20136 },
20137 // Minute
20138 m: function(date, token, localize2) {
20139 if (token === "mo") {
20140 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
20141 }
20142 return lightFormatters.m(date, token);
20143 },
20144 // Second
20145 s: function(date, token, localize2) {
20146 if (token === "so") {
20147 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
20148 }
20149 return lightFormatters.s(date, token);
20150 },
20151 // Fraction of second
20152 S: function(date, token) {
20153 return lightFormatters.S(date, token);
20154 },
20155 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
20156 X: function(date, token, _localize) {
20157 const timezoneOffset = date.getTimezoneOffset();
20158 if (timezoneOffset === 0) {
20159 return "Z";
20160 }
20161 switch (token) {
20162 // Hours and optional minutes
20163 case "X":
20164 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20165 // Hours, minutes and optional seconds without `:` delimiter
20166 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20167 // so this token always has the same output as `XX`
20168 case "XXXX":
20169 case "XX":
20170 return formatTimezone(timezoneOffset);
20171 // Hours, minutes and optional seconds with `:` delimiter
20172 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20173 // so this token always has the same output as `XXX`
20174 case "XXXXX":
20175 case "XXX":
20176 // Hours and minutes with `:` delimiter
20177 default:
20178 return formatTimezone(timezoneOffset, ":");
20179 }
20180 },
20181 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
20182 x: function(date, token, _localize) {
20183 const timezoneOffset = date.getTimezoneOffset();
20184 switch (token) {
20185 // Hours and optional minutes
20186 case "x":
20187 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20188 // Hours, minutes and optional seconds without `:` delimiter
20189 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20190 // so this token always has the same output as `xx`
20191 case "xxxx":
20192 case "xx":
20193 return formatTimezone(timezoneOffset);
20194 // Hours, minutes and optional seconds with `:` delimiter
20195 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20196 // so this token always has the same output as `xxx`
20197 case "xxxxx":
20198 case "xxx":
20199 // Hours and minutes with `:` delimiter
20200 default:
20201 return formatTimezone(timezoneOffset, ":");
20202 }
20203 },
20204 // Timezone (GMT)
20205 O: function(date, token, _localize) {
20206 const timezoneOffset = date.getTimezoneOffset();
20207 switch (token) {
20208 // Short
20209 case "O":
20210 case "OO":
20211 case "OOO":
20212 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20213 // Long
20214 case "OOOO":
20215 default:
20216 return "GMT" + formatTimezone(timezoneOffset, ":");
20217 }
20218 },
20219 // Timezone (specific non-location)
20220 z: function(date, token, _localize) {
20221 const timezoneOffset = date.getTimezoneOffset();
20222 switch (token) {
20223 // Short
20224 case "z":
20225 case "zz":
20226 case "zzz":
20227 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20228 // Long
20229 case "zzzz":
20230 default:
20231 return "GMT" + formatTimezone(timezoneOffset, ":");
20232 }
20233 },
20234 // Seconds timestamp
20235 t: function(date, token, _localize) {
20236 const timestamp = Math.trunc(+date / 1e3);
20237 return addLeadingZeros(timestamp, token.length);
20238 },
20239 // Milliseconds timestamp
20240 T: function(date, token, _localize) {
20241 return addLeadingZeros(+date, token.length);
20242 }
20243 };
20244 function formatTimezoneShort(offset4, delimiter = "") {
20245 const sign = offset4 > 0 ? "-" : "+";
20246 const absOffset = Math.abs(offset4);
20247 const hours = Math.trunc(absOffset / 60);
20248 const minutes = absOffset % 60;
20249 if (minutes === 0) {
20250 return sign + String(hours);
20251 }
20252 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
20253 }
20254 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
20255 if (offset4 % 60 === 0) {
20256 const sign = offset4 > 0 ? "-" : "+";
20257 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
20258 }
20259 return formatTimezone(offset4, delimiter);
20260 }
20261 function formatTimezone(offset4, delimiter = "") {
20262 const sign = offset4 > 0 ? "-" : "+";
20263 const absOffset = Math.abs(offset4);
20264 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
20265 const minutes = addLeadingZeros(absOffset % 60, 2);
20266 return sign + hours + delimiter + minutes;
20267 }
20268
20269 // node_modules/date-fns/_lib/format/longFormatters.js
20270 var dateLongFormatter = (pattern, formatLong2) => {
20271 switch (pattern) {
20272 case "P":
20273 return formatLong2.date({ width: "short" });
20274 case "PP":
20275 return formatLong2.date({ width: "medium" });
20276 case "PPP":
20277 return formatLong2.date({ width: "long" });
20278 case "PPPP":
20279 default:
20280 return formatLong2.date({ width: "full" });
20281 }
20282 };
20283 var timeLongFormatter = (pattern, formatLong2) => {
20284 switch (pattern) {
20285 case "p":
20286 return formatLong2.time({ width: "short" });
20287 case "pp":
20288 return formatLong2.time({ width: "medium" });
20289 case "ppp":
20290 return formatLong2.time({ width: "long" });
20291 case "pppp":
20292 default:
20293 return formatLong2.time({ width: "full" });
20294 }
20295 };
20296 var dateTimeLongFormatter = (pattern, formatLong2) => {
20297 const matchResult = pattern.match(/(P+)(p+)?/) || [];
20298 const datePattern = matchResult[1];
20299 const timePattern = matchResult[2];
20300 if (!timePattern) {
20301 return dateLongFormatter(pattern, formatLong2);
20302 }
20303 let dateTimeFormat;
20304 switch (datePattern) {
20305 case "P":
20306 dateTimeFormat = formatLong2.dateTime({ width: "short" });
20307 break;
20308 case "PP":
20309 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
20310 break;
20311 case "PPP":
20312 dateTimeFormat = formatLong2.dateTime({ width: "long" });
20313 break;
20314 case "PPPP":
20315 default:
20316 dateTimeFormat = formatLong2.dateTime({ width: "full" });
20317 break;
20318 }
20319 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
20320 };
20321 var longFormatters = {
20322 p: timeLongFormatter,
20323 P: dateTimeLongFormatter
20324 };
20325
20326 // node_modules/date-fns/_lib/protectedTokens.js
20327 var dayOfYearTokenRE = /^D+$/;
20328 var weekYearTokenRE = /^Y+$/;
20329 var throwTokens = ["D", "DD", "YY", "YYYY"];
20330 function isProtectedDayOfYearToken(token) {
20331 return dayOfYearTokenRE.test(token);
20332 }
20333 function isProtectedWeekYearToken(token) {
20334 return weekYearTokenRE.test(token);
20335 }
20336 function warnOrThrowProtectedError(token, format6, input) {
20337 const _message = message(token, format6, input);
20338 console.warn(_message);
20339 if (throwTokens.includes(token)) throw new RangeError(_message);
20340 }
20341 function message(token, format6, input) {
20342 const subject = token[0] === "Y" ? "years" : "days of the month";
20343 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`;
20344 }
20345
20346 // node_modules/date-fns/format.js
20347 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
20348 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
20349 var escapedStringRegExp = /^'([^]*?)'?$/;
20350 var doubleQuoteRegExp = /''/g;
20351 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
20352 function format(date, formatStr, options) {
20353 const defaultOptions2 = getDefaultOptions();
20354 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
20355 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20356 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
20357 const originalDate = toDate(date, options?.in);
20358 if (!isValid(originalDate)) {
20359 throw new RangeError("Invalid time value");
20360 }
20361 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
20362 const firstCharacter = substring[0];
20363 if (firstCharacter === "p" || firstCharacter === "P") {
20364 const longFormatter = longFormatters[firstCharacter];
20365 return longFormatter(substring, locale.formatLong);
20366 }
20367 return substring;
20368 }).join("").match(formattingTokensRegExp).map((substring) => {
20369 if (substring === "''") {
20370 return { isToken: false, value: "'" };
20371 }
20372 const firstCharacter = substring[0];
20373 if (firstCharacter === "'") {
20374 return { isToken: false, value: cleanEscapedString(substring) };
20375 }
20376 if (formatters[firstCharacter]) {
20377 return { isToken: true, value: substring };
20378 }
20379 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
20380 throw new RangeError(
20381 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
20382 );
20383 }
20384 return { isToken: false, value: substring };
20385 });
20386 if (locale.localize.preprocessor) {
20387 parts = locale.localize.preprocessor(originalDate, parts);
20388 }
20389 const formatterOptions = {
20390 firstWeekContainsDate,
20391 weekStartsOn,
20392 locale
20393 };
20394 return parts.map((part) => {
20395 if (!part.isToken) return part.value;
20396 const token = part.value;
20397 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
20398 warnOrThrowProtectedError(token, formatStr, String(date));
20399 }
20400 const formatter = formatters[token[0]];
20401 return formatter(originalDate, token, locale.localize, formatterOptions);
20402 }).join("");
20403 }
20404 function cleanEscapedString(input) {
20405 const matched = input.match(escapedStringRegExp);
20406 if (!matched) {
20407 return input;
20408 }
20409 return matched[1].replace(doubleQuoteRegExp, "'");
20410 }
20411
20412 // node_modules/date-fns/subDays.js
20413 function subDays(date, amount, options) {
20414 return addDays(date, -amount, options);
20415 }
20416
20417 // node_modules/date-fns/subMonths.js
20418 function subMonths(date, amount, options) {
20419 return addMonths(date, -amount, options);
20420 }
20421
20422 // node_modules/date-fns/subWeeks.js
20423 function subWeeks(date, amount, options) {
20424 return addWeeks(date, -amount, options);
20425 }
20426
20427 // node_modules/date-fns/subYears.js
20428 function subYears(date, amount, options) {
20429 return addYears(date, -amount, options);
20430 }
20431
20432 // packages/dataviews/build-module/utils/operators.mjs
20433 var import_i18n23 = __toESM(require_i18n(), 1);
20434 var import_element42 = __toESM(require_element(), 1);
20435 var import_date = __toESM(require_date(), 1);
20436 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
20437 var filterTextWrappers = {
20438 Name: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
20439 Value: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
20440 };
20441 function getRelativeDate(value, unit) {
20442 switch (unit) {
20443 case "days":
20444 return subDays(/* @__PURE__ */ new Date(), value);
20445 case "weeks":
20446 return subWeeks(/* @__PURE__ */ new Date(), value);
20447 case "months":
20448 return subMonths(/* @__PURE__ */ new Date(), value);
20449 case "years":
20450 return subYears(/* @__PURE__ */ new Date(), value);
20451 default:
20452 return /* @__PURE__ */ new Date();
20453 }
20454 }
20455 var isNoneOperatorDefinition = {
20456 /* translators: DataViews operator name */
20457 label: (0, import_i18n23.__)("Is none of"),
20458 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20459 (0, import_i18n23.sprintf)(
20460 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
20461 (0, import_i18n23.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
20462 filter.name,
20463 activeElements.map((element) => element.label).join(", ")
20464 ),
20465 filterTextWrappers
20466 ),
20467 filter: ((item, field, filterValue) => {
20468 if (!filterValue?.length) {
20469 return true;
20470 }
20471 const fieldValue = field.getValue({ item });
20472 if (Array.isArray(fieldValue)) {
20473 return !filterValue.some(
20474 (fv) => fieldValue.includes(fv)
20475 );
20476 } else if (typeof fieldValue === "string") {
20477 return !filterValue.includes(fieldValue);
20478 }
20479 return false;
20480 }),
20481 selection: "multi"
20482 };
20483 var OPERATORS = [
20484 {
20485 name: OPERATOR_IS_ANY,
20486 /* translators: DataViews operator name */
20487 label: (0, import_i18n23.__)("Includes"),
20488 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20489 (0, import_i18n23.sprintf)(
20490 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
20491 (0, import_i18n23.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
20492 filter.name,
20493 activeElements.map((element) => element.label).join(", ")
20494 ),
20495 filterTextWrappers
20496 ),
20497 filter(item, field, filterValue) {
20498 if (!filterValue?.length) {
20499 return true;
20500 }
20501 const fieldValue = field.getValue({ item });
20502 if (Array.isArray(fieldValue)) {
20503 return filterValue.some(
20504 (fv) => fieldValue.includes(fv)
20505 );
20506 } else if (typeof fieldValue === "string") {
20507 return filterValue.includes(fieldValue);
20508 }
20509 return false;
20510 },
20511 selection: "multi"
20512 },
20513 {
20514 name: OPERATOR_IS_NONE,
20515 ...isNoneOperatorDefinition
20516 },
20517 {
20518 name: OPERATOR_IS_ALL,
20519 /* translators: DataViews operator name */
20520 label: (0, import_i18n23.__)("Includes all"),
20521 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20522 (0, import_i18n23.sprintf)(
20523 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
20524 (0, import_i18n23.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
20525 filter.name,
20526 activeElements.map((element) => element.label).join(", ")
20527 ),
20528 filterTextWrappers
20529 ),
20530 filter(item, field, filterValue) {
20531 if (!filterValue?.length) {
20532 return true;
20533 }
20534 return filterValue.every((value) => {
20535 return field.getValue({ item })?.includes(value);
20536 });
20537 },
20538 selection: "multi"
20539 },
20540 {
20541 name: OPERATOR_IS_NOT_ALL,
20542 ...isNoneOperatorDefinition
20543 },
20544 {
20545 name: OPERATOR_BETWEEN,
20546 /* translators: DataViews operator name */
20547 label: (0, import_i18n23.__)("Between (inc)"),
20548 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20549 (0, import_i18n23.sprintf)(
20550 /* 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". */
20551 (0, import_i18n23.__)(
20552 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
20553 ),
20554 filter.name,
20555 activeElements[0].label[0],
20556 activeElements[0].label[1]
20557 ),
20558 filterTextWrappers
20559 ),
20560 filter(item, field, filterValue) {
20561 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
20562 return true;
20563 }
20564 const fieldValue = field.getValue({ item });
20565 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
20566 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
20567 }
20568 return false;
20569 },
20570 selection: "custom"
20571 },
20572 {
20573 name: OPERATOR_IN_THE_PAST,
20574 /* translators: DataViews operator name */
20575 label: (0, import_i18n23.__)("In the past"),
20576 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20577 (0, import_i18n23.sprintf)(
20578 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
20579 (0, import_i18n23.__)(
20580 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
20581 ),
20582 filter.name,
20583 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
20584 ),
20585 filterTextWrappers
20586 ),
20587 filter(item, field, filterValue) {
20588 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
20589 return true;
20590 }
20591 const targetDate = getRelativeDate(
20592 filterValue.value,
20593 filterValue.unit
20594 );
20595 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
20596 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
20597 },
20598 selection: "custom"
20599 },
20600 {
20601 name: OPERATOR_OVER,
20602 /* translators: DataViews operator name */
20603 label: (0, import_i18n23.__)("Over"),
20604 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20605 (0, import_i18n23.sprintf)(
20606 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
20607 (0, import_i18n23.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
20608 filter.name,
20609 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
20610 ),
20611 filterTextWrappers
20612 ),
20613 filter(item, field, filterValue) {
20614 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
20615 return true;
20616 }
20617 const targetDate = getRelativeDate(
20618 filterValue.value,
20619 filterValue.unit
20620 );
20621 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
20622 return fieldValue < targetDate;
20623 },
20624 selection: "custom"
20625 },
20626 {
20627 name: OPERATOR_IS,
20628 /* translators: DataViews operator name */
20629 label: (0, import_i18n23.__)("Is"),
20630 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20631 (0, import_i18n23.sprintf)(
20632 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
20633 (0, import_i18n23.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
20634 filter.name,
20635 activeElements[0].label
20636 ),
20637 filterTextWrappers
20638 ),
20639 filter(item, field, filterValue) {
20640 return filterValue === field.getValue({ item }) || filterValue === void 0;
20641 },
20642 selection: "single"
20643 },
20644 {
20645 name: OPERATOR_IS_NOT,
20646 /* translators: DataViews operator name */
20647 label: (0, import_i18n23.__)("Is not"),
20648 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20649 (0, import_i18n23.sprintf)(
20650 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
20651 (0, import_i18n23.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
20652 filter.name,
20653 activeElements[0].label
20654 ),
20655 filterTextWrappers
20656 ),
20657 filter(item, field, filterValue) {
20658 return filterValue !== field.getValue({ item });
20659 },
20660 selection: "single"
20661 },
20662 {
20663 name: OPERATOR_LESS_THAN,
20664 /* translators: DataViews operator name */
20665 label: (0, import_i18n23.__)("Less than"),
20666 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20667 (0, import_i18n23.sprintf)(
20668 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
20669 (0, import_i18n23.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
20670 filter.name,
20671 activeElements[0].label
20672 ),
20673 filterTextWrappers
20674 ),
20675 filter(item, field, filterValue) {
20676 if (filterValue === void 0) {
20677 return true;
20678 }
20679 const fieldValue = field.getValue({ item });
20680 return fieldValue < filterValue;
20681 },
20682 selection: "single"
20683 },
20684 {
20685 name: OPERATOR_GREATER_THAN,
20686 /* translators: DataViews operator name */
20687 label: (0, import_i18n23.__)("Greater than"),
20688 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20689 (0, import_i18n23.sprintf)(
20690 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
20691 (0, import_i18n23.__)(
20692 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
20693 ),
20694 filter.name,
20695 activeElements[0].label
20696 ),
20697 filterTextWrappers
20698 ),
20699 filter(item, field, filterValue) {
20700 if (filterValue === void 0) {
20701 return true;
20702 }
20703 const fieldValue = field.getValue({ item });
20704 return fieldValue > filterValue;
20705 },
20706 selection: "single"
20707 },
20708 {
20709 name: OPERATOR_LESS_THAN_OR_EQUAL,
20710 /* translators: DataViews operator name */
20711 label: (0, import_i18n23.__)("Less than or equal"),
20712 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20713 (0, import_i18n23.sprintf)(
20714 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
20715 (0, import_i18n23.__)(
20716 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
20717 ),
20718 filter.name,
20719 activeElements[0].label
20720 ),
20721 filterTextWrappers
20722 ),
20723 filter(item, field, filterValue) {
20724 if (filterValue === void 0) {
20725 return true;
20726 }
20727 const fieldValue = field.getValue({ item });
20728 return fieldValue <= filterValue;
20729 },
20730 selection: "single"
20731 },
20732 {
20733 name: OPERATOR_GREATER_THAN_OR_EQUAL,
20734 /* translators: DataViews operator name */
20735 label: (0, import_i18n23.__)("Greater than or equal"),
20736 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20737 (0, import_i18n23.sprintf)(
20738 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
20739 (0, import_i18n23.__)(
20740 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
20741 ),
20742 filter.name,
20743 activeElements[0].label
20744 ),
20745 filterTextWrappers
20746 ),
20747 filter(item, field, filterValue) {
20748 if (filterValue === void 0) {
20749 return true;
20750 }
20751 const fieldValue = field.getValue({ item });
20752 return fieldValue >= filterValue;
20753 },
20754 selection: "single"
20755 },
20756 {
20757 name: OPERATOR_BEFORE,
20758 /* translators: DataViews operator name */
20759 label: (0, import_i18n23.__)("Before"),
20760 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20761 (0, import_i18n23.sprintf)(
20762 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
20763 (0, import_i18n23.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
20764 filter.name,
20765 activeElements[0].label
20766 ),
20767 filterTextWrappers
20768 ),
20769 filter(item, field, filterValue) {
20770 if (filterValue === void 0) {
20771 return true;
20772 }
20773 const filterDate = (0, import_date.getDate)(filterValue);
20774 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
20775 return fieldDate < filterDate;
20776 },
20777 selection: "single"
20778 },
20779 {
20780 name: OPERATOR_AFTER,
20781 /* translators: DataViews operator name */
20782 label: (0, import_i18n23.__)("After"),
20783 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20784 (0, import_i18n23.sprintf)(
20785 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
20786 (0, import_i18n23.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
20787 filter.name,
20788 activeElements[0].label
20789 ),
20790 filterTextWrappers
20791 ),
20792 filter(item, field, filterValue) {
20793 if (filterValue === void 0) {
20794 return true;
20795 }
20796 const filterDate = (0, import_date.getDate)(filterValue);
20797 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
20798 return fieldDate > filterDate;
20799 },
20800 selection: "single"
20801 },
20802 {
20803 name: OPERATOR_BEFORE_INC,
20804 /* translators: DataViews operator name */
20805 label: (0, import_i18n23.__)("Before (inc)"),
20806 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20807 (0, import_i18n23.sprintf)(
20808 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
20809 (0, import_i18n23.__)(
20810 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
20811 ),
20812 filter.name,
20813 activeElements[0].label
20814 ),
20815 filterTextWrappers
20816 ),
20817 filter(item, field, filterValue) {
20818 if (filterValue === void 0) {
20819 return true;
20820 }
20821 const filterDate = (0, import_date.getDate)(filterValue);
20822 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
20823 return fieldDate <= filterDate;
20824 },
20825 selection: "single"
20826 },
20827 {
20828 name: OPERATOR_AFTER_INC,
20829 /* translators: DataViews operator name */
20830 label: (0, import_i18n23.__)("After (inc)"),
20831 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20832 (0, import_i18n23.sprintf)(
20833 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
20834 (0, import_i18n23.__)(
20835 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
20836 ),
20837 filter.name,
20838 activeElements[0].label
20839 ),
20840 filterTextWrappers
20841 ),
20842 filter(item, field, filterValue) {
20843 if (filterValue === void 0) {
20844 return true;
20845 }
20846 const filterDate = (0, import_date.getDate)(filterValue);
20847 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
20848 return fieldDate >= filterDate;
20849 },
20850 selection: "single"
20851 },
20852 {
20853 name: OPERATOR_CONTAINS,
20854 /* translators: DataViews operator name */
20855 label: (0, import_i18n23.__)("Contains"),
20856 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20857 (0, import_i18n23.sprintf)(
20858 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
20859 (0, import_i18n23.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
20860 filter.name,
20861 activeElements[0].label
20862 ),
20863 filterTextWrappers
20864 ),
20865 filter(item, field, filterValue) {
20866 if (filterValue === void 0) {
20867 return true;
20868 }
20869 const fieldValue = field.getValue({ item });
20870 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
20871 },
20872 selection: "single"
20873 },
20874 {
20875 name: OPERATOR_NOT_CONTAINS,
20876 /* translators: DataViews operator name */
20877 label: (0, import_i18n23.__)("Doesn't contain"),
20878 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20879 (0, import_i18n23.sprintf)(
20880 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
20881 (0, import_i18n23.__)(
20882 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
20883 ),
20884 filter.name,
20885 activeElements[0].label
20886 ),
20887 filterTextWrappers
20888 ),
20889 filter(item, field, filterValue) {
20890 if (filterValue === void 0) {
20891 return true;
20892 }
20893 const fieldValue = field.getValue({ item });
20894 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
20895 },
20896 selection: "single"
20897 },
20898 {
20899 name: OPERATOR_STARTS_WITH,
20900 /* translators: DataViews operator name */
20901 label: (0, import_i18n23.__)("Starts with"),
20902 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20903 (0, import_i18n23.sprintf)(
20904 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
20905 (0, import_i18n23.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
20906 filter.name,
20907 activeElements[0].label
20908 ),
20909 filterTextWrappers
20910 ),
20911 filter(item, field, filterValue) {
20912 if (filterValue === void 0) {
20913 return true;
20914 }
20915 const fieldValue = field.getValue({ item });
20916 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
20917 },
20918 selection: "single"
20919 },
20920 {
20921 name: OPERATOR_ON,
20922 /* translators: DataViews operator name */
20923 label: (0, import_i18n23.__)("On"),
20924 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20925 (0, import_i18n23.sprintf)(
20926 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
20927 (0, import_i18n23.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
20928 filter.name,
20929 activeElements[0].label
20930 ),
20931 filterTextWrappers
20932 ),
20933 filter(item, field, filterValue) {
20934 if (filterValue === void 0) {
20935 return true;
20936 }
20937 const filterDate = (0, import_date.getDate)(filterValue);
20938 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
20939 return filterDate.getTime() === fieldDate.getTime();
20940 },
20941 selection: "single"
20942 },
20943 {
20944 name: OPERATOR_NOT_ON,
20945 /* translators: DataViews operator name */
20946 label: (0, import_i18n23.__)("Not on"),
20947 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20948 (0, import_i18n23.sprintf)(
20949 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
20950 (0, import_i18n23.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
20951 filter.name,
20952 activeElements[0].label
20953 ),
20954 filterTextWrappers
20955 ),
20956 filter(item, field, filterValue) {
20957 if (filterValue === void 0) {
20958 return true;
20959 }
20960 const filterDate = (0, import_date.getDate)(filterValue);
20961 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
20962 return filterDate.getTime() !== fieldDate.getTime();
20963 },
20964 selection: "single"
20965 }
20966 ];
20967 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
20968 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
20969 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
20970 (op) => op.name === name
20971 );
20972 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
20973
20974 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
20975 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
20976 var ENTER = "Enter";
20977 var SPACE = " ";
20978 var FilterText = ({
20979 activeElements,
20980 filterInView,
20981 filter
20982 }) => {
20983 if (activeElements === void 0 || activeElements.length === 0) {
20984 return filter.name;
20985 }
20986 const operator = getOperatorByName(filterInView?.operator);
20987 if (operator !== void 0) {
20988 return operator.filterText(filter, activeElements);
20989 }
20990 return (0, import_i18n24.sprintf)(
20991 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
20992 (0, import_i18n24.__)("Unknown status for %1$s"),
20993 filter.name
20994 );
20995 };
20996 function OperatorSelector({
20997 filter,
20998 view,
20999 onChangeView
21000 }) {
21001 const operatorOptions = filter.operators?.map((operator) => ({
21002 value: operator,
21003 label: getOperatorByName(operator)?.label || operator
21004 }));
21005 const currentFilter = view.filters?.find(
21006 (_filter) => _filter.field === filter.field
21007 );
21008 const value = currentFilter?.operator || filter.operators[0];
21009 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
21010 Stack,
21011 {
21012 direction: "row",
21013 gap: "sm",
21014 justify: "flex-start",
21015 className: "dataviews-filters__summary-operators-container",
21016 align: "center",
21017 children: [
21018 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_components20.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
21019 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
21020 import_components20.SelectControl,
21021 {
21022 className: "dataviews-filters__summary-operators-filter-select",
21023 label: (0, import_i18n24.__)("Conditions"),
21024 value,
21025 options: operatorOptions,
21026 onChange: (newValue) => {
21027 const newOperator = newValue;
21028 const currentOperator = currentFilter?.operator;
21029 const newFilters = currentFilter ? [
21030 ...(view.filters ?? []).map(
21031 (_filter) => {
21032 if (_filter.field === filter.field) {
21033 const currentOpSelectionModel = getOperatorByName(
21034 currentOperator
21035 )?.selection;
21036 const newOpSelectionModel = getOperatorByName(
21037 newOperator
21038 )?.selection;
21039 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
21040 currentOpSelectionModel,
21041 newOpSelectionModel
21042 ].includes("custom");
21043 return {
21044 ..._filter,
21045 value: shouldResetValue ? void 0 : _filter.value,
21046 operator: newOperator
21047 };
21048 }
21049 return _filter;
21050 }
21051 )
21052 ] : [
21053 ...view.filters ?? [],
21054 {
21055 field: filter.field,
21056 operator: newOperator,
21057 value: void 0
21058 }
21059 ];
21060 onChangeView({
21061 ...view,
21062 page: 1,
21063 filters: newFilters
21064 });
21065 },
21066 size: "small",
21067 variant: "minimal",
21068 hideLabelFromVision: true
21069 }
21070 )
21071 ]
21072 }
21073 );
21074 }
21075 function Filter({
21076 addFilterRef,
21077 openedFilter,
21078 fields,
21079 ...commonProps
21080 }) {
21081 const toggleRef = (0, import_element43.useRef)(null);
21082 const { filter, view, onChangeView } = commonProps;
21083 const filterInView = view.filters?.find(
21084 (f2) => f2.field === filter.field
21085 );
21086 let activeElements = [];
21087 const field = (0, import_element43.useMemo)(() => {
21088 const currentField = fields.find((f2) => f2.id === filter.field);
21089 if (currentField) {
21090 return {
21091 ...currentField,
21092 // Configure getValue as if Item was a plain object.
21093 // See related input-widget.tsx
21094 getValue: ({ item }) => item[currentField.id]
21095 };
21096 }
21097 return currentField;
21098 }, [fields, filter.field]);
21099 const { elements } = useElements({
21100 elements: filter.elements,
21101 getElements: filter.getElements
21102 });
21103 if (elements.length > 0) {
21104 activeElements = elements.filter((element) => {
21105 if (filter.singleSelection) {
21106 return element.value === filterInView?.value;
21107 }
21108 return filterInView?.value?.includes(element.value);
21109 });
21110 } else if (Array.isArray(filterInView?.value)) {
21111 const label = filterInView.value.map((v2) => {
21112 const formattedValue = field?.getValueFormatted({
21113 item: { [field.id]: v2 },
21114 field
21115 });
21116 return formattedValue || String(v2);
21117 });
21118 activeElements = [
21119 {
21120 value: filterInView.value,
21121 // @ts-ignore
21122 label
21123 }
21124 ];
21125 } else if (typeof filterInView?.value === "object") {
21126 activeElements = [
21127 { value: filterInView.value, label: filterInView.value }
21128 ];
21129 } else if (filterInView?.value !== void 0) {
21130 const label = field !== void 0 ? field.getValueFormatted({
21131 item: { [field.id]: filterInView.value },
21132 field
21133 }) : String(filterInView.value);
21134 activeElements = [
21135 {
21136 value: filterInView.value,
21137 label
21138 }
21139 ];
21140 }
21141 const isPrimary = filter.isPrimary;
21142 const isLocked = filterInView?.isLocked;
21143 const hasValues = !isLocked && filterInView?.value !== void 0;
21144 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
21145 const resetOrRemoveLabel = isPrimary ? (0, import_i18n24.__)("Reset") : (0, import_i18n24.__)("Remove");
21146 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
21147 import_components20.Dropdown,
21148 {
21149 defaultOpen: openedFilter === filter.field,
21150 contentClassName: "dataviews-filters__summary-popover",
21151 popoverProps: { placement: "bottom-start", role: "dialog" },
21152 onClose: () => {
21153 toggleRef.current?.focus();
21154 },
21155 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
21156 /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(tooltip_exports.Root, { children: [
21157 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
21158 tooltip_exports.Trigger,
21159 {
21160 render: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
21161 "div",
21162 {
21163 className: clsx_default(
21164 "dataviews-filters__summary-chip",
21165 {
21166 "has-reset": canResetOrRemove,
21167 "has-values": hasValues,
21168 "is-not-clickable": isLocked
21169 }
21170 ),
21171 role: "button",
21172 tabIndex: isLocked ? -1 : 0,
21173 onClick: () => {
21174 if (!isLocked) {
21175 onToggle();
21176 }
21177 },
21178 onKeyDown: (event) => {
21179 if (!isLocked && [ENTER, SPACE].includes(
21180 event.key
21181 )) {
21182 onToggle();
21183 event.preventDefault();
21184 }
21185 },
21186 "aria-disabled": isLocked,
21187 "aria-pressed": isOpen,
21188 "aria-expanded": isOpen,
21189 ref: toggleRef,
21190 children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
21191 FilterText,
21192 {
21193 activeElements,
21194 filterInView,
21195 filter
21196 }
21197 )
21198 }
21199 )
21200 }
21201 ),
21202 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(tooltip_exports.Popup, { children: (0, import_i18n24.sprintf)(
21203 /* translators: 1: Filter name. */
21204 (0, import_i18n24.__)("Filter by: %1$s"),
21205 filter.name.toLowerCase()
21206 ) })
21207 ] }),
21208 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(tooltip_exports.Root, { children: [
21209 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
21210 tooltip_exports.Trigger,
21211 {
21212 render: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
21213 "button",
21214 {
21215 className: clsx_default(
21216 "dataviews-filters__summary-chip-remove",
21217 { "has-values": hasValues }
21218 ),
21219 "aria-label": resetOrRemoveLabel,
21220 onClick: () => {
21221 onChangeView({
21222 ...view,
21223 page: 1,
21224 filters: view.filters?.filter(
21225 (_filter) => _filter.field !== filter.field
21226 )
21227 });
21228 if (!isPrimary) {
21229 addFilterRef.current?.focus();
21230 } else {
21231 toggleRef.current?.focus();
21232 }
21233 },
21234 children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_components20.Icon, { icon: close_small_default })
21235 }
21236 )
21237 }
21238 ),
21239 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
21240 ] })
21241 ] }),
21242 renderContent: () => {
21243 return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
21244 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(OperatorSelector, { ...commonProps }),
21245 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
21246 SearchWidget,
21247 {
21248 ...commonProps,
21249 filter: {
21250 ...commonProps.filter,
21251 elements
21252 }
21253 }
21254 ) : /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(InputWidget, { ...commonProps, fields })
21255 ] });
21256 }
21257 }
21258 );
21259 }
21260
21261 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
21262 var import_components21 = __toESM(require_components(), 1);
21263 var import_i18n25 = __toESM(require_i18n(), 1);
21264 var import_element44 = __toESM(require_element(), 1);
21265 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
21266 var { Menu: Menu4 } = unlock3(import_components21.privateApis);
21267 function AddFilterMenu({
21268 filters,
21269 view,
21270 onChangeView,
21271 setOpenedFilter,
21272 triggerProps
21273 }) {
21274 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21275 return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(Menu4, { children: [
21276 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(Menu4.TriggerButton, { ...triggerProps }),
21277 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
21278 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21279 Menu4.Item,
21280 {
21281 onClick: () => {
21282 setOpenedFilter(filter.field);
21283 onChangeView({
21284 ...view,
21285 page: 1,
21286 filters: [
21287 ...view.filters || [],
21288 {
21289 field: filter.field,
21290 value: void 0,
21291 operator: filter.operators[0]
21292 }
21293 ]
21294 });
21295 },
21296 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(Menu4.ItemLabel, { children: filter.name })
21297 },
21298 filter.field
21299 );
21300 }) })
21301 ] });
21302 }
21303 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
21304 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
21305 return null;
21306 }
21307 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21308 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21309 AddFilterMenu,
21310 {
21311 triggerProps: {
21312 render: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21313 import_components21.Button,
21314 {
21315 accessibleWhenDisabled: true,
21316 size: "compact",
21317 className: "dataviews-filters-button",
21318 variant: "tertiary",
21319 disabled: !inactiveFilters.length,
21320 ref
21321 }
21322 ),
21323 children: (0, import_i18n25.__)("Add filter")
21324 },
21325 ...{ filters, view, onChangeView, setOpenedFilter }
21326 }
21327 );
21328 }
21329 var add_filter_default = (0, import_element44.forwardRef)(AddFilter);
21330
21331 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
21332 var import_components22 = __toESM(require_components(), 1);
21333 var import_i18n26 = __toESM(require_i18n(), 1);
21334 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
21335 function ResetFilter({
21336 filters,
21337 view,
21338 onChangeView
21339 }) {
21340 const isPrimary = (field) => filters.some(
21341 (_filter) => _filter.field === field && _filter.isPrimary
21342 );
21343 const isDisabled = !view.search && !view.filters?.some(
21344 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
21345 );
21346 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
21347 import_components22.Button,
21348 {
21349 disabled: isDisabled,
21350 accessibleWhenDisabled: true,
21351 size: "compact",
21352 variant: "tertiary",
21353 className: "dataviews-filters__reset-button",
21354 onClick: () => {
21355 onChangeView({
21356 ...view,
21357 page: 1,
21358 search: "",
21359 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
21360 });
21361 },
21362 children: (0, import_i18n26.__)("Reset")
21363 }
21364 );
21365 }
21366
21367 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
21368 var import_element45 = __toESM(require_element(), 1);
21369 function useFilters(fields, view) {
21370 return (0, import_element45.useMemo)(() => {
21371 const filters = [];
21372 fields.forEach((field) => {
21373 if (field.filterBy === false || !field.hasElements && !field.Edit) {
21374 return;
21375 }
21376 const operators = field.filterBy.operators;
21377 const isPrimary = !!field.filterBy?.isPrimary;
21378 const isLocked = view.filters?.some(
21379 (f2) => f2.field === field.id && !!f2.isLocked
21380 ) ?? false;
21381 filters.push({
21382 field: field.id,
21383 name: field.label,
21384 elements: field.elements,
21385 getElements: field.getElements,
21386 hasElements: field.hasElements,
21387 singleSelection: operators.some(
21388 (op) => isSingleSelectionOperator(op)
21389 ),
21390 operators,
21391 isVisible: isLocked || isPrimary || !!view.filters?.some(
21392 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
21393 ),
21394 isPrimary,
21395 isLocked
21396 });
21397 });
21398 filters.sort((a2, b2) => {
21399 if (a2.isLocked && !b2.isLocked) {
21400 return -1;
21401 }
21402 if (!a2.isLocked && b2.isLocked) {
21403 return 1;
21404 }
21405 if (a2.isPrimary && !b2.isPrimary) {
21406 return -1;
21407 }
21408 if (!a2.isPrimary && b2.isPrimary) {
21409 return 1;
21410 }
21411 return a2.name.localeCompare(b2.name);
21412 });
21413 return filters;
21414 }, [fields, view]);
21415 }
21416 var use_filters_default = useFilters;
21417
21418 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
21419 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
21420 function Filters({ className }) {
21421 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element46.useContext)(dataviews_context_default);
21422 const addFilterRef = (0, import_element46.useRef)(null);
21423 const filters = use_filters_default(fields, view);
21424 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
21425 add_filter_default,
21426 {
21427 filters,
21428 view,
21429 onChangeView,
21430 ref: addFilterRef,
21431 setOpenedFilter
21432 },
21433 "add-filter"
21434 );
21435 const visibleFilters = filters.filter((filter) => filter.isVisible);
21436 if (visibleFilters.length === 0) {
21437 return null;
21438 }
21439 const filterComponents = [
21440 ...visibleFilters.map((filter) => {
21441 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
21442 Filter,
21443 {
21444 filter,
21445 view,
21446 fields,
21447 onChangeView,
21448 addFilterRef,
21449 openedFilter
21450 },
21451 filter.field
21452 );
21453 }),
21454 addFilter
21455 ];
21456 filterComponents.push(
21457 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
21458 ResetFilter,
21459 {
21460 filters,
21461 view,
21462 onChangeView
21463 },
21464 "reset-filters"
21465 )
21466 );
21467 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
21468 Stack,
21469 {
21470 direction: "row",
21471 justify: "flex-start",
21472 gap: "sm",
21473 style: { width: "fit-content" },
21474 wrap: "wrap",
21475 className,
21476 children: filterComponents
21477 }
21478 );
21479 }
21480 var filters_default = (0, import_element46.memo)(Filters);
21481
21482 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
21483 var import_element47 = __toESM(require_element(), 1);
21484 var import_components23 = __toESM(require_components(), 1);
21485 var import_i18n27 = __toESM(require_i18n(), 1);
21486 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
21487 function FiltersToggle() {
21488 const {
21489 filters,
21490 view,
21491 onChangeView,
21492 setOpenedFilter,
21493 isShowingFilter,
21494 setIsShowingFilter
21495 } = (0, import_element47.useContext)(dataviews_context_default);
21496 const buttonRef = (0, import_element47.useRef)(null);
21497 const onChangeViewWithFilterVisibility = (0, import_element47.useCallback)(
21498 (_view) => {
21499 onChangeView(_view);
21500 setIsShowingFilter(true);
21501 },
21502 [onChangeView, setIsShowingFilter]
21503 );
21504 if (filters.length === 0) {
21505 return null;
21506 }
21507 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
21508 const addFilterButtonProps = {
21509 label: (0, import_i18n27.__)("Add filter"),
21510 "aria-expanded": false,
21511 isPressed: false
21512 };
21513 const toggleFiltersButtonProps = {
21514 label: (0, import_i18n27._x)("Filter", "verb"),
21515 "aria-expanded": isShowingFilter,
21516 isPressed: isShowingFilter,
21517 onClick: () => {
21518 if (!isShowingFilter) {
21519 setOpenedFilter(null);
21520 }
21521 setIsShowingFilter(!isShowingFilter);
21522 }
21523 };
21524 const hasPrimaryOrLockedFilters = filters.some(
21525 (filter) => filter.isPrimary || filter.isLocked
21526 );
21527 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
21528 import_components23.Button,
21529 {
21530 ref: buttonRef,
21531 className: "dataviews-filters__visibility-toggle",
21532 size: "compact",
21533 icon: funnel_default,
21534 disabled: hasPrimaryOrLockedFilters,
21535 accessibleWhenDisabled: true,
21536 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
21537 }
21538 );
21539 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
21540 AddFilterMenu,
21541 {
21542 filters,
21543 view,
21544 onChangeView: onChangeViewWithFilterVisibility,
21545 setOpenedFilter,
21546 triggerProps: { render: buttonComponent }
21547 }
21548 ) : /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
21549 FilterVisibilityToggle,
21550 {
21551 buttonRef,
21552 filtersCount: view.filters?.length,
21553 children: buttonComponent
21554 }
21555 ) });
21556 }
21557 function FilterVisibilityToggle({
21558 buttonRef,
21559 filtersCount,
21560 children
21561 }) {
21562 (0, import_element47.useEffect)(
21563 () => () => {
21564 buttonRef.current?.focus();
21565 },
21566 [buttonRef]
21567 );
21568 return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(import_jsx_runtime78.Fragment, { children: [
21569 children,
21570 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
21571 ] });
21572 }
21573 var toggle_default = FiltersToggle;
21574
21575 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
21576 var import_element48 = __toESM(require_element(), 1);
21577 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
21578 function FiltersToggled(props) {
21579 const { isShowingFilter } = (0, import_element48.useContext)(dataviews_context_default);
21580 if (!isShowingFilter) {
21581 return null;
21582 }
21583 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(filters_default, { ...props });
21584 }
21585 var filters_toggled_default = FiltersToggled;
21586
21587 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
21588 var import_element49 = __toESM(require_element(), 1);
21589 var import_components24 = __toESM(require_components(), 1);
21590 var import_i18n28 = __toESM(require_i18n(), 1);
21591 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
21592 function DataViewsLayout({ className }) {
21593 const {
21594 actions = [],
21595 data,
21596 fields,
21597 getItemId,
21598 getItemLevel,
21599 hasInitiallyLoaded,
21600 isLoading,
21601 view,
21602 onChangeView,
21603 selection,
21604 onChangeSelection,
21605 setOpenedFilter,
21606 onClickItem,
21607 isItemClickable,
21608 renderItemLink,
21609 defaultLayouts,
21610 containerRef,
21611 empty = /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("p", { children: (0, import_i18n28.__)("No results") })
21612 } = (0, import_element49.useContext)(dataviews_context_default);
21613 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
21614 delay: 200
21615 });
21616 if (!hasInitiallyLoaded) {
21617 if (!isDelayedInitialLoading) {
21618 return null;
21619 }
21620 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components24.Spinner, {}) }) });
21621 }
21622 const ViewComponent = VIEW_LAYOUTS.find(
21623 (v2) => v2.type === view.type && defaultLayouts[v2.type]
21624 )?.component;
21625 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
21626 ViewComponent,
21627 {
21628 className,
21629 actions,
21630 data,
21631 fields,
21632 getItemId,
21633 getItemLevel,
21634 isLoading,
21635 onChangeView,
21636 onChangeSelection,
21637 selection,
21638 setOpenedFilter,
21639 onClickItem,
21640 renderItemLink,
21641 isItemClickable,
21642 view,
21643 empty
21644 }
21645 ) });
21646 }
21647
21648 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
21649 var import_element50 = __toESM(require_element(), 1);
21650 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
21651 var EMPTY_ARRAY5 = [];
21652 function DataViewsFooter() {
21653 const {
21654 view,
21655 paginationInfo: { totalItems = 0, totalPages },
21656 data,
21657 actions = EMPTY_ARRAY5,
21658 isLoading,
21659 hasInitiallyLoaded
21660 } = (0, import_element50.useContext)(dataviews_context_default);
21661 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
21662 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
21663 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
21664 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
21665 return null;
21666 }
21667 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21668 "div",
21669 {
21670 className: "dataviews-footer",
21671 inert: isRefreshing ? "true" : void 0,
21672 children: /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
21673 Stack,
21674 {
21675 direction: "row",
21676 justify: "end",
21677 align: "center",
21678 className: clsx_default("dataviews-footer__content", {
21679 "is-refreshing": isDelayedRefreshing
21680 }),
21681 gap: "sm",
21682 children: [
21683 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(BulkActionsFooter, {}),
21684 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(dataviews_pagination_default, {})
21685 ]
21686 }
21687 )
21688 }
21689 );
21690 }
21691
21692 // packages/dataviews/build-module/components/dataviews-search/index.mjs
21693 var import_i18n29 = __toESM(require_i18n(), 1);
21694 var import_element51 = __toESM(require_element(), 1);
21695 var import_components25 = __toESM(require_components(), 1);
21696 var import_compose9 = __toESM(require_compose(), 1);
21697 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
21698 var DataViewsSearch = (0, import_element51.memo)(function Search({ label }) {
21699 const { view, onChangeView } = (0, import_element51.useContext)(dataviews_context_default);
21700 const [search, setSearch, debouncedSearch] = (0, import_compose9.useDebouncedInput)(
21701 view.search
21702 );
21703 (0, import_element51.useEffect)(() => {
21704 if (view.search !== debouncedSearch) {
21705 setSearch(view.search ?? "");
21706 }
21707 }, [view.search, setSearch]);
21708 const onChangeViewRef = (0, import_element51.useRef)(onChangeView);
21709 const viewRef = (0, import_element51.useRef)(view);
21710 (0, import_element51.useEffect)(() => {
21711 onChangeViewRef.current = onChangeView;
21712 viewRef.current = view;
21713 }, [onChangeView, view]);
21714 (0, import_element51.useEffect)(() => {
21715 if (debouncedSearch !== viewRef.current?.search) {
21716 onChangeViewRef.current({
21717 ...viewRef.current,
21718 page: view.page ? 1 : void 0,
21719 startPosition: view.startPosition ? 1 : void 0,
21720 search: debouncedSearch
21721 });
21722 }
21723 }, [debouncedSearch]);
21724 const searchLabel = label || (0, import_i18n29.__)("Search");
21725 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21726 import_components25.SearchControl,
21727 {
21728 className: "dataviews-search",
21729 onChange: setSearch,
21730 value: search,
21731 label: searchLabel,
21732 placeholder: searchLabel,
21733 size: "compact"
21734 }
21735 );
21736 });
21737 var dataviews_search_default = DataViewsSearch;
21738
21739 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
21740 var import_components26 = __toESM(require_components(), 1);
21741 var import_i18n30 = __toESM(require_i18n(), 1);
21742 var import_element52 = __toESM(require_element(), 1);
21743 var import_warning = __toESM(require_warning(), 1);
21744 var import_compose10 = __toESM(require_compose(), 1);
21745 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
21746 var { Menu: Menu5 } = unlock3(import_components26.privateApis);
21747 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
21748 className: "dataviews-config__popover",
21749 placement: "bottom-end",
21750 offset: 9
21751 };
21752 function ViewTypeMenu() {
21753 const { view, onChangeView, defaultLayouts } = (0, import_element52.useContext)(dataviews_context_default);
21754 const availableLayouts = Object.keys(defaultLayouts);
21755 if (availableLayouts.length <= 1) {
21756 return null;
21757 }
21758 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
21759 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(Menu5, { children: [
21760 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21761 Menu5.TriggerButton,
21762 {
21763 render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21764 import_components26.Button,
21765 {
21766 size: "compact",
21767 icon: activeView?.icon,
21768 label: (0, import_i18n30.__)("Layout")
21769 }
21770 )
21771 }
21772 ),
21773 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
21774 const config = VIEW_LAYOUTS.find(
21775 (v2) => v2.type === layout
21776 );
21777 if (!config) {
21778 return null;
21779 }
21780 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21781 Menu5.RadioItem,
21782 {
21783 value: layout,
21784 name: "view-actions-available-view",
21785 checked: layout === view.type,
21786 hideOnClick: true,
21787 onChange: (e2) => {
21788 switch (e2.target.value) {
21789 case "list":
21790 case "grid":
21791 case "table":
21792 case "pickerGrid":
21793 case "pickerTable":
21794 case "activity":
21795 const viewWithoutLayout = { ...view };
21796 if ("layout" in viewWithoutLayout) {
21797 delete viewWithoutLayout.layout;
21798 }
21799 return onChangeView({
21800 ...viewWithoutLayout,
21801 type: e2.target.value,
21802 ...defaultLayouts[e2.target.value]
21803 });
21804 }
21805 (0, import_warning.default)("Invalid dataview");
21806 },
21807 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Menu5.ItemLabel, { children: config.label })
21808 },
21809 layout
21810 );
21811 }) })
21812 ] });
21813 }
21814 function SortFieldControl() {
21815 const { view, fields, onChangeView } = (0, import_element52.useContext)(dataviews_context_default);
21816 const orderOptions = (0, import_element52.useMemo)(() => {
21817 const sortableFields = fields.filter(
21818 (field) => field.enableSorting !== false
21819 );
21820 return sortableFields.map((field) => {
21821 return {
21822 label: field.label,
21823 value: field.id
21824 };
21825 });
21826 }, [fields]);
21827 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21828 import_components26.SelectControl,
21829 {
21830 __next40pxDefaultSize: true,
21831 label: (0, import_i18n30.__)("Sort by"),
21832 value: view.sort?.field,
21833 options: orderOptions,
21834 onChange: (value) => {
21835 onChangeView({
21836 ...view,
21837 sort: {
21838 direction: view?.sort?.direction || "desc",
21839 field: value
21840 },
21841 showLevels: false
21842 });
21843 }
21844 }
21845 );
21846 }
21847 function SortDirectionControl() {
21848 const { view, fields, onChangeView } = (0, import_element52.useContext)(dataviews_context_default);
21849 const sortableFields = fields.filter(
21850 (field) => field.enableSorting !== false
21851 );
21852 if (sortableFields.length === 0) {
21853 return null;
21854 }
21855 let value = view.sort?.direction;
21856 if (!value && view.sort?.field) {
21857 value = "desc";
21858 }
21859 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21860 import_components26.__experimentalToggleGroupControl,
21861 {
21862 className: "dataviews-view-config__sort-direction",
21863 __next40pxDefaultSize: true,
21864 isBlock: true,
21865 label: (0, import_i18n30.__)("Order"),
21866 value,
21867 onChange: (newDirection) => {
21868 if (newDirection === "asc" || newDirection === "desc") {
21869 onChangeView({
21870 ...view,
21871 sort: {
21872 direction: newDirection,
21873 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
21874 fields.find(
21875 (field) => field.enableSorting !== false
21876 )?.id || ""
21877 },
21878 showLevels: false
21879 });
21880 return;
21881 }
21882 (0, import_warning.default)("Invalid direction");
21883 },
21884 children: SORTING_DIRECTIONS.map((direction) => {
21885 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21886 import_components26.__experimentalToggleGroupControlOptionIcon,
21887 {
21888 value: direction,
21889 icon: sortIcons[direction],
21890 label: sortLabels[direction]
21891 },
21892 direction
21893 );
21894 })
21895 }
21896 );
21897 }
21898 function ItemsPerPageControl() {
21899 const { view, config, onChangeView } = (0, import_element52.useContext)(dataviews_context_default);
21900 const { infiniteScrollEnabled } = view;
21901 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
21902 return null;
21903 }
21904 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21905 import_components26.__experimentalToggleGroupControl,
21906 {
21907 __next40pxDefaultSize: true,
21908 isBlock: true,
21909 label: (0, import_i18n30.__)("Items per page"),
21910 value: view.perPage || 10,
21911 disabled: !view?.sort?.field,
21912 onChange: (newItemsPerPage) => {
21913 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
21914 onChangeView({
21915 ...view,
21916 perPage: newItemsPerPageNumber,
21917 page: 1
21918 });
21919 },
21920 children: config.perPageSizes.map((value) => {
21921 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21922 import_components26.__experimentalToggleGroupControlOption,
21923 {
21924 value,
21925 label: value.toString()
21926 },
21927 value
21928 );
21929 })
21930 }
21931 );
21932 }
21933 function ResetViewButton() {
21934 const { onReset } = (0, import_element52.useContext)(dataviews_context_default);
21935 if (onReset === void 0) {
21936 return null;
21937 }
21938 const isDisabled = onReset === false;
21939 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21940 import_components26.Button,
21941 {
21942 variant: "tertiary",
21943 size: "compact",
21944 disabled: isDisabled,
21945 accessibleWhenDisabled: true,
21946 className: "dataviews-view-config__reset-button",
21947 onClick: () => {
21948 if (typeof onReset === "function") {
21949 onReset();
21950 }
21951 },
21952 children: (0, import_i18n30.__)("Reset view")
21953 }
21954 );
21955 }
21956 function DataviewsViewConfigDropdown() {
21957 const { view, onReset } = (0, import_element52.useContext)(dataviews_context_default);
21958 const popoverId = (0, import_compose10.useInstanceId)(
21959 _DataViewsViewConfig,
21960 "dataviews-view-config-dropdown"
21961 );
21962 const activeLayout = VIEW_LAYOUTS.find(
21963 (layout) => layout.type === view.type
21964 );
21965 const isModified = typeof onReset === "function";
21966 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21967 import_components26.Dropdown,
21968 {
21969 expandOnMobile: true,
21970 popoverProps: {
21971 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
21972 id: popoverId
21973 },
21974 renderToggle: ({ onToggle, isOpen }) => {
21975 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
21976 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21977 import_components26.Button,
21978 {
21979 size: "compact",
21980 icon: cog_default,
21981 label: (0, import_i18n30._x)(
21982 "View options",
21983 "View is used as a noun"
21984 ),
21985 onClick: onToggle,
21986 "aria-expanded": isOpen ? "true" : "false",
21987 "aria-controls": popoverId
21988 }
21989 ),
21990 isModified && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
21991 ] });
21992 },
21993 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21994 import_components26.__experimentalDropdownContentWrapper,
21995 {
21996 paddingSize: "medium",
21997 className: "dataviews-config__popover-content-wrapper",
21998 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
21999 Stack,
22000 {
22001 direction: "column",
22002 className: "dataviews-view-config",
22003 gap: "xl",
22004 children: [
22005 /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
22006 Stack,
22007 {
22008 direction: "row",
22009 justify: "space-between",
22010 align: "center",
22011 className: "dataviews-view-config__header",
22012 children: [
22013 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22014 import_components26.__experimentalHeading,
22015 {
22016 level: 2,
22017 className: "dataviews-settings-section__title",
22018 children: (0, import_i18n30.__)("Appearance")
22019 }
22020 ),
22021 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(ResetViewButton, {})
22022 ]
22023 }
22024 ),
22025 /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22026 /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
22027 Stack,
22028 {
22029 direction: "row",
22030 gap: "sm",
22031 className: "dataviews-view-config__sort-controls",
22032 children: [
22033 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(SortFieldControl, {}),
22034 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(SortDirectionControl, {})
22035 ]
22036 }
22037 ),
22038 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(activeLayout.viewConfigOptions, {}),
22039 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(ItemsPerPageControl, {}),
22040 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(PropertiesSection, {})
22041 ] })
22042 ]
22043 }
22044 )
22045 }
22046 )
22047 }
22048 );
22049 }
22050 function _DataViewsViewConfig() {
22051 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(import_jsx_runtime83.Fragment, { children: [
22052 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(ViewTypeMenu, {}),
22053 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(DataviewsViewConfigDropdown, {})
22054 ] });
22055 }
22056 var DataViewsViewConfig = (0, import_element52.memo)(_DataViewsViewConfig);
22057 var dataviews_view_config_default = DataViewsViewConfig;
22058
22059 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22060 var import_components27 = __toESM(require_components(), 1);
22061 var import_element53 = __toESM(require_element(), 1);
22062
22063 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
22064 function getCustomValidity(isValid2, validity) {
22065 let customValidity;
22066 if (isValid2?.required && validity?.required) {
22067 customValidity = validity?.required?.message ? validity.required : void 0;
22068 } else if (isValid2?.pattern && validity?.pattern) {
22069 customValidity = validity.pattern;
22070 } else if (isValid2?.min && validity?.min) {
22071 customValidity = validity.min;
22072 } else if (isValid2?.max && validity?.max) {
22073 customValidity = validity.max;
22074 } else if (isValid2?.minLength && validity?.minLength) {
22075 customValidity = validity.minLength;
22076 } else if (isValid2?.maxLength && validity?.maxLength) {
22077 customValidity = validity.maxLength;
22078 } else if (isValid2?.elements && validity?.elements) {
22079 customValidity = validity.elements;
22080 } else if (validity?.custom) {
22081 customValidity = validity.custom;
22082 }
22083 return customValidity;
22084 }
22085
22086 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22087 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
22088 var { ValidatedCheckboxControl } = unlock3(import_components27.privateApis);
22089 function Checkbox({
22090 field,
22091 onChange,
22092 data,
22093 hideLabelFromVision,
22094 markWhenOptional,
22095 validity
22096 }) {
22097 const { getValue, setValue, label, description, isValid: isValid2 } = field;
22098 const disabled2 = field.isDisabled({ item: data, field });
22099 const onChangeControl = (0, import_element53.useCallback)(() => {
22100 onChange(
22101 setValue({ item: data, value: !getValue({ item: data }) })
22102 );
22103 }, [data, getValue, onChange, setValue]);
22104 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22105 ValidatedCheckboxControl,
22106 {
22107 required: !!field.isValid?.required,
22108 markWhenOptional,
22109 customValidity: getCustomValidity(isValid2, validity),
22110 hidden: hideLabelFromVision,
22111 label,
22112 help: description,
22113 checked: getValue({ item: data }),
22114 onChange: onChangeControl,
22115 disabled: disabled2
22116 }
22117 );
22118 }
22119
22120 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
22121 var import_components28 = __toESM(require_components(), 1);
22122 var import_element54 = __toESM(require_element(), 1);
22123 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
22124 var { ValidatedComboboxControl } = unlock3(import_components28.privateApis);
22125 function Combobox3({
22126 data,
22127 field,
22128 onChange,
22129 hideLabelFromVision,
22130 validity
22131 }) {
22132 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
22133 const value = getValue({ item: data }) ?? "";
22134 const onChangeControl = (0, import_element54.useCallback)(
22135 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
22136 [data, onChange, setValue]
22137 );
22138 const { elements, isLoading } = useElements({
22139 elements: field.elements,
22140 getElements: field.getElements
22141 });
22142 if (isLoading) {
22143 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(import_components28.Spinner, {});
22144 }
22145 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
22146 ValidatedComboboxControl,
22147 {
22148 required: !!field.isValid?.required,
22149 customValidity: getCustomValidity(isValid2, validity),
22150 label,
22151 value,
22152 help: description,
22153 placeholder,
22154 options: elements,
22155 onChange: onChangeControl,
22156 hideLabelFromVision,
22157 allowReset: true,
22158 expandOnFocus: true
22159 }
22160 );
22161 }
22162
22163 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22164 var import_components30 = __toESM(require_components(), 1);
22165 var import_element57 = __toESM(require_element(), 1);
22166 var import_i18n32 = __toESM(require_i18n(), 1);
22167 var import_date3 = __toESM(require_date(), 1);
22168
22169 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
22170 var import_components29 = __toESM(require_components(), 1);
22171 var import_element55 = __toESM(require_element(), 1);
22172 var import_i18n31 = __toESM(require_i18n(), 1);
22173 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
22174 var TIME_UNITS_OPTIONS = {
22175 [OPERATOR_IN_THE_PAST]: [
22176 { value: "days", label: (0, import_i18n31.__)("Days") },
22177 { value: "weeks", label: (0, import_i18n31.__)("Weeks") },
22178 { value: "months", label: (0, import_i18n31.__)("Months") },
22179 { value: "years", label: (0, import_i18n31.__)("Years") }
22180 ],
22181 [OPERATOR_OVER]: [
22182 { value: "days", label: (0, import_i18n31.__)("Days ago") },
22183 { value: "weeks", label: (0, import_i18n31.__)("Weeks ago") },
22184 { value: "months", label: (0, import_i18n31.__)("Months ago") },
22185 { value: "years", label: (0, import_i18n31.__)("Years ago") }
22186 ]
22187 };
22188 function RelativeDateControl({
22189 className,
22190 data,
22191 field,
22192 onChange,
22193 hideLabelFromVision,
22194 operator
22195 }) {
22196 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
22197 const { id, label, description, getValue, setValue } = field;
22198 const disabled2 = field.isDisabled({ item: data, field });
22199 const fieldValue = getValue({ item: data });
22200 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
22201 const onChangeValue = (0, import_element55.useCallback)(
22202 (newValue) => onChange(
22203 setValue({
22204 item: data,
22205 value: { value: Number(newValue), unit }
22206 })
22207 ),
22208 [onChange, setValue, data, unit]
22209 );
22210 const onChangeUnit = (0, import_element55.useCallback)(
22211 (newUnit) => onChange(
22212 setValue({
22213 item: data,
22214 value: { value: relValue, unit: newUnit }
22215 })
22216 ),
22217 [onChange, setValue, data, relValue]
22218 );
22219 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22220 import_components29.BaseControl,
22221 {
22222 id,
22223 className: clsx_default(className, "dataviews-controls__relative-date"),
22224 label,
22225 hideLabelFromVision,
22226 help: description,
22227 children: /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(Stack, { direction: "row", gap: "sm", children: [
22228 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22229 import_components29.__experimentalNumberControl,
22230 {
22231 __next40pxDefaultSize: true,
22232 className: "dataviews-controls__relative-date-number",
22233 spinControls: "none",
22234 min: 1,
22235 step: 1,
22236 value: relValue,
22237 onChange: onChangeValue,
22238 disabled: disabled2
22239 }
22240 ),
22241 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22242 import_components29.SelectControl,
22243 {
22244 className: "dataviews-controls__relative-date-unit",
22245 __next40pxDefaultSize: true,
22246 label: (0, import_i18n31.__)("Unit"),
22247 value: unit,
22248 options,
22249 onChange: onChangeUnit,
22250 hideLabelFromVision: true,
22251 disabled: disabled2
22252 }
22253 )
22254 ] })
22255 }
22256 );
22257 }
22258
22259 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
22260 var import_element56 = __toESM(require_element(), 1);
22261 function useDisabledDateMatchers(isValid2, parseDateFn) {
22262 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
22263 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
22264 const disabledMatchers = (0, import_element56.useMemo)(() => {
22265 const matchers = [];
22266 if (minConstraint) {
22267 const minDate = parseDateFn(minConstraint);
22268 if (minDate) {
22269 matchers.push({ before: minDate });
22270 }
22271 }
22272 if (maxConstraint) {
22273 const maxDate = parseDateFn(maxConstraint);
22274 if (maxDate) {
22275 matchers.push({ after: maxDate });
22276 }
22277 }
22278 return matchers.length > 0 ? matchers : void 0;
22279 }, [minConstraint, maxConstraint, parseDateFn]);
22280 return { minConstraint, maxConstraint, disabledMatchers };
22281 }
22282
22283 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
22284 var import_date2 = __toESM(require_date(), 1);
22285 function parseDateTime(dateTimeString) {
22286 if (!dateTimeString) {
22287 return null;
22288 }
22289 const parsed = (0, import_date2.getDate)(dateTimeString);
22290 return parsed && isValid(parsed) ? parsed : null;
22291 }
22292
22293 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22294 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
22295 var { DateCalendar, ValidatedInputControl } = unlock3(import_components30.privateApis);
22296 var formatDateTime = (value) => {
22297 if (!value) {
22298 return "";
22299 }
22300 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
22301 };
22302 function CalendarDateTimeControl({
22303 data,
22304 field,
22305 onChange,
22306 hideLabelFromVision,
22307 markWhenOptional,
22308 validity,
22309 config
22310 }) {
22311 const { compact } = config || {};
22312 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
22313 const disabled2 = field.isDisabled({ item: data, field });
22314 const fieldValue = getValue({ item: data });
22315 const value = typeof fieldValue === "string" ? fieldValue : void 0;
22316 const [calendarMonth, setCalendarMonth] = (0, import_element57.useState)(() => {
22317 const parsedDate = parseDateTime(value);
22318 return parsedDate || /* @__PURE__ */ new Date();
22319 });
22320 const inputControlRef = (0, import_element57.useRef)(null);
22321 const validationTimeoutRef = (0, import_element57.useRef)(void 0);
22322 const previousFocusRef = (0, import_element57.useRef)(null);
22323 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
22324 const onChangeCallback = (0, import_element57.useCallback)(
22325 (newValue) => onChange(setValue({ item: data, value: newValue })),
22326 [data, onChange, setValue]
22327 );
22328 (0, import_element57.useEffect)(() => {
22329 return () => {
22330 if (validationTimeoutRef.current) {
22331 clearTimeout(validationTimeoutRef.current);
22332 }
22333 };
22334 }, []);
22335 const onSelectDate = (0, import_element57.useCallback)(
22336 (newDate) => {
22337 let dateTimeValue;
22338 if (newDate) {
22339 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
22340 let wpTime;
22341 if (value) {
22342 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
22343 } else {
22344 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
22345 }
22346 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
22347 dateTimeValue = finalDateTime.toISOString();
22348 onChangeCallback(dateTimeValue);
22349 if (validationTimeoutRef.current) {
22350 clearTimeout(validationTimeoutRef.current);
22351 }
22352 } else {
22353 onChangeCallback(void 0);
22354 }
22355 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
22356 validationTimeoutRef.current = setTimeout(() => {
22357 if (inputControlRef.current) {
22358 inputControlRef.current.focus();
22359 inputControlRef.current.blur();
22360 onChangeCallback(dateTimeValue);
22361 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
22362 previousFocusRef.current.focus();
22363 }
22364 }
22365 }, 0);
22366 },
22367 [onChangeCallback, value]
22368 );
22369 const handleManualDateTimeChange = (0, import_element57.useCallback)(
22370 (newValue) => {
22371 if (newValue) {
22372 const dateTime = (0, import_date3.getDate)(newValue);
22373 onChangeCallback(dateTime.toISOString());
22374 const parsedDate = parseDateTime(dateTime.toISOString());
22375 if (parsedDate) {
22376 setCalendarMonth(parsedDate);
22377 }
22378 } else {
22379 onChangeCallback(void 0);
22380 }
22381 },
22382 [onChangeCallback]
22383 );
22384 const { format: fieldFormat } = field;
22385 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
22386 const {
22387 timezone: { string: timezoneString }
22388 } = (0, import_date3.getSettings)();
22389 let displayLabel = label;
22390 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
22391 displayLabel = `${label} (${(0, import_i18n32.__)("Required")})`;
22392 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
22393 displayLabel = `${label} (${(0, import_i18n32.__)("Optional")})`;
22394 }
22395 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22396 import_components30.BaseControl,
22397 {
22398 id,
22399 label: displayLabel,
22400 help: description,
22401 hideLabelFromVision,
22402 children: /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22403 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22404 ValidatedInputControl,
22405 {
22406 ref: inputControlRef,
22407 __next40pxDefaultSize: true,
22408 required: !!isValid2?.required,
22409 customValidity: getCustomValidity(isValid2, validity),
22410 type: "datetime-local",
22411 label: (0, import_i18n32.__)("Date time"),
22412 hideLabelFromVision: true,
22413 value: formatDateTime(value),
22414 onChange: handleManualDateTimeChange,
22415 disabled: disabled2,
22416 min: minConstraint ? formatDateTime(minConstraint) : void 0,
22417 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
22418 }
22419 ),
22420 !compact && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22421 DateCalendar,
22422 {
22423 style: { width: "100%" },
22424 selected: value ? parseDateTime(value) || void 0 : void 0,
22425 onSelect: onSelectDate,
22426 month: calendarMonth,
22427 onMonthChange: setCalendarMonth,
22428 timeZone: timezoneString || void 0,
22429 weekStartsOn,
22430 disabled: disabled2 || disabledMatchers
22431 }
22432 )
22433 ] })
22434 }
22435 );
22436 }
22437 function DateTime({
22438 data,
22439 field,
22440 onChange,
22441 hideLabelFromVision,
22442 markWhenOptional,
22443 operator,
22444 validity,
22445 config
22446 }) {
22447 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
22448 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22449 RelativeDateControl,
22450 {
22451 className: "dataviews-controls__datetime",
22452 data,
22453 field,
22454 onChange,
22455 hideLabelFromVision,
22456 operator
22457 }
22458 );
22459 }
22460 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22461 CalendarDateTimeControl,
22462 {
22463 data,
22464 field,
22465 onChange,
22466 hideLabelFromVision,
22467 markWhenOptional,
22468 validity,
22469 config
22470 }
22471 );
22472 }
22473
22474 // packages/dataviews/build-module/components/dataform-controls/date.mjs
22475 var import_components31 = __toESM(require_components(), 1);
22476 var import_element58 = __toESM(require_element(), 1);
22477 var import_i18n33 = __toESM(require_i18n(), 1);
22478 var import_date4 = __toESM(require_date(), 1);
22479 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
22480 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock3(import_components31.privateApis);
22481 var DATE_PRESETS = [
22482 {
22483 id: "today",
22484 label: (0, import_i18n33.__)("Today"),
22485 getValue: () => (0, import_date4.getDate)(null)
22486 },
22487 {
22488 id: "yesterday",
22489 label: (0, import_i18n33.__)("Yesterday"),
22490 getValue: () => {
22491 const today = (0, import_date4.getDate)(null);
22492 return subDays(today, 1);
22493 }
22494 },
22495 {
22496 id: "past-week",
22497 label: (0, import_i18n33.__)("Past week"),
22498 getValue: () => {
22499 const today = (0, import_date4.getDate)(null);
22500 return subDays(today, 7);
22501 }
22502 },
22503 {
22504 id: "past-month",
22505 label: (0, import_i18n33.__)("Past month"),
22506 getValue: () => {
22507 const today = (0, import_date4.getDate)(null);
22508 return subMonths(today, 1);
22509 }
22510 }
22511 ];
22512 var DATE_RANGE_PRESETS = [
22513 {
22514 id: "last-7-days",
22515 label: (0, import_i18n33.__)("Last 7 days"),
22516 getValue: () => {
22517 const today = (0, import_date4.getDate)(null);
22518 return [subDays(today, 7), today];
22519 }
22520 },
22521 {
22522 id: "last-30-days",
22523 label: (0, import_i18n33.__)("Last 30 days"),
22524 getValue: () => {
22525 const today = (0, import_date4.getDate)(null);
22526 return [subDays(today, 30), today];
22527 }
22528 },
22529 {
22530 id: "month-to-date",
22531 label: (0, import_i18n33.__)("Month to date"),
22532 getValue: () => {
22533 const today = (0, import_date4.getDate)(null);
22534 return [startOfMonth(today), today];
22535 }
22536 },
22537 {
22538 id: "last-year",
22539 label: (0, import_i18n33.__)("Last year"),
22540 getValue: () => {
22541 const today = (0, import_date4.getDate)(null);
22542 return [subYears(today, 1), today];
22543 }
22544 },
22545 {
22546 id: "year-to-date",
22547 label: (0, import_i18n33.__)("Year to date"),
22548 getValue: () => {
22549 const today = (0, import_date4.getDate)(null);
22550 return [startOfYear(today), today];
22551 }
22552 }
22553 ];
22554 var parseDate = (dateString) => {
22555 if (!dateString) {
22556 return null;
22557 }
22558 const parsed = (0, import_date4.getDate)(dateString);
22559 return parsed && isValid(parsed) ? parsed : null;
22560 };
22561 var formatDate = (date) => {
22562 if (!date) {
22563 return "";
22564 }
22565 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
22566 };
22567 function ValidatedDateControl({
22568 field,
22569 validity,
22570 inputRefs,
22571 isTouched,
22572 setIsTouched,
22573 children
22574 }) {
22575 const { isValid: isValid2 } = field;
22576 const [customValidity, setCustomValidity] = (0, import_element58.useState)(void 0);
22577 const validateRefs = (0, import_element58.useCallback)(() => {
22578 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
22579 for (const ref of refs) {
22580 const input = ref.current;
22581 if (input && !input.validity.valid) {
22582 setCustomValidity({
22583 type: "invalid",
22584 message: input.validationMessage
22585 });
22586 return;
22587 }
22588 }
22589 setCustomValidity(void 0);
22590 }, [inputRefs]);
22591 (0, import_element58.useEffect)(() => {
22592 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
22593 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
22594 for (const ref of refs) {
22595 const input = ref.current;
22596 if (input) {
22597 input.setCustomValidity(
22598 result?.type === "invalid" && result.message ? result.message : ""
22599 );
22600 }
22601 }
22602 }, [inputRefs, isValid2, validity]);
22603 (0, import_element58.useEffect)(() => {
22604 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
22605 const handleInvalid = (event) => {
22606 event.preventDefault();
22607 setIsTouched(true);
22608 };
22609 for (const ref of refs) {
22610 ref.current?.addEventListener("invalid", handleInvalid);
22611 }
22612 return () => {
22613 for (const ref of refs) {
22614 ref.current?.removeEventListener("invalid", handleInvalid);
22615 }
22616 };
22617 }, [inputRefs, setIsTouched]);
22618 (0, import_element58.useEffect)(() => {
22619 if (!isTouched) {
22620 return;
22621 }
22622 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
22623 if (result) {
22624 setCustomValidity(result);
22625 } else {
22626 validateRefs();
22627 }
22628 }, [isTouched, isValid2, validity, validateRefs]);
22629 const onBlur = (event) => {
22630 if (isTouched) {
22631 return;
22632 }
22633 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
22634 setIsTouched(true);
22635 }
22636 };
22637 return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)("div", { onBlur, children: [
22638 children,
22639 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(
22640 "p",
22641 {
22642 className: clsx_default(
22643 "components-validated-control__indicator",
22644 customValidity.type === "invalid" ? "is-invalid" : void 0
22645 ),
22646 children: [
22647 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22648 import_components31.Icon,
22649 {
22650 className: "components-validated-control__indicator-icon",
22651 icon: error_default,
22652 size: 16,
22653 fill: "currentColor"
22654 }
22655 ),
22656 customValidity.message
22657 ]
22658 }
22659 ) })
22660 ] });
22661 }
22662 function CalendarDateControl({
22663 data,
22664 field,
22665 onChange,
22666 hideLabelFromVision,
22667 markWhenOptional,
22668 validity
22669 }) {
22670 const {
22671 id,
22672 label,
22673 description,
22674 setValue,
22675 getValue,
22676 isValid: isValid2,
22677 format: fieldFormat
22678 } = field;
22679 const disabled2 = field.isDisabled({ item: data, field });
22680 const [selectedPresetId, setSelectedPresetId] = (0, import_element58.useState)(
22681 null
22682 );
22683 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
22684 const fieldValue = getValue({ item: data });
22685 const value = typeof fieldValue === "string" ? fieldValue : void 0;
22686 const [calendarMonth, setCalendarMonth] = (0, import_element58.useState)(() => {
22687 const parsedDate = parseDate(value);
22688 return parsedDate || /* @__PURE__ */ new Date();
22689 });
22690 const [isTouched, setIsTouched] = (0, import_element58.useState)(false);
22691 const validityTargetRef = (0, import_element58.useRef)(null);
22692 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
22693 const onChangeCallback = (0, import_element58.useCallback)(
22694 (newValue) => onChange(setValue({ item: data, value: newValue })),
22695 [data, onChange, setValue]
22696 );
22697 const onSelectDate = (0, import_element58.useCallback)(
22698 (newDate) => {
22699 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
22700 onChangeCallback(dateValue);
22701 setSelectedPresetId(null);
22702 setIsTouched(true);
22703 },
22704 [onChangeCallback]
22705 );
22706 const handlePresetClick = (0, import_element58.useCallback)(
22707 (preset) => {
22708 const presetDate = preset.getValue();
22709 const dateValue = formatDate(presetDate);
22710 setCalendarMonth(presetDate);
22711 onChangeCallback(dateValue);
22712 setSelectedPresetId(preset.id);
22713 setIsTouched(true);
22714 },
22715 [onChangeCallback]
22716 );
22717 const handleManualDateChange = (0, import_element58.useCallback)(
22718 (newValue) => {
22719 onChangeCallback(newValue);
22720 if (newValue) {
22721 const parsedDate = parseDate(newValue);
22722 if (parsedDate) {
22723 setCalendarMonth(parsedDate);
22724 }
22725 }
22726 setSelectedPresetId(null);
22727 setIsTouched(true);
22728 },
22729 [onChangeCallback]
22730 );
22731 const {
22732 timezone: { string: timezoneString }
22733 } = (0, import_date4.getSettings)();
22734 let displayLabel = label;
22735 if (isValid2?.required && !markWhenOptional) {
22736 displayLabel = `${label} (${(0, import_i18n33.__)("Required")})`;
22737 } else if (!isValid2?.required && markWhenOptional) {
22738 displayLabel = `${label} (${(0, import_i18n33.__)("Optional")})`;
22739 }
22740 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22741 ValidatedDateControl,
22742 {
22743 field,
22744 validity,
22745 inputRefs: validityTargetRef,
22746 isTouched,
22747 setIsTouched,
22748 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22749 import_components31.BaseControl,
22750 {
22751 id,
22752 className: "dataviews-controls__date",
22753 label: displayLabel,
22754 help: description,
22755 hideLabelFromVision,
22756 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22757 /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(
22758 Stack,
22759 {
22760 direction: "row",
22761 gap: "sm",
22762 wrap: "wrap",
22763 justify: "flex-start",
22764 children: [
22765 DATE_PRESETS.map((preset) => {
22766 const isSelected2 = selectedPresetId === preset.id;
22767 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22768 import_components31.Button,
22769 {
22770 className: "dataviews-controls__date-preset",
22771 variant: "tertiary",
22772 isPressed: isSelected2,
22773 size: "small",
22774 disabled: disabled2,
22775 accessibleWhenDisabled: true,
22776 onClick: () => handlePresetClick(preset),
22777 children: preset.label
22778 },
22779 preset.id
22780 );
22781 }),
22782 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22783 import_components31.Button,
22784 {
22785 className: "dataviews-controls__date-preset",
22786 variant: "tertiary",
22787 isPressed: !selectedPresetId,
22788 size: "small",
22789 disabled: !!selectedPresetId || disabled2,
22790 accessibleWhenDisabled: true,
22791 children: (0, import_i18n33.__)("Custom")
22792 }
22793 )
22794 ]
22795 }
22796 ),
22797 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22798 import_components31.__experimentalInputControl,
22799 {
22800 __next40pxDefaultSize: true,
22801 ref: validityTargetRef,
22802 type: "date",
22803 label: (0, import_i18n33.__)("Date"),
22804 hideLabelFromVision: true,
22805 value,
22806 onChange: handleManualDateChange,
22807 required: !!field.isValid?.required,
22808 disabled: disabled2,
22809 min: minConstraint,
22810 max: maxConstraint
22811 }
22812 ),
22813 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22814 DateCalendar2,
22815 {
22816 style: { width: "100%" },
22817 selected: value ? parseDate(value) || void 0 : void 0,
22818 onSelect: onSelectDate,
22819 month: calendarMonth,
22820 onMonthChange: setCalendarMonth,
22821 timeZone: timezoneString || void 0,
22822 weekStartsOn,
22823 disabled: disabled2 || disabledMatchers,
22824 disableNavigation: disabled2
22825 }
22826 )
22827 ] })
22828 }
22829 )
22830 }
22831 );
22832 }
22833 function CalendarDateRangeControl({
22834 data,
22835 field,
22836 onChange,
22837 hideLabelFromVision,
22838 markWhenOptional,
22839 validity
22840 }) {
22841 const {
22842 id,
22843 label,
22844 description,
22845 getValue,
22846 setValue,
22847 isValid: isValid2,
22848 format: fieldFormat
22849 } = field;
22850 const disabled2 = field.isDisabled({ item: data, field });
22851 let value;
22852 const fieldValue = getValue({ item: data });
22853 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
22854 value = fieldValue;
22855 }
22856 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
22857 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
22858 const onChangeCallback = (0, import_element58.useCallback)(
22859 (newValue) => {
22860 onChange(
22861 setValue({
22862 item: data,
22863 value: newValue
22864 })
22865 );
22866 },
22867 [data, onChange, setValue]
22868 );
22869 const [selectedPresetId, setSelectedPresetId] = (0, import_element58.useState)(
22870 null
22871 );
22872 const selectedRange = (0, import_element58.useMemo)(() => {
22873 if (!value) {
22874 return { from: void 0, to: void 0 };
22875 }
22876 const [from, to] = value;
22877 return {
22878 from: parseDate(from) || void 0,
22879 to: parseDate(to) || void 0
22880 };
22881 }, [value]);
22882 const [calendarMonth, setCalendarMonth] = (0, import_element58.useState)(() => {
22883 return selectedRange.from || /* @__PURE__ */ new Date();
22884 });
22885 const [isTouched, setIsTouched] = (0, import_element58.useState)(false);
22886 const fromInputRef = (0, import_element58.useRef)(null);
22887 const toInputRef = (0, import_element58.useRef)(null);
22888 const updateDateRange = (0, import_element58.useCallback)(
22889 (fromDate, toDate2) => {
22890 if (fromDate && toDate2) {
22891 onChangeCallback([
22892 formatDate(fromDate),
22893 formatDate(toDate2)
22894 ]);
22895 } else if (!fromDate && !toDate2) {
22896 onChangeCallback(void 0);
22897 }
22898 },
22899 [onChangeCallback]
22900 );
22901 const onSelectCalendarRange = (0, import_element58.useCallback)(
22902 (newRange) => {
22903 updateDateRange(newRange?.from, newRange?.to);
22904 setSelectedPresetId(null);
22905 setIsTouched(true);
22906 },
22907 [updateDateRange]
22908 );
22909 const handlePresetClick = (0, import_element58.useCallback)(
22910 (preset) => {
22911 const [startDate, endDate] = preset.getValue();
22912 setCalendarMonth(startDate);
22913 updateDateRange(startDate, endDate);
22914 setSelectedPresetId(preset.id);
22915 setIsTouched(true);
22916 },
22917 [updateDateRange]
22918 );
22919 const handleManualDateChange = (0, import_element58.useCallback)(
22920 (fromOrTo, newValue) => {
22921 const [currentFrom, currentTo] = value || [
22922 void 0,
22923 void 0
22924 ];
22925 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
22926 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
22927 updateDateRange(updatedFrom, updatedTo);
22928 if (newValue) {
22929 const parsedDate = parseDate(newValue);
22930 if (parsedDate) {
22931 setCalendarMonth(parsedDate);
22932 }
22933 }
22934 setSelectedPresetId(null);
22935 setIsTouched(true);
22936 },
22937 [value, updateDateRange]
22938 );
22939 const { timezone } = (0, import_date4.getSettings)();
22940 let displayLabel = label;
22941 if (field.isValid?.required && !markWhenOptional) {
22942 displayLabel = `${label} (${(0, import_i18n33.__)("Required")})`;
22943 } else if (!field.isValid?.required && markWhenOptional) {
22944 displayLabel = `${label} (${(0, import_i18n33.__)("Optional")})`;
22945 }
22946 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22947 ValidatedDateControl,
22948 {
22949 field,
22950 validity,
22951 inputRefs: [fromInputRef, toInputRef],
22952 isTouched,
22953 setIsTouched,
22954 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22955 import_components31.BaseControl,
22956 {
22957 id,
22958 className: "dataviews-controls__date",
22959 label: displayLabel,
22960 help: description,
22961 hideLabelFromVision,
22962 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22963 /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(
22964 Stack,
22965 {
22966 direction: "row",
22967 gap: "sm",
22968 wrap: "wrap",
22969 justify: "flex-start",
22970 children: [
22971 DATE_RANGE_PRESETS.map((preset) => {
22972 const isSelected2 = selectedPresetId === preset.id;
22973 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22974 import_components31.Button,
22975 {
22976 className: "dataviews-controls__date-preset",
22977 variant: "tertiary",
22978 isPressed: isSelected2,
22979 size: "small",
22980 disabled: disabled2,
22981 accessibleWhenDisabled: true,
22982 onClick: () => handlePresetClick(preset),
22983 children: preset.label
22984 },
22985 preset.id
22986 );
22987 }),
22988 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22989 import_components31.Button,
22990 {
22991 className: "dataviews-controls__date-preset",
22992 variant: "tertiary",
22993 isPressed: !selectedPresetId,
22994 size: "small",
22995 accessibleWhenDisabled: true,
22996 disabled: !!selectedPresetId || disabled2,
22997 children: (0, import_i18n33.__)("Custom")
22998 }
22999 )
23000 ]
23001 }
23002 ),
23003 /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(
23004 Stack,
23005 {
23006 direction: "row",
23007 gap: "sm",
23008 justify: "space-between",
23009 className: "dataviews-controls__date-range-inputs",
23010 children: [
23011 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
23012 import_components31.__experimentalInputControl,
23013 {
23014 __next40pxDefaultSize: true,
23015 ref: fromInputRef,
23016 type: "date",
23017 label: (0, import_i18n33.__)("From"),
23018 hideLabelFromVision: true,
23019 value: value?.[0],
23020 onChange: (newValue) => handleManualDateChange("from", newValue),
23021 required: !!field.isValid?.required,
23022 disabled: disabled2,
23023 min: minConstraint,
23024 max: maxConstraint
23025 }
23026 ),
23027 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
23028 import_components31.__experimentalInputControl,
23029 {
23030 __next40pxDefaultSize: true,
23031 ref: toInputRef,
23032 type: "date",
23033 label: (0, import_i18n33.__)("To"),
23034 hideLabelFromVision: true,
23035 value: value?.[1],
23036 onChange: (newValue) => handleManualDateChange("to", newValue),
23037 required: !!field.isValid?.required,
23038 disabled: disabled2,
23039 min: minConstraint,
23040 max: maxConstraint
23041 }
23042 )
23043 ]
23044 }
23045 ),
23046 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
23047 DateRangeCalendar,
23048 {
23049 style: { width: "100%" },
23050 selected: selectedRange,
23051 onSelect: onSelectCalendarRange,
23052 month: calendarMonth,
23053 onMonthChange: setCalendarMonth,
23054 timeZone: timezone.string || void 0,
23055 weekStartsOn,
23056 disabled: disabled2 || disabledMatchers
23057 }
23058 )
23059 ] })
23060 }
23061 )
23062 }
23063 );
23064 }
23065 function DateControl({
23066 data,
23067 field,
23068 onChange,
23069 hideLabelFromVision,
23070 markWhenOptional,
23071 operator,
23072 validity
23073 }) {
23074 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23075 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
23076 RelativeDateControl,
23077 {
23078 className: "dataviews-controls__date",
23079 data,
23080 field,
23081 onChange,
23082 hideLabelFromVision,
23083 operator
23084 }
23085 );
23086 }
23087 if (operator === OPERATOR_BETWEEN) {
23088 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
23089 CalendarDateRangeControl,
23090 {
23091 data,
23092 field,
23093 onChange,
23094 hideLabelFromVision,
23095 markWhenOptional,
23096 validity
23097 }
23098 );
23099 }
23100 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
23101 CalendarDateControl,
23102 {
23103 data,
23104 field,
23105 onChange,
23106 hideLabelFromVision,
23107 markWhenOptional,
23108 validity
23109 }
23110 );
23111 }
23112
23113 // packages/dataviews/build-module/components/dataform-controls/select.mjs
23114 var import_components32 = __toESM(require_components(), 1);
23115 var import_element59 = __toESM(require_element(), 1);
23116 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
23117 var { ValidatedSelectControl } = unlock3(import_components32.privateApis);
23118 function Select({
23119 data,
23120 field,
23121 onChange,
23122 hideLabelFromVision,
23123 markWhenOptional,
23124 validity
23125 }) {
23126 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
23127 const disabled2 = field.isDisabled({ item: data, field });
23128 const isMultiple = type === "array";
23129 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
23130 const onChangeControl = (0, import_element59.useCallback)(
23131 (newValue) => onChange(setValue({ item: data, value: newValue })),
23132 [data, onChange, setValue]
23133 );
23134 const { elements, isLoading } = useElements({
23135 elements: field.elements,
23136 getElements: field.getElements
23137 });
23138 if (isLoading) {
23139 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components32.Spinner, {});
23140 }
23141 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23142 ValidatedSelectControl,
23143 {
23144 required: !!field.isValid?.required,
23145 markWhenOptional,
23146 customValidity: getCustomValidity(isValid2, validity),
23147 label,
23148 value,
23149 help: description,
23150 options: elements,
23151 onChange: onChangeControl,
23152 __next40pxDefaultSize: true,
23153 hideLabelFromVision,
23154 multiple: isMultiple,
23155 disabled: disabled2
23156 }
23157 );
23158 }
23159
23160 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
23161 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
23162 var ELEMENTS_THRESHOLD = 10;
23163 function AdaptiveSelect(props) {
23164 const { field } = props;
23165 const { elements } = useElements({
23166 elements: field.elements,
23167 getElements: field.getElements
23168 });
23169 if (elements.length >= ELEMENTS_THRESHOLD) {
23170 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Combobox3, { ...props });
23171 }
23172 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Select, { ...props });
23173 }
23174
23175 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23176 var import_components34 = __toESM(require_components(), 1);
23177
23178 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
23179 var import_components33 = __toESM(require_components(), 1);
23180 var import_element60 = __toESM(require_element(), 1);
23181 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
23182 var { ValidatedInputControl: ValidatedInputControl2 } = unlock3(import_components33.privateApis);
23183 function ValidatedText({
23184 data,
23185 field,
23186 onChange,
23187 hideLabelFromVision,
23188 markWhenOptional,
23189 type,
23190 prefix,
23191 suffix,
23192 validity
23193 }) {
23194 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
23195 const value = getValue({ item: data });
23196 const disabled2 = field.isDisabled({ item: data, field });
23197 const onChangeControl = (0, import_element60.useCallback)(
23198 (newValue) => onChange(
23199 setValue({
23200 item: data,
23201 value: newValue
23202 })
23203 ),
23204 [data, setValue, onChange]
23205 );
23206 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
23207 ValidatedInputControl2,
23208 {
23209 required: !!isValid2.required,
23210 markWhenOptional,
23211 customValidity: getCustomValidity(isValid2, validity),
23212 label,
23213 placeholder,
23214 value: value ?? "",
23215 help: description,
23216 onChange: onChangeControl,
23217 hideLabelFromVision,
23218 type,
23219 prefix,
23220 suffix,
23221 disabled: disabled2,
23222 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
23223 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
23224 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
23225 __next40pxDefaultSize: true
23226 }
23227 );
23228 }
23229
23230 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23231 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
23232 function Email({
23233 data,
23234 field,
23235 onChange,
23236 hideLabelFromVision,
23237 markWhenOptional,
23238 validity
23239 }) {
23240 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
23241 ValidatedText,
23242 {
23243 ...{
23244 data,
23245 field,
23246 onChange,
23247 hideLabelFromVision,
23248 markWhenOptional,
23249 validity,
23250 type: "email",
23251 prefix: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_components34.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_components34.Icon, { icon: envelope_default }) })
23252 }
23253 }
23254 );
23255 }
23256
23257 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
23258 var import_components35 = __toESM(require_components(), 1);
23259 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
23260 function Telephone({
23261 data,
23262 field,
23263 onChange,
23264 hideLabelFromVision,
23265 markWhenOptional,
23266 validity
23267 }) {
23268 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
23269 ValidatedText,
23270 {
23271 ...{
23272 data,
23273 field,
23274 onChange,
23275 hideLabelFromVision,
23276 markWhenOptional,
23277 validity,
23278 type: "tel",
23279 prefix: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components35.Icon, { icon: mobile_default }) })
23280 }
23281 }
23282 );
23283 }
23284
23285 // packages/dataviews/build-module/components/dataform-controls/url.mjs
23286 var import_components36 = __toESM(require_components(), 1);
23287 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
23288 function Url({
23289 data,
23290 field,
23291 onChange,
23292 hideLabelFromVision,
23293 markWhenOptional,
23294 validity
23295 }) {
23296 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23297 ValidatedText,
23298 {
23299 ...{
23300 data,
23301 field,
23302 onChange,
23303 hideLabelFromVision,
23304 markWhenOptional,
23305 validity,
23306 type: "url",
23307 prefix: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components36.Icon, { icon: link_default }) })
23308 }
23309 }
23310 );
23311 }
23312
23313 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
23314 var import_components37 = __toESM(require_components(), 1);
23315 var import_element61 = __toESM(require_element(), 1);
23316 var import_i18n34 = __toESM(require_i18n(), 1);
23317 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
23318 var { ValidatedNumberControl } = unlock3(import_components37.privateApis);
23319 function toNumberOrEmpty(value) {
23320 if (value === "" || value === void 0) {
23321 return "";
23322 }
23323 const number = Number(value);
23324 return Number.isFinite(number) ? number : "";
23325 }
23326 function BetweenControls({
23327 value,
23328 onChange,
23329 hideLabelFromVision,
23330 step
23331 }) {
23332 const [min2 = "", max2 = ""] = value;
23333 const onChangeMin = (0, import_element61.useCallback)(
23334 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
23335 [onChange, max2]
23336 );
23337 const onChangeMax = (0, import_element61.useCallback)(
23338 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
23339 [onChange, min2]
23340 );
23341 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23342 import_components37.BaseControl,
23343 {
23344 help: (0, import_i18n34.__)("The max. value must be greater than the min. value."),
23345 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(import_components37.Flex, { direction: "row", gap: 4, children: [
23346 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23347 import_components37.__experimentalNumberControl,
23348 {
23349 label: (0, import_i18n34.__)("Min."),
23350 value: min2,
23351 max: max2 ? Number(max2) - step : void 0,
23352 onChange: onChangeMin,
23353 __next40pxDefaultSize: true,
23354 hideLabelFromVision,
23355 step
23356 }
23357 ),
23358 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23359 import_components37.__experimentalNumberControl,
23360 {
23361 label: (0, import_i18n34.__)("Max."),
23362 value: max2,
23363 min: min2 ? Number(min2) + step : void 0,
23364 onChange: onChangeMax,
23365 __next40pxDefaultSize: true,
23366 hideLabelFromVision,
23367 step
23368 }
23369 )
23370 ] })
23371 }
23372 );
23373 }
23374 function ValidatedNumber({
23375 data,
23376 field,
23377 onChange,
23378 hideLabelFromVision,
23379 markWhenOptional,
23380 operator,
23381 validity
23382 }) {
23383 const decimals = field.format?.decimals ?? 0;
23384 const step = Math.pow(10, Math.abs(decimals) * -1);
23385 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23386 const value = getValue({ item: data }) ?? "";
23387 const disabled2 = field.isDisabled({ item: data, field });
23388 const onChangeControl = (0, import_element61.useCallback)(
23389 (newValue) => {
23390 onChange(
23391 setValue({
23392 item: data,
23393 // Do not convert an empty string or undefined to a number,
23394 // otherwise there's a mismatch between the UI control (empty)
23395 // and the data relied by onChange (0).
23396 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
23397 })
23398 );
23399 },
23400 [data, onChange, setValue]
23401 );
23402 const onChangeBetweenControls = (0, import_element61.useCallback)(
23403 (newValue) => {
23404 onChange(
23405 setValue({
23406 item: data,
23407 value: newValue
23408 })
23409 );
23410 },
23411 [data, onChange, setValue]
23412 );
23413 if (operator === OPERATOR_BETWEEN) {
23414 let valueBetween = ["", ""];
23415 if (Array.isArray(value) && value.length === 2 && value.every(
23416 (element) => typeof element === "number" || element === ""
23417 )) {
23418 valueBetween = value;
23419 }
23420 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23421 BetweenControls,
23422 {
23423 value: valueBetween,
23424 onChange: onChangeBetweenControls,
23425 hideLabelFromVision,
23426 step
23427 }
23428 );
23429 }
23430 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23431 ValidatedNumberControl,
23432 {
23433 required: !!isValid2.required,
23434 markWhenOptional,
23435 customValidity: getCustomValidity(isValid2, validity),
23436 label,
23437 help: description,
23438 value,
23439 onChange: onChangeControl,
23440 __next40pxDefaultSize: true,
23441 hideLabelFromVision,
23442 step,
23443 min: isValid2.min ? isValid2.min.constraint : void 0,
23444 max: isValid2.max ? isValid2.max.constraint : void 0,
23445 disabled: disabled2
23446 }
23447 );
23448 }
23449
23450 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
23451 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
23452 function Integer(props) {
23453 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(ValidatedNumber, { ...props });
23454 }
23455
23456 // packages/dataviews/build-module/components/dataform-controls/number.mjs
23457 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
23458 function Number2(props) {
23459 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(ValidatedNumber, { ...props });
23460 }
23461
23462 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
23463 var import_components38 = __toESM(require_components(), 1);
23464 var import_element62 = __toESM(require_element(), 1);
23465 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
23466 var { ValidatedRadioControl } = unlock3(import_components38.privateApis);
23467 function Radio({
23468 data,
23469 field,
23470 onChange,
23471 hideLabelFromVision,
23472 markWhenOptional,
23473 validity
23474 }) {
23475 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23476 const disabled2 = field.isDisabled({ item: data, field });
23477 const { elements, isLoading } = useElements({
23478 elements: field.elements,
23479 getElements: field.getElements
23480 });
23481 const value = getValue({ item: data });
23482 const onChangeControl = (0, import_element62.useCallback)(
23483 (newValue) => onChange(setValue({ item: data, value: newValue })),
23484 [data, onChange, setValue]
23485 );
23486 if (isLoading) {
23487 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_components38.Spinner, {});
23488 }
23489 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
23490 ValidatedRadioControl,
23491 {
23492 required: !!field.isValid?.required,
23493 markWhenOptional,
23494 customValidity: getCustomValidity(isValid2, validity),
23495 label,
23496 help: description,
23497 onChange: onChangeControl,
23498 options: elements,
23499 selected: value,
23500 hideLabelFromVision,
23501 disabled: disabled2
23502 }
23503 );
23504 }
23505
23506 // packages/dataviews/build-module/components/dataform-controls/text.mjs
23507 var import_element63 = __toESM(require_element(), 1);
23508 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
23509 function Text3({
23510 data,
23511 field,
23512 onChange,
23513 hideLabelFromVision,
23514 markWhenOptional,
23515 config,
23516 validity
23517 }) {
23518 const { prefix, suffix } = config || {};
23519 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
23520 ValidatedText,
23521 {
23522 ...{
23523 data,
23524 field,
23525 onChange,
23526 hideLabelFromVision,
23527 markWhenOptional,
23528 validity,
23529 prefix: prefix ? (0, import_element63.createElement)(prefix) : void 0,
23530 suffix: suffix ? (0, import_element63.createElement)(suffix) : void 0
23531 }
23532 }
23533 );
23534 }
23535
23536 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
23537 var import_components39 = __toESM(require_components(), 1);
23538 var import_element64 = __toESM(require_element(), 1);
23539 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
23540 var { ValidatedToggleControl } = unlock3(import_components39.privateApis);
23541 function Toggle({
23542 field,
23543 onChange,
23544 data,
23545 hideLabelFromVision,
23546 markWhenOptional,
23547 validity
23548 }) {
23549 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23550 const disabled2 = field.isDisabled({ item: data, field });
23551 const onChangeControl = (0, import_element64.useCallback)(() => {
23552 onChange(
23553 setValue({ item: data, value: !getValue({ item: data }) })
23554 );
23555 }, [onChange, setValue, data, getValue]);
23556 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
23557 ValidatedToggleControl,
23558 {
23559 required: !!isValid2.required,
23560 markWhenOptional,
23561 customValidity: getCustomValidity(isValid2, validity),
23562 hidden: hideLabelFromVision,
23563 label,
23564 help: description,
23565 checked: getValue({ item: data }),
23566 onChange: onChangeControl,
23567 disabled: disabled2
23568 }
23569 );
23570 }
23571
23572 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
23573 var import_components40 = __toESM(require_components(), 1);
23574 var import_element65 = __toESM(require_element(), 1);
23575 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
23576 var { ValidatedTextareaControl } = unlock3(import_components40.privateApis);
23577 function Textarea({
23578 data,
23579 field,
23580 onChange,
23581 hideLabelFromVision,
23582 markWhenOptional,
23583 config,
23584 validity
23585 }) {
23586 const { rows = 4 } = config || {};
23587 const disabled2 = field.isDisabled({ item: data, field });
23588 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
23589 const value = field.getValue({ item: data });
23590 const onChangeControl = (0, import_element65.useCallback)(
23591 (newValue) => onChange(setValue({ item: data, value: newValue })),
23592 [data, onChange, setValue]
23593 );
23594 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
23595 ValidatedTextareaControl,
23596 {
23597 required: !!isValid2.required,
23598 markWhenOptional,
23599 customValidity: getCustomValidity(isValid2, validity),
23600 label,
23601 placeholder,
23602 value: value ?? "",
23603 help: description,
23604 onChange: onChangeControl,
23605 rows,
23606 disabled: disabled2,
23607 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
23608 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
23609 __next40pxDefaultSize: true,
23610 hideLabelFromVision
23611 }
23612 );
23613 }
23614
23615 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
23616 var import_components41 = __toESM(require_components(), 1);
23617 var import_element66 = __toESM(require_element(), 1);
23618 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
23619 var { ValidatedToggleGroupControl } = unlock3(import_components41.privateApis);
23620 function ToggleGroup({
23621 data,
23622 field,
23623 onChange,
23624 hideLabelFromVision,
23625 markWhenOptional,
23626 validity
23627 }) {
23628 const { getValue, setValue, isValid: isValid2 } = field;
23629 const disabled2 = field.isDisabled({ item: data, field });
23630 const value = getValue({ item: data });
23631 const onChangeControl = (0, import_element66.useCallback)(
23632 (newValue) => onChange(setValue({ item: data, value: newValue })),
23633 [data, onChange, setValue]
23634 );
23635 const { elements, isLoading } = useElements({
23636 elements: field.elements,
23637 getElements: field.getElements
23638 });
23639 if (isLoading) {
23640 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components41.Spinner, {});
23641 }
23642 if (elements.length === 0) {
23643 return null;
23644 }
23645 const selectedOption = elements.find((el) => el.value === value);
23646 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
23647 ValidatedToggleGroupControl,
23648 {
23649 required: !!field.isValid?.required,
23650 markWhenOptional,
23651 customValidity: getCustomValidity(isValid2, validity),
23652 __next40pxDefaultSize: true,
23653 isBlock: true,
23654 label: field.label,
23655 help: selectedOption?.description || field.description,
23656 onChange: onChangeControl,
23657 value,
23658 hideLabelFromVision,
23659 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
23660 import_components41.__experimentalToggleGroupControlOption,
23661 {
23662 label: el.label,
23663 value: el.value,
23664 disabled: disabled2
23665 },
23666 el.value
23667 ))
23668 }
23669 );
23670 }
23671
23672 // packages/dataviews/build-module/components/dataform-controls/array.mjs
23673 var import_components42 = __toESM(require_components(), 1);
23674 var import_element67 = __toESM(require_element(), 1);
23675 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
23676 var { ValidatedFormTokenField } = unlock3(import_components42.privateApis);
23677 function ArrayControl({
23678 data,
23679 field,
23680 onChange,
23681 hideLabelFromVision,
23682 markWhenOptional,
23683 validity
23684 }) {
23685 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
23686 const value = getValue({ item: data });
23687 const disabled2 = field.isDisabled({ item: data, field });
23688 const { elements, isLoading } = useElements({
23689 elements: field.elements,
23690 getElements: field.getElements
23691 });
23692 const arrayValueAsElements = (0, import_element67.useMemo)(
23693 () => Array.isArray(value) ? value.map((token) => {
23694 const element = elements?.find(
23695 (suggestion) => suggestion.value === token
23696 );
23697 return element || { value: token, label: token };
23698 }) : [],
23699 [value, elements]
23700 );
23701 const onChangeControl = (0, import_element67.useCallback)(
23702 (tokens) => {
23703 const valueTokens = tokens.map((token) => {
23704 if (typeof token === "object" && "value" in token) {
23705 return token.value;
23706 }
23707 return token;
23708 });
23709 onChange(setValue({ item: data, value: valueTokens }));
23710 },
23711 [onChange, setValue, data]
23712 );
23713 if (isLoading) {
23714 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_components42.Spinner, {});
23715 }
23716 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
23717 ValidatedFormTokenField,
23718 {
23719 required: !!isValid2?.required,
23720 markWhenOptional,
23721 customValidity: getCustomValidity(isValid2, validity),
23722 label: hideLabelFromVision ? void 0 : label,
23723 value: arrayValueAsElements,
23724 onChange: onChangeControl,
23725 placeholder,
23726 suggestions: elements?.map((element) => element.value),
23727 disabled: disabled2,
23728 __experimentalValidateInput: (token) => {
23729 if (field.isValid?.elements && elements) {
23730 return elements.some(
23731 (element) => element.value === token || element.label === token
23732 );
23733 }
23734 return true;
23735 },
23736 __experimentalExpandOnFocus: elements && elements.length > 0,
23737 help: description ?? (field.isValid?.elements ? "" : void 0),
23738 displayTransform: (token) => {
23739 if (typeof token === "object" && "label" in token) {
23740 return token.label;
23741 }
23742 if (typeof token === "string" && elements) {
23743 const element = elements.find(
23744 (el) => el.value === token
23745 );
23746 return element?.label || token;
23747 }
23748 return token;
23749 },
23750 __experimentalRenderItem: ({ item }) => {
23751 if (typeof item === "string" && elements) {
23752 const element = elements.find(
23753 (el) => el.value === item
23754 );
23755 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", { children: element?.label || item });
23756 }
23757 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", { children: item });
23758 }
23759 }
23760 );
23761 }
23762
23763 // node_modules/colord/index.mjs
23764 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
23765 var t = function(r3) {
23766 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
23767 };
23768 var n = function(r3, t2, n2) {
23769 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
23770 };
23771 var e = function(r3, t2, n2) {
23772 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
23773 };
23774 var u = function(r3) {
23775 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
23776 };
23777 var a = function(r3) {
23778 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
23779 };
23780 var o = function(r3) {
23781 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
23782 };
23783 var i = /^#([0-9a-f]{3,8})$/i;
23784 var s = function(r3) {
23785 var t2 = r3.toString(16);
23786 return t2.length < 2 ? "0" + t2 : t2;
23787 };
23788 var h = function(r3) {
23789 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;
23790 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
23791 };
23792 var b = function(r3) {
23793 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
23794 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
23795 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;
23796 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 };
23797 };
23798 var g = function(r3) {
23799 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
23800 };
23801 var d = function(r3) {
23802 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
23803 };
23804 var f = function(r3) {
23805 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 }));
23806 var t2, n2, e2;
23807 };
23808 var c = function(r3) {
23809 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 };
23810 var t2, n2, e2, u2;
23811 };
23812 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
23813 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
23814 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
23815 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
23816 var y = { string: [[function(r3) {
23817 var t2 = i.exec(r3);
23818 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;
23819 }, "hex"], [function(r3) {
23820 var t2 = v.exec(r3) || m.exec(r3);
23821 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;
23822 }, "rgb"], [function(t2) {
23823 var n2 = l.exec(t2) || p.exec(t2);
23824 if (!n2) return null;
23825 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) });
23826 return f(a2);
23827 }, "hsl"]], object: [[function(r3) {
23828 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
23829 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
23830 }, "rgb"], [function(r3) {
23831 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
23832 if (!t(n2) || !t(e2) || !t(u2)) return null;
23833 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
23834 return f(i2);
23835 }, "hsl"], [function(r3) {
23836 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
23837 if (!t(n2) || !t(a2) || !t(o2)) return null;
23838 var h2 = (function(r4) {
23839 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
23840 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
23841 return b(h2);
23842 }, "hsv"]] };
23843 var N = function(r3, t2) {
23844 for (var n2 = 0; n2 < t2.length; n2++) {
23845 var e2 = t2[n2][0](r3);
23846 if (e2) return [e2, t2[n2][1]];
23847 }
23848 return [null, void 0];
23849 };
23850 var x = function(r3) {
23851 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
23852 };
23853 var M = function(r3, t2) {
23854 var n2 = c(r3);
23855 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
23856 };
23857 var H = function(r3) {
23858 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
23859 };
23860 var $ = function(r3, t2) {
23861 var n2 = c(r3);
23862 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
23863 };
23864 var j = (function() {
23865 function r3(r4) {
23866 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
23867 }
23868 return r3.prototype.isValid = function() {
23869 return null !== this.parsed;
23870 }, r3.prototype.brightness = function() {
23871 return n(H(this.rgba), 2);
23872 }, r3.prototype.isDark = function() {
23873 return H(this.rgba) < 0.5;
23874 }, r3.prototype.isLight = function() {
23875 return H(this.rgba) >= 0.5;
23876 }, r3.prototype.toHex = function() {
23877 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;
23878 var r4, t2, e2, u2, a2, i2;
23879 }, r3.prototype.toRgb = function() {
23880 return o(this.rgba);
23881 }, r3.prototype.toRgbString = function() {
23882 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 + ")";
23883 var r4, t2, n2, e2, u2;
23884 }, r3.prototype.toHsl = function() {
23885 return d(c(this.rgba));
23886 }, r3.prototype.toHslString = function() {
23887 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 + "%)";
23888 var r4, t2, n2, e2, u2;
23889 }, r3.prototype.toHsv = function() {
23890 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
23891 var r4;
23892 }, r3.prototype.invert = function() {
23893 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
23894 var r4;
23895 }, r3.prototype.saturate = function(r4) {
23896 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
23897 }, r3.prototype.desaturate = function(r4) {
23898 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
23899 }, r3.prototype.grayscale = function() {
23900 return w(M(this.rgba, -1));
23901 }, r3.prototype.lighten = function(r4) {
23902 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
23903 }, r3.prototype.darken = function(r4) {
23904 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
23905 }, r3.prototype.rotate = function(r4) {
23906 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
23907 }, r3.prototype.alpha = function(r4) {
23908 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
23909 var t2;
23910 }, r3.prototype.hue = function(r4) {
23911 var t2 = c(this.rgba);
23912 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
23913 }, r3.prototype.isEqual = function(r4) {
23914 return this.toHex() === w(r4).toHex();
23915 }, r3;
23916 })();
23917 var w = function(r3) {
23918 return r3 instanceof j ? r3 : new j(r3);
23919 };
23920
23921 // packages/dataviews/build-module/components/dataform-controls/color.mjs
23922 var import_components43 = __toESM(require_components(), 1);
23923 var import_element68 = __toESM(require_element(), 1);
23924 var import_i18n35 = __toESM(require_i18n(), 1);
23925 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
23926 var { ValidatedInputControl: ValidatedInputControl3 } = unlock3(import_components43.privateApis);
23927 var ColorPickerDropdown = ({
23928 color,
23929 onColorChange,
23930 disabled: disabled2
23931 }) => {
23932 const validColor = color && w(color).isValid() ? color : "#ffffff";
23933 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
23934 import_components43.Dropdown,
23935 {
23936 className: "dataviews-controls__color-picker-dropdown",
23937 popoverProps: { resize: false },
23938 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
23939 import_components43.Button,
23940 {
23941 onClick: onToggle,
23942 "aria-label": (0, import_i18n35.__)("Open color picker"),
23943 size: "small",
23944 disabled: disabled2,
23945 accessibleWhenDisabled: true,
23946 icon: () => /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_components43.ColorIndicator, { colorValue: validColor })
23947 }
23948 ),
23949 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_components43.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
23950 import_components43.ColorPicker,
23951 {
23952 color: validColor,
23953 onChange: onColorChange,
23954 enableAlpha: true
23955 }
23956 ) })
23957 }
23958 );
23959 };
23960 function Color({
23961 data,
23962 field,
23963 onChange,
23964 hideLabelFromVision,
23965 markWhenOptional,
23966 validity
23967 }) {
23968 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
23969 const disabled2 = field.isDisabled({ item: data, field });
23970 const value = field.getValue({ item: data }) || "";
23971 const handleColorChange = (0, import_element68.useCallback)(
23972 (newColor) => {
23973 onChange(setValue({ item: data, value: newColor }));
23974 },
23975 [data, onChange, setValue]
23976 );
23977 const handleInputChange = (0, import_element68.useCallback)(
23978 (newValue) => {
23979 onChange(setValue({ item: data, value: newValue || "" }));
23980 },
23981 [data, onChange, setValue]
23982 );
23983 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
23984 ValidatedInputControl3,
23985 {
23986 required: !!field.isValid?.required,
23987 markWhenOptional,
23988 customValidity: getCustomValidity(isValid2, validity),
23989 label,
23990 placeholder,
23991 value,
23992 help: description,
23993 onChange: handleInputChange,
23994 hideLabelFromVision,
23995 type: "text",
23996 disabled: disabled2,
23997 prefix: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_components43.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
23998 ColorPickerDropdown,
23999 {
24000 color: value,
24001 onColorChange: handleColorChange,
24002 disabled: disabled2
24003 }
24004 ) })
24005 }
24006 );
24007 }
24008
24009 // packages/dataviews/build-module/components/dataform-controls/password.mjs
24010 var import_components44 = __toESM(require_components(), 1);
24011 var import_element69 = __toESM(require_element(), 1);
24012 var import_i18n36 = __toESM(require_i18n(), 1);
24013 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
24014 function Password({
24015 data,
24016 field,
24017 onChange,
24018 hideLabelFromVision,
24019 markWhenOptional,
24020 validity
24021 }) {
24022 const [isVisible2, setIsVisible] = (0, import_element69.useState)(false);
24023 const disabled2 = field.isDisabled({ item: data, field });
24024 const toggleVisibility = (0, import_element69.useCallback)(() => {
24025 setIsVisible((prev) => !prev);
24026 }, []);
24027 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
24028 ValidatedText,
24029 {
24030 ...{
24031 data,
24032 field,
24033 onChange,
24034 hideLabelFromVision,
24035 markWhenOptional,
24036 validity,
24037 type: isVisible2 ? "text" : "password",
24038 suffix: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components44.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
24039 import_components44.Button,
24040 {
24041 icon: isVisible2 ? unseen_default : seen_default,
24042 onClick: toggleVisibility,
24043 size: "small",
24044 label: isVisible2 ? (0, import_i18n36.__)("Hide password") : (0, import_i18n36.__)("Show password"),
24045 disabled: disabled2,
24046 accessibleWhenDisabled: true
24047 }
24048 ) })
24049 }
24050 }
24051 );
24052 }
24053
24054 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
24055 function hasElements(field) {
24056 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
24057 }
24058
24059 // packages/dataviews/build-module/components/dataform-controls/index.mjs
24060 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
24061 var FORM_CONTROLS = {
24062 adaptiveSelect: AdaptiveSelect,
24063 array: ArrayControl,
24064 checkbox: Checkbox,
24065 color: Color,
24066 combobox: Combobox3,
24067 datetime: DateTime,
24068 date: DateControl,
24069 email: Email,
24070 telephone: Telephone,
24071 url: Url,
24072 integer: Integer,
24073 number: Number2,
24074 password: Password,
24075 radio: Radio,
24076 select: Select,
24077 text: Text3,
24078 toggle: Toggle,
24079 textarea: Textarea,
24080 toggleGroup: ToggleGroup
24081 };
24082 function isEditConfig(value) {
24083 return value && typeof value === "object" && typeof value.control === "string";
24084 }
24085 function createConfiguredControl(config) {
24086 const { control, ...controlConfig } = config;
24087 const BaseControlType = getControlByType(control);
24088 if (BaseControlType === null) {
24089 return null;
24090 }
24091 return function ConfiguredControl(props) {
24092 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(BaseControlType, { ...props, config: controlConfig });
24093 };
24094 }
24095 function getControl(field, fallback) {
24096 if (typeof field.Edit === "function") {
24097 return field.Edit;
24098 }
24099 if (typeof field.Edit === "string") {
24100 return getControlByType(field.Edit);
24101 }
24102 if (isEditConfig(field.Edit)) {
24103 return createConfiguredControl(field.Edit);
24104 }
24105 if (hasElements(field) && field.type !== "array") {
24106 return getControlByType("adaptiveSelect");
24107 }
24108 if (fallback === null) {
24109 return null;
24110 }
24111 return getControlByType(fallback);
24112 }
24113 function getControlByType(type) {
24114 if (Object.keys(FORM_CONTROLS).includes(type)) {
24115 return FORM_CONTROLS[type];
24116 }
24117 return null;
24118 }
24119
24120 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
24121 function getFilterBy(field, defaultOperators, validOperators) {
24122 if (field.filterBy === false) {
24123 return false;
24124 }
24125 const operators = field.filterBy?.operators?.filter(
24126 (op) => validOperators.includes(op)
24127 ) ?? defaultOperators;
24128 if (operators.length === 0) {
24129 return false;
24130 }
24131 return {
24132 isPrimary: !!field.filterBy?.isPrimary,
24133 operators
24134 };
24135 }
24136 var get_filter_by_default = getFilterBy;
24137
24138 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
24139 var getValueFromId = (id) => ({ item }) => {
24140 const path = id.split(".");
24141 let value = item;
24142 for (const segment of path) {
24143 if (value.hasOwnProperty(segment)) {
24144 value = value[segment];
24145 } else {
24146 value = void 0;
24147 }
24148 }
24149 return value;
24150 };
24151 var get_value_from_id_default = getValueFromId;
24152
24153 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
24154 var setValueFromId = (id) => ({ value }) => {
24155 const path = id.split(".");
24156 const result = {};
24157 let current = result;
24158 for (const segment of path.slice(0, -1)) {
24159 current[segment] = {};
24160 current = current[segment];
24161 }
24162 current[path.at(-1)] = value;
24163 return result;
24164 };
24165 var set_value_from_id_default = setValueFromId;
24166
24167 // packages/dataviews/build-module/field-types/email.mjs
24168 var import_i18n37 = __toESM(require_i18n(), 1);
24169
24170 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
24171 function RenderFromElements({
24172 item,
24173 field
24174 }) {
24175 const { elements, isLoading } = useElements({
24176 elements: field.elements,
24177 getElements: field.getElements
24178 });
24179 const value = field.getValue({ item });
24180 if (isLoading) {
24181 return value;
24182 }
24183 if (elements.length === 0) {
24184 return value;
24185 }
24186 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
24187 }
24188
24189 // packages/dataviews/build-module/field-types/utils/render-default.mjs
24190 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
24191 function render({
24192 item,
24193 field
24194 }) {
24195 if (field.hasElements) {
24196 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(RenderFromElements, { item, field });
24197 }
24198 return field.getValueFormatted({ item, field });
24199 }
24200
24201 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
24202 var sort_text_default = (a2, b2, direction) => {
24203 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
24204 };
24205
24206 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
24207 function isValidRequired(item, field) {
24208 const value = field.getValue({ item });
24209 return ![void 0, "", null].includes(value);
24210 }
24211
24212 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
24213 function isValidMinLength(item, field) {
24214 if (typeof field.isValid.minLength?.constraint !== "number") {
24215 return false;
24216 }
24217 const value = field.getValue({ item });
24218 if ([void 0, "", null].includes(value)) {
24219 return true;
24220 }
24221 return String(value).length >= field.isValid.minLength.constraint;
24222 }
24223
24224 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
24225 function isValidMaxLength(item, field) {
24226 if (typeof field.isValid.maxLength?.constraint !== "number") {
24227 return false;
24228 }
24229 const value = field.getValue({ item });
24230 if ([void 0, "", null].includes(value)) {
24231 return true;
24232 }
24233 return String(value).length <= field.isValid.maxLength.constraint;
24234 }
24235
24236 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
24237 function isValidPattern(item, field) {
24238 if (field.isValid.pattern?.constraint === void 0) {
24239 return true;
24240 }
24241 try {
24242 const regexp = new RegExp(field.isValid.pattern.constraint);
24243 const value = field.getValue({ item });
24244 if ([void 0, "", null].includes(value)) {
24245 return true;
24246 }
24247 return regexp.test(String(value));
24248 } catch {
24249 return false;
24250 }
24251 }
24252
24253 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
24254 function isValidElements(item, field) {
24255 const elements = field.elements ?? [];
24256 const validValues = elements.map((el) => el.value);
24257 if (validValues.length === 0) {
24258 return true;
24259 }
24260 const value = field.getValue({ item });
24261 return [].concat(value).every((v2) => validValues.includes(v2));
24262 }
24263
24264 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
24265 function getValueFormatted({
24266 item,
24267 field
24268 }) {
24269 return field.getValue({ item });
24270 }
24271 var get_value_formatted_default_default = getValueFormatted;
24272
24273 // packages/dataviews/build-module/field-types/email.mjs
24274 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])?)*$/;
24275 function isValidCustom(item, field) {
24276 const value = field.getValue({ item });
24277 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
24278 return (0, import_i18n37.__)("Value must be a valid email address.");
24279 }
24280 return null;
24281 }
24282 var email_default = {
24283 type: "email",
24284 render,
24285 Edit: "email",
24286 sort: sort_text_default,
24287 enableSorting: true,
24288 enableGlobalSearch: false,
24289 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24290 validOperators: [
24291 OPERATOR_IS,
24292 OPERATOR_IS_NOT,
24293 OPERATOR_CONTAINS,
24294 OPERATOR_NOT_CONTAINS,
24295 OPERATOR_STARTS_WITH,
24296 // Multiple selection
24297 OPERATOR_IS_ANY,
24298 OPERATOR_IS_NONE,
24299 OPERATOR_IS_ALL,
24300 OPERATOR_IS_NOT_ALL
24301 ],
24302 format: {},
24303 getValueFormatted: get_value_formatted_default_default,
24304 validate: {
24305 required: isValidRequired,
24306 pattern: isValidPattern,
24307 minLength: isValidMinLength,
24308 maxLength: isValidMaxLength,
24309 elements: isValidElements,
24310 custom: isValidCustom
24311 }
24312 };
24313
24314 // packages/dataviews/build-module/field-types/integer.mjs
24315 var import_i18n38 = __toESM(require_i18n(), 1);
24316
24317 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
24318 var sort_number_default = (a2, b2, direction) => {
24319 return direction === "asc" ? a2 - b2 : b2 - a2;
24320 };
24321
24322 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
24323 function isValidMin(item, field) {
24324 if (typeof field.isValid.min?.constraint !== "number") {
24325 return false;
24326 }
24327 const value = field.getValue({ item });
24328 if ([void 0, "", null].includes(value)) {
24329 return true;
24330 }
24331 return Number(value) >= field.isValid.min.constraint;
24332 }
24333
24334 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
24335 function isValidMax(item, field) {
24336 if (typeof field.isValid.max?.constraint !== "number") {
24337 return false;
24338 }
24339 const value = field.getValue({ item });
24340 if ([void 0, "", null].includes(value)) {
24341 return true;
24342 }
24343 return Number(value) <= field.isValid.max.constraint;
24344 }
24345
24346 // packages/dataviews/build-module/field-types/integer.mjs
24347 var format2 = {
24348 separatorThousand: ","
24349 };
24350 function getValueFormatted2({
24351 item,
24352 field
24353 }) {
24354 let value = field.getValue({ item });
24355 if (value === null || value === void 0) {
24356 return "";
24357 }
24358 value = Number(value);
24359 if (!Number.isFinite(value)) {
24360 return String(value);
24361 }
24362 let formatInteger;
24363 if (field.type !== "integer") {
24364 formatInteger = format2;
24365 } else {
24366 formatInteger = field.format;
24367 }
24368 const { separatorThousand } = formatInteger;
24369 const integerValue = Math.trunc(value);
24370 if (!separatorThousand) {
24371 return String(integerValue);
24372 }
24373 return String(integerValue).replace(
24374 /\B(?=(\d{3})+(?!\d))/g,
24375 separatorThousand
24376 );
24377 }
24378 function isValidCustom2(item, field) {
24379 const value = field.getValue({ item });
24380 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
24381 return (0, import_i18n38.__)("Value must be an integer.");
24382 }
24383 return null;
24384 }
24385 var integer_default = {
24386 type: "integer",
24387 render,
24388 Edit: "integer",
24389 sort: sort_number_default,
24390 enableSorting: true,
24391 enableGlobalSearch: false,
24392 defaultOperators: [
24393 OPERATOR_IS,
24394 OPERATOR_IS_NOT,
24395 OPERATOR_LESS_THAN,
24396 OPERATOR_GREATER_THAN,
24397 OPERATOR_LESS_THAN_OR_EQUAL,
24398 OPERATOR_GREATER_THAN_OR_EQUAL,
24399 OPERATOR_BETWEEN
24400 ],
24401 validOperators: [
24402 // Single-selection
24403 OPERATOR_IS,
24404 OPERATOR_IS_NOT,
24405 OPERATOR_LESS_THAN,
24406 OPERATOR_GREATER_THAN,
24407 OPERATOR_LESS_THAN_OR_EQUAL,
24408 OPERATOR_GREATER_THAN_OR_EQUAL,
24409 OPERATOR_BETWEEN,
24410 // Multiple-selection
24411 OPERATOR_IS_ANY,
24412 OPERATOR_IS_NONE,
24413 OPERATOR_IS_ALL,
24414 OPERATOR_IS_NOT_ALL
24415 ],
24416 format: format2,
24417 getValueFormatted: getValueFormatted2,
24418 validate: {
24419 required: isValidRequired,
24420 min: isValidMin,
24421 max: isValidMax,
24422 elements: isValidElements,
24423 custom: isValidCustom2
24424 }
24425 };
24426
24427 // packages/dataviews/build-module/field-types/number.mjs
24428 var import_i18n39 = __toESM(require_i18n(), 1);
24429 var format3 = {
24430 separatorThousand: ",",
24431 separatorDecimal: ".",
24432 decimals: 2
24433 };
24434 function getValueFormatted3({
24435 item,
24436 field
24437 }) {
24438 let value = field.getValue({ item });
24439 if (value === null || value === void 0) {
24440 return "";
24441 }
24442 value = Number(value);
24443 if (!Number.isFinite(value)) {
24444 return String(value);
24445 }
24446 let formatNumber;
24447 if (field.type !== "number") {
24448 formatNumber = format3;
24449 } else {
24450 formatNumber = field.format;
24451 }
24452 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
24453 const fixedValue = value.toFixed(decimals);
24454 const [integerPart, decimalPart] = fixedValue.split(".");
24455 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
24456 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
24457 }
24458 function isEmpty2(value) {
24459 return value === "" || value === void 0 || value === null;
24460 }
24461 function isValidCustom3(item, field) {
24462 const value = field.getValue({ item });
24463 if (!isEmpty2(value) && !Number.isFinite(value)) {
24464 return (0, import_i18n39.__)("Value must be a number.");
24465 }
24466 return null;
24467 }
24468 var number_default = {
24469 type: "number",
24470 render,
24471 Edit: "number",
24472 sort: sort_number_default,
24473 enableSorting: true,
24474 enableGlobalSearch: false,
24475 defaultOperators: [
24476 OPERATOR_IS,
24477 OPERATOR_IS_NOT,
24478 OPERATOR_LESS_THAN,
24479 OPERATOR_GREATER_THAN,
24480 OPERATOR_LESS_THAN_OR_EQUAL,
24481 OPERATOR_GREATER_THAN_OR_EQUAL,
24482 OPERATOR_BETWEEN
24483 ],
24484 validOperators: [
24485 // Single-selection
24486 OPERATOR_IS,
24487 OPERATOR_IS_NOT,
24488 OPERATOR_LESS_THAN,
24489 OPERATOR_GREATER_THAN,
24490 OPERATOR_LESS_THAN_OR_EQUAL,
24491 OPERATOR_GREATER_THAN_OR_EQUAL,
24492 OPERATOR_BETWEEN,
24493 // Multiple-selection
24494 OPERATOR_IS_ANY,
24495 OPERATOR_IS_NONE,
24496 OPERATOR_IS_ALL,
24497 OPERATOR_IS_NOT_ALL
24498 ],
24499 format: format3,
24500 getValueFormatted: getValueFormatted3,
24501 validate: {
24502 required: isValidRequired,
24503 min: isValidMin,
24504 max: isValidMax,
24505 elements: isValidElements,
24506 custom: isValidCustom3
24507 }
24508 };
24509
24510 // packages/dataviews/build-module/field-types/text.mjs
24511 var text_default = {
24512 type: "text",
24513 render,
24514 Edit: "text",
24515 sort: sort_text_default,
24516 enableSorting: true,
24517 enableGlobalSearch: false,
24518 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24519 validOperators: [
24520 // Single selection
24521 OPERATOR_IS,
24522 OPERATOR_IS_NOT,
24523 OPERATOR_CONTAINS,
24524 OPERATOR_NOT_CONTAINS,
24525 OPERATOR_STARTS_WITH,
24526 // Multiple selection
24527 OPERATOR_IS_ANY,
24528 OPERATOR_IS_NONE,
24529 OPERATOR_IS_ALL,
24530 OPERATOR_IS_NOT_ALL
24531 ],
24532 format: {},
24533 getValueFormatted: get_value_formatted_default_default,
24534 validate: {
24535 required: isValidRequired,
24536 pattern: isValidPattern,
24537 minLength: isValidMinLength,
24538 maxLength: isValidMaxLength,
24539 elements: isValidElements
24540 }
24541 };
24542
24543 // packages/dataviews/build-module/field-types/datetime.mjs
24544 var import_date7 = __toESM(require_date(), 1);
24545
24546 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
24547 var import_date6 = __toESM(require_date(), 1);
24548 function parseDateLike(value) {
24549 if (!value) {
24550 return null;
24551 }
24552 if (!isValid(new Date(value))) {
24553 return null;
24554 }
24555 const parsed = (0, import_date6.getDate)(value);
24556 return parsed && isValid(parsed) ? parsed : null;
24557 }
24558 function validateDateLikeBoundary(item, field, boundary) {
24559 const constraint = field.isValid[boundary]?.constraint;
24560 if (typeof constraint !== "string") {
24561 return false;
24562 }
24563 const value = field.getValue({ item });
24564 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
24565 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
24566 return true;
24567 }
24568 const parsedConstraint = parseDateLike(constraint);
24569 const parsedValue = parseDateLike(String(boundaryValue));
24570 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
24571 }
24572 function isValidMinDate(item, field) {
24573 return validateDateLikeBoundary(item, field, "min");
24574 }
24575 function isValidMaxDate(item, field) {
24576 return validateDateLikeBoundary(item, field, "max");
24577 }
24578
24579 // packages/dataviews/build-module/field-types/datetime.mjs
24580 var format4 = {
24581 datetime: (0, import_date7.getSettings)().formats.datetime,
24582 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
24583 };
24584 function getValueFormatted4({
24585 item,
24586 field
24587 }) {
24588 const value = field.getValue({ item });
24589 if (["", void 0, null].includes(value)) {
24590 return "";
24591 }
24592 let formatDatetime;
24593 if (field.type !== "datetime") {
24594 formatDatetime = format4;
24595 } else {
24596 formatDatetime = field.format;
24597 }
24598 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
24599 }
24600 var sort = (a2, b2, direction) => {
24601 const timeA = new Date(a2).getTime();
24602 const timeB = new Date(b2).getTime();
24603 return direction === "asc" ? timeA - timeB : timeB - timeA;
24604 };
24605 var datetime_default = {
24606 type: "datetime",
24607 render,
24608 Edit: "datetime",
24609 sort,
24610 enableSorting: true,
24611 enableGlobalSearch: false,
24612 defaultOperators: [
24613 OPERATOR_ON,
24614 OPERATOR_NOT_ON,
24615 OPERATOR_BEFORE,
24616 OPERATOR_AFTER,
24617 OPERATOR_BEFORE_INC,
24618 OPERATOR_AFTER_INC,
24619 OPERATOR_IN_THE_PAST,
24620 OPERATOR_OVER
24621 ],
24622 validOperators: [
24623 OPERATOR_ON,
24624 OPERATOR_NOT_ON,
24625 OPERATOR_BEFORE,
24626 OPERATOR_AFTER,
24627 OPERATOR_BEFORE_INC,
24628 OPERATOR_AFTER_INC,
24629 OPERATOR_IN_THE_PAST,
24630 OPERATOR_OVER
24631 ],
24632 format: format4,
24633 getValueFormatted: getValueFormatted4,
24634 validate: {
24635 required: isValidRequired,
24636 elements: isValidElements,
24637 min: isValidMinDate,
24638 max: isValidMaxDate
24639 }
24640 };
24641
24642 // packages/dataviews/build-module/field-types/date.mjs
24643 var import_date8 = __toESM(require_date(), 1);
24644 var format5 = {
24645 date: (0, import_date8.getSettings)().formats.date,
24646 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
24647 };
24648 function getValueFormatted5({
24649 item,
24650 field
24651 }) {
24652 const value = field.getValue({ item });
24653 if (["", void 0, null].includes(value)) {
24654 return "";
24655 }
24656 let formatDate2;
24657 if (field.type !== "date") {
24658 formatDate2 = format5;
24659 } else {
24660 formatDate2 = field.format;
24661 }
24662 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
24663 }
24664 var sort2 = (a2, b2, direction) => {
24665 const timeA = new Date(a2).getTime();
24666 const timeB = new Date(b2).getTime();
24667 return direction === "asc" ? timeA - timeB : timeB - timeA;
24668 };
24669 var date_default = {
24670 type: "date",
24671 render,
24672 Edit: "date",
24673 sort: sort2,
24674 enableSorting: true,
24675 enableGlobalSearch: false,
24676 defaultOperators: [
24677 OPERATOR_ON,
24678 OPERATOR_NOT_ON,
24679 OPERATOR_BEFORE,
24680 OPERATOR_AFTER,
24681 OPERATOR_BEFORE_INC,
24682 OPERATOR_AFTER_INC,
24683 OPERATOR_IN_THE_PAST,
24684 OPERATOR_OVER,
24685 OPERATOR_BETWEEN
24686 ],
24687 validOperators: [
24688 OPERATOR_ON,
24689 OPERATOR_NOT_ON,
24690 OPERATOR_BEFORE,
24691 OPERATOR_AFTER,
24692 OPERATOR_BEFORE_INC,
24693 OPERATOR_AFTER_INC,
24694 OPERATOR_IN_THE_PAST,
24695 OPERATOR_OVER,
24696 OPERATOR_BETWEEN
24697 ],
24698 format: format5,
24699 getValueFormatted: getValueFormatted5,
24700 validate: {
24701 required: isValidRequired,
24702 elements: isValidElements,
24703 min: isValidMinDate,
24704 max: isValidMaxDate
24705 }
24706 };
24707
24708 // packages/dataviews/build-module/field-types/boolean.mjs
24709 var import_i18n40 = __toESM(require_i18n(), 1);
24710
24711 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
24712 function isValidRequiredForBool(item, field) {
24713 const value = field.getValue({ item });
24714 return value === true;
24715 }
24716
24717 // packages/dataviews/build-module/field-types/boolean.mjs
24718 function getValueFormatted6({
24719 item,
24720 field
24721 }) {
24722 const value = field.getValue({ item });
24723 if (value === true) {
24724 return (0, import_i18n40.__)("True");
24725 }
24726 if (value === false) {
24727 return (0, import_i18n40.__)("False");
24728 }
24729 return "";
24730 }
24731 function isValidCustom4(item, field) {
24732 const value = field.getValue({ item });
24733 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
24734 return (0, import_i18n40.__)("Value must be true, false, or undefined");
24735 }
24736 return null;
24737 }
24738 var sort3 = (a2, b2, direction) => {
24739 const boolA = Boolean(a2);
24740 const boolB = Boolean(b2);
24741 if (boolA === boolB) {
24742 return 0;
24743 }
24744 if (direction === "asc") {
24745 return boolA ? 1 : -1;
24746 }
24747 return boolA ? -1 : 1;
24748 };
24749 var boolean_default = {
24750 type: "boolean",
24751 render,
24752 Edit: "checkbox",
24753 sort: sort3,
24754 validate: {
24755 required: isValidRequiredForBool,
24756 elements: isValidElements,
24757 custom: isValidCustom4
24758 },
24759 enableSorting: true,
24760 enableGlobalSearch: false,
24761 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
24762 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
24763 format: {},
24764 getValueFormatted: getValueFormatted6
24765 };
24766
24767 // packages/dataviews/build-module/field-types/media.mjs
24768 var media_default = {
24769 type: "media",
24770 render: () => null,
24771 Edit: null,
24772 sort: () => 0,
24773 enableSorting: false,
24774 enableGlobalSearch: false,
24775 defaultOperators: [],
24776 validOperators: [],
24777 format: {},
24778 getValueFormatted: get_value_formatted_default_default,
24779 // cannot validate any constraint, so
24780 // the only available validation for the field author
24781 // would be providing a custom validator.
24782 validate: {}
24783 };
24784
24785 // packages/dataviews/build-module/field-types/array.mjs
24786 var import_i18n41 = __toESM(require_i18n(), 1);
24787
24788 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
24789 function isValidRequiredForArray(item, field) {
24790 const value = field.getValue({ item });
24791 return Array.isArray(value) && value.length > 0 && value.every(
24792 (element) => ![void 0, "", null].includes(element)
24793 );
24794 }
24795
24796 // packages/dataviews/build-module/field-types/array.mjs
24797 function getValueFormatted7({
24798 item,
24799 field
24800 }) {
24801 const value = field.getValue({ item });
24802 const arr = Array.isArray(value) ? value : [];
24803 return arr.join(", ");
24804 }
24805 function render2({ item, field }) {
24806 return getValueFormatted7({ item, field });
24807 }
24808 function isValidCustom5(item, field) {
24809 const value = field.getValue({ item });
24810 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
24811 return (0, import_i18n41.__)("Value must be an array.");
24812 }
24813 if (!value.every((v2) => typeof v2 === "string")) {
24814 return (0, import_i18n41.__)("Every value must be a string.");
24815 }
24816 return null;
24817 }
24818 var sort4 = (a2, b2, direction) => {
24819 const arrA = Array.isArray(a2) ? a2 : [];
24820 const arrB = Array.isArray(b2) ? b2 : [];
24821 if (arrA.length !== arrB.length) {
24822 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
24823 }
24824 const joinedA = arrA.join(",");
24825 const joinedB = arrB.join(",");
24826 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
24827 };
24828 var array_default = {
24829 type: "array",
24830 render: render2,
24831 Edit: "array",
24832 sort: sort4,
24833 enableSorting: true,
24834 enableGlobalSearch: false,
24835 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24836 validOperators: [
24837 OPERATOR_IS_ANY,
24838 OPERATOR_IS_NONE,
24839 OPERATOR_IS_ALL,
24840 OPERATOR_IS_NOT_ALL
24841 ],
24842 format: {},
24843 getValueFormatted: getValueFormatted7,
24844 validate: {
24845 required: isValidRequiredForArray,
24846 elements: isValidElements,
24847 custom: isValidCustom5
24848 }
24849 };
24850
24851 // packages/dataviews/build-module/field-types/password.mjs
24852 function getValueFormatted8({
24853 item,
24854 field
24855 }) {
24856 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
24857 }
24858 var password_default = {
24859 type: "password",
24860 render,
24861 Edit: "password",
24862 sort: () => 0,
24863 // Passwords should not be sortable for security reasons
24864 enableSorting: false,
24865 enableGlobalSearch: false,
24866 defaultOperators: [],
24867 validOperators: [],
24868 format: {},
24869 getValueFormatted: getValueFormatted8,
24870 validate: {
24871 required: isValidRequired,
24872 pattern: isValidPattern,
24873 minLength: isValidMinLength,
24874 maxLength: isValidMaxLength,
24875 elements: isValidElements
24876 }
24877 };
24878
24879 // packages/dataviews/build-module/field-types/telephone.mjs
24880 var telephone_default = {
24881 type: "telephone",
24882 render,
24883 Edit: "telephone",
24884 sort: sort_text_default,
24885 enableSorting: true,
24886 enableGlobalSearch: false,
24887 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24888 validOperators: [
24889 OPERATOR_IS,
24890 OPERATOR_IS_NOT,
24891 OPERATOR_CONTAINS,
24892 OPERATOR_NOT_CONTAINS,
24893 OPERATOR_STARTS_WITH,
24894 // Multiple selection
24895 OPERATOR_IS_ANY,
24896 OPERATOR_IS_NONE,
24897 OPERATOR_IS_ALL,
24898 OPERATOR_IS_NOT_ALL
24899 ],
24900 format: {},
24901 getValueFormatted: get_value_formatted_default_default,
24902 validate: {
24903 required: isValidRequired,
24904 pattern: isValidPattern,
24905 minLength: isValidMinLength,
24906 maxLength: isValidMaxLength,
24907 elements: isValidElements
24908 }
24909 };
24910
24911 // packages/dataviews/build-module/field-types/color.mjs
24912 var import_i18n42 = __toESM(require_i18n(), 1);
24913 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
24914 function render3({ item, field }) {
24915 if (field.hasElements) {
24916 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(RenderFromElements, { item, field });
24917 }
24918 const value = get_value_formatted_default_default({ item, field });
24919 if (!value || !w(value).isValid()) {
24920 return value;
24921 }
24922 return /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
24923 /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24924 "div",
24925 {
24926 style: {
24927 width: "16px",
24928 height: "16px",
24929 borderRadius: "50%",
24930 backgroundColor: value,
24931 border: "1px solid #ddd",
24932 flexShrink: 0
24933 }
24934 }
24935 ),
24936 /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("span", { children: value })
24937 ] });
24938 }
24939 function isValidCustom6(item, field) {
24940 const value = field.getValue({ item });
24941 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
24942 return (0, import_i18n42.__)("Value must be a valid color.");
24943 }
24944 return null;
24945 }
24946 var sort5 = (a2, b2, direction) => {
24947 const colorA = w(a2);
24948 const colorB = w(b2);
24949 if (!colorA.isValid() && !colorB.isValid()) {
24950 return 0;
24951 }
24952 if (!colorA.isValid()) {
24953 return direction === "asc" ? 1 : -1;
24954 }
24955 if (!colorB.isValid()) {
24956 return direction === "asc" ? -1 : 1;
24957 }
24958 const hslA = colorA.toHsl();
24959 const hslB = colorB.toHsl();
24960 if (hslA.h !== hslB.h) {
24961 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
24962 }
24963 if (hslA.s !== hslB.s) {
24964 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
24965 }
24966 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
24967 };
24968 var color_default = {
24969 type: "color",
24970 render: render3,
24971 Edit: "color",
24972 sort: sort5,
24973 enableSorting: true,
24974 enableGlobalSearch: false,
24975 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24976 validOperators: [
24977 OPERATOR_IS,
24978 OPERATOR_IS_NOT,
24979 OPERATOR_IS_ANY,
24980 OPERATOR_IS_NONE
24981 ],
24982 format: {},
24983 getValueFormatted: get_value_formatted_default_default,
24984 validate: {
24985 required: isValidRequired,
24986 elements: isValidElements,
24987 custom: isValidCustom6
24988 }
24989 };
24990
24991 // packages/dataviews/build-module/field-types/url.mjs
24992 var url_default = {
24993 type: "url",
24994 render,
24995 Edit: "url",
24996 sort: sort_text_default,
24997 enableSorting: true,
24998 enableGlobalSearch: false,
24999 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25000 validOperators: [
25001 OPERATOR_IS,
25002 OPERATOR_IS_NOT,
25003 OPERATOR_CONTAINS,
25004 OPERATOR_NOT_CONTAINS,
25005 OPERATOR_STARTS_WITH,
25006 // Multiple selection
25007 OPERATOR_IS_ANY,
25008 OPERATOR_IS_NONE,
25009 OPERATOR_IS_ALL,
25010 OPERATOR_IS_NOT_ALL
25011 ],
25012 format: {},
25013 getValueFormatted: get_value_formatted_default_default,
25014 validate: {
25015 required: isValidRequired,
25016 pattern: isValidPattern,
25017 minLength: isValidMinLength,
25018 maxLength: isValidMaxLength,
25019 elements: isValidElements
25020 }
25021 };
25022
25023 // packages/dataviews/build-module/field-types/no-type.mjs
25024 var sort6 = (a2, b2, direction) => {
25025 if (typeof a2 === "number" && typeof b2 === "number") {
25026 return sort_number_default(a2, b2, direction);
25027 }
25028 return sort_text_default(a2, b2, direction);
25029 };
25030 var no_type_default = {
25031 // type: no type for this one
25032 render,
25033 Edit: null,
25034 sort: sort6,
25035 enableSorting: true,
25036 enableGlobalSearch: false,
25037 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25038 validOperators: getAllOperatorNames(),
25039 format: {},
25040 getValueFormatted: get_value_formatted_default_default,
25041 validate: {
25042 required: isValidRequired,
25043 elements: isValidElements
25044 }
25045 };
25046
25047 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
25048 function supportsNumericRangeConstraint(type) {
25049 return type === "integer" || type === "number";
25050 }
25051 function supportsDateRangeConstraint(type) {
25052 return type === "date" || type === "datetime";
25053 }
25054 function normalizeRangeRule(value, fieldType, key) {
25055 const validator = fieldType.validate[key];
25056 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
25057 return { constraint: value, validate: validator };
25058 }
25059 return void 0;
25060 }
25061 function getIsValid(field, fieldType) {
25062 const rules = field.isValid;
25063 let required;
25064 if (rules?.required === true && fieldType.validate.required !== void 0) {
25065 required = {
25066 constraint: true,
25067 validate: fieldType.validate.required
25068 };
25069 }
25070 let elements;
25071 if ((rules?.elements === true || // elements is enabled unless the field opts-out
25072 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
25073 elements = {
25074 constraint: true,
25075 validate: fieldType.validate.elements
25076 };
25077 }
25078 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
25079 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
25080 const minLengthValue = rules?.minLength;
25081 let minLength;
25082 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
25083 minLength = {
25084 constraint: minLengthValue,
25085 validate: fieldType.validate.minLength
25086 };
25087 }
25088 const maxLengthValue = rules?.maxLength;
25089 let maxLength;
25090 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
25091 maxLength = {
25092 constraint: maxLengthValue,
25093 validate: fieldType.validate.maxLength
25094 };
25095 }
25096 const patternValue = rules?.pattern;
25097 let pattern;
25098 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
25099 pattern = {
25100 constraint: patternValue,
25101 validate: fieldType.validate.pattern
25102 };
25103 }
25104 const custom = rules?.custom ?? fieldType.validate.custom;
25105 return {
25106 required,
25107 elements,
25108 min: min2,
25109 max: max2,
25110 minLength,
25111 maxLength,
25112 pattern,
25113 custom
25114 };
25115 }
25116
25117 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
25118 function getFilter(fieldType) {
25119 return fieldType.validOperators.reduce((accumulator, operator) => {
25120 const operatorObj = getOperatorByName(operator);
25121 if (operatorObj?.filter) {
25122 accumulator[operator] = operatorObj.filter;
25123 }
25124 return accumulator;
25125 }, {});
25126 }
25127
25128 // packages/dataviews/build-module/field-types/utils/get-format.mjs
25129 function getFormat(field, fieldType) {
25130 return {
25131 ...fieldType.format,
25132 ...field.format
25133 };
25134 }
25135 var get_format_default = getFormat;
25136
25137 // packages/dataviews/build-module/field-types/index.mjs
25138 function getFieldTypeByName(type) {
25139 const found = [
25140 email_default,
25141 integer_default,
25142 number_default,
25143 text_default,
25144 datetime_default,
25145 date_default,
25146 boolean_default,
25147 media_default,
25148 array_default,
25149 password_default,
25150 telephone_default,
25151 color_default,
25152 url_default
25153 ].find((fieldType) => fieldType?.type === type);
25154 if (!!found) {
25155 return found;
25156 }
25157 return no_type_default;
25158 }
25159 function normalizeFields(fields) {
25160 return fields.map((field) => {
25161 const fieldType = getFieldTypeByName(field.type);
25162 const getValue = field.getValue || get_value_from_id_default(field.id);
25163 const sort7 = function(a2, b2, direction) {
25164 const aValue = getValue({ item: a2 });
25165 const bValue = getValue({ item: b2 });
25166 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
25167 };
25168 return {
25169 id: field.id,
25170 label: field.label || field.id,
25171 header: field.header || field.label || field.id,
25172 description: field.description,
25173 placeholder: field.placeholder,
25174 getValue,
25175 setValue: field.setValue || set_value_from_id_default(field.id),
25176 elements: field.elements,
25177 getElements: field.getElements,
25178 hasElements: hasElements(field),
25179 isVisible: field.isVisible,
25180 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
25181 enableHiding: field.enableHiding ?? true,
25182 readOnly: field.readOnly ?? false,
25183 // The type provides defaults for the following props
25184 type: fieldType.type,
25185 render: field.render ?? fieldType.render,
25186 Edit: getControl(field, fieldType.Edit),
25187 sort: sort7,
25188 enableSorting: field.enableSorting ?? fieldType.enableSorting,
25189 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
25190 isValid: getIsValid(field, fieldType),
25191 filterBy: get_filter_by_default(
25192 field,
25193 fieldType.defaultOperators,
25194 fieldType.validOperators
25195 ),
25196 filter: getFilter(fieldType),
25197 format: get_format_default(field, fieldType),
25198 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
25199 };
25200 });
25201 }
25202
25203 // packages/dataviews/build-module/hooks/use-data.mjs
25204 var import_element70 = __toESM(require_element(), 1);
25205 function useData({
25206 view,
25207 data: shownData,
25208 getItemId,
25209 isLoading,
25210 paginationInfo,
25211 selection
25212 }) {
25213 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
25214 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element70.useState)(
25215 !isLoading
25216 );
25217 (0, import_element70.useEffect)(() => {
25218 if (!isLoading) {
25219 setHasInitiallyLoaded(true);
25220 }
25221 }, [isLoading]);
25222 const previousDataRef = (0, import_element70.useRef)(shownData);
25223 const previousPaginationInfoRef = (0, import_element70.useRef)(paginationInfo);
25224 (0, import_element70.useEffect)(() => {
25225 if (!isLoading) {
25226 previousDataRef.current = shownData;
25227 previousPaginationInfoRef.current = paginationInfo;
25228 }
25229 }, [shownData, isLoading, paginationInfo]);
25230 const [visibleEntries, setVisibleEntries] = (0, import_element70.useState)([]);
25231 const positionMapRef = (0, import_element70.useRef)(/* @__PURE__ */ new Map());
25232 const allLoadedRecordsRef = (0, import_element70.useRef)([]);
25233 const prevViewParamsRef = (0, import_element70.useRef)({
25234 search: void 0,
25235 filters: void 0,
25236 perPage: void 0
25237 });
25238 const scrollDirectionRef = (0, import_element70.useRef)(void 0);
25239 const prevStartPositionRef = (0, import_element70.useRef)(void 0);
25240 const hasInitializedRef = (0, import_element70.useRef)(false);
25241 const allLoadedRecords = (0, import_element70.useMemo)(() => {
25242 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
25243 if (view.startPosition < prevStartPositionRef.current) {
25244 scrollDirectionRef.current = "up";
25245 } else if (view.startPosition > prevStartPositionRef.current) {
25246 scrollDirectionRef.current = "down";
25247 }
25248 }
25249 prevStartPositionRef.current = view.startPosition;
25250 const currentFiltersKey = JSON.stringify(view.filters ?? []);
25251 const prevFiltersKey = prevViewParamsRef.current.filters;
25252 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
25253 hasInitializedRef.current = true;
25254 prevViewParamsRef.current = {
25255 search: view.search,
25256 filters: currentFiltersKey,
25257 perPage: view.perPage
25258 };
25259 if (shouldReset) {
25260 positionMapRef.current.clear();
25261 scrollDirectionRef.current = void 0;
25262 const startPosition = view.search ? 1 : view.startPosition ?? 1;
25263 const records = shownData.map((record, index2) => {
25264 const position = startPosition + index2;
25265 positionMapRef.current.set(getItemId(record), position);
25266 return {
25267 ...record,
25268 position
25269 };
25270 });
25271 allLoadedRecordsRef.current = records;
25272 return records;
25273 }
25274 const prev = allLoadedRecordsRef.current;
25275 const shownDataIds = new Set(shownData.map(getItemId));
25276 const scrollDirection = scrollDirectionRef.current;
25277 const basePosition = view.search ? 1 : view.startPosition ?? 1;
25278 const newRecords = shownData.map((record, index2) => {
25279 const itemId = getItemId(record);
25280 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
25281 if (position !== void 0) {
25282 positionMapRef.current.set(itemId, position);
25283 }
25284 return {
25285 ...record,
25286 position
25287 };
25288 });
25289 if (newRecords.length === 0) {
25290 return prev;
25291 }
25292 const prevWithoutDuplicates = prev.filter(
25293 (record) => !shownDataIds.has(getItemId(record))
25294 );
25295 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
25296 allRecords.sort((a2, b2) => {
25297 const posA = a2.position;
25298 const posB = b2.position;
25299 return posA - posB;
25300 });
25301 let result = allRecords;
25302 if (visibleEntries.length > 0) {
25303 const visibleMin = Math.min(...visibleEntries);
25304 const visibleMax = Math.max(...visibleEntries);
25305 const buffer = 20;
25306 const recordPositions = allRecords.map(
25307 (r3) => r3.position
25308 );
25309 const minRecordPos = Math.min(...recordPositions);
25310 const maxRecordPos = Math.max(...recordPositions);
25311 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
25312 if (hasOverlap) {
25313 result = allRecords.filter((record) => {
25314 const itemId = getItemId(record);
25315 const isSelected2 = selection?.includes(itemId);
25316 if (isSelected2) {
25317 return true;
25318 }
25319 const itemPosition = record.position;
25320 if (scrollDirection === "up") {
25321 return itemPosition <= visibleMax + buffer;
25322 } else if (scrollDirection === "down") {
25323 return itemPosition >= visibleMin - buffer;
25324 }
25325 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
25326 });
25327 }
25328 }
25329 allLoadedRecordsRef.current = result;
25330 return result;
25331 }, [
25332 shownData,
25333 view.search,
25334 view.filters,
25335 view.perPage,
25336 view.startPosition,
25337 view.infiniteScrollEnabled,
25338 visibleEntries,
25339 selection,
25340 getItemId
25341 ]);
25342 if (!isInfiniteScrollEnabled) {
25343 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
25344 return {
25345 data: dataToReturn.map((item) => ({
25346 ...item,
25347 position: void 0
25348 })),
25349 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
25350 hasInitiallyLoaded,
25351 setVisibleEntries: void 0
25352 };
25353 }
25354 return {
25355 data: allLoadedRecords,
25356 paginationInfo,
25357 hasInitiallyLoaded,
25358 setVisibleEntries
25359 };
25360 }
25361
25362 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
25363 var import_element71 = __toESM(require_element(), 1);
25364 var import_compose11 = __toESM(require_compose(), 1);
25365 function captureAnchorElement(container, anchorElementRef, direction) {
25366 const containerRect = container.getBoundingClientRect();
25367 const centerY = containerRect.top + containerRect.height / 2;
25368 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
25369 if (items.length === 0) {
25370 return false;
25371 }
25372 const bestAnchor = items.reduce((best, item) => {
25373 const itemRect = item.getBoundingClientRect();
25374 const itemCenterY = itemRect.top + itemRect.height / 2;
25375 const distance = Math.abs(itemCenterY - centerY);
25376 const bestRect = best.getBoundingClientRect();
25377 const bestCenterY = bestRect.top + bestRect.height / 2;
25378 const bestDistance = Math.abs(bestCenterY - centerY);
25379 return distance < bestDistance ? item : best;
25380 });
25381 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
25382 const anchorRect = bestAnchor.getBoundingClientRect();
25383 anchorElementRef.current = {
25384 posinset,
25385 viewportOffset: anchorRect.top - containerRect.top,
25386 direction
25387 };
25388 return true;
25389 }
25390 function useInfiniteScroll({
25391 view,
25392 onChangeView,
25393 isLoading,
25394 paginationInfo,
25395 containerRef,
25396 setVisibleEntries
25397 }) {
25398 const anchorElementRef = (0, import_element71.useRef)(null);
25399 const viewRef = (0, import_element71.useRef)(view);
25400 const isLoadingRef = (0, import_element71.useRef)(isLoading);
25401 const onChangeViewRef = (0, import_element71.useRef)(onChangeView);
25402 const totalItemsRef = (0, import_element71.useRef)(paginationInfo.totalItems);
25403 (0, import_element71.useLayoutEffect)(() => {
25404 viewRef.current = view;
25405 isLoadingRef.current = isLoading;
25406 onChangeViewRef.current = onChangeView;
25407 totalItemsRef.current = paginationInfo.totalItems;
25408 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
25409 const intersectionObserverCallback = (0, import_element71.useCallback)(
25410 (entries) => {
25411 if (!setVisibleEntries) {
25412 return;
25413 }
25414 setVisibleEntries((prev) => {
25415 const newVisibleEntries = new Set(prev);
25416 let hasChanged = false;
25417 entries.forEach((entry) => {
25418 const posInSet = Number(
25419 entry.target?.attributes?.getNamedItem(
25420 "aria-posinset"
25421 )?.value
25422 );
25423 if (isNaN(posInSet)) {
25424 return;
25425 }
25426 if (entry.isIntersecting) {
25427 if (!newVisibleEntries.has(posInSet)) {
25428 newVisibleEntries.add(posInSet);
25429 hasChanged = true;
25430 }
25431 } else if (newVisibleEntries.has(posInSet)) {
25432 newVisibleEntries.delete(posInSet);
25433 hasChanged = true;
25434 }
25435 });
25436 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
25437 });
25438 },
25439 [setVisibleEntries]
25440 );
25441 (0, import_element71.useLayoutEffect)(() => {
25442 const container = containerRef.current;
25443 const anchor = anchorElementRef.current;
25444 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
25445 return;
25446 }
25447 const anchorElement = container.querySelector(
25448 `[aria-posinset="${anchor.posinset}"]`
25449 );
25450 if (anchorElement) {
25451 const containerRect = container.getBoundingClientRect();
25452 const anchorRect = anchorElement.getBoundingClientRect();
25453 const currentOffset = anchorRect.top - containerRect.top;
25454 const scrollAdjustment = currentOffset - anchor.viewportOffset;
25455 if (Math.abs(scrollAdjustment) > 1) {
25456 container.scrollTop += scrollAdjustment;
25457 }
25458 }
25459 anchorElementRef.current = null;
25460 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
25461 const intersectionObserverRef = (0, import_element71.useRef)(
25462 null
25463 );
25464 (0, import_element71.useEffect)(() => {
25465 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
25466 if (intersectionObserverRef.current) {
25467 intersectionObserverRef.current.disconnect();
25468 intersectionObserverRef.current = null;
25469 }
25470 return;
25471 }
25472 intersectionObserverRef.current = new IntersectionObserver(
25473 intersectionObserverCallback,
25474 { root: null, rootMargin: "0px", threshold: 0.1 }
25475 );
25476 return () => {
25477 if (intersectionObserverRef.current) {
25478 intersectionObserverRef.current.disconnect();
25479 intersectionObserverRef.current = null;
25480 }
25481 };
25482 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
25483 (0, import_element71.useEffect)(() => {
25484 if (!view.infiniteScrollEnabled || !containerRef.current) {
25485 return;
25486 }
25487 let lastScrollTop = 0;
25488 const BOTTOM_THRESHOLD = 600;
25489 const TOP_THRESHOLD = 800;
25490 const handleScroll = (0, import_compose11.throttle)((event) => {
25491 const currentView = viewRef.current;
25492 const totalItems = totalItemsRef.current;
25493 const target = event.target;
25494 const scrollTop = target.scrollTop;
25495 const scrollHeight = target.scrollHeight;
25496 const clientHeight = target.clientHeight;
25497 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
25498 lastScrollTop = scrollTop;
25499 if (isLoadingRef.current) {
25500 return;
25501 }
25502 const currentStartPosition = currentView.startPosition || 1;
25503 const batchSize = currentView.perPage || 10;
25504 const currentEndPosition = Math.min(
25505 currentStartPosition + batchSize,
25506 totalItems
25507 );
25508 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
25509 if (currentEndPosition < totalItems) {
25510 const newStartPosition = currentEndPosition;
25511 captureAnchorElement(target, anchorElementRef, "down");
25512 onChangeViewRef.current({
25513 ...currentView,
25514 startPosition: newStartPosition
25515 });
25516 }
25517 }
25518 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
25519 if (currentStartPosition > 1) {
25520 const calculatedStartPosition = currentStartPosition - batchSize;
25521 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
25522 captureAnchorElement(target, anchorElementRef, "up");
25523 onChangeViewRef.current({
25524 ...currentView,
25525 startPosition: newStartPosition
25526 });
25527 }
25528 }
25529 }, 50);
25530 const container = containerRef.current;
25531 container.addEventListener("scroll", handleScroll);
25532 return () => {
25533 container.removeEventListener("scroll", handleScroll);
25534 handleScroll.cancel();
25535 };
25536 }, [containerRef, view.infiniteScrollEnabled]);
25537 return {
25538 intersectionObserver: intersectionObserverRef.current
25539 };
25540 }
25541
25542 // packages/dataviews/build-module/dataviews/index.mjs
25543 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
25544 var defaultGetItemId = (item) => item.id;
25545 var defaultIsItemClickable = () => true;
25546 var EMPTY_ARRAY6 = [];
25547 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
25548 var dataViewsLayouts = VIEW_LAYOUTS.filter(
25549 (viewLayout) => !viewLayout.isPicker
25550 );
25551 function DefaultUI({
25552 header,
25553 search = true,
25554 searchLabel = void 0
25555 }) {
25556 const { view } = (0, import_element72.useContext)(dataviews_context_default);
25557 const isInfiniteScroll = view.infiniteScrollEnabled;
25558 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [
25559 /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
25560 Stack,
25561 {
25562 direction: "row",
25563 align: "top",
25564 justify: "space-between",
25565 className: clsx_default("dataviews__view-actions", {
25566 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
25567 }),
25568 gap: "xs",
25569 children: [
25570 /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
25571 Stack,
25572 {
25573 direction: "row",
25574 justify: "start",
25575 gap: "sm",
25576 className: "dataviews__search",
25577 children: [
25578 search && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(dataviews_search_default, { label: searchLabel }),
25579 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(toggle_default, {})
25580 ]
25581 }
25582 ),
25583 /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
25584 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(dataviews_view_config_default, {}),
25585 header
25586 ] })
25587 ]
25588 }
25589 ),
25590 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
25591 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(DataViewsLayout, {}),
25592 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(DataViewsFooter, {})
25593 ] });
25594 }
25595 function DataViews({
25596 view,
25597 onChangeView,
25598 fields,
25599 search = true,
25600 searchLabel = void 0,
25601 actions = EMPTY_ARRAY6,
25602 data,
25603 getItemId = defaultGetItemId,
25604 getItemLevel,
25605 isLoading = false,
25606 paginationInfo,
25607 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
25608 selection: selectionProperty,
25609 onChangeSelection,
25610 onClickItem,
25611 renderItemLink,
25612 isItemClickable = defaultIsItemClickable,
25613 header,
25614 children,
25615 config = { perPageSizes: [10, 20, 50, 100] },
25616 empty,
25617 onReset
25618 }) {
25619 const [selectionState, setSelectionState] = (0, import_element72.useState)([]);
25620 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
25621 const selection = isUncontrolled ? selectionState : selectionProperty;
25622 const {
25623 data: displayData,
25624 paginationInfo: displayPaginationInfo,
25625 hasInitiallyLoaded,
25626 setVisibleEntries
25627 } = useData({
25628 view,
25629 data,
25630 getItemId,
25631 isLoading,
25632 selection,
25633 paginationInfo
25634 });
25635 const containerRef = (0, import_element72.useRef)(null);
25636 const [containerWidth, setContainerWidth] = (0, import_element72.useState)(0);
25637 const resizeObserverRef = (0, import_compose12.useResizeObserver)(
25638 (resizeObserverEntries) => {
25639 setContainerWidth(
25640 resizeObserverEntries[0].borderBoxSize[0].inlineSize
25641 );
25642 },
25643 { box: "border-box" }
25644 );
25645 const [openedFilter, setOpenedFilter] = (0, import_element72.useState)(null);
25646 function setSelectionWithChange(value) {
25647 const newValue = typeof value === "function" ? value(selection) : value;
25648 if (isUncontrolled) {
25649 setSelectionState(newValue);
25650 }
25651 if (onChangeSelection) {
25652 onChangeSelection(newValue);
25653 }
25654 }
25655 const _fields = (0, import_element72.useMemo)(() => normalizeFields(fields), [fields]);
25656 const _selection = (0, import_element72.useMemo)(() => {
25657 if (view.infiniteScrollEnabled) {
25658 return selection;
25659 }
25660 return selection.filter(
25661 (id) => data.some((item) => getItemId(item) === id)
25662 );
25663 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
25664 const filters = use_filters_default(_fields, view);
25665 const hasPrimaryOrLockedFilters = (0, import_element72.useMemo)(
25666 () => (filters || []).some(
25667 (filter) => filter.isPrimary || filter.isLocked
25668 ),
25669 [filters]
25670 );
25671 const [isShowingFilter, setIsShowingFilter] = (0, import_element72.useState)(
25672 hasPrimaryOrLockedFilters
25673 );
25674 const { intersectionObserver } = useInfiniteScroll({
25675 view,
25676 onChangeView,
25677 isLoading,
25678 paginationInfo,
25679 containerRef,
25680 setVisibleEntries
25681 });
25682 (0, import_element72.useEffect)(() => {
25683 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
25684 setIsShowingFilter(true);
25685 }
25686 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
25687 const defaultLayouts = (0, import_element72.useMemo)(
25688 () => Object.fromEntries(
25689 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
25690 return dataViewsLayouts.some(
25691 (viewLayout) => viewLayout.type === layoutType
25692 );
25693 }).map(([key, value]) => [
25694 key,
25695 value === true ? {} : value
25696 ])
25697 ),
25698 [defaultLayoutsProperty]
25699 );
25700 if (!defaultLayouts[view.type]) {
25701 return null;
25702 }
25703 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25704 dataviews_context_default.Provider,
25705 {
25706 value: {
25707 view,
25708 onChangeView,
25709 fields: _fields,
25710 actions,
25711 data: displayData,
25712 isLoading,
25713 paginationInfo: displayPaginationInfo,
25714 selection: _selection,
25715 onChangeSelection: setSelectionWithChange,
25716 openedFilter,
25717 setOpenedFilter,
25718 getItemId,
25719 getItemLevel,
25720 isItemClickable,
25721 onClickItem,
25722 renderItemLink,
25723 containerWidth,
25724 containerRef,
25725 resizeObserverRef,
25726 defaultLayouts,
25727 filters,
25728 isShowingFilter,
25729 setIsShowingFilter,
25730 config,
25731 empty,
25732 hasInitiallyLoaded,
25733 onReset,
25734 intersectionObserver
25735 },
25736 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25737 DefaultUI,
25738 {
25739 header,
25740 search,
25741 searchLabel
25742 }
25743 ) })
25744 }
25745 );
25746 }
25747 var DataViewsSubComponents = DataViews;
25748 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
25749 DataViewsSubComponents.Filters = filters_default;
25750 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
25751 DataViewsSubComponents.FiltersToggle = toggle_default;
25752 DataViewsSubComponents.Layout = DataViewsLayout;
25753 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
25754 DataViewsSubComponents.Pagination = DataViewsPagination;
25755 DataViewsSubComponents.Search = dataviews_search_default;
25756 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
25757 DataViewsSubComponents.Footer = DataViewsFooter;
25758 var dataviews_default = DataViewsSubComponents;
25759
25760 // packages/dataviews/build-module/utils/filter-sort-and-paginate.mjs
25761 var import_remove_accents2 = __toESM(require_remove_accents(), 1);
25762 var import_deprecated = __toESM(require_deprecated(), 1);
25763 function normalizeSearchInput2(input = "") {
25764 return (0, import_remove_accents2.default)(input.trim().toLowerCase());
25765 }
25766 var EMPTY_ARRAY7 = [];
25767 function filterSortAndPaginate(data, view, fields) {
25768 if (!data) {
25769 return {
25770 data: EMPTY_ARRAY7,
25771 paginationInfo: { totalItems: 0, totalPages: 0 }
25772 };
25773 }
25774 const _fields = normalizeFields(fields);
25775 let filteredData = [...data];
25776 if (view.search) {
25777 const normalizedSearch = normalizeSearchInput2(view.search);
25778 filteredData = filteredData.filter((item) => {
25779 return _fields.filter((field) => field.enableGlobalSearch).some((field) => {
25780 const fieldValue = field.getValue({ item });
25781 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
25782 return values.some(
25783 (value) => normalizeSearchInput2(String(value)).includes(
25784 normalizedSearch
25785 )
25786 );
25787 });
25788 });
25789 }
25790 if (view.filters && view.filters?.length > 0) {
25791 view.filters.forEach((filter) => {
25792 const field = _fields.find(
25793 (_field) => _field.id === filter.field
25794 );
25795 if (field) {
25796 if (filter.operator === OPERATOR_IS_NOT_ALL) {
25797 (0, import_deprecated.default)("The 'isNotAll' filter operator", {
25798 since: "7.0",
25799 alternative: "'isNone'"
25800 });
25801 }
25802 const handler = field.filter[filter.operator];
25803 if (handler) {
25804 filteredData = filteredData.filter(
25805 (item) => handler(item, field, filter.value)
25806 );
25807 }
25808 }
25809 });
25810 }
25811 const sortByField = view.sort?.field ? _fields.find((field) => {
25812 return field.enableSorting !== false && field.id === view.sort?.field;
25813 }) : null;
25814 const groupByField = view.groupBy?.field ? _fields.find((field) => {
25815 return field.enableSorting !== false && field.id === view.groupBy?.field;
25816 }) : null;
25817 if (sortByField || groupByField) {
25818 filteredData.sort((a2, b2) => {
25819 if (groupByField) {
25820 const groupCompare = groupByField.sort(
25821 a2,
25822 b2,
25823 view.groupBy?.direction ?? "asc"
25824 );
25825 if (groupCompare !== 0) {
25826 return groupCompare;
25827 }
25828 }
25829 if (sortByField) {
25830 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc");
25831 }
25832 return 0;
25833 });
25834 }
25835 let totalItems = filteredData.length;
25836 let totalPages = 1;
25837 if (view.infiniteScrollEnabled && view.startPosition !== void 0 && view.perPage !== void 0) {
25838 const start = view.startPosition - 1;
25839 const end = Math.min(start + view.perPage, totalItems);
25840 filteredData = filteredData?.slice(start, end);
25841 } else if (view.page !== void 0 && view.perPage !== void 0) {
25842 const start = (view.page - 1) * view.perPage;
25843 totalItems = filteredData?.length || 0;
25844 totalPages = Math.ceil(totalItems / view.perPage);
25845 filteredData = filteredData?.slice(start, start + view.perPage);
25846 }
25847 return {
25848 data: filteredData,
25849 paginationInfo: {
25850 totalItems,
25851 totalPages
25852 }
25853 };
25854 }
25855
25856 // packages/admin-ui/build-module/navigable-region/index.mjs
25857 var import_element73 = __toESM(require_element(), 1);
25858 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
25859 var NavigableRegion = (0, import_element73.forwardRef)(
25860 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
25861 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
25862 Tag,
25863 {
25864 ref,
25865 className: clsx_default("admin-ui-navigable-region", className),
25866 "aria-label": ariaLabel,
25867 role: "region",
25868 tabIndex: "-1",
25869 ...props,
25870 children
25871 }
25872 );
25873 }
25874 );
25875 NavigableRegion.displayName = "NavigableRegion";
25876 var navigable_region_default = NavigableRegion;
25877
25878 // packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs
25879 var import_components45 = __toESM(require_components(), 1);
25880 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components45.createSlotFill)("SidebarToggle");
25881
25882 // packages/admin-ui/build-module/page/header.mjs
25883 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
25884 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
25885 function getRuntime7() {
25886 const globalScope = globalThis;
25887 if (globalScope.__wpStyleRuntime) {
25888 return globalScope.__wpStyleRuntime;
25889 }
25890 globalScope.__wpStyleRuntime = {
25891 documents: /* @__PURE__ */ new Map(),
25892 styles: /* @__PURE__ */ new Map(),
25893 injectedStyles: /* @__PURE__ */ new WeakMap()
25894 };
25895 if (typeof document !== "undefined") {
25896 registerDocument7(document);
25897 }
25898 return globalScope.__wpStyleRuntime;
25899 }
25900 function documentContainsStyleHash7(targetDocument, hash) {
25901 if (!targetDocument.head) {
25902 return false;
25903 }
25904 for (const style of targetDocument.head.querySelectorAll(
25905 `style[${STYLE_HASH_ATTRIBUTE7}]`
25906 )) {
25907 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
25908 return true;
25909 }
25910 }
25911 return false;
25912 }
25913 function injectStyle7(targetDocument, hash, css) {
25914 if (!targetDocument.head) {
25915 return;
25916 }
25917 const runtime = getRuntime7();
25918 let injectedStyles = runtime.injectedStyles.get(targetDocument);
25919 if (!injectedStyles) {
25920 injectedStyles = /* @__PURE__ */ new Set();
25921 runtime.injectedStyles.set(targetDocument, injectedStyles);
25922 }
25923 if (injectedStyles.has(hash)) {
25924 return;
25925 }
25926 if (documentContainsStyleHash7(targetDocument, hash)) {
25927 injectedStyles.add(hash);
25928 return;
25929 }
25930 const style = targetDocument.createElement("style");
25931 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
25932 style.appendChild(targetDocument.createTextNode(css));
25933 targetDocument.head.appendChild(style);
25934 injectedStyles.add(hash);
25935 }
25936 function registerDocument7(targetDocument) {
25937 const runtime = getRuntime7();
25938 runtime.documents.set(
25939 targetDocument,
25940 (runtime.documents.get(targetDocument) ?? 0) + 1
25941 );
25942 for (const [hash, css] of runtime.styles) {
25943 injectStyle7(targetDocument, hash, css);
25944 }
25945 return () => {
25946 const count = runtime.documents.get(targetDocument);
25947 if (count === void 0) {
25948 return;
25949 }
25950 if (count <= 1) {
25951 runtime.documents.delete(targetDocument);
25952 return;
25953 }
25954 runtime.documents.set(targetDocument, count - 1);
25955 };
25956 }
25957 function registerStyle7(hash, css) {
25958 const runtime = getRuntime7();
25959 runtime.styles.set(hash, css);
25960 for (const targetDocument of runtime.documents.keys()) {
25961 injectStyle7(targetDocument, hash, css);
25962 }
25963 }
25964 if (typeof process === "undefined" || true) {
25965 registerStyle7("aa9c241ccc", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-bg-surface-neutral,#fcfcfc);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-bg-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:calc(var(--wpds-dimension-base, 4px)*8)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:calc(var(--wpds-dimension-base, 4px)*6);width:calc(var(--wpds-dimension-base, 4px)*6);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-fg-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}");
25966 }
25967 var style_default6 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" };
25968 function Header({
25969 headingLevel = 1,
25970 breadcrumbs,
25971 badges,
25972 visual,
25973 title,
25974 subTitle,
25975 actions,
25976 showSidebarToggle = true
25977 }) {
25978 const HeadingTag = `h${headingLevel}`;
25979 return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(Stack, { direction: "column", className: style_default6.header, children: [
25980 /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(
25981 Stack,
25982 {
25983 className: style_default6["header-content"],
25984 direction: "row",
25985 gap: "sm",
25986 justify: "space-between",
25987 children: [
25988 /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", justify: "start", children: [
25989 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
25990 SidebarToggleSlot,
25991 {
25992 bubblesVirtually: true,
25993 className: style_default6["sidebar-toggle-slot"]
25994 }
25995 ),
25996 visual && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
25997 "div",
25998 {
25999 className: style_default6["header-visual"],
26000 "aria-hidden": "true",
26001 children: visual
26002 }
26003 ),
26004 title && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
26005 Text,
26006 {
26007 className: style_default6["header-title"],
26008 render: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(HeadingTag, {}),
26009 variant: "heading-lg",
26010 children: title
26011 }
26012 ),
26013 breadcrumbs,
26014 badges
26015 ] }),
26016 actions && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
26017 Stack,
26018 {
26019 align: "center",
26020 className: style_default6["header-actions"],
26021 direction: "row",
26022 gap: "sm",
26023 children: actions
26024 }
26025 )
26026 ]
26027 }
26028 ),
26029 subTitle && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
26030 Text,
26031 {
26032 render: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("p", {}),
26033 variant: "body-md",
26034 className: style_default6["header-subtitle"],
26035 children: subTitle
26036 }
26037 )
26038 ] });
26039 }
26040
26041 // packages/admin-ui/build-module/page/index.mjs
26042 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
26043 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
26044 function getRuntime8() {
26045 const globalScope = globalThis;
26046 if (globalScope.__wpStyleRuntime) {
26047 return globalScope.__wpStyleRuntime;
26048 }
26049 globalScope.__wpStyleRuntime = {
26050 documents: /* @__PURE__ */ new Map(),
26051 styles: /* @__PURE__ */ new Map(),
26052 injectedStyles: /* @__PURE__ */ new WeakMap()
26053 };
26054 if (typeof document !== "undefined") {
26055 registerDocument8(document);
26056 }
26057 return globalScope.__wpStyleRuntime;
26058 }
26059 function documentContainsStyleHash8(targetDocument, hash) {
26060 if (!targetDocument.head) {
26061 return false;
26062 }
26063 for (const style of targetDocument.head.querySelectorAll(
26064 `style[${STYLE_HASH_ATTRIBUTE8}]`
26065 )) {
26066 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
26067 return true;
26068 }
26069 }
26070 return false;
26071 }
26072 function injectStyle8(targetDocument, hash, css) {
26073 if (!targetDocument.head) {
26074 return;
26075 }
26076 const runtime = getRuntime8();
26077 let injectedStyles = runtime.injectedStyles.get(targetDocument);
26078 if (!injectedStyles) {
26079 injectedStyles = /* @__PURE__ */ new Set();
26080 runtime.injectedStyles.set(targetDocument, injectedStyles);
26081 }
26082 if (injectedStyles.has(hash)) {
26083 return;
26084 }
26085 if (documentContainsStyleHash8(targetDocument, hash)) {
26086 injectedStyles.add(hash);
26087 return;
26088 }
26089 const style = targetDocument.createElement("style");
26090 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
26091 style.appendChild(targetDocument.createTextNode(css));
26092 targetDocument.head.appendChild(style);
26093 injectedStyles.add(hash);
26094 }
26095 function registerDocument8(targetDocument) {
26096 const runtime = getRuntime8();
26097 runtime.documents.set(
26098 targetDocument,
26099 (runtime.documents.get(targetDocument) ?? 0) + 1
26100 );
26101 for (const [hash, css] of runtime.styles) {
26102 injectStyle8(targetDocument, hash, css);
26103 }
26104 return () => {
26105 const count = runtime.documents.get(targetDocument);
26106 if (count === void 0) {
26107 return;
26108 }
26109 if (count <= 1) {
26110 runtime.documents.delete(targetDocument);
26111 return;
26112 }
26113 runtime.documents.set(targetDocument, count - 1);
26114 };
26115 }
26116 function registerStyle8(hash, css) {
26117 const runtime = getRuntime8();
26118 runtime.styles.set(hash, css);
26119 for (const targetDocument of runtime.documents.keys()) {
26120 injectStyle8(targetDocument, hash, css);
26121 }
26122 }
26123 if (typeof process === "undefined" || true) {
26124 registerStyle8("aa9c241ccc", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-bg-surface-neutral,#fcfcfc);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-bg-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:calc(var(--wpds-dimension-base, 4px)*8)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:calc(var(--wpds-dimension-base, 4px)*6);width:calc(var(--wpds-dimension-base, 4px)*6);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-fg-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}");
26125 }
26126 var style_default7 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" };
26127 function Page({
26128 headingLevel,
26129 breadcrumbs,
26130 badges,
26131 visual,
26132 title,
26133 subTitle,
26134 children,
26135 className,
26136 actions,
26137 ariaLabel,
26138 hasPadding = false,
26139 showSidebarToggle = true
26140 }) {
26141 const classes = clsx_default(style_default7.page, className);
26142 const effectiveAriaLabel = ariaLabel ?? (typeof title === "string" ? title : "");
26143 return /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(navigable_region_default, { className: classes, ariaLabel: effectiveAriaLabel, children: [
26144 (title || breadcrumbs || badges || actions || visual) && /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
26145 Header,
26146 {
26147 headingLevel,
26148 breadcrumbs,
26149 badges,
26150 visual,
26151 title,
26152 subTitle,
26153 actions,
26154 showSidebarToggle
26155 }
26156 ),
26157 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
26158 "div",
26159 {
26160 className: clsx_default(
26161 style_default7.content,
26162 style_default7["has-padding"]
26163 ),
26164 children
26165 }
26166 ) : children
26167 ] });
26168 }
26169 Page.SidebarToggleFill = SidebarToggleFill;
26170 var page_default = Page;
26171
26172 // routes/pattern-list/stage.tsx
26173 var import_core_data4 = __toESM(require_core_data());
26174 var import_components46 = __toESM(require_components());
26175 var import_data11 = __toESM(require_data());
26176 var import_element76 = __toESM(require_element());
26177 var import_editor = __toESM(require_editor());
26178 var import_patterns3 = __toESM(require_patterns());
26179 var import_i18n47 = __toESM(require_i18n());
26180
26181 // routes/lock-unlock.ts
26182 var import_private_apis4 = __toESM(require_private_apis());
26183 var { lock: lock4, unlock: unlock4 } = (0, import_private_apis4.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
26184 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
26185 "@wordpress/routes"
26186 );
26187
26188 // routes/pattern-list/view-utils.ts
26189 var import_i18n43 = __toESM(require_i18n());
26190 var LAYOUT_GRID2 = "grid";
26191 var LAYOUT_TABLE2 = "table";
26192 var DEFAULT_VIEW = {
26193 type: LAYOUT_GRID2,
26194 perPage: 20,
26195 sort: {
26196 field: "title",
26197 direction: "asc"
26198 },
26199 filters: [],
26200 fields: ["sync-status"],
26201 layout: {
26202 badgeFields: ["sync-status"]
26203 },
26204 titleField: "title",
26205 mediaField: "preview"
26206 };
26207 var DEFAULT_VIEWS = [
26208 {
26209 slug: "all",
26210 label: (0, import_i18n43.__)("All patterns")
26211 },
26212 {
26213 slug: "my-patterns",
26214 label: (0, import_i18n43.__)("My patterns")
26215 },
26216 {
26217 slug: "registered",
26218 label: (0, import_i18n43.__)("Registered")
26219 }
26220 ];
26221 var DEFAULT_LAYOUTS2 = {
26222 [LAYOUT_TABLE2]: true,
26223 [LAYOUT_GRID2]: {
26224 layout: {
26225 badgeFields: ["sync-status"]
26226 }
26227 }
26228 };
26229
26230 // routes/pattern-list/fields/preview.tsx
26231 var import_i18n44 = __toESM(require_i18n());
26232 import { Preview } from "@wordpress/lazy-editor";
26233 function PreviewField({ item }) {
26234 return /* @__PURE__ */ React.createElement(
26235 Preview,
26236 {
26237 blocks: item.blocks,
26238 content: item.content,
26239 description: item.description
26240 }
26241 );
26242 }
26243 var previewField = {
26244 label: (0, import_i18n44.__)("Preview"),
26245 id: "preview",
26246 render: PreviewField,
26247 enableSorting: false
26248 };
26249
26250 // routes/pattern-list/fields/sync-status.tsx
26251 var import_i18n45 = __toESM(require_i18n());
26252 var import_patterns = __toESM(require_patterns());
26253 var { PATTERN_SYNC_TYPES } = unlock4(import_patterns.privateApis);
26254 var OPERATOR_IS2 = "is";
26255 var SYNC_FILTERS = [
26256 {
26257 value: PATTERN_SYNC_TYPES.full,
26258 label: (0, import_i18n45._x)("Synced", "pattern (singular)"),
26259 description: (0, import_i18n45.__)("Patterns that are kept in sync across the site.")
26260 },
26261 {
26262 value: PATTERN_SYNC_TYPES.unsynced,
26263 label: (0, import_i18n45._x)("Not synced", "pattern (singular)"),
26264 description: (0, import_i18n45.__)(
26265 "Patterns that can be changed freely without affecting the site."
26266 )
26267 }
26268 ];
26269 var patternStatusField = {
26270 label: (0, import_i18n45.__)("Sync status"),
26271 id: "sync-status",
26272 render: ({ item }) => {
26273 const syncStatus = item.syncStatus;
26274 return /* @__PURE__ */ React.createElement(
26275 "span",
26276 {
26277 className: `routes-pattern-list__field-sync-status-${syncStatus}`
26278 },
26279 SYNC_FILTERS.find(({ value }) => value === syncStatus)?.label
26280 );
26281 },
26282 elements: SYNC_FILTERS,
26283 filterBy: {
26284 operators: [OPERATOR_IS2],
26285 isPrimary: true
26286 },
26287 enableSorting: false
26288 };
26289
26290 // routes/pattern-list/fields/category.tsx
26291 var import_i18n46 = __toESM(require_i18n());
26292 var import_data9 = __toESM(require_data());
26293 var import_core_data2 = __toESM(require_core_data());
26294 var import_element74 = __toESM(require_element());
26295 var OPERATOR_IS3 = "is";
26296 function CategoryField({ item }) {
26297 const blockPatternCategories = (0, import_data9.useSelect)(
26298 (select2) => select2(import_core_data2.store).getBlockPatternCategories(),
26299 []
26300 );
26301 const categoryLabels = (0, import_element74.useMemo)(() => {
26302 if (!item.categories || !Array.isArray(item.categories)) {
26303 return [];
26304 }
26305 return item.categories.map((catSlug) => {
26306 const category = blockPatternCategories?.find(
26307 (cat) => cat.name === catSlug
26308 );
26309 return category ? category.label || category.name : null;
26310 }).filter(Boolean);
26311 }, [item.categories, blockPatternCategories]);
26312 if (categoryLabels.length === 0) {
26313 return /* @__PURE__ */ React.createElement("span", { className: "pattern-category-field__empty" }, "\u2014");
26314 }
26315 return /* @__PURE__ */ React.createElement("span", { className: "pattern-category-field" }, categoryLabels.join(", "));
26316 }
26317 function usePatternCategories() {
26318 const userPatternCategories = (0, import_data9.useSelect)(
26319 (select2) => select2(import_core_data2.store).getUserPatternCategories(),
26320 []
26321 );
26322 const blockPatternCategories = (0, import_data9.useSelect)(
26323 (select2) => select2(import_core_data2.store).getBlockPatternCategories(),
26324 []
26325 );
26326 return (0, import_element74.useMemo)(() => {
26327 const categoryMap = /* @__PURE__ */ new Map();
26328 userPatternCategories?.forEach((cat) => {
26329 if (!categoryMap.has(cat.name)) {
26330 categoryMap.set(cat.name, {
26331 value: cat.name,
26332 label: cat.label || cat.name
26333 });
26334 }
26335 });
26336 blockPatternCategories?.forEach((cat) => {
26337 if (!categoryMap.has(cat.name)) {
26338 categoryMap.set(cat.name, {
26339 value: cat.name,
26340 label: cat.label || cat.name
26341 });
26342 }
26343 });
26344 return Array.from(categoryMap.values()).sort(
26345 (a2, b2) => a2.label.localeCompare(b2.label)
26346 );
26347 }, [userPatternCategories, blockPatternCategories]);
26348 }
26349 function usePatternCategoryField() {
26350 const categories = usePatternCategories();
26351 return {
26352 label: (0, import_i18n46.__)("Category"),
26353 id: "category",
26354 render: CategoryField,
26355 elements: categories,
26356 getValue: ({ item }) => {
26357 return item.categories;
26358 },
26359 filterBy: {
26360 operators: [OPERATOR_IS3],
26361 isPrimary: true
26362 },
26363 enableSorting: false
26364 };
26365 }
26366
26367 // routes/pattern-list/use-patterns.ts
26368 var import_data10 = __toESM(require_data());
26369 var import_core_data3 = __toESM(require_core_data());
26370 var import_element75 = __toESM(require_element());
26371 var import_patterns2 = __toESM(require_patterns());
26372 var import_block_editor = __toESM(require_block_editor());
26373
26374 // routes/pattern-list/utils.ts
26375 var filterOutDuplicatesByName = (currentItem, index2, items) => index2 === items.findIndex((item) => currentItem.name === item.name);
26376
26377 // routes/pattern-list/use-patterns.ts
26378 var {
26379 PATTERN_TYPES,
26380 PATTERN_SYNC_TYPES: PATTERN_SYNC_TYPES2,
26381 EXCLUDED_PATTERN_SOURCES,
26382 PATTERN_DEFAULT_CATEGORY
26383 } = unlock4(import_patterns2.privateApis);
26384 var { extractWords, getNormalizedSearchTerms, normalizeString: normalizeString2 } = unlock4(
26385 import_block_editor.privateApis
26386 );
26387 function normalizeThemePattern(pattern) {
26388 return {
26389 id: pattern.name,
26390 title: pattern.title,
26391 content: pattern.content,
26392 keywords: pattern.keywords || [],
26393 type: PATTERN_TYPES.theme,
26394 // Normalize categories to always be an array of slugs
26395 categories: pattern.categories || [],
26396 // Theme patterns are always unsynced
26397 syncStatus: PATTERN_SYNC_TYPES2.unsynced,
26398 description: pattern.description || ""
26399 };
26400 }
26401 function normalizeUserPattern(pattern, userPatternCategories) {
26402 const categories = [];
26403 if (pattern.wp_pattern_category && Array.isArray(pattern.wp_pattern_category)) {
26404 pattern.wp_pattern_category.forEach((catId) => {
26405 const category = userPatternCategories?.find(
26406 (cat) => cat.id === catId
26407 );
26408 if (category) {
26409 categories.push(category.name);
26410 }
26411 });
26412 }
26413 const numericId = pattern.id;
26414 return {
26415 id: pattern.name || pattern.id.toString(),
26416 _recordId: numericId,
26417 // Keep numeric ID for permissions lookup
26418 keywords: [],
26419 type: PATTERN_TYPES.user,
26420 // Normalize categories to always be an array of slugs
26421 categories,
26422 // Normalize sync status
26423 syncStatus: pattern.wp_pattern_sync_status || PATTERN_SYNC_TYPES2.full,
26424 title: typeof pattern.title === "string" ? pattern.title : pattern.title.raw,
26425 content: typeof pattern.content === "string" ? pattern.content : pattern.content.raw,
26426 description: pattern.excerpt?.raw || "",
26427 blocks: pattern.blocks
26428 };
26429 }
26430 var removeMatchingTerms = (unmatchedTerms, unprocessedTerms) => {
26431 return unmatchedTerms.filter(
26432 (term) => !getNormalizedSearchTerms(unprocessedTerms).some(
26433 (unprocessedTerm) => unprocessedTerm.includes(term)
26434 )
26435 );
26436 };
26437 function getItemSearchRank(item, searchTerm, config) {
26438 const { categoryId, hasCategory, onlyFilterByCategory } = config;
26439 let rank = categoryId === PATTERN_DEFAULT_CATEGORY || categoryId === "my-patterns" && item.type === PATTERN_TYPES.user || hasCategory && hasCategory(item, categoryId || "") ? 1 : 0;
26440 if (!rank || onlyFilterByCategory) {
26441 return rank;
26442 }
26443 const normalizedSearchInput = normalizeString2(searchTerm);
26444 const normalizedTitle = normalizeString2(item.title);
26445 if (normalizedSearchInput === normalizedTitle) {
26446 rank += 30;
26447 } else if (normalizedTitle.startsWith(normalizedSearchInput)) {
26448 rank += 20;
26449 } else {
26450 const terms = [
26451 item.id,
26452 item.title,
26453 item.description,
26454 ...item.keywords
26455 ].join(" ");
26456 const normalizedSearchTerms = extractWords(normalizedSearchInput);
26457 const unmatchedTerms = removeMatchingTerms(
26458 normalizedSearchTerms,
26459 terms
26460 );
26461 if (unmatchedTerms.length === 0) {
26462 rank += 10;
26463 }
26464 }
26465 return rank;
26466 }
26467 function searchItems(items = [], searchInput = "", config = {}) {
26468 const normalizedSearchTerms = getNormalizedSearchTerms(searchInput);
26469 const onlyFilterByCategory = config.categoryId !== PATTERN_DEFAULT_CATEGORY && !normalizedSearchTerms.length;
26470 const searchRankConfig = { ...config, onlyFilterByCategory };
26471 const threshold = onlyFilterByCategory ? 0 : 1;
26472 const rankedItems = items.map((item) => {
26473 return [
26474 item,
26475 getItemSearchRank(item, searchInput, searchRankConfig)
26476 ];
26477 }).filter(([, rank]) => rank > threshold);
26478 if (normalizedSearchTerms.length === 0) {
26479 return rankedItems.map(([item]) => item);
26480 }
26481 rankedItems.sort(([, rank1], [, rank2]) => rank2 - rank1);
26482 return rankedItems.map(([item]) => item);
26483 }
26484 var selectThemePatterns = (0, import_data10.createSelector)(
26485 (select2) => {
26486 const { getBlockPatterns } = select2(import_core_data3.store);
26487 const { isResolving: isResolvingSelector } = select2(import_core_data3.store);
26488 const restBlockPatterns = getBlockPatterns();
26489 const patterns = (restBlockPatterns || []).filter(
26490 (pattern) => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source)
26491 ).filter(filterOutDuplicatesByName).filter((pattern) => pattern.inserter !== false).map(normalizeThemePattern);
26492 return {
26493 patterns,
26494 isResolving: isResolvingSelector("getBlockPatterns")
26495 };
26496 },
26497 (select2) => [
26498 select2(import_core_data3.store).getBlockPatterns(),
26499 select2(import_core_data3.store).isResolving("getBlockPatterns")
26500 ]
26501 );
26502 var selectUserPatterns = (0, import_data10.createSelector)(
26503 (select2, syncStatus = void 0, search = "") => {
26504 const {
26505 getEntityRecords,
26506 isResolving: isResolvingSelector,
26507 getUserPatternCategories
26508 } = select2(import_core_data3.store);
26509 const query = { per_page: -1 };
26510 const patternPosts = getEntityRecords(
26511 "postType",
26512 PATTERN_TYPES.user,
26513 query
26514 );
26515 const userPatternCategories = getUserPatternCategories();
26516 let patterns = (patternPosts ?? []).map(
26517 (pattern) => normalizeUserPattern(pattern, userPatternCategories)
26518 );
26519 const isResolving = isResolvingSelector("getEntityRecords", [
26520 "postType",
26521 PATTERN_TYPES.user,
26522 query
26523 ]);
26524 if (syncStatus) {
26525 patterns = patterns.filter(
26526 (pattern) => pattern.syncStatus === syncStatus
26527 );
26528 }
26529 patterns = searchItems(patterns, search, {
26530 // We exit user pattern retrieval early if we aren't in the
26531 // catch-all category for user created patterns, so it has
26532 // to be in the category.
26533 categoryId: PATTERN_DEFAULT_CATEGORY,
26534 hasCategory: () => true
26535 });
26536 return {
26537 patterns,
26538 isResolving,
26539 categories: userPatternCategories
26540 };
26541 },
26542 (select2) => [
26543 select2(import_core_data3.store).getEntityRecords("postType", PATTERN_TYPES.user, {
26544 per_page: -1
26545 }),
26546 select2(import_core_data3.store).isResolving("getEntityRecords", [
26547 "postType",
26548 PATTERN_TYPES.user,
26549 { per_page: -1 }
26550 ]),
26551 select2(import_core_data3.store).getUserPatternCategories()
26552 ]
26553 );
26554 var selectPatterns = (0, import_data10.createSelector)(
26555 (select2, categoryId, syncStatus, search = "") => {
26556 const {
26557 patterns: themePatterns,
26558 isResolving: isResolvingThemePatterns
26559 } = selectThemePatterns(select2);
26560 const { patterns: userPatterns, isResolving: isResolvingUserPatterns } = selectUserPatterns(select2);
26561 let patterns = [
26562 ...themePatterns || [],
26563 ...userPatterns || []
26564 ];
26565 if (syncStatus) {
26566 patterns = patterns.filter(
26567 (pattern) => pattern.syncStatus === syncStatus
26568 );
26569 }
26570 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
26571 patterns = searchItems(patterns, search, {
26572 categoryId,
26573 hasCategory: (item, currentCategory) => {
26574 return item.categories?.includes(currentCategory);
26575 }
26576 });
26577 } else {
26578 patterns = searchItems(patterns, search, {
26579 categoryId: PATTERN_DEFAULT_CATEGORY,
26580 hasCategory: () => true
26581 });
26582 }
26583 return {
26584 patterns,
26585 isResolving: isResolvingThemePatterns || isResolvingUserPatterns
26586 };
26587 },
26588 (select2) => [
26589 selectThemePatterns(select2),
26590 selectUserPatterns(select2)
26591 ]
26592 );
26593 function useAugmentPatternsWithPermissions(patterns) {
26594 const idsAndTypes = (0, import_element75.useMemo)(
26595 () => patterns?.filter((record) => record.type !== PATTERN_TYPES.theme).map((record) => [
26596 record.type,
26597 record._recordId,
26598 record.id
26599 ]) ?? [],
26600 [patterns]
26601 );
26602 const permissions = (0, import_data10.useSelect)(
26603 (select2) => {
26604 const { getEntityRecordPermissions } = unlock4(
26605 select2(import_core_data3.store)
26606 );
26607 return idsAndTypes.reduce(
26608 (acc, [type, numericId, stringId]) => {
26609 acc[stringId] = getEntityRecordPermissions(
26610 "postType",
26611 type,
26612 numericId
26613 );
26614 return acc;
26615 },
26616 {}
26617 );
26618 },
26619 [idsAndTypes]
26620 );
26621 return (0, import_element75.useMemo)(
26622 () => patterns?.map((record) => ({
26623 ...record,
26624 permissions: permissions?.[record.id] ?? {}
26625 })) ?? [],
26626 [patterns, permissions]
26627 );
26628 }
26629 var usePatterns = (postType, categoryId, { search = "", syncStatus } = {}) => {
26630 return (0, import_data10.useSelect)(
26631 (select2) => {
26632 if (postType === PATTERN_TYPES.user) {
26633 const result = selectUserPatterns(select2, syncStatus, search);
26634 let { patterns } = result;
26635 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
26636 patterns = patterns.filter(
26637 (pattern) => pattern.categories.includes(categoryId)
26638 );
26639 }
26640 return {
26641 patterns,
26642 isResolving: result.isResolving
26643 };
26644 } else if (postType === PATTERN_TYPES.theme) {
26645 const result = selectThemePatterns(select2);
26646 let { patterns } = result;
26647 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
26648 patterns = patterns.filter(
26649 (pattern) => pattern.categories.includes(categoryId)
26650 );
26651 }
26652 patterns = searchItems(patterns, search, {
26653 categoryId: categoryId || PATTERN_DEFAULT_CATEGORY,
26654 hasCategory: () => true
26655 });
26656 return {
26657 patterns,
26658 isResolving: result.isResolving
26659 };
26660 }
26661 return selectPatterns(select2, categoryId, syncStatus, search);
26662 },
26663 [categoryId, postType, search, syncStatus]
26664 );
26665 };
26666 var use_patterns_default = usePatterns;
26667
26668 // routes/pattern-list/style.scss
26669 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='c329396b1f']")) {
26670 const style = document.createElement("style");
26671 style.setAttribute("data-wp-hash", "c329396b1f");
26672 style.appendChild(document.createTextNode(":root{--wp-block-synced-color:#7a00df;--wp-block-synced-color--rgb:122,0,223;--wp-bound-block-color:var(--wp-block-synced-color);--wp-editor-canvas-background:#ddd;--wp-admin-theme-color:#007cba;--wp-admin-theme-color--rgb:0,124,186;--wp-admin-theme-color-darker-10:#006ba1;--wp-admin-theme-color-darker-10--rgb:0,107,160.5;--wp-admin-theme-color-darker-20:#005a87;--wp-admin-theme-color-darker-20--rgb:0,90,135;--wp-admin-border-width-focus:2px}@media (min-resolution:192dpi){:root{--wp-admin-border-width-focus:1.5px}}.patterns-menu-items__convert-modal{z-index:1000001}.patterns-menu-items__convert-modal [role=dialog]>[role=document]{width:350px}.patterns-menu-items__convert-modal .patterns-menu-items__convert-modal-categories{position:relative}.patterns-menu-items__convert-modal .components-form-token-field__suggestions-list:not(:empty){background-color:#fff;border:1px solid var(--wp-admin-theme-color);border-bottom-left-radius:2px;border-bottom-right-radius:2px;box-shadow:0 0 .5px .5px var(--wp-admin-theme-color);box-sizing:border-box;left:-1px;max-height:96px;min-width:auto;position:absolute;width:calc(100% + 2px);z-index:1}.patterns-create-modal__name-input input[type=text]{margin:0}.patterns-rename-pattern-category-modal__validation-message{color:#cc1818}@media (min-width:782px){.patterns-rename-pattern-category-modal__validation-message{width:320px}}.pattern-overrides-control__allow-overrides-button{justify-content:center;width:100%}.routes-pattern-list__tabs-wrapper{border-bottom:1px solid #f0f0f0;padding:0 24px}.dataviews-view-grid__badge-fields .dataviews-view-grid__field-value:has(.routes-pattern-list__field-sync-status-fully){background:rgba(var(--wp-block-synced-color--rgb),.04);color:var(--wp-block-synced-color)}"));
26673 document.head.appendChild(style);
26674 }
26675
26676 // routes/pattern-list/stage.tsx
26677 var { usePostActions, patternTitleField } = unlock4(import_editor.privateApis);
26678 var { Tabs } = unlock4(import_components46.privateApis);
26679 var { PATTERN_TYPES: PATTERN_TYPES2, CreatePatternModal } = unlock4(import_patterns3.privateApis);
26680 function PatternList() {
26681 const invalidate = useInvalidate();
26682 const { type = "all" } = useParams({
26683 from: "/patterns/list/$type"
26684 });
26685 const navigate = useNavigate();
26686 const searchParams = useSearch({ from: "/patterns/list/$type" });
26687 const postTypeObject = (0, import_data11.useSelect)(
26688 (select2) => select2(import_core_data4.store).getPostType("wp_block"),
26689 []
26690 );
26691 const labels = postTypeObject?.labels;
26692 const canCreateRecord = (0, import_data11.useSelect)(
26693 (select2) => select2(import_core_data4.store).canUser("create", {
26694 kind: "postType",
26695 name: "wp_block"
26696 }),
26697 []
26698 );
26699 const [showPatternModal, setShowPatternModal] = (0, import_element76.useState)(false);
26700 const handleQueryParamsChange = (0, import_element76.useCallback)(
26701 (params) => {
26702 navigate({
26703 search: {
26704 ...searchParams,
26705 ...params
26706 }
26707 });
26708 },
26709 [searchParams, navigate]
26710 );
26711 const { view, isModified, updateView, resetToDefault } = useView({
26712 kind: "postType",
26713 name: "wp_block",
26714 slug: "default-new",
26715 defaultView: DEFAULT_VIEW,
26716 queryParams: searchParams,
26717 onChangeQueryParams: handleQueryParamsChange
26718 });
26719 const onReset = () => {
26720 resetToDefault();
26721 invalidate();
26722 };
26723 const onChangeView = (newView) => {
26724 updateView(newView);
26725 if (newView.type !== view.type) {
26726 invalidate();
26727 }
26728 };
26729 const categoryFilter = (0, import_element76.useMemo)(() => {
26730 const filter = view.filters?.find((f2) => f2.field === "category");
26731 return filter?.value || "all-patterns";
26732 }, [view.filters]);
26733 const syncStatusFilter = (0, import_element76.useMemo)(() => {
26734 const filter = view.filters?.find((f2) => f2.field === "sync-status");
26735 return filter?.value;
26736 }, [view.filters]);
26737 const patternType = (0, import_element76.useMemo)(() => {
26738 if (type === "my-patterns") {
26739 return PATTERN_TYPES2.user;
26740 } else if (type === "registered") {
26741 return PATTERN_TYPES2.theme;
26742 }
26743 return null;
26744 }, [type]);
26745 const { patterns, isResolving } = use_patterns_default(
26746 patternType,
26747 categoryFilter,
26748 {
26749 search: view.search,
26750 syncStatus: syncStatusFilter
26751 }
26752 );
26753 const patternsWithPermissions = useAugmentPatternsWithPermissions(patterns);
26754 const patternCategoryField = usePatternCategoryField();
26755 const fields = (0, import_element76.useMemo)(() => {
26756 const patternFields = [
26757 previewField,
26758 patternTitleField,
26759 patternCategoryField
26760 ];
26761 if (type === "my-patterns" || type === "all") {
26762 patternFields.push(patternStatusField);
26763 }
26764 return patternFields;
26765 }, [type, patternCategoryField]);
26766 const { data: posts, paginationInfo } = (0, import_element76.useMemo)(() => {
26767 const viewWithoutFilters = { ...view };
26768 delete viewWithoutFilters.search;
26769 viewWithoutFilters.filters = [];
26770 return filterSortAndPaginate(
26771 patternsWithPermissions,
26772 viewWithoutFilters,
26773 fields
26774 );
26775 }, [patternsWithPermissions, view, fields]);
26776 const { totalItems, totalPages } = paginationInfo;
26777 const cleanupDeletedPostIdsFromUrl = (0, import_element76.useCallback)(
26778 (deletedItems) => {
26779 const deletedIds = deletedItems.map((item) => item.id);
26780 const currentPostIds = searchParams.postIds || [];
26781 const remainingPostIds = currentPostIds.filter(
26782 (id) => !deletedIds.includes(id)
26783 );
26784 if (remainingPostIds.length !== currentPostIds.length) {
26785 navigate({
26786 search: {
26787 ...searchParams,
26788 postIds: remainingPostIds.length > 0 ? remainingPostIds : void 0
26789 }
26790 });
26791 } else {
26792 invalidate();
26793 }
26794 },
26795 [invalidate, searchParams, navigate]
26796 );
26797 const postTypeActions = usePostActions({
26798 postType: "wp_block",
26799 context: "list",
26800 onActionPerformed: (actionId, items) => {
26801 if (actionId === "move-to-trash" || actionId === "permanently-delete") {
26802 cleanupDeletedPostIdsFromUrl(items);
26803 }
26804 }
26805 });
26806 const actions = (0, import_element76.useMemo)(() => {
26807 return [
26808 ...postTypeActions?.flatMap((action) => {
26809 if (action.id === "view-post-revisions") {
26810 return [];
26811 }
26812 return [action];
26813 })
26814 ];
26815 }, [postTypeActions]);
26816 const handleTabChange = (0, import_element76.useCallback)(
26817 (typeSlug) => {
26818 navigate({
26819 to: `/patterns/list/${typeSlug}`
26820 });
26821 },
26822 [navigate]
26823 );
26824 if (!postTypeObject) {
26825 return null;
26826 }
26827 const selection = searchParams.postIds ?? [];
26828 if (view.type === "list" && selection.length === 0 && posts?.length > 0) {
26829 selection.push(posts[0].id);
26830 }
26831 if (view.type === "list") {
26832 selection.splice(1);
26833 }
26834 return /* @__PURE__ */ React.createElement(
26835 page_default,
26836 {
26837 title: (0, import_i18n47.__)("Patterns"),
26838 headingLevel: 2,
26839 subTitle: (0, import_i18n47.__)(
26840 "Reusable design elements for your site. Create once, use everywhere."
26841 ),
26842 className: "pattern-page",
26843 actions: labels?.add_new_item && canCreateRecord && /* @__PURE__ */ React.createElement(
26844 import_components46.Button,
26845 {
26846 variant: "primary",
26847 onClick: () => setShowPatternModal(true),
26848 size: "compact"
26849 },
26850 labels.add_new_item
26851 ),
26852 hasPadding: false
26853 },
26854 DEFAULT_VIEWS.length > 1 && /* @__PURE__ */ React.createElement("div", { className: "routes-pattern-list__tabs-wrapper" }, /* @__PURE__ */ React.createElement(
26855 Tabs,
26856 {
26857 onSelect: handleTabChange,
26858 selectedTabId: type ?? "all"
26859 },
26860 /* @__PURE__ */ React.createElement(Tabs.TabList, null, DEFAULT_VIEWS.map(
26861 (filter) => /* @__PURE__ */ React.createElement(
26862 Tabs.Tab,
26863 {
26864 tabId: filter.slug,
26865 key: filter.slug
26866 },
26867 filter.label
26868 )
26869 ))
26870 )),
26871 /* @__PURE__ */ React.createElement(
26872 dataviews_default,
26873 {
26874 data: posts,
26875 fields,
26876 view,
26877 onChangeView,
26878 actions,
26879 isLoading: isResolving,
26880 paginationInfo: {
26881 totalItems,
26882 totalPages
26883 },
26884 defaultLayouts: DEFAULT_LAYOUTS2,
26885 selection,
26886 onReset: isModified ? onReset : false,
26887 onChangeSelection: (items) => {
26888 navigate({
26889 search: {
26890 ...searchParams,
26891 postIds: items.length > 0 ? items : void 0,
26892 edit: items.length === 0 ? void 0 : searchParams.edit
26893 }
26894 });
26895 },
26896 isItemClickable: (item) => item.type !== PATTERN_TYPES2.theme,
26897 renderItemLink: ({
26898 item,
26899 ...props
26900 }) => /* @__PURE__ */ React.createElement(
26901 Link,
26902 {
26903 to: `/types/wp_block/edit/${encodeURIComponent(
26904 item.id
26905 )}`,
26906 ...props,
26907 onClick: (event) => {
26908 event.stopPropagation();
26909 }
26910 }
26911 )
26912 }
26913 ),
26914 showPatternModal && /* @__PURE__ */ React.createElement(
26915 CreatePatternModal,
26916 {
26917 onClose: () => setShowPatternModal(false),
26918 onSuccess: ({
26919 pattern
26920 }) => {
26921 setShowPatternModal(false);
26922 navigate({
26923 to: `/types/wp_block/edit/${encodeURIComponent(
26924 pattern.id
26925 )}`
26926 });
26927 },
26928 content: []
26929 }
26930 )
26931 );
26932 }
26933 var stage = PatternList;
26934 export {
26935 stage
26936 };
26937 /*! Bundled license information:
26938
26939 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
26940 (**
26941 * @license React
26942 * use-sync-external-store-shim.development.js
26943 *
26944 * Copyright (c) Meta Platforms, Inc. and affiliates.
26945 *
26946 * This source code is licensed under the MIT license found in the
26947 * LICENSE file in the root directory of this source tree.
26948 *)
26949
26950 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
26951 (**
26952 * @license React
26953 * use-sync-external-store-shim/with-selector.development.js
26954 *
26955 * Copyright (c) Meta Platforms, Inc. and affiliates.
26956 *
26957 * This source code is licensed under the MIT license found in the
26958 * LICENSE file in the root directory of this source tree.
26959 *)
26960 */
26961