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

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

27,962 lines 958.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var __create = Object.create;
2 var __defProp = Object.defineProperty;
3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4 var __getOwnPropNames = Object.getOwnPropertyNames;
5 var __getProtoOf = Object.getPrototypeOf;
6 var __hasOwnProp = Object.prototype.hasOwnProperty;
7 var __commonJS = (cb, mod) => function __require() {
8 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9 };
10 var __export = (target, all) => {
11 for (var name in all)
12 __defProp(target, name, { get: all[name], enumerable: true });
13 };
14 var __copyProps = (to, from, except, desc) => {
15 if (from && typeof from === "object" || typeof from === "function") {
16 for (let key of __getOwnPropNames(from))
17 if (!__hasOwnProp.call(to, key) && key !== except)
18 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19 }
20 return to;
21 };
22 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23 // If the importer is in node compatibility mode or this is not an ESM
24 // file that has been converted to a CommonJS file using a Babel-
25 // compatible transform (i.e. "__esModule" has not been set), then set
26 // "default" to the CommonJS "module.exports" for node compatibility.
27 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28 mod
29 ));
30
31 // package-external:@wordpress/element
32 var require_element = __commonJS({
33 "package-external:@wordpress/element"(exports, module) {
34 module.exports = window.wp.element;
35 }
36 });
37
38 // package-external:@wordpress/data
39 var require_data = __commonJS({
40 "package-external:@wordpress/data"(exports, module) {
41 module.exports = window.wp.data;
42 }
43 });
44
45 // package-external:@wordpress/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 === React50.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 = useState37({
114 inst: { value, getSnapshot }
115 });
116 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
117 useLayoutEffect5(
118 function() {
119 inst.value = value;
120 inst.getSnapshot = getSnapshot;
121 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
122 },
123 [subscribe2, value, getSnapshot]
124 );
125 useEffect32(
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 React50 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState37 = React50.useState, useEffect32 = React50.useEffect, useLayoutEffect5 = React50.useLayoutEffect, useDebugValue2 = React50.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 !== React50.useSyncExternalStore ? React50.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 React50 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef48 = React50.useRef, useEffect32 = React50.useEffect, useMemo44 = React50.useMemo, useDebugValue2 = React50.useDebugValue;
180 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
181 var instRef = useRef48(null);
182 if (null === instRef.current) {
183 var inst = { hasValue: false, value: null };
184 instRef.current = inst;
185 } else inst = instRef.current;
186 instRef = useMemo44(
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 useEffect32(
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/rich-text
837 var require_rich_text = __commonJS({
838 "package-external:@wordpress/rich-text"(exports, module) {
839 module.exports = window.wp.richText;
840 }
841 });
842
843 // package-external:@wordpress/deprecated
844 var require_deprecated = __commonJS({
845 "package-external:@wordpress/deprecated"(exports, module) {
846 module.exports = window.wp.deprecated;
847 }
848 });
849
850 // package-external:@wordpress/editor
851 var require_editor = __commonJS({
852 "package-external:@wordpress/editor"(exports, module) {
853 module.exports = window.wp.editor;
854 }
855 });
856
857 // package-external:@wordpress/patterns
858 var require_patterns = __commonJS({
859 "package-external:@wordpress/patterns"(exports, module) {
860 module.exports = window.wp.patterns;
861 }
862 });
863
864 // package-external:@wordpress/block-editor
865 var require_block_editor = __commonJS({
866 "package-external:@wordpress/block-editor"(exports, module) {
867 module.exports = window.wp.blockEditor;
868 }
869 });
870
871 // routes/pattern-list/stage.tsx
872 import {
873 useParams,
874 useNavigate,
875 useSearch,
876 Link,
877 useInvalidate
878 } from "@wordpress/route";
879
880 // node_modules/dequal/dist/index.mjs
881 var has = Object.prototype.hasOwnProperty;
882 function find(iter, tar, key) {
883 for (key of iter.keys()) {
884 if (dequal(key, tar)) return key;
885 }
886 }
887 function dequal(foo, bar) {
888 var ctor, len, tmp;
889 if (foo === bar) return true;
890 if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
891 if (ctor === Date) return foo.getTime() === bar.getTime();
892 if (ctor === RegExp) return foo.toString() === bar.toString();
893 if (ctor === Array) {
894 if ((len = foo.length) === bar.length) {
895 while (len-- && dequal(foo[len], bar[len])) ;
896 }
897 return len === -1;
898 }
899 if (ctor === Set) {
900 if (foo.size !== bar.size) {
901 return false;
902 }
903 for (len of foo) {
904 tmp = len;
905 if (tmp && typeof tmp === "object") {
906 tmp = find(bar, tmp);
907 if (!tmp) return false;
908 }
909 if (!bar.has(tmp)) return false;
910 }
911 return true;
912 }
913 if (ctor === Map) {
914 if (foo.size !== bar.size) {
915 return false;
916 }
917 for (len of foo) {
918 tmp = len[0];
919 if (tmp && typeof tmp === "object") {
920 tmp = find(bar, tmp);
921 if (!tmp) return false;
922 }
923 if (!dequal(len[1], bar.get(tmp))) {
924 return false;
925 }
926 }
927 return true;
928 }
929 if (ctor === ArrayBuffer) {
930 foo = new Uint8Array(foo);
931 bar = new Uint8Array(bar);
932 } else if (ctor === DataView) {
933 if ((len = foo.byteLength) === bar.byteLength) {
934 while (len-- && foo.getInt8(len) === bar.getInt8(len)) ;
935 }
936 return len === -1;
937 }
938 if (ArrayBuffer.isView(foo)) {
939 if ((len = foo.byteLength) === bar.byteLength) {
940 while (len-- && foo[len] === bar[len]) ;
941 }
942 return len === -1;
943 }
944 if (!ctor || typeof foo === "object") {
945 len = 0;
946 for (ctor in foo) {
947 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
948 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
949 }
950 return Object.keys(bar).length === len;
951 }
952 }
953 return foo !== foo && bar !== bar;
954 }
955
956 // packages/views/build-module/use-view.mjs
957 var import_element = __toESM(require_element(), 1);
958 var import_data = __toESM(require_data(), 1);
959 var import_preferences = __toESM(require_preferences(), 1);
960
961 // packages/views/build-module/preference-keys.mjs
962 function generatePreferenceKey(kind, name, slug) {
963 return `dataviews-${kind}-${name}-${slug}`;
964 }
965
966 // packages/views/build-module/filter-utils.mjs
967 var SCALAR_VALUES = [
968 "titleField",
969 "mediaField",
970 "descriptionField",
971 "showTitle",
972 "showMedia",
973 "showDescription",
974 "showLevels",
975 "infiniteScrollEnabled"
976 ];
977 function mergeActiveViewOverrides(view, activeViewOverrides, defaultView) {
978 if (!activeViewOverrides) {
979 return view;
980 }
981 let result = view;
982 for (const key of SCALAR_VALUES) {
983 if (key in activeViewOverrides) {
984 result = { ...result, [key]: activeViewOverrides[key] };
985 }
986 }
987 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
988 const activeFields = new Set(
989 activeViewOverrides.filters.map((f2) => f2.field)
990 );
991 const preserved = (view.filters ?? []).filter(
992 (f2) => !activeFields.has(f2.field)
993 );
994 result = {
995 ...result,
996 filters: [...preserved, ...activeViewOverrides.filters]
997 };
998 }
999 if (activeViewOverrides.sort) {
1000 const isDefaultSort = defaultView && view.sort?.field === defaultView.sort?.field && view.sort?.direction === defaultView.sort?.direction;
1001 if (isDefaultSort) {
1002 result = {
1003 ...result,
1004 sort: activeViewOverrides.sort
1005 };
1006 }
1007 }
1008 if (activeViewOverrides.layout) {
1009 result = {
1010 ...result,
1011 layout: {
1012 ...result.layout,
1013 ...activeViewOverrides.layout
1014 }
1015 };
1016 }
1017 if (activeViewOverrides.groupBy) {
1018 result = {
1019 ...result,
1020 groupBy: activeViewOverrides.groupBy
1021 };
1022 }
1023 return result;
1024 }
1025 function stripActiveViewOverrides(view, activeViewOverrides, defaultView) {
1026 if (!activeViewOverrides) {
1027 return view;
1028 }
1029 let result = view;
1030 for (const key of SCALAR_VALUES) {
1031 if (key in activeViewOverrides) {
1032 const { [key]: _, ...rest } = result;
1033 result = rest;
1034 }
1035 }
1036 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
1037 const activeFields = new Set(
1038 activeViewOverrides.filters.map((f2) => f2.field)
1039 );
1040 result = {
1041 ...result,
1042 filters: (view.filters ?? []).filter(
1043 (f2) => !activeFields.has(f2.field)
1044 )
1045 };
1046 }
1047 if (activeViewOverrides.sort && view.sort?.field === activeViewOverrides.sort.field && view.sort?.direction === activeViewOverrides.sort.direction) {
1048 result = {
1049 ...result,
1050 sort: defaultView?.sort
1051 };
1052 }
1053 if (activeViewOverrides.layout && "layout" in result && result.layout) {
1054 const layout = { ...result.layout };
1055 for (const key of Object.keys(activeViewOverrides.layout)) {
1056 delete layout[key];
1057 }
1058 result = {
1059 ...result,
1060 layout: Object.keys(layout).length > 0 ? layout : void 0
1061 };
1062 }
1063 if (activeViewOverrides.groupBy && "groupBy" in result) {
1064 const { groupBy: _, ...rest } = result;
1065 result = rest;
1066 }
1067 return result;
1068 }
1069
1070 // packages/views/build-module/use-view.mjs
1071 function omit(obj, keys) {
1072 const result = { ...obj };
1073 for (const key of keys) {
1074 delete result[key];
1075 }
1076 return result;
1077 }
1078 function useView(config) {
1079 const {
1080 kind,
1081 name,
1082 slug,
1083 defaultView,
1084 activeViewOverrides,
1085 queryParams,
1086 onChangeQueryParams
1087 } = config;
1088 const preferenceKey = generatePreferenceKey(kind, name, slug);
1089 const persistedView = (0, import_data.useSelect)(
1090 (select2) => {
1091 return select2(import_preferences.store).get(
1092 "core/views",
1093 preferenceKey
1094 );
1095 },
1096 [preferenceKey]
1097 );
1098 const { set: set2 } = (0, import_data.useDispatch)(import_preferences.store);
1099 const baseView = (0, import_element.useMemo)(
1100 () => persistedView ?? defaultView ?? {},
1101 [persistedView, defaultView]
1102 );
1103 const page = Number(queryParams?.page ?? baseView.page ?? 1);
1104 const search = queryParams?.search ?? baseView.search ?? "";
1105 const combinedOverrides = (0, import_element.useMemo)(() => {
1106 const rawDefaults = config.defaultLayouts?.[baseView.type];
1107 const layoutTypeDefaults = !rawDefaults || rawDefaults === true ? {} : rawDefaults;
1108 return { ...layoutTypeDefaults, ...activeViewOverrides };
1109 }, [config.defaultLayouts, baseView.type, activeViewOverrides]);
1110 const view = (0, import_element.useMemo)(() => {
1111 return mergeActiveViewOverrides(
1112 {
1113 ...baseView,
1114 page,
1115 search
1116 },
1117 combinedOverrides,
1118 defaultView
1119 );
1120 }, [baseView, page, search, combinedOverrides, defaultView]);
1121 const isModified = !!persistedView;
1122 const updateView = (0, import_element.useCallback)(
1123 (newView) => {
1124 const urlParams = {
1125 page: newView?.page,
1126 search: newView?.search
1127 };
1128 const preferenceView = stripActiveViewOverrides(
1129 omit(newView, ["page", "search"]),
1130 combinedOverrides,
1131 defaultView
1132 );
1133 if (onChangeQueryParams && !dequal(urlParams, { page, search })) {
1134 onChangeQueryParams(urlParams);
1135 }
1136 const comparableBaseView = stripActiveViewOverrides(
1137 baseView,
1138 combinedOverrides,
1139 defaultView
1140 );
1141 const comparableDefaultView = stripActiveViewOverrides(
1142 defaultView,
1143 combinedOverrides,
1144 defaultView
1145 );
1146 if (!dequal(comparableBaseView, preferenceView)) {
1147 if (dequal(preferenceView, comparableDefaultView)) {
1148 set2("core/views", preferenceKey, void 0);
1149 } else {
1150 set2("core/views", preferenceKey, preferenceView);
1151 }
1152 }
1153 },
1154 [
1155 onChangeQueryParams,
1156 page,
1157 search,
1158 baseView,
1159 defaultView,
1160 combinedOverrides,
1161 set2,
1162 preferenceKey
1163 ]
1164 );
1165 const resetToDefault = (0, import_element.useCallback)(() => {
1166 set2("core/views", preferenceKey, void 0);
1167 }, [preferenceKey, set2]);
1168 return {
1169 view,
1170 isModified,
1171 updateView,
1172 resetToDefault
1173 };
1174 }
1175
1176 // packages/views/build-module/load-view.mjs
1177 var import_data2 = __toESM(require_data(), 1);
1178 var import_preferences2 = __toESM(require_preferences(), 1);
1179
1180 // packages/views/build-module/use-view-config.mjs
1181 var import_data3 = __toESM(require_data(), 1);
1182 var import_core_data = __toESM(require_core_data(), 1);
1183
1184 // packages/views/build-module/lock-unlock.mjs
1185 var import_private_apis = __toESM(require_private_apis(), 1);
1186 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
1187 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
1188 "@wordpress/views"
1189 );
1190
1191 // node_modules/clsx/dist/clsx.mjs
1192 function r(e2) {
1193 var t2, f2, n2 = "";
1194 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
1195 else if ("object" == typeof e2) if (Array.isArray(e2)) {
1196 var o2 = e2.length;
1197 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
1198 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
1199 return n2;
1200 }
1201 function clsx() {
1202 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
1203 return n2;
1204 }
1205 var clsx_default = clsx;
1206
1207 // packages/dataviews/build-module/dataviews/index.mjs
1208 var import_element78 = __toESM(require_element(), 1);
1209 var import_compose14 = __toESM(require_compose(), 1);
1210
1211 // node_modules/@base-ui/utils/safeReact.mjs
1212 var React2 = __toESM(require_react(), 1);
1213 var SafeReact = {
1214 ...React2
1215 };
1216
1217 // node_modules/@base-ui/utils/useRefWithInit.mjs
1218 var React3 = __toESM(require_react(), 1);
1219 var UNINITIALIZED = {};
1220 function useRefWithInit(init2, initArg) {
1221 const ref = React3.useRef(UNINITIALIZED);
1222 if (ref.current === UNINITIALIZED) {
1223 ref.current = init2(initArg);
1224 }
1225 return ref;
1226 }
1227
1228 // node_modules/@base-ui/utils/useStableCallback.mjs
1229 var useInsertionEffect = SafeReact.useInsertionEffect;
1230 var useSafeInsertionEffect = (
1231 // React 17 doesn't have useInsertionEffect.
1232 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
1233 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn()
1234 );
1235 function useStableCallback(callback) {
1236 const stable = useRefWithInit(createStableCallback).current;
1237 stable.next = callback;
1238 useSafeInsertionEffect(stable.effect);
1239 return stable.trampoline;
1240 }
1241 function createStableCallback() {
1242 const stable = {
1243 next: void 0,
1244 callback: assertNotCalled,
1245 trampoline: (...args) => stable.callback?.(...args),
1246 effect: () => {
1247 stable.callback = stable.next;
1248 }
1249 };
1250 return stable;
1251 }
1252 function assertNotCalled() {
1253 if (true) {
1254 throw (
1255 /* minify-error-disabled */
1256 new Error("Base UI: Cannot call an event handler while rendering.")
1257 );
1258 }
1259 }
1260
1261 // node_modules/@base-ui/utils/useIsoLayoutEffect.mjs
1262 var React4 = __toESM(require_react(), 1);
1263 var noop = () => {
1264 };
1265 var useIsoLayoutEffect = typeof document !== "undefined" ? React4.useLayoutEffect : noop;
1266
1267 // node_modules/@base-ui/utils/warn.mjs
1268 var set;
1269 if (true) {
1270 set = /* @__PURE__ */ new Set();
1271 }
1272 function warn(...messages) {
1273 if (true) {
1274 const messageKey = messages.join(" ");
1275 if (!set.has(messageKey)) {
1276 set.add(messageKey);
1277 console.warn(`Base UI: ${messageKey}`);
1278 }
1279 }
1280 }
1281
1282 // node_modules/@base-ui/react/internals/direction-context/DirectionContext.mjs
1283 var React5 = __toESM(require_react(), 1);
1284 var DirectionContext = /* @__PURE__ */ React5.createContext(void 0);
1285 if (true) DirectionContext.displayName = "DirectionContext";
1286 function useDirection() {
1287 const context = React5.useContext(DirectionContext);
1288 return context?.direction ?? "ltr";
1289 }
1290
1291 // node_modules/@base-ui/react/internals/useRenderElement.mjs
1292 var React8 = __toESM(require_react(), 1);
1293
1294 // node_modules/@base-ui/utils/useMergedRefs.mjs
1295 function useMergedRefs(a2, b2, c2, d2) {
1296 const forkRef = useRefWithInit(createForkRef).current;
1297 if (didChange(forkRef, a2, b2, c2, d2)) {
1298 update(forkRef, [a2, b2, c2, d2]);
1299 }
1300 return forkRef.callback;
1301 }
1302 function useMergedRefsN(refs) {
1303 const forkRef = useRefWithInit(createForkRef).current;
1304 if (didChangeN(forkRef, refs)) {
1305 update(forkRef, refs);
1306 }
1307 return forkRef.callback;
1308 }
1309 function createForkRef() {
1310 return {
1311 callback: null,
1312 cleanup: null,
1313 refs: []
1314 };
1315 }
1316 function didChange(forkRef, a2, b2, c2, d2) {
1317 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1318 }
1319 function didChangeN(forkRef, newRefs) {
1320 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
1321 }
1322 function update(forkRef, refs) {
1323 forkRef.refs = refs;
1324 if (refs.every((ref) => ref == null)) {
1325 forkRef.callback = null;
1326 return;
1327 }
1328 forkRef.callback = (instance) => {
1329 if (forkRef.cleanup) {
1330 forkRef.cleanup();
1331 forkRef.cleanup = null;
1332 }
1333 if (instance != null) {
1334 const cleanupCallbacks = Array(refs.length).fill(null);
1335 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1336 const ref = refs[i2];
1337 if (ref == null) {
1338 continue;
1339 }
1340 switch (typeof ref) {
1341 case "function": {
1342 const refCleanup = ref(instance);
1343 if (typeof refCleanup === "function") {
1344 cleanupCallbacks[i2] = refCleanup;
1345 }
1346 break;
1347 }
1348 case "object": {
1349 ref.current = instance;
1350 break;
1351 }
1352 default:
1353 }
1354 }
1355 forkRef.cleanup = () => {
1356 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1357 const ref = refs[i2];
1358 if (ref == null) {
1359 continue;
1360 }
1361 switch (typeof ref) {
1362 case "function": {
1363 const cleanupCallback = cleanupCallbacks[i2];
1364 if (typeof cleanupCallback === "function") {
1365 cleanupCallback();
1366 } else {
1367 ref(null);
1368 }
1369 break;
1370 }
1371 case "object": {
1372 ref.current = null;
1373 break;
1374 }
1375 default:
1376 }
1377 }
1378 };
1379 }
1380 };
1381 }
1382
1383 // node_modules/@base-ui/utils/getReactElementRef.mjs
1384 var React7 = __toESM(require_react(), 1);
1385
1386 // node_modules/@base-ui/utils/reactVersion.mjs
1387 var React6 = __toESM(require_react(), 1);
1388 var majorVersion = parseInt(React6.version, 10);
1389 function isReactVersionAtLeast(reactVersionToCheck) {
1390 return majorVersion >= reactVersionToCheck;
1391 }
1392
1393 // node_modules/@base-ui/utils/getReactElementRef.mjs
1394 function getReactElementRef(element) {
1395 if (!/* @__PURE__ */ React7.isValidElement(element)) {
1396 return null;
1397 }
1398 const reactElement = element;
1399 const propsWithRef = reactElement.props;
1400 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1401 }
1402
1403 // node_modules/@base-ui/utils/mergeObjects.mjs
1404 function mergeObjects(a2, b2) {
1405 if (a2 && !b2) {
1406 return a2;
1407 }
1408 if (!a2 && b2) {
1409 return b2;
1410 }
1411 if (a2 || b2) {
1412 return {
1413 ...a2,
1414 ...b2
1415 };
1416 }
1417 return void 0;
1418 }
1419
1420 // node_modules/@base-ui/utils/empty.mjs
1421 function NOOP() {
1422 }
1423 var EMPTY_ARRAY = Object.freeze([]);
1424 var EMPTY_OBJECT = Object.freeze({});
1425
1426 // node_modules/@base-ui/react/internals/getStateAttributesProps.mjs
1427 function getStateAttributesProps(state, customMapping) {
1428 const props = {};
1429 for (const key in state) {
1430 const value = state[key];
1431 if (customMapping?.hasOwnProperty(key)) {
1432 const customProps = customMapping[key](value);
1433 if (customProps != null) {
1434 Object.assign(props, customProps);
1435 }
1436 continue;
1437 }
1438 if (value === true) {
1439 props[`data-${key.toLowerCase()}`] = "";
1440 } else if (value) {
1441 props[`data-${key.toLowerCase()}`] = value.toString();
1442 }
1443 }
1444 return props;
1445 }
1446
1447 // node_modules/@base-ui/react/utils/resolveClassName.mjs
1448 function resolveClassName(className, state) {
1449 return typeof className === "function" ? className(state) : className;
1450 }
1451
1452 // node_modules/@base-ui/react/utils/resolveStyle.mjs
1453 function resolveStyle(style, state) {
1454 return typeof style === "function" ? style(state) : style;
1455 }
1456
1457 // node_modules/@base-ui/react/merge-props/mergeProps.mjs
1458 var EMPTY_PROPS = {};
1459 function mergeProps(a2, b2, c2, d2, e2) {
1460 if (!c2 && !d2 && !e2 && !a2) {
1461 return createInitialMergedProps(b2);
1462 }
1463 let merged = createInitialMergedProps(a2);
1464 if (b2) {
1465 merged = mergeInto(merged, b2);
1466 }
1467 if (c2) {
1468 merged = mergeInto(merged, c2);
1469 }
1470 if (d2) {
1471 merged = mergeInto(merged, d2);
1472 }
1473 if (e2) {
1474 merged = mergeInto(merged, e2);
1475 }
1476 return merged;
1477 }
1478 function mergePropsN(props) {
1479 if (props.length === 0) {
1480 return EMPTY_PROPS;
1481 }
1482 if (props.length === 1) {
1483 return createInitialMergedProps(props[0]);
1484 }
1485 let merged = createInitialMergedProps(props[0]);
1486 for (let i2 = 1; i2 < props.length; i2 += 1) {
1487 merged = mergeInto(merged, props[i2]);
1488 }
1489 return merged;
1490 }
1491 function createInitialMergedProps(inputProps) {
1492 if (isPropsGetter(inputProps)) {
1493 return {
1494 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1495 };
1496 }
1497 return copyInitialProps(inputProps);
1498 }
1499 function mergeInto(merged, inputProps) {
1500 if (isPropsGetter(inputProps)) {
1501 return resolvePropsGetter(inputProps, merged);
1502 }
1503 return mutablyMergeInto(merged, inputProps);
1504 }
1505 function copyInitialProps(inputProps) {
1506 const copiedProps = {
1507 ...inputProps
1508 };
1509 for (const propName in copiedProps) {
1510 const propValue = copiedProps[propName];
1511 if (isEventHandler(propName, propValue)) {
1512 copiedProps[propName] = wrapEventHandler(propValue);
1513 }
1514 }
1515 return copiedProps;
1516 }
1517 function mutablyMergeInto(mergedProps, externalProps) {
1518 if (!externalProps) {
1519 return mergedProps;
1520 }
1521 for (const propName in externalProps) {
1522 const externalPropValue = externalProps[propName];
1523 switch (propName) {
1524 case "style": {
1525 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1526 break;
1527 }
1528 case "className": {
1529 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1530 break;
1531 }
1532 default: {
1533 if (isEventHandler(propName, externalPropValue)) {
1534 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1535 } else {
1536 mergedProps[propName] = externalPropValue;
1537 }
1538 }
1539 }
1540 }
1541 return mergedProps;
1542 }
1543 function isEventHandler(key, value) {
1544 const code0 = key.charCodeAt(0);
1545 const code1 = key.charCodeAt(1);
1546 const code2 = key.charCodeAt(2);
1547 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1548 }
1549 function isPropsGetter(inputProps) {
1550 return typeof inputProps === "function";
1551 }
1552 function resolvePropsGetter(inputProps, previousProps) {
1553 if (isPropsGetter(inputProps)) {
1554 return inputProps(previousProps);
1555 }
1556 return inputProps ?? EMPTY_PROPS;
1557 }
1558 function mergeEventHandlers(ourHandler, theirHandler) {
1559 if (!theirHandler) {
1560 return ourHandler;
1561 }
1562 if (!ourHandler) {
1563 return wrapEventHandler(theirHandler);
1564 }
1565 return (...args) => {
1566 const event = args[0];
1567 if (isSyntheticEvent(event)) {
1568 const baseUIEvent = event;
1569 makeEventPreventable(baseUIEvent);
1570 const result2 = theirHandler(...args);
1571 if (!baseUIEvent.baseUIHandlerPrevented) {
1572 ourHandler?.(...args);
1573 }
1574 return result2;
1575 }
1576 const result = theirHandler(...args);
1577 ourHandler?.(...args);
1578 return result;
1579 };
1580 }
1581 function wrapEventHandler(handler) {
1582 if (!handler) {
1583 return handler;
1584 }
1585 return (...args) => {
1586 const event = args[0];
1587 if (isSyntheticEvent(event)) {
1588 makeEventPreventable(event);
1589 }
1590 return handler(...args);
1591 };
1592 }
1593 function makeEventPreventable(event) {
1594 event.preventBaseUIHandler = () => {
1595 event.baseUIHandlerPrevented = true;
1596 };
1597 return event;
1598 }
1599 function mergeClassNames(ourClassName, theirClassName) {
1600 if (theirClassName) {
1601 if (ourClassName) {
1602 return theirClassName + " " + ourClassName;
1603 }
1604 return theirClassName;
1605 }
1606 return ourClassName;
1607 }
1608 function isSyntheticEvent(event) {
1609 return event != null && typeof event === "object" && "nativeEvent" in event;
1610 }
1611
1612 // node_modules/@base-ui/react/internals/useRenderElement.mjs
1613 var import_react = __toESM(require_react(), 1);
1614 function useRenderElement(element, componentProps, params = {}) {
1615 const renderProp = componentProps.render;
1616 const outProps = useRenderElementProps(componentProps, params);
1617 if (params.enabled === false) {
1618 return null;
1619 }
1620 const state = params.state ?? EMPTY_OBJECT;
1621 return evaluateRenderProp(element, renderProp, outProps, state);
1622 }
1623 function useRenderElementProps(componentProps, params = {}) {
1624 const {
1625 className: classNameProp,
1626 style: styleProp,
1627 render: renderProp
1628 } = componentProps;
1629 const {
1630 state = EMPTY_OBJECT,
1631 ref,
1632 props,
1633 stateAttributesMapping: stateAttributesMapping3,
1634 enabled = true
1635 } = params;
1636 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1637 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1638 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
1639 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1640 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1641 if (typeof document !== "undefined") {
1642 if (!enabled) {
1643 useMergedRefs(null, null);
1644 } else if (Array.isArray(ref)) {
1645 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1646 } else {
1647 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1648 }
1649 }
1650 if (!enabled) {
1651 return EMPTY_OBJECT;
1652 }
1653 if (className !== void 0) {
1654 outProps.className = mergeClassNames(outProps.className, className);
1655 }
1656 if (style !== void 0) {
1657 outProps.style = mergeObjects(outProps.style, style);
1658 }
1659 return outProps;
1660 }
1661 function resolveRenderFunctionProps(props) {
1662 if (Array.isArray(props)) {
1663 return mergePropsN(props);
1664 }
1665 return mergeProps(void 0, props);
1666 }
1667 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1668 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1669 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1670 function evaluateRenderProp(element, render4, props, state) {
1671 if (render4) {
1672 if (typeof render4 === "function") {
1673 if (true) {
1674 warnIfRenderPropLooksLikeComponent(render4);
1675 }
1676 return render4(props, state);
1677 }
1678 const mergedProps = mergeProps(props, render4.props);
1679 mergedProps.ref = props.ref;
1680 let newElement = render4;
1681 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1682 const children = React8.Children.toArray(render4);
1683 newElement = children[0];
1684 }
1685 if (true) {
1686 if (!/* @__PURE__ */ React8.isValidElement(newElement)) {
1687 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"));
1688 }
1689 }
1690 return /* @__PURE__ */ React8.cloneElement(newElement, mergedProps);
1691 }
1692 if (element) {
1693 if (typeof element === "string") {
1694 return renderTag(element, props);
1695 }
1696 }
1697 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1698 }
1699 function warnIfRenderPropLooksLikeComponent(renderFn) {
1700 const functionName = renderFn.name;
1701 if (functionName.length === 0) {
1702 return;
1703 }
1704 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1705 return;
1706 }
1707 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1708 return;
1709 }
1710 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");
1711 }
1712 function renderTag(Tag, props) {
1713 if (Tag === "button") {
1714 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1715 type: "button",
1716 ...props,
1717 key: props.key
1718 });
1719 }
1720 if (Tag === "img") {
1721 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1722 alt: "",
1723 ...props,
1724 key: props.key
1725 });
1726 }
1727 return /* @__PURE__ */ React8.createElement(Tag, props);
1728 }
1729
1730 // node_modules/@base-ui/utils/useId.mjs
1731 var React9 = __toESM(require_react(), 1);
1732 var globalId = 0;
1733 function useGlobalId(idOverride, prefix = "mui") {
1734 const [defaultId, setDefaultId] = React9.useState(idOverride);
1735 const id = idOverride || defaultId;
1736 React9.useEffect(() => {
1737 if (defaultId == null) {
1738 globalId += 1;
1739 setDefaultId(`${prefix}-${globalId}`);
1740 }
1741 }, [defaultId, prefix]);
1742 return id;
1743 }
1744 var maybeReactUseId = SafeReact.useId;
1745 function useId(idOverride, prefix) {
1746 if (maybeReactUseId !== void 0) {
1747 const reactId = maybeReactUseId();
1748 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1749 }
1750 return useGlobalId(idOverride, prefix);
1751 }
1752
1753 // node_modules/@base-ui/react/internals/useBaseUiId.mjs
1754 function useBaseUiId(idOverride) {
1755 return useId(idOverride, "base-ui");
1756 }
1757
1758 // node_modules/@base-ui/react/internals/reason-parts.mjs
1759 var reason_parts_exports = {};
1760 __export(reason_parts_exports, {
1761 cancelOpen: () => cancelOpen,
1762 chipRemovePress: () => chipRemovePress,
1763 clearPress: () => clearPress,
1764 closePress: () => closePress,
1765 closeWatcher: () => closeWatcher,
1766 decrementPress: () => decrementPress,
1767 disabled: () => disabled,
1768 drag: () => drag,
1769 escapeKey: () => escapeKey,
1770 focusOut: () => focusOut,
1771 imperativeAction: () => imperativeAction,
1772 incrementPress: () => incrementPress,
1773 initial: () => initial,
1774 inputBlur: () => inputBlur,
1775 inputChange: () => inputChange,
1776 inputClear: () => inputClear,
1777 inputPaste: () => inputPaste,
1778 inputPress: () => inputPress,
1779 itemPress: () => itemPress,
1780 keyboard: () => keyboard,
1781 linkPress: () => linkPress,
1782 listNavigation: () => listNavigation,
1783 missing: () => missing,
1784 none: () => none,
1785 outsidePress: () => outsidePress,
1786 pointer: () => pointer,
1787 scrub: () => scrub,
1788 siblingOpen: () => siblingOpen,
1789 swipe: () => swipe,
1790 trackPress: () => trackPress,
1791 triggerFocus: () => triggerFocus,
1792 triggerHover: () => triggerHover,
1793 triggerPress: () => triggerPress,
1794 wheel: () => wheel,
1795 windowResize: () => windowResize
1796 });
1797 var none = "none";
1798 var triggerPress = "trigger-press";
1799 var triggerHover = "trigger-hover";
1800 var triggerFocus = "trigger-focus";
1801 var outsidePress = "outside-press";
1802 var itemPress = "item-press";
1803 var closePress = "close-press";
1804 var linkPress = "link-press";
1805 var clearPress = "clear-press";
1806 var chipRemovePress = "chip-remove-press";
1807 var trackPress = "track-press";
1808 var incrementPress = "increment-press";
1809 var decrementPress = "decrement-press";
1810 var inputChange = "input-change";
1811 var inputClear = "input-clear";
1812 var inputBlur = "input-blur";
1813 var inputPaste = "input-paste";
1814 var inputPress = "input-press";
1815 var focusOut = "focus-out";
1816 var escapeKey = "escape-key";
1817 var closeWatcher = "close-watcher";
1818 var listNavigation = "list-navigation";
1819 var keyboard = "keyboard";
1820 var pointer = "pointer";
1821 var drag = "drag";
1822 var wheel = "wheel";
1823 var scrub = "scrub";
1824 var cancelOpen = "cancel-open";
1825 var siblingOpen = "sibling-open";
1826 var disabled = "disabled";
1827 var missing = "missing";
1828 var initial = "initial";
1829 var imperativeAction = "imperative-action";
1830 var swipe = "swipe";
1831 var windowResize = "window-resize";
1832
1833 // node_modules/@base-ui/react/internals/createBaseUIEventDetails.mjs
1834 function createChangeEventDetails(reason, event, trigger, customProperties) {
1835 let canceled = false;
1836 let allowPropagation = false;
1837 const custom = customProperties ?? EMPTY_OBJECT;
1838 const details = {
1839 reason,
1840 event: event ?? new Event("base-ui"),
1841 cancel() {
1842 canceled = true;
1843 },
1844 allowPropagation() {
1845 allowPropagation = true;
1846 },
1847 get isCanceled() {
1848 return canceled;
1849 },
1850 get isPropagationAllowed() {
1851 return allowPropagation;
1852 },
1853 trigger,
1854 ...custom
1855 };
1856 return details;
1857 }
1858
1859 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs
1860 var React11 = __toESM(require_react(), 1);
1861
1862 // node_modules/@base-ui/utils/useOnMount.mjs
1863 var React10 = __toESM(require_react(), 1);
1864 var EMPTY = [];
1865 function useOnMount(fn) {
1866 React10.useEffect(fn, EMPTY);
1867 }
1868
1869 // node_modules/@base-ui/utils/useAnimationFrame.mjs
1870 var EMPTY2 = null;
1871 var LAST_RAF = globalThis.requestAnimationFrame;
1872 var Scheduler = class {
1873 /* This implementation uses an array as a backing data-structure for frame callbacks.
1874 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1875 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1876 * be much more efficient if there is a call pattern that alterns as
1877 * "request-cancel-request-cancel-…".
1878 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1879 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1880 callbacks = [];
1881 callbacksCount = 0;
1882 nextId = 1;
1883 startId = 1;
1884 isScheduled = false;
1885 tick = (timestamp) => {
1886 this.isScheduled = false;
1887 const currentCallbacks = this.callbacks;
1888 const currentCallbacksCount = this.callbacksCount;
1889 this.callbacks = [];
1890 this.callbacksCount = 0;
1891 this.startId = this.nextId;
1892 if (currentCallbacksCount > 0) {
1893 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1894 currentCallbacks[i2]?.(timestamp);
1895 }
1896 }
1897 };
1898 request(fn) {
1899 const id = this.nextId;
1900 this.nextId += 1;
1901 this.callbacks.push(fn);
1902 this.callbacksCount += 1;
1903 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1904 if (!this.isScheduled || didRAFChange) {
1905 requestAnimationFrame(this.tick);
1906 this.isScheduled = true;
1907 }
1908 return id;
1909 }
1910 cancel(id) {
1911 const index2 = id - this.startId;
1912 if (index2 < 0 || index2 >= this.callbacks.length) {
1913 return;
1914 }
1915 this.callbacks[index2] = null;
1916 this.callbacksCount -= 1;
1917 }
1918 };
1919 var scheduler = new Scheduler();
1920 var AnimationFrame = class _AnimationFrame {
1921 static create() {
1922 return new _AnimationFrame();
1923 }
1924 static request(fn) {
1925 return scheduler.request(fn);
1926 }
1927 static cancel(id) {
1928 return scheduler.cancel(id);
1929 }
1930 currentId = EMPTY2;
1931 /**
1932 * Executes `fn` after `delay`, clearing any previously scheduled call.
1933 */
1934 request(fn) {
1935 this.cancel();
1936 this.currentId = scheduler.request(() => {
1937 this.currentId = EMPTY2;
1938 fn();
1939 });
1940 }
1941 cancel = () => {
1942 if (this.currentId !== EMPTY2) {
1943 scheduler.cancel(this.currentId);
1944 this.currentId = EMPTY2;
1945 }
1946 };
1947 disposeEffect = () => {
1948 return this.cancel;
1949 };
1950 };
1951 function useAnimationFrame() {
1952 const timeout = useRefWithInit(AnimationFrame.create).current;
1953 useOnMount(timeout.disposeEffect);
1954 return timeout;
1955 }
1956
1957 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs
1958 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1959 const [transitionStatus, setTransitionStatus] = React11.useState(open && enableIdleState ? "idle" : void 0);
1960 const [mounted, setMounted] = React11.useState(open);
1961 if (open && !mounted) {
1962 setMounted(true);
1963 setTransitionStatus("starting");
1964 }
1965 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1966 setTransitionStatus("ending");
1967 }
1968 if (!open && !mounted && transitionStatus === "ending") {
1969 setTransitionStatus(void 0);
1970 }
1971 useIsoLayoutEffect(() => {
1972 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1973 const frame = AnimationFrame.request(() => {
1974 setTransitionStatus("ending");
1975 });
1976 return () => {
1977 AnimationFrame.cancel(frame);
1978 };
1979 }
1980 return void 0;
1981 }, [open, mounted, transitionStatus, deferEndingState]);
1982 useIsoLayoutEffect(() => {
1983 if (!open || enableIdleState) {
1984 return void 0;
1985 }
1986 const frame = AnimationFrame.request(() => {
1987 setTransitionStatus(void 0);
1988 });
1989 return () => {
1990 AnimationFrame.cancel(frame);
1991 };
1992 }, [enableIdleState, open]);
1993 useIsoLayoutEffect(() => {
1994 if (!open || !enableIdleState) {
1995 return void 0;
1996 }
1997 if (open && mounted && transitionStatus !== "idle") {
1998 setTransitionStatus("starting");
1999 }
2000 const frame = AnimationFrame.request(() => {
2001 setTransitionStatus("idle");
2002 });
2003 return () => {
2004 AnimationFrame.cancel(frame);
2005 };
2006 }, [enableIdleState, open, mounted, transitionStatus]);
2007 return {
2008 mounted,
2009 setMounted,
2010 transitionStatus
2011 };
2012 }
2013
2014 // node_modules/@base-ui/react/internals/stateAttributesMapping.mjs
2015 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
2016 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
2017 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
2018 return TransitionStatusDataAttributes2;
2019 })({});
2020 var STARTING_HOOK = {
2021 [TransitionStatusDataAttributes.startingStyle]: ""
2022 };
2023 var ENDING_HOOK = {
2024 [TransitionStatusDataAttributes.endingStyle]: ""
2025 };
2026 var transitionStatusMapping = {
2027 transitionStatus(value) {
2028 if (value === "starting") {
2029 return STARTING_HOOK;
2030 }
2031 if (value === "ending") {
2032 return ENDING_HOOK;
2033 }
2034 return null;
2035 }
2036 };
2037
2038 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
2039 function hasWindow() {
2040 return typeof window !== "undefined";
2041 }
2042 function getNodeName(node) {
2043 if (isNode(node)) {
2044 return (node.nodeName || "").toLowerCase();
2045 }
2046 return "#document";
2047 }
2048 function getWindow(node) {
2049 var _node$ownerDocument;
2050 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2051 }
2052 function getDocumentElement(node) {
2053 var _ref;
2054 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2055 }
2056 function isNode(value) {
2057 if (!hasWindow()) {
2058 return false;
2059 }
2060 return value instanceof Node || value instanceof getWindow(value).Node;
2061 }
2062 function isElement(value) {
2063 if (!hasWindow()) {
2064 return false;
2065 }
2066 return value instanceof Element || value instanceof getWindow(value).Element;
2067 }
2068 function isHTMLElement(value) {
2069 if (!hasWindow()) {
2070 return false;
2071 }
2072 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2073 }
2074 function isShadowRoot(value) {
2075 if (!hasWindow() || typeof ShadowRoot === "undefined") {
2076 return false;
2077 }
2078 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2079 }
2080 function isOverflowElement(element) {
2081 const {
2082 overflow,
2083 overflowX,
2084 overflowY,
2085 display
2086 } = getComputedStyle2(element);
2087 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
2088 }
2089 function isTableElement(element) {
2090 return /^(table|td|th)$/.test(getNodeName(element));
2091 }
2092 function isTopLayer(element) {
2093 try {
2094 if (element.matches(":popover-open")) {
2095 return true;
2096 }
2097 } catch (_e) {
2098 }
2099 try {
2100 return element.matches(":modal");
2101 } catch (_e) {
2102 return false;
2103 }
2104 }
2105 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
2106 var containRe = /paint|layout|strict|content/;
2107 var isNotNone = (value) => !!value && value !== "none";
2108 var isWebKitValue;
2109 function isContainingBlock(elementOrCss) {
2110 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
2111 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 || "");
2112 }
2113 function getContainingBlock(element) {
2114 let currentNode = getParentNode(element);
2115 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2116 if (isContainingBlock(currentNode)) {
2117 return currentNode;
2118 } else if (isTopLayer(currentNode)) {
2119 return null;
2120 }
2121 currentNode = getParentNode(currentNode);
2122 }
2123 return null;
2124 }
2125 function isWebKit() {
2126 if (isWebKitValue == null) {
2127 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
2128 }
2129 return isWebKitValue;
2130 }
2131 function isLastTraversableNode(node) {
2132 return /^(html|body|#document)$/.test(getNodeName(node));
2133 }
2134 function getComputedStyle2(element) {
2135 return getWindow(element).getComputedStyle(element);
2136 }
2137 function getNodeScroll(element) {
2138 if (isElement(element)) {
2139 return {
2140 scrollLeft: element.scrollLeft,
2141 scrollTop: element.scrollTop
2142 };
2143 }
2144 return {
2145 scrollLeft: element.scrollX,
2146 scrollTop: element.scrollY
2147 };
2148 }
2149 function getParentNode(node) {
2150 if (getNodeName(node) === "html") {
2151 return node;
2152 }
2153 const result = (
2154 // Step into the shadow DOM of the parent of a slotted node.
2155 node.assignedSlot || // DOM Element detected.
2156 node.parentNode || // ShadowRoot detected.
2157 isShadowRoot(node) && node.host || // Fallback.
2158 getDocumentElement(node)
2159 );
2160 return isShadowRoot(result) ? result.host : result;
2161 }
2162 function getNearestOverflowAncestor(node) {
2163 const parentNode = getParentNode(node);
2164 if (isLastTraversableNode(parentNode)) {
2165 return node.ownerDocument ? node.ownerDocument.body : node.body;
2166 }
2167 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2168 return parentNode;
2169 }
2170 return getNearestOverflowAncestor(parentNode);
2171 }
2172 function getOverflowAncestors(node, list, traverseIframes) {
2173 var _node$ownerDocument2;
2174 if (list === void 0) {
2175 list = [];
2176 }
2177 if (traverseIframes === void 0) {
2178 traverseIframes = true;
2179 }
2180 const scrollableAncestor = getNearestOverflowAncestor(node);
2181 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2182 const win = getWindow(scrollableAncestor);
2183 if (isBody) {
2184 const frameElement = getFrameElement(win);
2185 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2186 } else {
2187 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2188 }
2189 }
2190 function getFrameElement(win) {
2191 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2192 }
2193
2194 // node_modules/@base-ui/utils/addEventListener.mjs
2195 function addEventListener(target, type, listener, options) {
2196 target.addEventListener(type, listener, options);
2197 return () => {
2198 target.removeEventListener(type, listener, options);
2199 };
2200 }
2201
2202 // node_modules/@base-ui/utils/useValueAsRef.mjs
2203 function useValueAsRef(value) {
2204 const latest = useRefWithInit(createLatestRef, value).current;
2205 latest.next = value;
2206 useIsoLayoutEffect(latest.effect);
2207 return latest;
2208 }
2209 function createLatestRef(value) {
2210 const latest = {
2211 current: value,
2212 next: value,
2213 effect: () => {
2214 latest.current = latest.next;
2215 }
2216 };
2217 return latest;
2218 }
2219
2220 // node_modules/@base-ui/utils/owner.mjs
2221 function ownerDocument(node) {
2222 return node?.ownerDocument || document;
2223 }
2224
2225 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs
2226 var React12 = __toESM(require_react(), 1);
2227
2228 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs
2229 var ReactDOM = __toESM(require_react_dom(), 1);
2230
2231 // node_modules/@base-ui/react/utils/resolveRef.mjs
2232 function resolveRef(maybeRef) {
2233 if (maybeRef == null) {
2234 return maybeRef;
2235 }
2236 return "current" in maybeRef ? maybeRef.current : maybeRef;
2237 }
2238
2239 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs
2240 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
2241 const frame = useAnimationFrame();
2242 return useStableCallback((fnToExecute, signal = null) => {
2243 frame.cancel();
2244 const element = resolveRef(elementOrRef);
2245 if (element == null) {
2246 return;
2247 }
2248 const resolvedElement = element;
2249 const done = () => {
2250 ReactDOM.flushSync(fnToExecute);
2251 };
2252 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
2253 fnToExecute();
2254 return;
2255 }
2256 function exec() {
2257 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
2258 if (!signal?.aborted) {
2259 done();
2260 }
2261 }).catch(() => {
2262 if (treatAbortedAsFinished) {
2263 if (!signal?.aborted) {
2264 done();
2265 }
2266 return;
2267 }
2268 const currentAnimations = resolvedElement.getAnimations();
2269 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
2270 exec();
2271 }
2272 });
2273 }
2274 if (waitForStartingStyleRemoved) {
2275 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
2276 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2277 frame.request(exec);
2278 return;
2279 }
2280 const attributeObserver = new MutationObserver(() => {
2281 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2282 attributeObserver.disconnect();
2283 exec();
2284 }
2285 });
2286 attributeObserver.observe(resolvedElement, {
2287 attributes: true,
2288 attributeFilter: [startingStyleAttribute]
2289 });
2290 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
2291 once: true
2292 });
2293 return;
2294 }
2295 frame.request(exec);
2296 });
2297 }
2298
2299 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs
2300 function useOpenChangeComplete(parameters) {
2301 const {
2302 enabled = true,
2303 open,
2304 ref,
2305 onComplete: onCompleteParam
2306 } = parameters;
2307 const onComplete = useStableCallback(onCompleteParam);
2308 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2309 React12.useEffect(() => {
2310 if (!enabled) {
2311 return void 0;
2312 }
2313 const abortController = new AbortController();
2314 runOnceAnimationsFinish(onComplete, abortController.signal);
2315 return () => {
2316 abortController.abort();
2317 };
2318 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2319 }
2320
2321 // node_modules/@base-ui/utils/useOnFirstRender.mjs
2322 var React13 = __toESM(require_react(), 1);
2323 function useOnFirstRender(fn) {
2324 const ref = React13.useRef(true);
2325 if (ref.current) {
2326 ref.current = false;
2327 fn();
2328 }
2329 }
2330
2331 // node_modules/@base-ui/utils/platform/parts.mjs
2332 var parts_exports = {};
2333 __export(parts_exports, {
2334 engine: () => engine_exports,
2335 env: () => env_exports,
2336 os: () => os_exports,
2337 screenReader: () => screen_reader_exports
2338 });
2339
2340 // node_modules/@base-ui/utils/platform/os.mjs
2341 var os_exports = {};
2342 __export(os_exports, {
2343 android: () => android,
2344 apple: () => apple,
2345 ios: () => ios,
2346 linux: () => linux,
2347 mac: () => mac,
2348 windows: () => windows
2349 });
2350
2351 // node_modules/@base-ui/utils/platform/shared.mjs
2352 function readRawData() {
2353 if (typeof navigator === "undefined") {
2354 return {
2355 userAgent: "",
2356 platform: "",
2357 maxTouchPoints: 0
2358 };
2359 }
2360 if (true) {
2361 const uaData = navigator.userAgentData;
2362 if (uaData && Array.isArray(uaData.brands)) {
2363 return {
2364 userAgent: uaData.brands.map(({
2365 brand,
2366 version: version2
2367 }) => `${brand}/${version2}`).join(" "),
2368 platform: uaData.platform ?? navigator.platform ?? "",
2369 maxTouchPoints: navigator.maxTouchPoints ?? 0
2370 };
2371 }
2372 }
2373 return {
2374 userAgent: navigator.userAgent,
2375 platform: navigator.platform ?? "",
2376 maxTouchPoints: navigator.maxTouchPoints ?? 0
2377 };
2378 }
2379 var {
2380 userAgent,
2381 platform,
2382 maxTouchPoints
2383 } = readRawData();
2384 var lowerUserAgent = userAgent.toLowerCase();
2385 var lowerPlatform = platform.toLowerCase();
2386
2387 // node_modules/@base-ui/utils/platform/os.mjs
2388 var ios = /^i(os$|p)/.test(lowerPlatform) || lowerPlatform === "macintel" && maxTouchPoints > 1;
2389 var ANDROID_STRING = "android";
2390 var android = lowerPlatform === ANDROID_STRING || lowerUserAgent.includes(ANDROID_STRING);
2391 var mac = !ios && lowerPlatform.startsWith("mac");
2392 var windows = lowerPlatform.startsWith("win");
2393 var linux = !android && /^(linux|chrome os)/.test(lowerPlatform);
2394 var apple = mac || ios;
2395
2396 // node_modules/@base-ui/utils/platform/engine.mjs
2397 var engine_exports = {};
2398 __export(engine_exports, {
2399 blink: () => blink,
2400 gecko: () => gecko,
2401 webkit: () => webkit
2402 });
2403 var webkit = typeof CSS !== "undefined" && !!CSS.supports?.("-webkit-backdrop-filter:none");
2404 var gecko = !webkit && lowerUserAgent.includes("firefox");
2405 var blink = !webkit && lowerUserAgent.includes("chrom");
2406
2407 // node_modules/@base-ui/utils/platform/screen-reader.mjs
2408 var screen_reader_exports = {};
2409 __export(screen_reader_exports, {
2410 voiceOver: () => voiceOver
2411 });
2412 var voiceOver = apple;
2413
2414 // node_modules/@base-ui/utils/platform/env.mjs
2415 var env_exports = {};
2416 __export(env_exports, {
2417 jsdom: () => jsdom
2418 });
2419 var jsdom = /jsdom|happydom/.test(lowerUserAgent);
2420
2421 // node_modules/@base-ui/utils/useTimeout.mjs
2422 var EMPTY3 = 0;
2423 var Timeout = class _Timeout {
2424 static create() {
2425 return new _Timeout();
2426 }
2427 currentId = EMPTY3;
2428 /**
2429 * Executes `fn` after `delay`, clearing any previously scheduled call.
2430 */
2431 start(delay, fn) {
2432 this.clear();
2433 this.currentId = setTimeout(() => {
2434 this.currentId = EMPTY3;
2435 fn();
2436 }, delay);
2437 }
2438 isStarted() {
2439 return this.currentId !== EMPTY3;
2440 }
2441 clear = () => {
2442 if (this.currentId !== EMPTY3) {
2443 clearTimeout(this.currentId);
2444 this.currentId = EMPTY3;
2445 }
2446 };
2447 disposeEffect = () => {
2448 return this.clear;
2449 };
2450 };
2451 function useTimeout() {
2452 const timeout = useRefWithInit(Timeout.create).current;
2453 useOnMount(timeout.disposeEffect);
2454 return timeout;
2455 }
2456
2457 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs
2458 var React14 = __toESM(require_react(), 1);
2459
2460 // node_modules/@base-ui/react/floating-ui-react/utils/event.mjs
2461 function isReactEvent(event) {
2462 return "nativeEvent" in event;
2463 }
2464 function isMouseLikePointerType(pointerType, strict) {
2465 const values = ["mouse", "pen"];
2466 if (!strict) {
2467 values.push("", void 0);
2468 }
2469 return values.includes(pointerType);
2470 }
2471 function isClickLikeEvent(event) {
2472 const type = event.type;
2473 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2474 }
2475
2476 // node_modules/@base-ui/react/floating-ui-react/utils/constants.mjs
2477 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
2478 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
2479
2480 // node_modules/@base-ui/react/internals/shadowDom.mjs
2481 function activeElement(doc) {
2482 let element = doc.activeElement;
2483 while (element?.shadowRoot?.activeElement != null) {
2484 element = element.shadowRoot.activeElement;
2485 }
2486 return element;
2487 }
2488 function contains(parent, child) {
2489 if (!parent || !child) {
2490 return false;
2491 }
2492 const rootNode = child.getRootNode?.();
2493 if (parent.contains(child)) {
2494 return true;
2495 }
2496 if (rootNode && isShadowRoot(rootNode)) {
2497 let next = child;
2498 while (next) {
2499 if (parent === next) {
2500 return true;
2501 }
2502 next = next.parentNode || next.host;
2503 }
2504 }
2505 return false;
2506 }
2507 function getTarget(event) {
2508 if ("composedPath" in event) {
2509 return event.composedPath()[0];
2510 }
2511 return event.target;
2512 }
2513
2514 // node_modules/@base-ui/react/floating-ui-react/utils/element.mjs
2515 function isTargetInsideEnabledTrigger(target, triggerElements) {
2516 if (!isElement(target)) {
2517 return false;
2518 }
2519 const targetElement = target;
2520 if (triggerElements.hasElement(targetElement)) {
2521 return !targetElement.hasAttribute("data-trigger-disabled");
2522 }
2523 for (const [, trigger] of triggerElements.entries()) {
2524 if (contains(trigger, targetElement)) {
2525 return !trigger.hasAttribute("data-trigger-disabled");
2526 }
2527 }
2528 return false;
2529 }
2530 function isEventTargetWithin(event, node) {
2531 if (node == null) {
2532 return false;
2533 }
2534 if ("composedPath" in event) {
2535 return event.composedPath().includes(node);
2536 }
2537 const eventAgain = event;
2538 return eventAgain.target != null && node.contains(eventAgain.target);
2539 }
2540 function isRootElement(element) {
2541 return element.matches("html,body");
2542 }
2543 function isTypeableElement(element) {
2544 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
2545 }
2546 function isInteractiveElement(element) {
2547 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
2548 }
2549 function matchesFocusVisible(element) {
2550 if (!element || parts_exports.env.jsdom) {
2551 return true;
2552 }
2553 try {
2554 return element.matches(":focus-visible");
2555 } catch (_e) {
2556 return true;
2557 }
2558 }
2559
2560 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverShared.mjs
2561 function resolveValue(value, pointerType) {
2562 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
2563 return 0;
2564 }
2565 if (typeof value === "function") {
2566 return value();
2567 }
2568 return value;
2569 }
2570 function getDelay(value, prop, pointerType) {
2571 const result = resolveValue(value, pointerType);
2572 if (typeof result === "number") {
2573 return result;
2574 }
2575 return result?.[prop];
2576 }
2577 function getRestMs(value) {
2578 if (typeof value === "function") {
2579 return value();
2580 }
2581 return value;
2582 }
2583 function isClickLikeOpenEvent(openEventType, interactedInside) {
2584 return interactedInside || openEventType === "click" || openEventType === "mousedown";
2585 }
2586 function isHoverOpenEvent(openEventType) {
2587 return openEventType?.includes("mouse") && openEventType !== "mousedown";
2588 }
2589
2590 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs
2591 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
2592 var FloatingDelayGroupContext = /* @__PURE__ */ React14.createContext({
2593 hasProvider: false,
2594 timeoutMs: 0,
2595 delayRef: {
2596 current: 0
2597 },
2598 initialDelayRef: {
2599 current: 0
2600 },
2601 timeout: new Timeout(),
2602 currentIdRef: {
2603 current: null
2604 },
2605 currentContextRef: {
2606 current: null
2607 }
2608 });
2609 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
2610 function resetDelayRef(delayRef, initialDelayRef) {
2611 delayRef.current = initialDelayRef.current;
2612 }
2613 function FloatingDelayGroup(props) {
2614 const {
2615 children,
2616 delay,
2617 timeoutMs = 0
2618 } = props;
2619 const delayRef = React14.useRef(delay);
2620 const initialDelayRef = React14.useRef(delay);
2621 const currentIdRef = React14.useRef(null);
2622 const currentContextRef = React14.useRef(null);
2623 const timeout = useTimeout();
2624 useIsoLayoutEffect(() => {
2625 initialDelayRef.current = delay;
2626 if (!currentIdRef.current) {
2627 delayRef.current = delay;
2628 return;
2629 }
2630 delayRef.current = {
2631 open: getDelay(delayRef.current, "open"),
2632 close: getDelay(delay, "close")
2633 };
2634 }, [delay, currentIdRef, delayRef, initialDelayRef]);
2635 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
2636 value: React14.useMemo(() => ({
2637 hasProvider: true,
2638 delayRef,
2639 initialDelayRef,
2640 currentIdRef,
2641 timeoutMs,
2642 currentContextRef,
2643 timeout
2644 }), [timeoutMs, timeout]),
2645 children
2646 });
2647 }
2648 function useDelayGroup(context, options = {
2649 open: false
2650 }) {
2651 const {
2652 open
2653 } = options;
2654 const store = "rootStore" in context ? context.rootStore : context;
2655 const floatingId = store.useState("floatingId");
2656 const groupContext = React14.useContext(FloatingDelayGroupContext);
2657 const {
2658 currentIdRef,
2659 delayRef,
2660 timeoutMs,
2661 initialDelayRef,
2662 currentContextRef,
2663 hasProvider,
2664 timeout
2665 } = groupContext;
2666 const [isInstantPhase, setIsInstantPhase] = React14.useState(false);
2667 const openRef = React14.useRef(open);
2668 const isUnmountedRef = React14.useRef(false);
2669 useIsoLayoutEffect(() => {
2670 openRef.current = open;
2671 }, [open]);
2672 useIsoLayoutEffect(() => {
2673 return () => {
2674 isUnmountedRef.current = true;
2675 };
2676 }, []);
2677 useIsoLayoutEffect(() => {
2678 function unset() {
2679 if (!isUnmountedRef.current) {
2680 setIsInstantPhase(false);
2681 }
2682 currentContextRef.current?.setIsInstantPhase(false);
2683 currentIdRef.current = null;
2684 currentContextRef.current = null;
2685 delayRef.current = initialDelayRef.current;
2686 timeout.clear();
2687 }
2688 if (!currentIdRef.current) {
2689 return void 0;
2690 }
2691 if (!open && currentIdRef.current === floatingId) {
2692 setIsInstantPhase(false);
2693 if (timeoutMs) {
2694 const closingId = floatingId;
2695 timeout.start(timeoutMs, () => {
2696 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
2697 return;
2698 }
2699 unset();
2700 });
2701 return () => {
2702 if (openRef.current || currentIdRef.current !== closingId) {
2703 timeout.clear();
2704 }
2705 };
2706 }
2707 unset();
2708 }
2709 return void 0;
2710 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
2711 useIsoLayoutEffect(() => {
2712 if (!open) {
2713 return;
2714 }
2715 const prevContext = currentContextRef.current;
2716 const prevId = currentIdRef.current;
2717 timeout.clear();
2718 currentContextRef.current = {
2719 onOpenChange: store.setOpen,
2720 setIsInstantPhase
2721 };
2722 currentIdRef.current = floatingId;
2723 delayRef.current = {
2724 open: 0,
2725 close: getDelay(initialDelayRef.current, "close")
2726 };
2727 if (prevId !== null && prevId !== floatingId) {
2728 setIsInstantPhase(true);
2729 prevContext?.setIsInstantPhase(true);
2730 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
2731 } else {
2732 setIsInstantPhase(false);
2733 prevContext?.setIsInstantPhase(false);
2734 }
2735 }, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
2736 useIsoLayoutEffect(() => {
2737 return () => {
2738 if (currentIdRef.current === floatingId) {
2739 currentContextRef.current = null;
2740 if (!openRef.current) {
2741 return;
2742 }
2743 currentIdRef.current = null;
2744 resetDelayRef(delayRef, initialDelayRef);
2745 timeout.clear();
2746 }
2747 };
2748 }, [currentContextRef, currentIdRef, delayRef, floatingId, initialDelayRef, timeout]);
2749 return React14.useMemo(() => ({
2750 hasProvider,
2751 delayRef,
2752 isInstantPhase
2753 }), [hasProvider, delayRef, isInstantPhase]);
2754 }
2755
2756 // node_modules/@base-ui/utils/mergeCleanups.mjs
2757 function mergeCleanups(...cleanups) {
2758 return () => {
2759 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
2760 const cleanup = cleanups[i2];
2761 if (cleanup) {
2762 cleanup();
2763 }
2764 }
2765 };
2766 }
2767
2768 // node_modules/@base-ui/react/utils/FocusGuard.mjs
2769 var React15 = __toESM(require_react(), 1);
2770
2771 // node_modules/@base-ui/utils/visuallyHidden.mjs
2772 var visuallyHiddenBase = {
2773 clipPath: "inset(50%)",
2774 overflow: "hidden",
2775 whiteSpace: "nowrap",
2776 border: 0,
2777 padding: 0,
2778 width: 1,
2779 height: 1,
2780 margin: -1
2781 };
2782 var visuallyHidden = {
2783 ...visuallyHiddenBase,
2784 position: "fixed",
2785 top: 0,
2786 left: 0
2787 };
2788 var visuallyHiddenInput = {
2789 ...visuallyHiddenBase,
2790 position: "absolute"
2791 };
2792
2793 // node_modules/@base-ui/react/utils/FocusGuard.mjs
2794 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
2795 var FocusGuard = /* @__PURE__ */ React15.forwardRef(function FocusGuard2(props, ref) {
2796 const [role, setRole] = React15.useState();
2797 useIsoLayoutEffect(() => {
2798 if (parts_exports.screenReader.voiceOver && parts_exports.engine.webkit) {
2799 setRole("button");
2800 }
2801 }, []);
2802 const restProps = {
2803 tabIndex: 0,
2804 // Role is only for VoiceOver
2805 role
2806 };
2807 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
2808 ...props,
2809 ref,
2810 style: visuallyHidden,
2811 "aria-hidden": role ? void 0 : true,
2812 ...restProps,
2813 "data-base-ui-focus-guard": ""
2814 });
2815 });
2816 if (true) FocusGuard.displayName = "FocusGuard";
2817
2818 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2819 var sides = ["top", "right", "bottom", "left"];
2820 var min = Math.min;
2821 var max = Math.max;
2822 var round = Math.round;
2823 var floor = Math.floor;
2824 var createCoords = (v2) => ({
2825 x: v2,
2826 y: v2
2827 });
2828 var oppositeSideMap = {
2829 left: "right",
2830 right: "left",
2831 bottom: "top",
2832 top: "bottom"
2833 };
2834 function clamp(start, value, end) {
2835 return max(start, min(value, end));
2836 }
2837 function evaluate(value, param) {
2838 return typeof value === "function" ? value(param) : value;
2839 }
2840 function getSide(placement) {
2841 return placement.split("-")[0];
2842 }
2843 function getAlignment(placement) {
2844 return placement.split("-")[1];
2845 }
2846 function getOppositeAxis(axis) {
2847 return axis === "x" ? "y" : "x";
2848 }
2849 function getAxisLength(axis) {
2850 return axis === "y" ? "height" : "width";
2851 }
2852 function getSideAxis(placement) {
2853 const firstChar = placement[0];
2854 return firstChar === "t" || firstChar === "b" ? "y" : "x";
2855 }
2856 function getAlignmentAxis(placement) {
2857 return getOppositeAxis(getSideAxis(placement));
2858 }
2859 function getAlignmentSides(placement, rects, rtl) {
2860 if (rtl === void 0) {
2861 rtl = false;
2862 }
2863 const alignment = getAlignment(placement);
2864 const alignmentAxis = getAlignmentAxis(placement);
2865 const length = getAxisLength(alignmentAxis);
2866 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
2867 if (rects.reference[length] > rects.floating[length]) {
2868 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
2869 }
2870 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
2871 }
2872 function getExpandedPlacements(placement) {
2873 const oppositePlacement = getOppositePlacement(placement);
2874 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
2875 }
2876 function getOppositeAlignmentPlacement(placement) {
2877 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
2878 }
2879 var lrPlacement = ["left", "right"];
2880 var rlPlacement = ["right", "left"];
2881 var tbPlacement = ["top", "bottom"];
2882 var btPlacement = ["bottom", "top"];
2883 function getSideList(side, isStart, rtl) {
2884 switch (side) {
2885 case "top":
2886 case "bottom":
2887 if (rtl) return isStart ? rlPlacement : lrPlacement;
2888 return isStart ? lrPlacement : rlPlacement;
2889 case "left":
2890 case "right":
2891 return isStart ? tbPlacement : btPlacement;
2892 default:
2893 return [];
2894 }
2895 }
2896 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
2897 const alignment = getAlignment(placement);
2898 let list = getSideList(getSide(placement), direction === "start", rtl);
2899 if (alignment) {
2900 list = list.map((side) => side + "-" + alignment);
2901 if (flipAlignment) {
2902 list = list.concat(list.map(getOppositeAlignmentPlacement));
2903 }
2904 }
2905 return list;
2906 }
2907 function getOppositePlacement(placement) {
2908 const side = getSide(placement);
2909 return oppositeSideMap[side] + placement.slice(side.length);
2910 }
2911 function expandPaddingObject(padding) {
2912 return {
2913 top: 0,
2914 right: 0,
2915 bottom: 0,
2916 left: 0,
2917 ...padding
2918 };
2919 }
2920 function getPaddingObject(padding) {
2921 return typeof padding !== "number" ? expandPaddingObject(padding) : {
2922 top: padding,
2923 right: padding,
2924 bottom: padding,
2925 left: padding
2926 };
2927 }
2928 function rectToClientRect(rect) {
2929 const {
2930 x: x2,
2931 y: y2,
2932 width,
2933 height
2934 } = rect;
2935 return {
2936 width,
2937 height,
2938 top: y2,
2939 left: x2,
2940 right: x2 + width,
2941 bottom: y2 + height,
2942 x: x2,
2943 y: y2
2944 };
2945 }
2946
2947 // node_modules/@base-ui/react/floating-ui-react/utils/composite.mjs
2948 function isHiddenByStyles(styles) {
2949 return styles.visibility === "hidden" || styles.visibility === "collapse";
2950 }
2951 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
2952 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
2953 return false;
2954 }
2955 if (typeof element.checkVisibility === "function") {
2956 return element.checkVisibility();
2957 }
2958 return styles.display !== "none" && styles.display !== "contents";
2959 }
2960
2961 // node_modules/@base-ui/react/floating-ui-react/utils/tabbable.mjs
2962 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
2963 function getParentElement(element) {
2964 const assignedSlot = element.assignedSlot;
2965 if (assignedSlot) {
2966 return assignedSlot;
2967 }
2968 if (element.parentElement) {
2969 return element.parentElement;
2970 }
2971 const rootNode = element.getRootNode();
2972 return isShadowRoot(rootNode) ? rootNode.host : null;
2973 }
2974 function getDetailsSummary(details) {
2975 for (const child of Array.from(details.children)) {
2976 if (getNodeName(child) === "summary") {
2977 return child;
2978 }
2979 }
2980 return null;
2981 }
2982 function isWithinOpenDetailsSummary(element, details) {
2983 const summary = getDetailsSummary(details);
2984 return !!summary && (element === summary || contains(summary, element));
2985 }
2986 function isFocusableCandidate(element) {
2987 const nodeName = element ? getNodeName(element) : "";
2988 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");
2989 }
2990 function isFocusableElement(element) {
2991 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
2992 return false;
2993 }
2994 for (let current = element; current; current = getParentElement(current)) {
2995 const isAncestor = current !== element;
2996 const isSlot = getNodeName(current) === "slot";
2997 if (current.hasAttribute("inert")) {
2998 return false;
2999 }
3000 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
3001 return false;
3002 }
3003 }
3004 return true;
3005 }
3006 function isVisibleInTabbableTree(element, isAncestor) {
3007 const styles = getComputedStyle2(element);
3008 if (!isAncestor) {
3009 return isElementVisible(element, styles);
3010 }
3011 return styles.display !== "none";
3012 }
3013 function getTabIndex(element) {
3014 const tabIndex = element.tabIndex;
3015 if (tabIndex < 0) {
3016 const nodeName = getNodeName(element);
3017 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
3018 return 0;
3019 }
3020 }
3021 return tabIndex;
3022 }
3023 function getNamedRadioInput(element) {
3024 if (getNodeName(element) !== "input") {
3025 return null;
3026 }
3027 const input = element;
3028 return input.type === "radio" && input.name !== "" ? input : null;
3029 }
3030 function isTabbableRadio(element, candidates) {
3031 const input = getNamedRadioInput(element);
3032 if (!input) {
3033 return true;
3034 }
3035 const checkedRadio = candidates.find((candidate) => {
3036 const radio = getNamedRadioInput(candidate);
3037 return radio?.name === input.name && radio.form === input.form && radio.checked;
3038 });
3039 if (checkedRadio) {
3040 return checkedRadio === input;
3041 }
3042 return candidates.find((candidate) => {
3043 const radio = getNamedRadioInput(candidate);
3044 return radio?.name === input.name && radio.form === input.form;
3045 }) === input;
3046 }
3047 function getComposedChildren(container) {
3048 if (isHTMLElement(container) && getNodeName(container) === "slot") {
3049 const assignedElements = container.assignedElements({
3050 flatten: true
3051 });
3052 if (assignedElements.length > 0) {
3053 return assignedElements;
3054 }
3055 }
3056 if (isHTMLElement(container) && container.shadowRoot) {
3057 return Array.from(container.shadowRoot.children);
3058 }
3059 return Array.from(container.children);
3060 }
3061 function appendCandidates(container, list) {
3062 getComposedChildren(container).forEach((child) => {
3063 if (isFocusableCandidate(child)) {
3064 list.push(child);
3065 }
3066 appendCandidates(child, list);
3067 });
3068 }
3069 function appendMatchingElements(container, selector2, list) {
3070 getComposedChildren(container).forEach((child) => {
3071 if (isHTMLElement(child) && child.matches(selector2)) {
3072 list.push(child);
3073 }
3074 appendMatchingElements(child, selector2, list);
3075 });
3076 }
3077 function focusable(container) {
3078 const candidates = [];
3079 appendCandidates(container, candidates);
3080 return candidates.filter(isFocusableElement);
3081 }
3082 function tabbable(container) {
3083 const candidates = focusable(container);
3084 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
3085 }
3086 function getTabbableIn(container, dir) {
3087 const list = tabbable(container);
3088 const len = list.length;
3089 if (len === 0) {
3090 return void 0;
3091 }
3092 const active = activeElement(ownerDocument(container));
3093 const index2 = list.indexOf(active);
3094 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
3095 return list[nextIndex];
3096 }
3097 function getNextTabbable(referenceElement) {
3098 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
3099 }
3100 function getPreviousTabbable(referenceElement) {
3101 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
3102 }
3103 function isOutsideEvent(event, container) {
3104 const containerElement = container || event.currentTarget;
3105 const relatedTarget = event.relatedTarget;
3106 return !relatedTarget || !contains(containerElement, relatedTarget);
3107 }
3108 function disableFocusInside(container) {
3109 const tabbableElements = tabbable(container);
3110 tabbableElements.forEach((element) => {
3111 element.dataset.tabindex = element.getAttribute("tabindex") || "";
3112 element.setAttribute("tabindex", "-1");
3113 });
3114 }
3115 function enableFocusInside(container) {
3116 const elements = [];
3117 appendMatchingElements(container, "[data-tabindex]", elements);
3118 elements.forEach((element) => {
3119 const tabindex = element.dataset.tabindex;
3120 delete element.dataset.tabindex;
3121 if (tabindex) {
3122 element.setAttribute("tabindex", tabindex);
3123 } else {
3124 element.removeAttribute("tabindex");
3125 }
3126 });
3127 }
3128
3129 // node_modules/@base-ui/react/floating-ui-react/utils/nodes.mjs
3130 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
3131 const directChildren = nodes.filter((node) => node.parentId === id);
3132 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
3133 }
3134
3135 // node_modules/@base-ui/react/floating-ui-react/utils/createAttribute.mjs
3136 function createAttribute(name) {
3137 return `data-base-ui-${name}`;
3138 }
3139
3140 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs
3141 var React16 = __toESM(require_react(), 1);
3142 var ReactDOM2 = __toESM(require_react_dom(), 1);
3143
3144 // node_modules/@base-ui/react/internals/constants.mjs
3145 var DISABLED_TRANSITIONS_STYLE = {
3146 style: {
3147 transition: "none"
3148 }
3149 };
3150 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
3151 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
3152 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
3153 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
3154 var POPUP_COLLISION_AVOIDANCE = {
3155 fallbackAxisSide: "end"
3156 };
3157 var ownerVisuallyHidden = {
3158 clipPath: "inset(50%)",
3159 position: "fixed",
3160 top: 0,
3161 left: 0
3162 };
3163
3164 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs
3165 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
3166 var PortalContext = /* @__PURE__ */ React16.createContext(null);
3167 if (true) PortalContext.displayName = "PortalContext";
3168 var usePortalContext = () => React16.useContext(PortalContext);
3169 var attr = createAttribute("portal");
3170 function useFloatingPortalNode(props = {}) {
3171 const {
3172 ref,
3173 container: containerProp,
3174 componentProps = EMPTY_OBJECT,
3175 elementProps
3176 } = props;
3177 const uniqueId = useId();
3178 const portalContext = usePortalContext();
3179 const parentPortalNode = portalContext?.portalNode;
3180 const [containerElement, setContainerElement] = React16.useState(null);
3181 const [portalNode, setPortalNode] = React16.useState(null);
3182 const setPortalNodeRef = useStableCallback((node) => {
3183 if (node !== null) {
3184 setPortalNode(node);
3185 }
3186 });
3187 const containerRef = React16.useRef(null);
3188 useIsoLayoutEffect(() => {
3189 if (containerProp === null) {
3190 if (containerRef.current) {
3191 containerRef.current = null;
3192 setPortalNode(null);
3193 setContainerElement(null);
3194 }
3195 return;
3196 }
3197 if (uniqueId == null) {
3198 return;
3199 }
3200 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
3201 if (resolvedContainer == null) {
3202 if (containerRef.current) {
3203 containerRef.current = null;
3204 setPortalNode(null);
3205 setContainerElement(null);
3206 }
3207 return;
3208 }
3209 if (containerRef.current !== resolvedContainer) {
3210 containerRef.current = resolvedContainer;
3211 setPortalNode(null);
3212 setContainerElement(resolvedContainer);
3213 }
3214 }, [containerProp, parentPortalNode, uniqueId]);
3215 const portalElement = useRenderElement("div", componentProps, {
3216 ref: [ref, setPortalNodeRef],
3217 props: [{
3218 id: uniqueId,
3219 [attr]: ""
3220 }, elementProps]
3221 });
3222 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
3223 return {
3224 portalNode,
3225 portalSubtree
3226 };
3227 }
3228 var FloatingPortal = /* @__PURE__ */ React16.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
3229 const {
3230 render: render4,
3231 className,
3232 style,
3233 children,
3234 container,
3235 renderGuards,
3236 ...elementProps
3237 } = componentProps;
3238 const {
3239 portalNode,
3240 portalSubtree
3241 } = useFloatingPortalNode({
3242 container,
3243 ref: forwardedRef,
3244 componentProps,
3245 elementProps
3246 });
3247 const beforeOutsideRef = React16.useRef(null);
3248 const afterOutsideRef = React16.useRef(null);
3249 const beforeInsideRef = React16.useRef(null);
3250 const afterInsideRef = React16.useRef(null);
3251 const [focusManagerState, setFocusManagerState] = React16.useState(null);
3252 const focusInsideDisabledRef = React16.useRef(false);
3253 const modal = focusManagerState?.modal;
3254 const open = focusManagerState?.open;
3255 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
3256 React16.useEffect(() => {
3257 if (!portalNode || modal) {
3258 return void 0;
3259 }
3260 function onFocus(event) {
3261 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
3262 if (event.type === "focusin") {
3263 if (focusInsideDisabledRef.current) {
3264 enableFocusInside(portalNode);
3265 focusInsideDisabledRef.current = false;
3266 }
3267 } else {
3268 disableFocusInside(portalNode);
3269 focusInsideDisabledRef.current = true;
3270 }
3271 }
3272 }
3273 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
3274 }, [portalNode, modal]);
3275 useIsoLayoutEffect(() => {
3276 if (!portalNode || open !== true || !focusInsideDisabledRef.current) {
3277 return;
3278 }
3279 enableFocusInside(portalNode);
3280 focusInsideDisabledRef.current = false;
3281 }, [open, portalNode]);
3282 const portalContextValue = React16.useMemo(() => ({
3283 beforeOutsideRef,
3284 afterOutsideRef,
3285 beforeInsideRef,
3286 afterInsideRef,
3287 portalNode,
3288 setFocusManagerState
3289 }), [portalNode]);
3290 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React16.Fragment, {
3291 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
3292 value: portalContextValue,
3293 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3294 "data-type": "outside",
3295 ref: beforeOutsideRef,
3296 onFocus: (event) => {
3297 if (isOutsideEvent(event, portalNode)) {
3298 beforeInsideRef.current?.focus();
3299 } else {
3300 const domReference = focusManagerState ? focusManagerState.domReference : null;
3301 const prevTabbable = getPreviousTabbable(domReference);
3302 prevTabbable?.focus();
3303 }
3304 }
3305 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
3306 "aria-owns": portalNode.id,
3307 style: ownerVisuallyHidden
3308 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3309 "data-type": "outside",
3310 ref: afterOutsideRef,
3311 onFocus: (event) => {
3312 if (isOutsideEvent(event, portalNode)) {
3313 afterInsideRef.current?.focus();
3314 } else {
3315 const domReference = focusManagerState ? focusManagerState.domReference : null;
3316 const nextTabbable = getNextTabbable(domReference);
3317 nextTabbable?.focus();
3318 if (focusManagerState?.closeOnFocusOut) {
3319 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
3320 }
3321 }
3322 }
3323 })]
3324 })]
3325 });
3326 });
3327 if (true) FloatingPortal.displayName = "FloatingPortal";
3328
3329 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs
3330 var React17 = __toESM(require_react(), 1);
3331
3332 // node_modules/@base-ui/react/floating-ui-react/utils/createEventEmitter.mjs
3333 function createEventEmitter() {
3334 const map = /* @__PURE__ */ new Map();
3335 return {
3336 emit(event, data) {
3337 map.get(event)?.forEach((listener) => listener(data));
3338 },
3339 on(event, listener) {
3340 if (!map.has(event)) {
3341 map.set(event, /* @__PURE__ */ new Set());
3342 }
3343 map.get(event).add(listener);
3344 },
3345 off(event, listener) {
3346 map.get(event)?.delete(listener);
3347 }
3348 };
3349 }
3350
3351 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs
3352 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
3353 var FloatingNodeContext = /* @__PURE__ */ React17.createContext(null);
3354 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
3355 var FloatingTreeContext = /* @__PURE__ */ React17.createContext(null);
3356 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3357 var useFloatingParentNodeId = () => React17.useContext(FloatingNodeContext)?.id || null;
3358 var useFloatingTree = (externalTree) => {
3359 const contextTree = React17.useContext(FloatingTreeContext);
3360 return externalTree ?? contextTree;
3361 };
3362
3363 // node_modules/@base-ui/react/floating-ui-react/hooks/useClientPoint.mjs
3364 var React18 = __toESM(require_react(), 1);
3365 function createVirtualElement(domElement, data) {
3366 let offsetX = null;
3367 let offsetY = null;
3368 let isAutoUpdateEvent = false;
3369 return {
3370 contextElement: domElement || void 0,
3371 getBoundingClientRect() {
3372 const domRect = domElement?.getBoundingClientRect() || {
3373 width: 0,
3374 height: 0,
3375 x: 0,
3376 y: 0
3377 };
3378 const isXAxis = data.axis === "x" || data.axis === "both";
3379 const isYAxis = data.axis === "y" || data.axis === "both";
3380 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
3381 let width = domRect.width;
3382 let height = domRect.height;
3383 let x2 = domRect.x;
3384 let y2 = domRect.y;
3385 if (offsetX == null && data.x && isXAxis) {
3386 offsetX = domRect.x - data.x;
3387 }
3388 if (offsetY == null && data.y && isYAxis) {
3389 offsetY = domRect.y - data.y;
3390 }
3391 x2 -= offsetX || 0;
3392 y2 -= offsetY || 0;
3393 width = 0;
3394 height = 0;
3395 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
3396 width = data.axis === "y" ? domRect.width : 0;
3397 height = data.axis === "x" ? domRect.height : 0;
3398 x2 = isXAxis && data.x != null ? data.x : x2;
3399 y2 = isYAxis && data.y != null ? data.y : y2;
3400 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
3401 height = data.axis === "x" ? domRect.height : height;
3402 width = data.axis === "y" ? domRect.width : width;
3403 }
3404 isAutoUpdateEvent = true;
3405 return {
3406 width,
3407 height,
3408 x: x2,
3409 y: y2,
3410 top: y2,
3411 right: x2 + width,
3412 bottom: y2 + height,
3413 left: x2
3414 };
3415 }
3416 };
3417 }
3418 function isMouseBasedEvent(event) {
3419 return event != null && event.clientX != null;
3420 }
3421 function useClientPoint(context, props = {}) {
3422 const {
3423 enabled = true,
3424 axis = "both"
3425 } = props;
3426 const store = "rootStore" in context ? context.rootStore : context;
3427 const open = store.useState("open");
3428 const floating = store.useState("floatingElement");
3429 const domReference = store.useState("domReferenceElement");
3430 const dataRef = store.context.dataRef;
3431 const initialRef = React18.useRef(false);
3432 const cleanupListenerRef = React18.useRef(null);
3433 const [pointerType, setPointerType] = React18.useState();
3434 const [reactive, setReactive] = React18.useState([]);
3435 const resetReference = useStableCallback((reference2) => {
3436 store.set("positionReference", reference2);
3437 });
3438 const setReference = useStableCallback((newX, newY, referenceElement) => {
3439 if (initialRef.current) {
3440 return;
3441 }
3442 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3443 return;
3444 }
3445 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3446 x: newX,
3447 y: newY,
3448 axis,
3449 dataRef,
3450 pointerType
3451 }));
3452 });
3453 const handleReferenceEnterOrMove = useStableCallback((event) => {
3454 if (!open) {
3455 setReference(event.clientX, event.clientY, event.currentTarget);
3456 } else if (!cleanupListenerRef.current) {
3457 setReference(event.clientX, event.clientY, event.currentTarget);
3458 setReactive([]);
3459 }
3460 });
3461 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
3462 React18.useEffect(() => {
3463 if (!enabled) {
3464 resetReference(domReference);
3465 return void 0;
3466 }
3467 if (!openCheck) {
3468 return void 0;
3469 }
3470 function cleanupListener() {
3471 cleanupListenerRef.current?.();
3472 cleanupListenerRef.current = null;
3473 }
3474 const win = getWindow(floating);
3475 function handleMouseMove(event) {
3476 const target = getTarget(event);
3477 if (!contains(floating, target)) {
3478 setReference(event.clientX, event.clientY);
3479 } else {
3480 cleanupListener();
3481 }
3482 }
3483 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3484 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3485 } else {
3486 resetReference(domReference);
3487 }
3488 return cleanupListener;
3489 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference, resetReference, reactive]);
3490 React18.useEffect(() => () => {
3491 store.set("positionReference", null);
3492 }, [store]);
3493 React18.useEffect(() => {
3494 if (enabled && !floating) {
3495 initialRef.current = false;
3496 }
3497 }, [enabled, floating]);
3498 React18.useEffect(() => {
3499 if (!enabled && open) {
3500 initialRef.current = true;
3501 }
3502 }, [enabled, open]);
3503 const reference = React18.useMemo(() => {
3504 function setPointerTypeRef(event) {
3505 setPointerType(event.pointerType);
3506 }
3507 return {
3508 onPointerDown: setPointerTypeRef,
3509 onPointerEnter: setPointerTypeRef,
3510 onMouseMove: handleReferenceEnterOrMove,
3511 onMouseEnter: handleReferenceEnterOrMove
3512 };
3513 }, [handleReferenceEnterOrMove]);
3514 return React18.useMemo(() => enabled ? {
3515 reference,
3516 trigger: reference
3517 } : {}, [enabled, reference]);
3518 }
3519
3520 // node_modules/@base-ui/react/floating-ui-react/hooks/useDismiss.mjs
3521 var React19 = __toESM(require_react(), 1);
3522 function alwaysFalse() {
3523 return false;
3524 }
3525 function normalizeProp(normalizable) {
3526 return {
3527 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
3528 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
3529 };
3530 }
3531 function useDismiss(context, props = {}) {
3532 const {
3533 enabled = true,
3534 escapeKey: escapeKey2 = true,
3535 outsidePress: outsidePressProp = true,
3536 outsidePressEvent = "sloppy",
3537 referencePress = alwaysFalse,
3538 bubbles,
3539 externalTree
3540 } = props;
3541 const store = "rootStore" in context ? context.rootStore : context;
3542 const open = store.useState("open");
3543 const floatingElement = store.useState("floatingElement");
3544 const {
3545 dataRef
3546 } = store.context;
3547 const tree = useFloatingTree(externalTree);
3548 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
3549 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
3550 const outsidePressEnabled = outsidePress2 !== false;
3551 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
3552 const {
3553 escapeKey: escapeKeyBubbles,
3554 outsidePress: outsidePressBubbles
3555 } = normalizeProp(bubbles);
3556 const pressStartedInsideRef = React19.useRef(false);
3557 const pressStartPreventedRef = React19.useRef(false);
3558 const suppressNextOutsideClickRef = React19.useRef(false);
3559 const isComposingRef = React19.useRef(false);
3560 const currentPointerTypeRef = React19.useRef("");
3561 const touchStateRef = React19.useRef(null);
3562 const cancelDismissOnEndTimeout = useTimeout();
3563 const clearInsideReactTreeTimeout = useTimeout();
3564 const clearInsideReactTree = useStableCallback(() => {
3565 clearInsideReactTreeTimeout.clear();
3566 dataRef.current.insideReactTree = false;
3567 });
3568 const hasBlockingChild = useStableCallback((bubbleKey) => {
3569 const nodeId = dataRef.current.floatingContext?.nodeId;
3570 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3571 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
3572 });
3573 const isEventWithinOwnElements = useStableCallback((event) => {
3574 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"));
3575 });
3576 const closeOnReferencePress = useStableCallback((event) => {
3577 if (!referencePress()) {
3578 return;
3579 }
3580 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3581 });
3582 const closeOnEscapeKeyDown = useStableCallback((event) => {
3583 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
3584 return;
3585 }
3586 if (isComposingRef.current) {
3587 return;
3588 }
3589 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
3590 return;
3591 }
3592 const native = isReactEvent(event) ? event.nativeEvent : event;
3593 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
3594 store.setOpen(false, eventDetails);
3595 if (!eventDetails.isCanceled) {
3596 event.preventDefault();
3597 }
3598 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
3599 event.stopPropagation();
3600 }
3601 });
3602 const markInsideReactTree = useStableCallback(() => {
3603 dataRef.current.insideReactTree = true;
3604 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
3605 });
3606 const markPressStartedInsideReactTree = useStableCallback((event) => {
3607 if (!open || !enabled || event.button !== 0) {
3608 return;
3609 }
3610 const target = getTarget(event.nativeEvent);
3611 if (!contains(store.select("floatingElement"), target)) {
3612 return;
3613 }
3614 if (!pressStartedInsideRef.current) {
3615 pressStartedInsideRef.current = true;
3616 pressStartPreventedRef.current = false;
3617 }
3618 });
3619 const markInsidePressStartPrevented = useStableCallback((event) => {
3620 if (!open || !enabled) {
3621 return;
3622 }
3623 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
3624 return;
3625 }
3626 if (pressStartedInsideRef.current) {
3627 pressStartPreventedRef.current = true;
3628 }
3629 });
3630 React19.useEffect(() => {
3631 if (!open || !enabled) {
3632 return void 0;
3633 }
3634 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
3635 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
3636 const compositionTimeout = new Timeout();
3637 const preventedPressSuppressionTimeout = new Timeout();
3638 function handleCompositionStart() {
3639 compositionTimeout.clear();
3640 isComposingRef.current = true;
3641 }
3642 function handleCompositionEnd() {
3643 compositionTimeout.start(
3644 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
3645 // Only apply to WebKit for the test to remain 0ms.
3646 parts_exports.engine.webkit ? 5 : 0,
3647 () => {
3648 isComposingRef.current = false;
3649 }
3650 );
3651 }
3652 function suppressImmediateOutsideClickAfterPreventedStart() {
3653 suppressNextOutsideClickRef.current = true;
3654 preventedPressSuppressionTimeout.start(0, () => {
3655 suppressNextOutsideClickRef.current = false;
3656 });
3657 }
3658 function resetPressStartState() {
3659 pressStartedInsideRef.current = false;
3660 pressStartPreventedRef.current = false;
3661 }
3662 function getOutsidePressEvent() {
3663 const type = currentPointerTypeRef.current;
3664 const computedType = type === "pen" || !type ? "mouse" : type;
3665 const outsidePressEventValue = getOutsidePressEventProp();
3666 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
3667 if (typeof resolved === "string") {
3668 return resolved;
3669 }
3670 return resolved[computedType];
3671 }
3672 function shouldIgnoreEvent(event) {
3673 const computedOutsidePressEvent = getOutsidePressEvent();
3674 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
3675 }
3676 function isEventWithinFloatingTree(event) {
3677 const nodeId = dataRef.current.floatingContext?.nodeId;
3678 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
3679 return isEventWithinOwnElements(event) || targetIsInsideChildren;
3680 }
3681 function closeOnPressOutside(event) {
3682 if (shouldIgnoreEvent(event)) {
3683 if (event.type !== "click" && !isEventWithinOwnElements(event)) {
3684 preventedPressSuppressionTimeout.clear();
3685 suppressNextOutsideClickRef.current = false;
3686 }
3687 clearInsideReactTree();
3688 return;
3689 }
3690 if (dataRef.current.insideReactTree) {
3691 clearInsideReactTree();
3692 return;
3693 }
3694 const target = getTarget(event);
3695 const inertSelector = `[${createAttribute("inert")}]`;
3696 const targetRoot = isElement(target) ? target.getRootNode() : null;
3697 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
3698 const triggers = store.context.triggerElements;
3699 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
3700 return;
3701 }
3702 let targetRootAncestor = isElement(target) ? target : null;
3703 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
3704 const nextParent = getParentNode(targetRootAncestor);
3705 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
3706 break;
3707 }
3708 targetRootAncestor = nextParent;
3709 }
3710 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
3711 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
3712 // element was injected after the floating element rendered.
3713 markers.every((marker) => !contains(targetRootAncestor, marker))) {
3714 return;
3715 }
3716 if (isHTMLElement(target) && !("touches" in event)) {
3717 const lastTraversableNode = isLastTraversableNode(target);
3718 const style = getComputedStyle2(target);
3719 const scrollRe = /auto|scroll/;
3720 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
3721 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
3722 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
3723 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
3724 const isRTL7 = style.direction === "rtl";
3725 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
3726 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
3727 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
3728 return;
3729 }
3730 }
3731 if (isEventWithinFloatingTree(event)) {
3732 return;
3733 }
3734 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
3735 preventedPressSuppressionTimeout.clear();
3736 suppressNextOutsideClickRef.current = false;
3737 return;
3738 }
3739 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3740 return;
3741 }
3742 if (hasBlockingChild("__outsidePressBubbles")) {
3743 return;
3744 }
3745 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
3746 clearInsideReactTree();
3747 }
3748 function handlePointerDown(event) {
3749 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
3750 return;
3751 }
3752 closeOnPressOutside(event);
3753 }
3754 function handleTouchStart(event) {
3755 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
3756 return;
3757 }
3758 const touch = event.touches[0];
3759 if (touch) {
3760 touchStateRef.current = {
3761 startTime: Date.now(),
3762 startX: touch.clientX,
3763 startY: touch.clientY,
3764 dismissOnTouchEnd: false,
3765 dismissOnMouseDown: true
3766 };
3767 cancelDismissOnEndTimeout.start(1e3, () => {
3768 if (touchStateRef.current) {
3769 touchStateRef.current.dismissOnTouchEnd = false;
3770 touchStateRef.current.dismissOnMouseDown = false;
3771 }
3772 });
3773 }
3774 }
3775 function addTargetEventListenerOnce(event, listener) {
3776 const target = getTarget(event);
3777 if (!target) {
3778 return;
3779 }
3780 const unsubscribe2 = addEventListener(target, event.type, () => {
3781 listener(event);
3782 unsubscribe2();
3783 });
3784 }
3785 function handleTouchStartCapture(event) {
3786 currentPointerTypeRef.current = "touch";
3787 addTargetEventListenerOnce(event, handleTouchStart);
3788 }
3789 function closeOnPressOutsideCapture(event) {
3790 cancelDismissOnEndTimeout.clear();
3791 if (event.type === "pointerdown") {
3792 currentPointerTypeRef.current = event.pointerType;
3793 }
3794 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
3795 return;
3796 }
3797 addTargetEventListenerOnce(event, (targetEvent) => {
3798 if (targetEvent.type === "pointerdown") {
3799 handlePointerDown(targetEvent);
3800 } else {
3801 closeOnPressOutside(targetEvent);
3802 }
3803 });
3804 }
3805 function handlePressEndCapture(event) {
3806 if (!pressStartedInsideRef.current) {
3807 return;
3808 }
3809 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
3810 resetPressStartState();
3811 if (getOutsidePressEvent() !== "intentional") {
3812 return;
3813 }
3814 if (event.type === "pointercancel") {
3815 if (pressStartedInsideDefaultPrevented) {
3816 suppressImmediateOutsideClickAfterPreventedStart();
3817 }
3818 return;
3819 }
3820 if (isEventWithinFloatingTree(event)) {
3821 return;
3822 }
3823 if (pressStartedInsideDefaultPrevented) {
3824 suppressImmediateOutsideClickAfterPreventedStart();
3825 return;
3826 }
3827 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3828 return;
3829 }
3830 preventedPressSuppressionTimeout.clear();
3831 suppressNextOutsideClickRef.current = true;
3832 clearInsideReactTree();
3833 }
3834 function handleTouchMove(event) {
3835 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
3836 return;
3837 }
3838 const touch = event.touches[0];
3839 if (!touch) {
3840 return;
3841 }
3842 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
3843 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
3844 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
3845 if (distance > 5) {
3846 touchStateRef.current.dismissOnTouchEnd = true;
3847 }
3848 if (distance > 10) {
3849 closeOnPressOutside(event);
3850 cancelDismissOnEndTimeout.clear();
3851 touchStateRef.current = null;
3852 }
3853 }
3854 function handleTouchMoveCapture(event) {
3855 addTargetEventListenerOnce(event, handleTouchMove);
3856 }
3857 function handleTouchEnd(event) {
3858 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
3859 return;
3860 }
3861 if (touchStateRef.current.dismissOnTouchEnd) {
3862 closeOnPressOutside(event);
3863 }
3864 cancelDismissOnEndTimeout.clear();
3865 touchStateRef.current = null;
3866 }
3867 function handleTouchEndCapture(event) {
3868 addTargetEventListenerOnce(event, handleTouchEnd);
3869 }
3870 const doc = ownerDocument(floatingElement);
3871 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)));
3872 return () => {
3873 unsubscribe();
3874 compositionTimeout.clear();
3875 preventedPressSuppressionTimeout.clear();
3876 resetPressStartState();
3877 suppressNextOutsideClickRef.current = false;
3878 };
3879 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store, cancelDismissOnEndTimeout]);
3880 React19.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
3881 const reference = React19.useMemo(() => ({
3882 onKeyDown: closeOnEscapeKeyDown,
3883 onPointerDown: closeOnReferencePress,
3884 onClick: closeOnReferencePress
3885 }), [closeOnEscapeKeyDown, closeOnReferencePress]);
3886 const floating = React19.useMemo(() => ({
3887 onKeyDown: closeOnEscapeKeyDown,
3888 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
3889 // `onPointerDown`, such as with <NumberField.ScrubArea>.
3890 // See https://github.com/mui/base-ui/pull/3379
3891 onPointerDown: markInsidePressStartPrevented,
3892 onMouseDown: markInsidePressStartPrevented,
3893 onClickCapture: markInsideReactTree,
3894 onMouseDownCapture(event) {
3895 markInsideReactTree();
3896 markPressStartedInsideReactTree(event);
3897 },
3898 onPointerDownCapture(event) {
3899 markInsideReactTree();
3900 markPressStartedInsideReactTree(event);
3901 },
3902 onMouseUpCapture: markInsideReactTree,
3903 onTouchEndCapture: markInsideReactTree,
3904 onTouchMoveCapture: markInsideReactTree
3905 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
3906 return React19.useMemo(() => enabled ? {
3907 reference,
3908 floating,
3909 trigger: reference
3910 } : {}, [enabled, reference, floating]);
3911 }
3912
3913 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs
3914 var React26 = __toESM(require_react(), 1);
3915
3916 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
3917 function computeCoordsFromPlacement(_ref, placement, rtl) {
3918 let {
3919 reference,
3920 floating
3921 } = _ref;
3922 const sideAxis = getSideAxis(placement);
3923 const alignmentAxis = getAlignmentAxis(placement);
3924 const alignLength = getAxisLength(alignmentAxis);
3925 const side = getSide(placement);
3926 const isVertical = sideAxis === "y";
3927 const commonX = reference.x + reference.width / 2 - floating.width / 2;
3928 const commonY = reference.y + reference.height / 2 - floating.height / 2;
3929 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
3930 let coords;
3931 switch (side) {
3932 case "top":
3933 coords = {
3934 x: commonX,
3935 y: reference.y - floating.height
3936 };
3937 break;
3938 case "bottom":
3939 coords = {
3940 x: commonX,
3941 y: reference.y + reference.height
3942 };
3943 break;
3944 case "right":
3945 coords = {
3946 x: reference.x + reference.width,
3947 y: commonY
3948 };
3949 break;
3950 case "left":
3951 coords = {
3952 x: reference.x - floating.width,
3953 y: commonY
3954 };
3955 break;
3956 default:
3957 coords = {
3958 x: reference.x,
3959 y: reference.y
3960 };
3961 }
3962 switch (getAlignment(placement)) {
3963 case "start":
3964 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
3965 break;
3966 case "end":
3967 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
3968 break;
3969 }
3970 return coords;
3971 }
3972 async function detectOverflow(state, options) {
3973 var _await$platform$isEle;
3974 if (options === void 0) {
3975 options = {};
3976 }
3977 const {
3978 x: x2,
3979 y: y2,
3980 platform: platform3,
3981 rects,
3982 elements,
3983 strategy
3984 } = state;
3985 const {
3986 boundary = "clippingAncestors",
3987 rootBoundary = "viewport",
3988 elementContext = "floating",
3989 altBoundary = false,
3990 padding = 0
3991 } = evaluate(options, state);
3992 const paddingObject = getPaddingObject(padding);
3993 const altContext = elementContext === "floating" ? "reference" : "floating";
3994 const element = elements[altBoundary ? altContext : elementContext];
3995 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
3996 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)),
3997 boundary,
3998 rootBoundary,
3999 strategy
4000 }));
4001 const rect = elementContext === "floating" ? {
4002 x: x2,
4003 y: y2,
4004 width: rects.floating.width,
4005 height: rects.floating.height
4006 } : rects.reference;
4007 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
4008 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
4009 x: 1,
4010 y: 1
4011 } : {
4012 x: 1,
4013 y: 1
4014 };
4015 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
4016 elements,
4017 rect,
4018 offsetParent,
4019 strategy
4020 }) : rect);
4021 return {
4022 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
4023 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
4024 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
4025 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
4026 };
4027 }
4028 var MAX_RESET_COUNT = 50;
4029 var computePosition = async (reference, floating, config) => {
4030 const {
4031 placement = "bottom",
4032 strategy = "absolute",
4033 middleware = [],
4034 platform: platform3
4035 } = config;
4036 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
4037 ...platform3,
4038 detectOverflow
4039 };
4040 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
4041 let rects = await platform3.getElementRects({
4042 reference,
4043 floating,
4044 strategy
4045 });
4046 let {
4047 x: x2,
4048 y: y2
4049 } = computeCoordsFromPlacement(rects, placement, rtl);
4050 let statefulPlacement = placement;
4051 let resetCount = 0;
4052 const middlewareData = {};
4053 for (let i2 = 0; i2 < middleware.length; i2++) {
4054 const currentMiddleware = middleware[i2];
4055 if (!currentMiddleware) {
4056 continue;
4057 }
4058 const {
4059 name,
4060 fn
4061 } = currentMiddleware;
4062 const {
4063 x: nextX,
4064 y: nextY,
4065 data,
4066 reset
4067 } = await fn({
4068 x: x2,
4069 y: y2,
4070 initialPlacement: placement,
4071 placement: statefulPlacement,
4072 strategy,
4073 middlewareData,
4074 rects,
4075 platform: platformWithDetectOverflow,
4076 elements: {
4077 reference,
4078 floating
4079 }
4080 });
4081 x2 = nextX != null ? nextX : x2;
4082 y2 = nextY != null ? nextY : y2;
4083 middlewareData[name] = {
4084 ...middlewareData[name],
4085 ...data
4086 };
4087 if (reset && resetCount < MAX_RESET_COUNT) {
4088 resetCount++;
4089 if (typeof reset === "object") {
4090 if (reset.placement) {
4091 statefulPlacement = reset.placement;
4092 }
4093 if (reset.rects) {
4094 rects = reset.rects === true ? await platform3.getElementRects({
4095 reference,
4096 floating,
4097 strategy
4098 }) : reset.rects;
4099 }
4100 ({
4101 x: x2,
4102 y: y2
4103 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
4104 }
4105 i2 = -1;
4106 }
4107 }
4108 return {
4109 x: x2,
4110 y: y2,
4111 placement: statefulPlacement,
4112 strategy,
4113 middlewareData
4114 };
4115 };
4116 var flip = function(options) {
4117 if (options === void 0) {
4118 options = {};
4119 }
4120 return {
4121 name: "flip",
4122 options,
4123 async fn(state) {
4124 var _middlewareData$arrow, _middlewareData$flip;
4125 const {
4126 placement,
4127 middlewareData,
4128 rects,
4129 initialPlacement,
4130 platform: platform3,
4131 elements
4132 } = state;
4133 const {
4134 mainAxis: checkMainAxis = true,
4135 crossAxis: checkCrossAxis = true,
4136 fallbackPlacements: specifiedFallbackPlacements,
4137 fallbackStrategy = "bestFit",
4138 fallbackAxisSideDirection = "none",
4139 flipAlignment = true,
4140 ...detectOverflowOptions
4141 } = evaluate(options, state);
4142 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4143 return {};
4144 }
4145 const side = getSide(placement);
4146 const initialSideAxis = getSideAxis(initialPlacement);
4147 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
4148 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4149 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
4150 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
4151 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
4152 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
4153 }
4154 const placements2 = [initialPlacement, ...fallbackPlacements];
4155 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4156 const overflows = [];
4157 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
4158 if (checkMainAxis) {
4159 overflows.push(overflow[side]);
4160 }
4161 if (checkCrossAxis) {
4162 const sides2 = getAlignmentSides(placement, rects, rtl);
4163 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
4164 }
4165 overflowsData = [...overflowsData, {
4166 placement,
4167 overflows
4168 }];
4169 if (!overflows.every((side2) => side2 <= 0)) {
4170 var _middlewareData$flip2, _overflowsData$filter;
4171 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
4172 const nextPlacement = placements2[nextIndex];
4173 if (nextPlacement) {
4174 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
4175 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
4176 // overflows the main axis.
4177 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
4178 return {
4179 data: {
4180 index: nextIndex,
4181 overflows: overflowsData
4182 },
4183 reset: {
4184 placement: nextPlacement
4185 }
4186 };
4187 }
4188 }
4189 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;
4190 if (!resetPlacement) {
4191 switch (fallbackStrategy) {
4192 case "bestFit": {
4193 var _overflowsData$filter2;
4194 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
4195 if (hasFallbackAxisSideDirection) {
4196 const currentSideAxis = getSideAxis(d2.placement);
4197 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
4198 // reading directions favoring greater width.
4199 currentSideAxis === "y";
4200 }
4201 return true;
4202 }).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];
4203 if (placement2) {
4204 resetPlacement = placement2;
4205 }
4206 break;
4207 }
4208 case "initialPlacement":
4209 resetPlacement = initialPlacement;
4210 break;
4211 }
4212 }
4213 if (placement !== resetPlacement) {
4214 return {
4215 reset: {
4216 placement: resetPlacement
4217 }
4218 };
4219 }
4220 }
4221 return {};
4222 }
4223 };
4224 };
4225 function getSideOffsets(overflow, rect) {
4226 return {
4227 top: overflow.top - rect.height,
4228 right: overflow.right - rect.width,
4229 bottom: overflow.bottom - rect.height,
4230 left: overflow.left - rect.width
4231 };
4232 }
4233 function isAnySideFullyClipped(overflow) {
4234 return sides.some((side) => overflow[side] >= 0);
4235 }
4236 var hide = function(options) {
4237 if (options === void 0) {
4238 options = {};
4239 }
4240 return {
4241 name: "hide",
4242 options,
4243 async fn(state) {
4244 const {
4245 rects,
4246 platform: platform3
4247 } = state;
4248 const {
4249 strategy = "referenceHidden",
4250 ...detectOverflowOptions
4251 } = evaluate(options, state);
4252 switch (strategy) {
4253 case "referenceHidden": {
4254 const overflow = await platform3.detectOverflow(state, {
4255 ...detectOverflowOptions,
4256 elementContext: "reference"
4257 });
4258 const offsets = getSideOffsets(overflow, rects.reference);
4259 return {
4260 data: {
4261 referenceHiddenOffsets: offsets,
4262 referenceHidden: isAnySideFullyClipped(offsets)
4263 }
4264 };
4265 }
4266 case "escaped": {
4267 const overflow = await platform3.detectOverflow(state, {
4268 ...detectOverflowOptions,
4269 altBoundary: true
4270 });
4271 const offsets = getSideOffsets(overflow, rects.floating);
4272 return {
4273 data: {
4274 escapedOffsets: offsets,
4275 escaped: isAnySideFullyClipped(offsets)
4276 }
4277 };
4278 }
4279 default: {
4280 return {};
4281 }
4282 }
4283 }
4284 };
4285 };
4286 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
4287 async function convertValueToCoords(state, options) {
4288 const {
4289 placement,
4290 platform: platform3,
4291 elements
4292 } = state;
4293 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4294 const side = getSide(placement);
4295 const alignment = getAlignment(placement);
4296 const isVertical = getSideAxis(placement) === "y";
4297 const mainAxisMulti = originSides.has(side) ? -1 : 1;
4298 const crossAxisMulti = rtl && isVertical ? -1 : 1;
4299 const rawValue = evaluate(options, state);
4300 let {
4301 mainAxis,
4302 crossAxis,
4303 alignmentAxis
4304 } = typeof rawValue === "number" ? {
4305 mainAxis: rawValue,
4306 crossAxis: 0,
4307 alignmentAxis: null
4308 } : {
4309 mainAxis: rawValue.mainAxis || 0,
4310 crossAxis: rawValue.crossAxis || 0,
4311 alignmentAxis: rawValue.alignmentAxis
4312 };
4313 if (alignment && typeof alignmentAxis === "number") {
4314 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
4315 }
4316 return isVertical ? {
4317 x: crossAxis * crossAxisMulti,
4318 y: mainAxis * mainAxisMulti
4319 } : {
4320 x: mainAxis * mainAxisMulti,
4321 y: crossAxis * crossAxisMulti
4322 };
4323 }
4324 var offset = function(options) {
4325 if (options === void 0) {
4326 options = 0;
4327 }
4328 return {
4329 name: "offset",
4330 options,
4331 async fn(state) {
4332 var _middlewareData$offse, _middlewareData$arrow;
4333 const {
4334 x: x2,
4335 y: y2,
4336 placement,
4337 middlewareData
4338 } = state;
4339 const diffCoords = await convertValueToCoords(state, options);
4340 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4341 return {};
4342 }
4343 return {
4344 x: x2 + diffCoords.x,
4345 y: y2 + diffCoords.y,
4346 data: {
4347 ...diffCoords,
4348 placement
4349 }
4350 };
4351 }
4352 };
4353 };
4354 var shift = function(options) {
4355 if (options === void 0) {
4356 options = {};
4357 }
4358 return {
4359 name: "shift",
4360 options,
4361 async fn(state) {
4362 const {
4363 x: x2,
4364 y: y2,
4365 placement,
4366 platform: platform3
4367 } = state;
4368 const {
4369 mainAxis: checkMainAxis = true,
4370 crossAxis: checkCrossAxis = false,
4371 limiter = {
4372 fn: (_ref) => {
4373 let {
4374 x: x3,
4375 y: y3
4376 } = _ref;
4377 return {
4378 x: x3,
4379 y: y3
4380 };
4381 }
4382 },
4383 ...detectOverflowOptions
4384 } = evaluate(options, state);
4385 const coords = {
4386 x: x2,
4387 y: y2
4388 };
4389 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4390 const crossAxis = getSideAxis(getSide(placement));
4391 const mainAxis = getOppositeAxis(crossAxis);
4392 let mainAxisCoord = coords[mainAxis];
4393 let crossAxisCoord = coords[crossAxis];
4394 if (checkMainAxis) {
4395 const minSide = mainAxis === "y" ? "top" : "left";
4396 const maxSide = mainAxis === "y" ? "bottom" : "right";
4397 const min2 = mainAxisCoord + overflow[minSide];
4398 const max2 = mainAxisCoord - overflow[maxSide];
4399 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
4400 }
4401 if (checkCrossAxis) {
4402 const minSide = crossAxis === "y" ? "top" : "left";
4403 const maxSide = crossAxis === "y" ? "bottom" : "right";
4404 const min2 = crossAxisCoord + overflow[minSide];
4405 const max2 = crossAxisCoord - overflow[maxSide];
4406 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
4407 }
4408 const limitedCoords = limiter.fn({
4409 ...state,
4410 [mainAxis]: mainAxisCoord,
4411 [crossAxis]: crossAxisCoord
4412 });
4413 return {
4414 ...limitedCoords,
4415 data: {
4416 x: limitedCoords.x - x2,
4417 y: limitedCoords.y - y2,
4418 enabled: {
4419 [mainAxis]: checkMainAxis,
4420 [crossAxis]: checkCrossAxis
4421 }
4422 }
4423 };
4424 }
4425 };
4426 };
4427 var limitShift = function(options) {
4428 if (options === void 0) {
4429 options = {};
4430 }
4431 return {
4432 options,
4433 fn(state) {
4434 const {
4435 x: x2,
4436 y: y2,
4437 placement,
4438 rects,
4439 middlewareData
4440 } = state;
4441 const {
4442 offset: offset4 = 0,
4443 mainAxis: checkMainAxis = true,
4444 crossAxis: checkCrossAxis = true
4445 } = evaluate(options, state);
4446 const coords = {
4447 x: x2,
4448 y: y2
4449 };
4450 const crossAxis = getSideAxis(placement);
4451 const mainAxis = getOppositeAxis(crossAxis);
4452 let mainAxisCoord = coords[mainAxis];
4453 let crossAxisCoord = coords[crossAxis];
4454 const rawOffset = evaluate(offset4, state);
4455 const computedOffset = typeof rawOffset === "number" ? {
4456 mainAxis: rawOffset,
4457 crossAxis: 0
4458 } : {
4459 mainAxis: 0,
4460 crossAxis: 0,
4461 ...rawOffset
4462 };
4463 if (checkMainAxis) {
4464 const len = mainAxis === "y" ? "height" : "width";
4465 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
4466 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
4467 if (mainAxisCoord < limitMin) {
4468 mainAxisCoord = limitMin;
4469 } else if (mainAxisCoord > limitMax) {
4470 mainAxisCoord = limitMax;
4471 }
4472 }
4473 if (checkCrossAxis) {
4474 var _middlewareData$offse, _middlewareData$offse2;
4475 const len = mainAxis === "y" ? "width" : "height";
4476 const isOriginSide = originSides.has(getSide(placement));
4477 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);
4478 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);
4479 if (crossAxisCoord < limitMin) {
4480 crossAxisCoord = limitMin;
4481 } else if (crossAxisCoord > limitMax) {
4482 crossAxisCoord = limitMax;
4483 }
4484 }
4485 return {
4486 [mainAxis]: mainAxisCoord,
4487 [crossAxis]: crossAxisCoord
4488 };
4489 }
4490 };
4491 };
4492 var size = function(options) {
4493 if (options === void 0) {
4494 options = {};
4495 }
4496 return {
4497 name: "size",
4498 options,
4499 async fn(state) {
4500 var _state$middlewareData, _state$middlewareData2;
4501 const {
4502 placement,
4503 rects,
4504 platform: platform3,
4505 elements
4506 } = state;
4507 const {
4508 apply = () => {
4509 },
4510 ...detectOverflowOptions
4511 } = evaluate(options, state);
4512 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4513 const side = getSide(placement);
4514 const alignment = getAlignment(placement);
4515 const isYAxis = getSideAxis(placement) === "y";
4516 const {
4517 width,
4518 height
4519 } = rects.floating;
4520 let heightSide;
4521 let widthSide;
4522 if (side === "top" || side === "bottom") {
4523 heightSide = side;
4524 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
4525 } else {
4526 widthSide = side;
4527 heightSide = alignment === "end" ? "top" : "bottom";
4528 }
4529 const maximumClippingHeight = height - overflow.top - overflow.bottom;
4530 const maximumClippingWidth = width - overflow.left - overflow.right;
4531 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
4532 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
4533 const noShift = !state.middlewareData.shift;
4534 let availableHeight = overflowAvailableHeight;
4535 let availableWidth = overflowAvailableWidth;
4536 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
4537 availableWidth = maximumClippingWidth;
4538 }
4539 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
4540 availableHeight = maximumClippingHeight;
4541 }
4542 if (noShift && !alignment) {
4543 const xMin = max(overflow.left, 0);
4544 const xMax = max(overflow.right, 0);
4545 const yMin = max(overflow.top, 0);
4546 const yMax = max(overflow.bottom, 0);
4547 if (isYAxis) {
4548 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
4549 } else {
4550 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
4551 }
4552 }
4553 await apply({
4554 ...state,
4555 availableWidth,
4556 availableHeight
4557 });
4558 const nextDimensions = await platform3.getDimensions(elements.floating);
4559 if (width !== nextDimensions.width || height !== nextDimensions.height) {
4560 return {
4561 reset: {
4562 rects: true
4563 }
4564 };
4565 }
4566 return {};
4567 }
4568 };
4569 };
4570
4571 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
4572 function getCssDimensions(element) {
4573 const css = getComputedStyle2(element);
4574 let width = parseFloat(css.width) || 0;
4575 let height = parseFloat(css.height) || 0;
4576 const hasOffset = isHTMLElement(element);
4577 const offsetWidth = hasOffset ? element.offsetWidth : width;
4578 const offsetHeight = hasOffset ? element.offsetHeight : height;
4579 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
4580 if (shouldFallback) {
4581 width = offsetWidth;
4582 height = offsetHeight;
4583 }
4584 return {
4585 width,
4586 height,
4587 $: shouldFallback
4588 };
4589 }
4590 function unwrapElement(element) {
4591 return !isElement(element) ? element.contextElement : element;
4592 }
4593 function getScale(element) {
4594 const domElement = unwrapElement(element);
4595 if (!isHTMLElement(domElement)) {
4596 return createCoords(1);
4597 }
4598 const rect = domElement.getBoundingClientRect();
4599 const {
4600 width,
4601 height,
4602 $: $2
4603 } = getCssDimensions(domElement);
4604 let x2 = ($2 ? round(rect.width) : rect.width) / width;
4605 let y2 = ($2 ? round(rect.height) : rect.height) / height;
4606 if (!x2 || !Number.isFinite(x2)) {
4607 x2 = 1;
4608 }
4609 if (!y2 || !Number.isFinite(y2)) {
4610 y2 = 1;
4611 }
4612 return {
4613 x: x2,
4614 y: y2
4615 };
4616 }
4617 var noOffsets = /* @__PURE__ */ createCoords(0);
4618 function getVisualOffsets(element) {
4619 const win = getWindow(element);
4620 if (!isWebKit() || !win.visualViewport) {
4621 return noOffsets;
4622 }
4623 return {
4624 x: win.visualViewport.offsetLeft,
4625 y: win.visualViewport.offsetTop
4626 };
4627 }
4628 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
4629 if (isFixed === void 0) {
4630 isFixed = false;
4631 }
4632 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
4633 return false;
4634 }
4635 return isFixed;
4636 }
4637 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
4638 if (includeScale === void 0) {
4639 includeScale = false;
4640 }
4641 if (isFixedStrategy === void 0) {
4642 isFixedStrategy = false;
4643 }
4644 const clientRect = element.getBoundingClientRect();
4645 const domElement = unwrapElement(element);
4646 let scale = createCoords(1);
4647 if (includeScale) {
4648 if (offsetParent) {
4649 if (isElement(offsetParent)) {
4650 scale = getScale(offsetParent);
4651 }
4652 } else {
4653 scale = getScale(element);
4654 }
4655 }
4656 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
4657 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
4658 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
4659 let width = clientRect.width / scale.x;
4660 let height = clientRect.height / scale.y;
4661 if (domElement) {
4662 const win = getWindow(domElement);
4663 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
4664 let currentWin = win;
4665 let currentIFrame = getFrameElement(currentWin);
4666 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
4667 const iframeScale = getScale(currentIFrame);
4668 const iframeRect = currentIFrame.getBoundingClientRect();
4669 const css = getComputedStyle2(currentIFrame);
4670 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
4671 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
4672 x2 *= iframeScale.x;
4673 y2 *= iframeScale.y;
4674 width *= iframeScale.x;
4675 height *= iframeScale.y;
4676 x2 += left;
4677 y2 += top;
4678 currentWin = getWindow(currentIFrame);
4679 currentIFrame = getFrameElement(currentWin);
4680 }
4681 }
4682 return rectToClientRect({
4683 width,
4684 height,
4685 x: x2,
4686 y: y2
4687 });
4688 }
4689 function getWindowScrollBarX(element, rect) {
4690 const leftScroll = getNodeScroll(element).scrollLeft;
4691 if (!rect) {
4692 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
4693 }
4694 return rect.left + leftScroll;
4695 }
4696 function getHTMLOffset(documentElement, scroll) {
4697 const htmlRect = documentElement.getBoundingClientRect();
4698 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
4699 const y2 = htmlRect.top + scroll.scrollTop;
4700 return {
4701 x: x2,
4702 y: y2
4703 };
4704 }
4705 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
4706 let {
4707 elements,
4708 rect,
4709 offsetParent,
4710 strategy
4711 } = _ref;
4712 const isFixed = strategy === "fixed";
4713 const documentElement = getDocumentElement(offsetParent);
4714 const topLayer = elements ? isTopLayer(elements.floating) : false;
4715 if (offsetParent === documentElement || topLayer && isFixed) {
4716 return rect;
4717 }
4718 let scroll = {
4719 scrollLeft: 0,
4720 scrollTop: 0
4721 };
4722 let scale = createCoords(1);
4723 const offsets = createCoords(0);
4724 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4725 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4726 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4727 scroll = getNodeScroll(offsetParent);
4728 }
4729 if (isOffsetParentAnElement) {
4730 const offsetRect = getBoundingClientRect(offsetParent);
4731 scale = getScale(offsetParent);
4732 offsets.x = offsetRect.x + offsetParent.clientLeft;
4733 offsets.y = offsetRect.y + offsetParent.clientTop;
4734 }
4735 }
4736 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4737 return {
4738 width: rect.width * scale.x,
4739 height: rect.height * scale.y,
4740 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
4741 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
4742 };
4743 }
4744 function getClientRects(element) {
4745 return Array.from(element.getClientRects());
4746 }
4747 function getDocumentRect(element) {
4748 const html = getDocumentElement(element);
4749 const scroll = getNodeScroll(element);
4750 const body = element.ownerDocument.body;
4751 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
4752 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
4753 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
4754 const y2 = -scroll.scrollTop;
4755 if (getComputedStyle2(body).direction === "rtl") {
4756 x2 += max(html.clientWidth, body.clientWidth) - width;
4757 }
4758 return {
4759 width,
4760 height,
4761 x: x2,
4762 y: y2
4763 };
4764 }
4765 var SCROLLBAR_MAX = 25;
4766 function getViewportRect(element, strategy) {
4767 const win = getWindow(element);
4768 const html = getDocumentElement(element);
4769 const visualViewport = win.visualViewport;
4770 let width = html.clientWidth;
4771 let height = html.clientHeight;
4772 let x2 = 0;
4773 let y2 = 0;
4774 if (visualViewport) {
4775 width = visualViewport.width;
4776 height = visualViewport.height;
4777 const visualViewportBased = isWebKit();
4778 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
4779 x2 = visualViewport.offsetLeft;
4780 y2 = visualViewport.offsetTop;
4781 }
4782 }
4783 const windowScrollbarX = getWindowScrollBarX(html);
4784 if (windowScrollbarX <= 0) {
4785 const doc = html.ownerDocument;
4786 const body = doc.body;
4787 const bodyStyles = getComputedStyle(body);
4788 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
4789 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
4790 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
4791 width -= clippingStableScrollbarWidth;
4792 }
4793 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
4794 width += windowScrollbarX;
4795 }
4796 return {
4797 width,
4798 height,
4799 x: x2,
4800 y: y2
4801 };
4802 }
4803 function getInnerBoundingClientRect(element, strategy) {
4804 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
4805 const top = clientRect.top + element.clientTop;
4806 const left = clientRect.left + element.clientLeft;
4807 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
4808 const width = element.clientWidth * scale.x;
4809 const height = element.clientHeight * scale.y;
4810 const x2 = left * scale.x;
4811 const y2 = top * scale.y;
4812 return {
4813 width,
4814 height,
4815 x: x2,
4816 y: y2
4817 };
4818 }
4819 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
4820 let rect;
4821 if (clippingAncestor === "viewport") {
4822 rect = getViewportRect(element, strategy);
4823 } else if (clippingAncestor === "document") {
4824 rect = getDocumentRect(getDocumentElement(element));
4825 } else if (isElement(clippingAncestor)) {
4826 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
4827 } else {
4828 const visualOffsets = getVisualOffsets(element);
4829 rect = {
4830 x: clippingAncestor.x - visualOffsets.x,
4831 y: clippingAncestor.y - visualOffsets.y,
4832 width: clippingAncestor.width,
4833 height: clippingAncestor.height
4834 };
4835 }
4836 return rectToClientRect(rect);
4837 }
4838 function hasFixedPositionAncestor(element, stopNode) {
4839 const parentNode = getParentNode(element);
4840 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
4841 return false;
4842 }
4843 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
4844 }
4845 function getClippingElementAncestors(element, cache) {
4846 const cachedResult = cache.get(element);
4847 if (cachedResult) {
4848 return cachedResult;
4849 }
4850 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
4851 let currentContainingBlockComputedStyle = null;
4852 const elementIsFixed = getComputedStyle2(element).position === "fixed";
4853 let currentNode = elementIsFixed ? getParentNode(element) : element;
4854 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
4855 const computedStyle = getComputedStyle2(currentNode);
4856 const currentNodeIsContaining = isContainingBlock(currentNode);
4857 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
4858 currentContainingBlockComputedStyle = null;
4859 }
4860 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
4861 if (shouldDropCurrentNode) {
4862 result = result.filter((ancestor) => ancestor !== currentNode);
4863 } else {
4864 currentContainingBlockComputedStyle = computedStyle;
4865 }
4866 currentNode = getParentNode(currentNode);
4867 }
4868 cache.set(element, result);
4869 return result;
4870 }
4871 function getClippingRect(_ref) {
4872 let {
4873 element,
4874 boundary,
4875 rootBoundary,
4876 strategy
4877 } = _ref;
4878 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
4879 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
4880 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
4881 let top = firstRect.top;
4882 let right = firstRect.right;
4883 let bottom = firstRect.bottom;
4884 let left = firstRect.left;
4885 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
4886 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
4887 top = max(rect.top, top);
4888 right = min(rect.right, right);
4889 bottom = min(rect.bottom, bottom);
4890 left = max(rect.left, left);
4891 }
4892 return {
4893 width: right - left,
4894 height: bottom - top,
4895 x: left,
4896 y: top
4897 };
4898 }
4899 function getDimensions(element) {
4900 const {
4901 width,
4902 height
4903 } = getCssDimensions(element);
4904 return {
4905 width,
4906 height
4907 };
4908 }
4909 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
4910 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4911 const documentElement = getDocumentElement(offsetParent);
4912 const isFixed = strategy === "fixed";
4913 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
4914 let scroll = {
4915 scrollLeft: 0,
4916 scrollTop: 0
4917 };
4918 const offsets = createCoords(0);
4919 function setLeftRTLScrollbarOffset() {
4920 offsets.x = getWindowScrollBarX(documentElement);
4921 }
4922 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4923 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4924 scroll = getNodeScroll(offsetParent);
4925 }
4926 if (isOffsetParentAnElement) {
4927 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
4928 offsets.x = offsetRect.x + offsetParent.clientLeft;
4929 offsets.y = offsetRect.y + offsetParent.clientTop;
4930 } else if (documentElement) {
4931 setLeftRTLScrollbarOffset();
4932 }
4933 }
4934 if (isFixed && !isOffsetParentAnElement && documentElement) {
4935 setLeftRTLScrollbarOffset();
4936 }
4937 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4938 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
4939 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
4940 return {
4941 x: x2,
4942 y: y2,
4943 width: rect.width,
4944 height: rect.height
4945 };
4946 }
4947 function isStaticPositioned(element) {
4948 return getComputedStyle2(element).position === "static";
4949 }
4950 function getTrueOffsetParent(element, polyfill) {
4951 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
4952 return null;
4953 }
4954 if (polyfill) {
4955 return polyfill(element);
4956 }
4957 let rawOffsetParent = element.offsetParent;
4958 if (getDocumentElement(element) === rawOffsetParent) {
4959 rawOffsetParent = rawOffsetParent.ownerDocument.body;
4960 }
4961 return rawOffsetParent;
4962 }
4963 function getOffsetParent(element, polyfill) {
4964 const win = getWindow(element);
4965 if (isTopLayer(element)) {
4966 return win;
4967 }
4968 if (!isHTMLElement(element)) {
4969 let svgOffsetParent = getParentNode(element);
4970 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
4971 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
4972 return svgOffsetParent;
4973 }
4974 svgOffsetParent = getParentNode(svgOffsetParent);
4975 }
4976 return win;
4977 }
4978 let offsetParent = getTrueOffsetParent(element, polyfill);
4979 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
4980 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
4981 }
4982 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
4983 return win;
4984 }
4985 return offsetParent || getContainingBlock(element) || win;
4986 }
4987 var getElementRects = async function(data) {
4988 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
4989 const getDimensionsFn = this.getDimensions;
4990 const floatingDimensions = await getDimensionsFn(data.floating);
4991 return {
4992 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
4993 floating: {
4994 x: 0,
4995 y: 0,
4996 width: floatingDimensions.width,
4997 height: floatingDimensions.height
4998 }
4999 };
5000 };
5001 function isRTL(element) {
5002 return getComputedStyle2(element).direction === "rtl";
5003 }
5004 var platform2 = {
5005 convertOffsetParentRelativeRectToViewportRelativeRect,
5006 getDocumentElement,
5007 getClippingRect,
5008 getOffsetParent,
5009 getElementRects,
5010 getClientRects,
5011 getDimensions,
5012 getScale,
5013 isElement,
5014 isRTL
5015 };
5016 function rectsAreEqual(a2, b2) {
5017 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
5018 }
5019 function observeMove(element, onMove) {
5020 let io = null;
5021 let timeoutId;
5022 const root = getDocumentElement(element);
5023 function cleanup() {
5024 var _io;
5025 clearTimeout(timeoutId);
5026 (_io = io) == null || _io.disconnect();
5027 io = null;
5028 }
5029 function refresh(skip, threshold) {
5030 if (skip === void 0) {
5031 skip = false;
5032 }
5033 if (threshold === void 0) {
5034 threshold = 1;
5035 }
5036 cleanup();
5037 const elementRectForRootMargin = element.getBoundingClientRect();
5038 const {
5039 left,
5040 top,
5041 width,
5042 height
5043 } = elementRectForRootMargin;
5044 if (!skip) {
5045 onMove();
5046 }
5047 if (!width || !height) {
5048 return;
5049 }
5050 const insetTop = floor(top);
5051 const insetRight = floor(root.clientWidth - (left + width));
5052 const insetBottom = floor(root.clientHeight - (top + height));
5053 const insetLeft = floor(left);
5054 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
5055 const options = {
5056 rootMargin,
5057 threshold: max(0, min(1, threshold)) || 1
5058 };
5059 let isFirstUpdate = true;
5060 function handleObserve(entries) {
5061 const ratio = entries[0].intersectionRatio;
5062 if (ratio !== threshold) {
5063 if (!isFirstUpdate) {
5064 return refresh();
5065 }
5066 if (!ratio) {
5067 timeoutId = setTimeout(() => {
5068 refresh(false, 1e-7);
5069 }, 1e3);
5070 } else {
5071 refresh(false, ratio);
5072 }
5073 }
5074 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
5075 refresh();
5076 }
5077 isFirstUpdate = false;
5078 }
5079 try {
5080 io = new IntersectionObserver(handleObserve, {
5081 ...options,
5082 // Handle <iframe>s
5083 root: root.ownerDocument
5084 });
5085 } catch (_e) {
5086 io = new IntersectionObserver(handleObserve, options);
5087 }
5088 io.observe(element);
5089 }
5090 refresh(true);
5091 return cleanup;
5092 }
5093 function autoUpdate(reference, floating, update2, options) {
5094 if (options === void 0) {
5095 options = {};
5096 }
5097 const {
5098 ancestorScroll = true,
5099 ancestorResize = true,
5100 elementResize = typeof ResizeObserver === "function",
5101 layoutShift = typeof IntersectionObserver === "function",
5102 animationFrame = false
5103 } = options;
5104 const referenceEl = unwrapElement(reference);
5105 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
5106 ancestors.forEach((ancestor) => {
5107 ancestorScroll && ancestor.addEventListener("scroll", update2, {
5108 passive: true
5109 });
5110 ancestorResize && ancestor.addEventListener("resize", update2);
5111 });
5112 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
5113 let reobserveFrame = -1;
5114 let resizeObserver = null;
5115 if (elementResize) {
5116 resizeObserver = new ResizeObserver((_ref) => {
5117 let [firstEntry] = _ref;
5118 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
5119 resizeObserver.unobserve(floating);
5120 cancelAnimationFrame(reobserveFrame);
5121 reobserveFrame = requestAnimationFrame(() => {
5122 var _resizeObserver;
5123 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
5124 });
5125 }
5126 update2();
5127 });
5128 if (referenceEl && !animationFrame) {
5129 resizeObserver.observe(referenceEl);
5130 }
5131 if (floating) {
5132 resizeObserver.observe(floating);
5133 }
5134 }
5135 let frameId;
5136 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
5137 if (animationFrame) {
5138 frameLoop();
5139 }
5140 function frameLoop() {
5141 const nextRefRect = getBoundingClientRect(reference);
5142 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
5143 update2();
5144 }
5145 prevRefRect = nextRefRect;
5146 frameId = requestAnimationFrame(frameLoop);
5147 }
5148 update2();
5149 return () => {
5150 var _resizeObserver2;
5151 ancestors.forEach((ancestor) => {
5152 ancestorScroll && ancestor.removeEventListener("scroll", update2);
5153 ancestorResize && ancestor.removeEventListener("resize", update2);
5154 });
5155 cleanupIo == null || cleanupIo();
5156 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
5157 resizeObserver = null;
5158 if (animationFrame) {
5159 cancelAnimationFrame(frameId);
5160 }
5161 };
5162 }
5163 var offset2 = offset;
5164 var shift2 = shift;
5165 var flip2 = flip;
5166 var size2 = size;
5167 var hide2 = hide;
5168 var limitShift2 = limitShift;
5169 var computePosition2 = (reference, floating, options) => {
5170 const cache = /* @__PURE__ */ new Map();
5171 const mergedOptions = {
5172 platform: platform2,
5173 ...options
5174 };
5175 const platformWithCache = {
5176 ...mergedOptions.platform,
5177 _c: cache
5178 };
5179 return computePosition(reference, floating, {
5180 ...mergedOptions,
5181 platform: platformWithCache
5182 });
5183 };
5184
5185 // node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
5186 var React20 = __toESM(require_react(), 1);
5187 var import_react2 = __toESM(require_react(), 1);
5188 var ReactDOM3 = __toESM(require_react_dom(), 1);
5189 var isClient = typeof document !== "undefined";
5190 var noop2 = function noop3() {
5191 };
5192 var index = isClient ? import_react2.useLayoutEffect : noop2;
5193 function deepEqual(a2, b2) {
5194 if (a2 === b2) {
5195 return true;
5196 }
5197 if (typeof a2 !== typeof b2) {
5198 return false;
5199 }
5200 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
5201 return true;
5202 }
5203 let length;
5204 let i2;
5205 let keys;
5206 if (a2 && b2 && typeof a2 === "object") {
5207 if (Array.isArray(a2)) {
5208 length = a2.length;
5209 if (length !== b2.length) return false;
5210 for (i2 = length; i2-- !== 0; ) {
5211 if (!deepEqual(a2[i2], b2[i2])) {
5212 return false;
5213 }
5214 }
5215 return true;
5216 }
5217 keys = Object.keys(a2);
5218 length = keys.length;
5219 if (length !== Object.keys(b2).length) {
5220 return false;
5221 }
5222 for (i2 = length; i2-- !== 0; ) {
5223 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
5224 return false;
5225 }
5226 }
5227 for (i2 = length; i2-- !== 0; ) {
5228 const key = keys[i2];
5229 if (key === "_owner" && a2.$$typeof) {
5230 continue;
5231 }
5232 if (!deepEqual(a2[key], b2[key])) {
5233 return false;
5234 }
5235 }
5236 return true;
5237 }
5238 return a2 !== a2 && b2 !== b2;
5239 }
5240 function getDPR(element) {
5241 if (typeof window === "undefined") {
5242 return 1;
5243 }
5244 const win = element.ownerDocument.defaultView || window;
5245 return win.devicePixelRatio || 1;
5246 }
5247 function roundByDPR(element, value) {
5248 const dpr = getDPR(element);
5249 return Math.round(value * dpr) / dpr;
5250 }
5251 function useLatestRef(value) {
5252 const ref = React20.useRef(value);
5253 index(() => {
5254 ref.current = value;
5255 });
5256 return ref;
5257 }
5258 function useFloating(options) {
5259 if (options === void 0) {
5260 options = {};
5261 }
5262 const {
5263 placement = "bottom",
5264 strategy = "absolute",
5265 middleware = [],
5266 platform: platform3,
5267 elements: {
5268 reference: externalReference,
5269 floating: externalFloating
5270 } = {},
5271 transform = true,
5272 whileElementsMounted,
5273 open
5274 } = options;
5275 const [data, setData] = React20.useState({
5276 x: 0,
5277 y: 0,
5278 strategy,
5279 placement,
5280 middlewareData: {},
5281 isPositioned: false
5282 });
5283 const [latestMiddleware, setLatestMiddleware] = React20.useState(middleware);
5284 if (!deepEqual(latestMiddleware, middleware)) {
5285 setLatestMiddleware(middleware);
5286 }
5287 const [_reference, _setReference] = React20.useState(null);
5288 const [_floating, _setFloating] = React20.useState(null);
5289 const setReference = React20.useCallback((node) => {
5290 if (node !== referenceRef.current) {
5291 referenceRef.current = node;
5292 _setReference(node);
5293 }
5294 }, []);
5295 const setFloating = React20.useCallback((node) => {
5296 if (node !== floatingRef.current) {
5297 floatingRef.current = node;
5298 _setFloating(node);
5299 }
5300 }, []);
5301 const referenceEl = externalReference || _reference;
5302 const floatingEl = externalFloating || _floating;
5303 const referenceRef = React20.useRef(null);
5304 const floatingRef = React20.useRef(null);
5305 const dataRef = React20.useRef(data);
5306 const hasWhileElementsMounted = whileElementsMounted != null;
5307 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5308 const platformRef = useLatestRef(platform3);
5309 const openRef = useLatestRef(open);
5310 const update2 = React20.useCallback(() => {
5311 if (!referenceRef.current || !floatingRef.current) {
5312 return;
5313 }
5314 const config = {
5315 placement,
5316 strategy,
5317 middleware: latestMiddleware
5318 };
5319 if (platformRef.current) {
5320 config.platform = platformRef.current;
5321 }
5322 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
5323 const fullData = {
5324 ...data2,
5325 // The floating element's position may be recomputed while it's closed
5326 // but still mounted (such as when transitioning out). To ensure
5327 // `isPositioned` will be `false` initially on the next open, avoid
5328 // setting it to `true` when `open === false` (must be specified).
5329 isPositioned: openRef.current !== false
5330 };
5331 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5332 dataRef.current = fullData;
5333 ReactDOM3.flushSync(() => {
5334 setData(fullData);
5335 });
5336 }
5337 });
5338 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
5339 index(() => {
5340 if (open === false && dataRef.current.isPositioned) {
5341 dataRef.current.isPositioned = false;
5342 setData((data2) => ({
5343 ...data2,
5344 isPositioned: false
5345 }));
5346 }
5347 }, [open]);
5348 const isMountedRef = React20.useRef(false);
5349 index(() => {
5350 isMountedRef.current = true;
5351 return () => {
5352 isMountedRef.current = false;
5353 };
5354 }, []);
5355 index(() => {
5356 if (referenceEl) referenceRef.current = referenceEl;
5357 if (floatingEl) floatingRef.current = floatingEl;
5358 if (referenceEl && floatingEl) {
5359 if (whileElementsMountedRef.current) {
5360 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
5361 }
5362 update2();
5363 }
5364 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
5365 const refs = React20.useMemo(() => ({
5366 reference: referenceRef,
5367 floating: floatingRef,
5368 setReference,
5369 setFloating
5370 }), [setReference, setFloating]);
5371 const elements = React20.useMemo(() => ({
5372 reference: referenceEl,
5373 floating: floatingEl
5374 }), [referenceEl, floatingEl]);
5375 const floatingStyles = React20.useMemo(() => {
5376 const initialStyles = {
5377 position: strategy,
5378 left: 0,
5379 top: 0
5380 };
5381 if (!elements.floating) {
5382 return initialStyles;
5383 }
5384 const x2 = roundByDPR(elements.floating, data.x);
5385 const y2 = roundByDPR(elements.floating, data.y);
5386 if (transform) {
5387 return {
5388 ...initialStyles,
5389 transform: "translate(" + x2 + "px, " + y2 + "px)",
5390 ...getDPR(elements.floating) >= 1.5 && {
5391 willChange: "transform"
5392 }
5393 };
5394 }
5395 return {
5396 position: strategy,
5397 left: x2,
5398 top: y2
5399 };
5400 }, [strategy, transform, elements.floating, data.x, data.y]);
5401 return React20.useMemo(() => ({
5402 ...data,
5403 update: update2,
5404 refs,
5405 elements,
5406 floatingStyles
5407 }), [data, update2, refs, elements, floatingStyles]);
5408 }
5409 var offset3 = (options, deps) => {
5410 const result = offset2(options);
5411 return {
5412 name: result.name,
5413 fn: result.fn,
5414 options: [options, deps]
5415 };
5416 };
5417 var shift3 = (options, deps) => {
5418 const result = shift2(options);
5419 return {
5420 name: result.name,
5421 fn: result.fn,
5422 options: [options, deps]
5423 };
5424 };
5425 var limitShift3 = (options, deps) => {
5426 const result = limitShift2(options);
5427 return {
5428 fn: result.fn,
5429 options: [options, deps]
5430 };
5431 };
5432 var flip3 = (options, deps) => {
5433 const result = flip2(options);
5434 return {
5435 name: result.name,
5436 fn: result.fn,
5437 options: [options, deps]
5438 };
5439 };
5440 var size3 = (options, deps) => {
5441 const result = size2(options);
5442 return {
5443 name: result.name,
5444 fn: result.fn,
5445 options: [options, deps]
5446 };
5447 };
5448 var hide3 = (options, deps) => {
5449 const result = hide2(options);
5450 return {
5451 name: result.name,
5452 fn: result.fn,
5453 options: [options, deps]
5454 };
5455 };
5456
5457 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs
5458 var React25 = __toESM(require_react(), 1);
5459 var ReactDOM4 = __toESM(require_react_dom(), 1);
5460
5461 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs
5462 var React24 = __toESM(require_react(), 1);
5463
5464 // node_modules/@base-ui/utils/store/createSelector.mjs
5465 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
5466 if (other.length > 0) {
5467 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
5468 }
5469 let selector2;
5470 if (a2 && b2 && c2 && d2 && e2 && f2) {
5471 selector2 = (state, a1, a22, a3) => {
5472 const va = a2(state, a1, a22, a3);
5473 const vb = b2(state, a1, a22, a3);
5474 const vc = c2(state, a1, a22, a3);
5475 const vd = d2(state, a1, a22, a3);
5476 const ve = e2(state, a1, a22, a3);
5477 return f2(va, vb, vc, vd, ve, a1, a22, a3);
5478 };
5479 } else if (a2 && b2 && c2 && d2 && e2) {
5480 selector2 = (state, a1, a22, a3) => {
5481 const va = a2(state, a1, a22, a3);
5482 const vb = b2(state, a1, a22, a3);
5483 const vc = c2(state, a1, a22, a3);
5484 const vd = d2(state, a1, a22, a3);
5485 return e2(va, vb, vc, vd, a1, a22, a3);
5486 };
5487 } else if (a2 && b2 && c2 && d2) {
5488 selector2 = (state, a1, a22, a3) => {
5489 const va = a2(state, a1, a22, a3);
5490 const vb = b2(state, a1, a22, a3);
5491 const vc = c2(state, a1, a22, a3);
5492 return d2(va, vb, vc, a1, a22, a3);
5493 };
5494 } else if (a2 && b2 && c2) {
5495 selector2 = (state, a1, a22, a3) => {
5496 const va = a2(state, a1, a22, a3);
5497 const vb = b2(state, a1, a22, a3);
5498 return c2(va, vb, a1, a22, a3);
5499 };
5500 } else if (a2 && b2) {
5501 selector2 = (state, a1, a22, a3) => {
5502 const va = a2(state, a1, a22, a3);
5503 return b2(va, a1, a22, a3);
5504 };
5505 } else if (a2) {
5506 selector2 = a2;
5507 } else {
5508 throw (
5509 /* minify-error-disabled */
5510 new Error("Missing arguments")
5511 );
5512 }
5513 return selector2;
5514 };
5515
5516 // node_modules/@base-ui/utils/store/useStore.mjs
5517 var React22 = __toESM(require_react(), 1);
5518 var import_shim = __toESM(require_shim(), 1);
5519 var import_with_selector = __toESM(require_with_selector(), 1);
5520
5521 // node_modules/@base-ui/utils/fastHooks.mjs
5522 var React21 = __toESM(require_react(), 1);
5523 var hooks = [];
5524 var currentInstance = void 0;
5525 function getInstance() {
5526 return currentInstance;
5527 }
5528 function register(hook) {
5529 hooks.push(hook);
5530 }
5531 function fastComponent(fn) {
5532 const FastComponent = (props, forwardedRef) => {
5533 const instance = useRefWithInit(createInstance).current;
5534 let result;
5535 try {
5536 currentInstance = instance;
5537 for (const hook of hooks) {
5538 hook.before(instance);
5539 }
5540 result = fn(props, forwardedRef);
5541 for (const hook of hooks) {
5542 hook.after(instance);
5543 }
5544 instance.didInitialize = true;
5545 } finally {
5546 currentInstance = void 0;
5547 }
5548 return result;
5549 };
5550 FastComponent.displayName = fn.displayName || fn.name;
5551 return FastComponent;
5552 }
5553 function fastComponentRef(fn) {
5554 return /* @__PURE__ */ React21.forwardRef(fastComponent(fn));
5555 }
5556 function createInstance() {
5557 return {
5558 didInitialize: false
5559 };
5560 }
5561
5562 // node_modules/@base-ui/utils/store/useStore.mjs
5563 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
5564 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
5565 function useStore(store, selector2, a1, a2, a3) {
5566 return useStoreImplementation(store, selector2, a1, a2, a3);
5567 }
5568 function useStoreR19(store, selector2, a1, a2, a3) {
5569 const getSelection = React22.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
5570 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
5571 }
5572 register({
5573 before(instance) {
5574 instance.syncIndex = 0;
5575 if (!instance.didInitialize) {
5576 instance.syncTick = 1;
5577 instance.syncHooks = [];
5578 instance.didChangeStore = true;
5579 instance.getSnapshot = () => {
5580 let didChange2 = false;
5581 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
5582 const hook = instance.syncHooks[i2];
5583 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
5584 if (!Object.is(hook.value, value)) {
5585 didChange2 = true;
5586 hook.value = value;
5587 }
5588 }
5589 if (didChange2) {
5590 instance.syncTick += 1;
5591 }
5592 return instance.syncTick;
5593 };
5594 }
5595 },
5596 after(instance) {
5597 if (instance.syncHooks.length > 0) {
5598 if (instance.didChangeStore) {
5599 instance.didChangeStore = false;
5600 instance.subscribe = (onStoreChange) => {
5601 const stores = /* @__PURE__ */ new Set();
5602 for (const hook of instance.syncHooks) {
5603 stores.add(hook.store);
5604 }
5605 const unsubscribes = [];
5606 for (const store of stores) {
5607 unsubscribes.push(store.subscribe(onStoreChange));
5608 }
5609 return () => {
5610 for (const unsubscribe of unsubscribes) {
5611 unsubscribe();
5612 }
5613 };
5614 };
5615 }
5616 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
5617 }
5618 }
5619 });
5620 function useStoreFast(store, selector2, a1, a2, a3) {
5621 const instance = getInstance();
5622 if (!instance) {
5623 return useStoreR19(store, selector2, a1, a2, a3);
5624 }
5625 const index2 = instance.syncIndex;
5626 instance.syncIndex += 1;
5627 let hook;
5628 if (!instance.didInitialize) {
5629 hook = {
5630 store,
5631 selector: selector2,
5632 a1,
5633 a2,
5634 a3,
5635 value: selector2(store.getSnapshot(), a1, a2, a3)
5636 };
5637 instance.syncHooks.push(hook);
5638 } else {
5639 hook = instance.syncHooks[index2];
5640 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
5641 if (hook.store !== store) {
5642 instance.didChangeStore = true;
5643 }
5644 hook.store = store;
5645 hook.selector = selector2;
5646 hook.a1 = a1;
5647 hook.a2 = a2;
5648 hook.a3 = a3;
5649 hook.value = selector2(store.getSnapshot(), a1, a2, a3);
5650 }
5651 }
5652 return hook.value;
5653 }
5654 function useStoreLegacy(store, selector2, a1, a2, a3) {
5655 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
5656 }
5657
5658 // node_modules/@base-ui/utils/store/Store.mjs
5659 var Store = class {
5660 /**
5661 * The current state of the store.
5662 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
5663 * 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).
5664 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
5665 *
5666 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
5667 */
5668 // Internal state to handle recursive `setState()` calls
5669 constructor(state) {
5670 this.state = state;
5671 this.listeners = /* @__PURE__ */ new Set();
5672 this.updateTick = 0;
5673 }
5674 /**
5675 * Registers a listener that will be called whenever the store's state changes.
5676 *
5677 * @param fn The listener function to be called on state changes.
5678 * @returns A function to unsubscribe the listener.
5679 */
5680 subscribe = (fn) => {
5681 this.listeners.add(fn);
5682 return () => {
5683 this.listeners.delete(fn);
5684 };
5685 };
5686 /**
5687 * Returns the current state of the store.
5688 */
5689 getSnapshot = () => {
5690 return this.state;
5691 };
5692 /**
5693 * Updates the entire store's state and notifies all registered listeners.
5694 *
5695 * @param newState The new state to set for the store.
5696 */
5697 setState(newState) {
5698 if (this.state === newState) {
5699 return;
5700 }
5701 this.state = newState;
5702 this.updateTick += 1;
5703 const currentTick = this.updateTick;
5704 for (const listener of this.listeners) {
5705 if (currentTick !== this.updateTick) {
5706 return;
5707 }
5708 listener(newState);
5709 }
5710 }
5711 /**
5712 * Merges the provided changes into the current state and notifies listeners if there are changes.
5713 *
5714 * @param changes An object containing the changes to apply to the current state.
5715 */
5716 update(changes) {
5717 for (const key in changes) {
5718 if (!Object.is(this.state[key], changes[key])) {
5719 this.setState({
5720 ...this.state,
5721 ...changes
5722 });
5723 return;
5724 }
5725 }
5726 }
5727 /**
5728 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
5729 *
5730 * @param key The key in the store's state to update.
5731 * @param value The new value to set for the specified key.
5732 */
5733 set(key, value) {
5734 if (!Object.is(this.state[key], value)) {
5735 this.setState({
5736 ...this.state,
5737 [key]: value
5738 });
5739 }
5740 }
5741 /**
5742 * Gives the state a new reference and updates all registered listeners.
5743 */
5744 notifyAll() {
5745 const newState = {
5746 ...this.state
5747 };
5748 this.setState(newState);
5749 }
5750 use(selector2, a1, a2, a3) {
5751 return useStore(this, selector2, a1, a2, a3);
5752 }
5753 };
5754
5755 // node_modules/@base-ui/utils/store/ReactStore.mjs
5756 var React23 = __toESM(require_react(), 1);
5757 var ReactStore = class extends Store {
5758 /**
5759 * Creates a new ReactStore instance.
5760 *
5761 * @param state Initial state of the store.
5762 * @param context Non-reactive context values.
5763 * @param selectors Optional selectors for use with `useState`.
5764 */
5765 constructor(state, context = {}, selectors3) {
5766 super(state);
5767 this.context = context;
5768 this.selectors = selectors3;
5769 }
5770 /**
5771 * Non-reactive values such as refs, callbacks, etc.
5772 */
5773 /**
5774 * Synchronizes a single external value into the store.
5775 *
5776 * Note that the while the value in `state` is updated immediately, the value returned
5777 * by `useState` is updated before the next render (similarly to React's `useState`).
5778 */
5779 useSyncedValue(key, value) {
5780 React23.useDebugValue(key);
5781 const store = this;
5782 useIsoLayoutEffect(() => {
5783 if (store.state[key] !== value) {
5784 store.set(key, value);
5785 }
5786 }, [store, key, value]);
5787 }
5788 /**
5789 * Synchronizes a single external value into the store and
5790 * cleans it up (sets to `undefined`) on unmount.
5791 *
5792 * Note that the while the value in `state` is updated immediately, the value returned
5793 * by `useState` is updated before the next render (similarly to React's `useState`).
5794 */
5795 useSyncedValueWithCleanup(key, value) {
5796 const store = this;
5797 useIsoLayoutEffect(() => {
5798 if (store.state[key] !== value) {
5799 store.set(key, value);
5800 }
5801 return () => {
5802 store.set(key, void 0);
5803 };
5804 }, [store, key, value]);
5805 }
5806 /**
5807 * Synchronizes multiple external values into the store.
5808 *
5809 * Note that the while the values in `state` are updated immediately, the values returned
5810 * by `useState` are updated before the next render (similarly to React's `useState`).
5811 */
5812 useSyncedValues(statePart) {
5813 const store = this;
5814 if (true) {
5815 React23.useDebugValue(statePart, (p2) => Object.keys(p2));
5816 const keys = React23.useRef(Object.keys(statePart)).current;
5817 const nextKeys = Object.keys(statePart);
5818 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
5819 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
5820 }
5821 }
5822 const dependencies = Object.values(statePart);
5823 useIsoLayoutEffect(() => {
5824 store.update(statePart);
5825 }, [store, ...dependencies]);
5826 }
5827 /**
5828 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
5829 * is non-undefined, the store's state at `key` is updated to match `controlled`.
5830 */
5831 useControlledProp(key, controlled) {
5832 React23.useDebugValue(key);
5833 const store = this;
5834 const isControlled = controlled !== void 0;
5835 useIsoLayoutEffect(() => {
5836 if (isControlled && !Object.is(store.state[key], controlled)) {
5837 store.setState({
5838 ...store.state,
5839 [key]: controlled
5840 });
5841 }
5842 }, [store, key, controlled, isControlled]);
5843 if (true) {
5844 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
5845 if (!cache.has(key)) {
5846 cache.set(key, isControlled);
5847 }
5848 const previouslyControlled = cache.get(key);
5849 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
5850 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).`);
5851 }
5852 }
5853 }
5854 /** Gets the current value from the store using a selector with the provided key.
5855 *
5856 * @param key Key of the selector to use.
5857 */
5858 select(key, a1, a2, a3) {
5859 const selector2 = this.selectors[key];
5860 return selector2(this.state, a1, a2, a3);
5861 }
5862 /**
5863 * Returns a value from the store's state using a selector function.
5864 * Used to subscribe to specific parts of the state.
5865 * This methods causes a rerender whenever the selected state changes.
5866 *
5867 * @param key Key of the selector to use.
5868 */
5869 useState(key, a1, a2, a3) {
5870 React23.useDebugValue(key);
5871 return useStore(this, this.selectors[key], a1, a2, a3);
5872 }
5873 /**
5874 * Wraps a function with `useStableCallback` to ensure it has a stable reference
5875 * and assigns it to the context.
5876 *
5877 * @param key Key of the event callback. Must be a function in the context.
5878 * @param fn Function to assign.
5879 */
5880 useContextCallback(key, fn) {
5881 React23.useDebugValue(key);
5882 const stableFunction = useStableCallback(fn ?? NOOP);
5883 this.context[key] = stableFunction;
5884 }
5885 /**
5886 * Returns a stable setter function for a specific key in the store's state.
5887 * It's commonly used to pass as a ref callback to React elements.
5888 *
5889 * @param key Key of the state to set.
5890 */
5891 useStateSetter(key) {
5892 const ref = React23.useRef(void 0);
5893 if (ref.current === void 0) {
5894 ref.current = (value) => {
5895 this.set(key, value);
5896 };
5897 }
5898 return ref.current;
5899 }
5900 /**
5901 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
5902 *
5903 * @param key Key of the selector to observe.
5904 * @param listener Listener function called when the selector result changes.
5905 */
5906 observe(selector2, listener) {
5907 let selectFn;
5908 if (typeof selector2 === "function") {
5909 selectFn = selector2;
5910 } else {
5911 selectFn = this.selectors[selector2];
5912 }
5913 let prevValue = selectFn(this.state);
5914 listener(prevValue, prevValue, this);
5915 return this.subscribe((nextState) => {
5916 const nextValue = selectFn(nextState);
5917 if (!Object.is(prevValue, nextValue)) {
5918 const oldValue = prevValue;
5919 prevValue = nextValue;
5920 listener(nextValue, oldValue, this);
5921 }
5922 });
5923 }
5924 };
5925
5926 // node_modules/@base-ui/react/floating-ui-react/components/FloatingRootStore.mjs
5927 var selectors = {
5928 open: createSelector((state) => state.open),
5929 transitionStatus: createSelector((state) => state.transitionStatus),
5930 domReferenceElement: createSelector((state) => state.domReferenceElement),
5931 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
5932 floatingElement: createSelector((state) => state.floatingElement),
5933 floatingId: createSelector((state) => state.floatingId)
5934 };
5935 var FloatingRootStore = class extends ReactStore {
5936 constructor(options) {
5937 const {
5938 syncOnly,
5939 nested,
5940 onOpenChange,
5941 triggerElements,
5942 ...initialState
5943 } = options;
5944 super({
5945 ...initialState,
5946 positionReference: initialState.referenceElement,
5947 domReferenceElement: initialState.referenceElement
5948 }, {
5949 onOpenChange,
5950 dataRef: {
5951 current: {}
5952 },
5953 events: createEventEmitter(),
5954 nested,
5955 triggerElements
5956 }, selectors);
5957 this.syncOnly = syncOnly;
5958 }
5959 /**
5960 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
5961 */
5962 syncOpenEvent = (newOpen, event) => {
5963 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
5964 // click events to upgrade a hover-open.
5965 event != null && isClickLikeEvent(event)) {
5966 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
5967 }
5968 };
5969 /**
5970 * Runs the root-owned side effects for an open state change.
5971 */
5972 dispatchOpenChange = (newOpen, eventDetails) => {
5973 this.syncOpenEvent(newOpen, eventDetails.event);
5974 const details = {
5975 open: newOpen,
5976 reason: eventDetails.reason,
5977 nativeEvent: eventDetails.event,
5978 nested: this.context.nested,
5979 triggerElement: eventDetails.trigger
5980 };
5981 this.context.events.emit("openchange", details);
5982 };
5983 /**
5984 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
5985 *
5986 * @param newOpen The new open state.
5987 * @param eventDetails Details about the event that triggered the open state change.
5988 */
5989 setOpen = (newOpen, eventDetails) => {
5990 if (this.syncOnly) {
5991 this.context.onOpenChange?.(newOpen, eventDetails);
5992 return;
5993 }
5994 this.dispatchOpenChange(newOpen, eventDetails);
5995 this.context.onOpenChange?.(newOpen, eventDetails);
5996 };
5997 };
5998
5999 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs
6000 function useSyncedFloatingRootContext(options) {
6001 const {
6002 popupStore,
6003 treatPopupAsFloatingElement = false,
6004 floatingRootContext: floatingRootContextProp,
6005 floatingId,
6006 nested,
6007 onOpenChange
6008 } = options;
6009 const open = popupStore.useState("open");
6010 const referenceElement = popupStore.useState("activeTriggerElement");
6011 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
6012 const triggerElements = popupStore.context.triggerElements;
6013 const handleOpenChange = onOpenChange;
6014 const internalStoreRef = React24.useRef(null);
6015 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
6016 internalStoreRef.current = new FloatingRootStore({
6017 open,
6018 transitionStatus: void 0,
6019 referenceElement,
6020 floatingElement,
6021 triggerElements,
6022 onOpenChange: handleOpenChange,
6023 floatingId,
6024 syncOnly: true,
6025 nested
6026 });
6027 }
6028 const store = floatingRootContextProp ?? internalStoreRef.current;
6029 popupStore.useSyncedValue("floatingId", floatingId);
6030 useIsoLayoutEffect(() => {
6031 const valuesToSync = {
6032 open,
6033 floatingId,
6034 referenceElement,
6035 floatingElement
6036 };
6037 if (isElement(referenceElement)) {
6038 valuesToSync.domReferenceElement = referenceElement;
6039 }
6040 if (store.state.positionReference === store.state.referenceElement) {
6041 valuesToSync.positionReference = referenceElement;
6042 }
6043 store.update(valuesToSync);
6044 }, [open, floatingId, referenceElement, floatingElement, store]);
6045 store.context.onOpenChange = handleOpenChange;
6046 store.context.nested = nested;
6047 return store;
6048 }
6049
6050 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs
6051 var FOCUSABLE_POPUP_PROPS = {
6052 tabIndex: -1,
6053 [FOCUSABLE_ATTRIBUTE]: ""
6054 };
6055 function usePopupStore(externalStore, createStore2, treatPopupAsFloatingElement = false) {
6056 const floatingId = useId();
6057 const nested = useFloatingParentNodeId() != null;
6058 const internalStoreRef = React25.useRef(null);
6059 if (externalStore === void 0 && internalStoreRef.current === null) {
6060 internalStoreRef.current = createStore2(floatingId, nested);
6061 }
6062 const store = externalStore ?? internalStoreRef.current;
6063 useSyncedFloatingRootContext({
6064 popupStore: store,
6065 treatPopupAsFloatingElement,
6066 floatingRootContext: store.state.floatingRootContext,
6067 floatingId,
6068 nested,
6069 onOpenChange: store.setOpen
6070 });
6071 return {
6072 store,
6073 internalStore: internalStoreRef.current
6074 };
6075 }
6076 function useTriggerRegistration(id, store) {
6077 const registeredElementIdRef = React25.useRef(null);
6078 const registeredElementRef = React25.useRef(null);
6079 return React25.useCallback((element) => {
6080 if (id === void 0) {
6081 return;
6082 }
6083 let shouldSyncTriggerCount = false;
6084 if (registeredElementIdRef.current !== null) {
6085 const registeredId = registeredElementIdRef.current;
6086 const registeredElement = registeredElementRef.current;
6087 const currentElement = store.context.triggerElements.getById(registeredId);
6088 if (registeredElement && currentElement === registeredElement) {
6089 store.context.triggerElements.delete(registeredId);
6090 shouldSyncTriggerCount = true;
6091 }
6092 registeredElementIdRef.current = null;
6093 registeredElementRef.current = null;
6094 }
6095 if (element !== null) {
6096 registeredElementIdRef.current = id;
6097 registeredElementRef.current = element;
6098 store.context.triggerElements.add(id, element);
6099 shouldSyncTriggerCount = true;
6100 }
6101 if (shouldSyncTriggerCount) {
6102 const triggerCount = store.context.triggerElements.size;
6103 if (store.select("open") && store.state.triggerCount !== triggerCount) {
6104 store.set("triggerCount", triggerCount);
6105 }
6106 }
6107 }, [store, id]);
6108 }
6109 function setPopupOpenState(state, open, trigger, preventUnmountOnClose = false) {
6110 if (open) {
6111 state.preventUnmountingOnClose = false;
6112 } else if (preventUnmountOnClose) {
6113 state.preventUnmountingOnClose = true;
6114 }
6115 const triggerId = trigger?.id ?? null;
6116 if (triggerId || open) {
6117 state.activeTriggerId = triggerId;
6118 state.activeTriggerElement = trigger ?? null;
6119 }
6120 }
6121 function attachPreventUnmountOnClose(eventDetails) {
6122 let preventUnmountOnClose = false;
6123 eventDetails.preventUnmountOnClose = () => {
6124 preventUnmountOnClose = true;
6125 };
6126 return () => preventUnmountOnClose;
6127 }
6128 function applyPopupOpenChange(store, nextOpen, eventDetails, options = {}) {
6129 const reason = eventDetails.reason;
6130 const isHover = reason === reason_parts_exports.triggerHover;
6131 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
6132 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
6133 const shouldPreventUnmountOnClose = attachPreventUnmountOnClose(eventDetails);
6134 store.context.onOpenChange?.(nextOpen, eventDetails);
6135 if (eventDetails.isCanceled) {
6136 return;
6137 }
6138 options.onBeforeDispatch?.();
6139 store.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
6140 const changeState = () => {
6141 const updatedState = {
6142 ...options.extraState,
6143 open: nextOpen
6144 };
6145 if (isFocusOpen) {
6146 updatedState.instantType = "focus";
6147 } else if (isDismissClose) {
6148 updatedState.instantType = "dismiss";
6149 } else if (isHover) {
6150 updatedState.instantType = void 0;
6151 }
6152 setPopupOpenState(updatedState, nextOpen, eventDetails.trigger, shouldPreventUnmountOnClose());
6153 store.update(updatedState);
6154 };
6155 if (isHover) {
6156 ReactDOM4.flushSync(changeState);
6157 } else {
6158 changeState();
6159 }
6160 }
6161 function useInitialOpenSync(store, openProp, defaultOpen, defaultTriggerId) {
6162 useOnFirstRender(() => {
6163 if (openProp === void 0 && store.state.open === false && defaultOpen) {
6164 store.state = {
6165 ...store.state,
6166 open: true,
6167 activeTriggerId: defaultTriggerId,
6168 preventUnmountingOnClose: false
6169 };
6170 }
6171 });
6172 }
6173 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
6174 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
6175 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
6176 const registerTrigger = useStableCallback((element) => {
6177 baseRegisterTrigger(element);
6178 if (!element) {
6179 return;
6180 }
6181 const open = store.select("open");
6182 const activeTriggerId = store.select("activeTriggerId");
6183 if (activeTriggerId === triggerId) {
6184 store.update({
6185 activeTriggerElement: element,
6186 ...open ? stateUpdates : null
6187 });
6188 return;
6189 }
6190 if (activeTriggerId == null && open) {
6191 store.update({
6192 activeTriggerId: triggerId,
6193 activeTriggerElement: element,
6194 ...stateUpdates
6195 });
6196 }
6197 });
6198 useIsoLayoutEffect(() => {
6199 if (isMountedByThisTrigger) {
6200 store.update({
6201 activeTriggerElement: triggerElementRef.current,
6202 ...stateUpdates
6203 });
6204 }
6205 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
6206 return {
6207 registerTrigger,
6208 isMountedByThisTrigger
6209 };
6210 }
6211 function useImplicitActiveTrigger(store, options = {}) {
6212 const {
6213 closeOnActiveTriggerUnmount = false
6214 } = options;
6215 const open = store.useState("open");
6216 const reactiveTriggerCount = store.useState("triggerCount");
6217 useIsoLayoutEffect(() => {
6218 if (!open) {
6219 if (store.state.triggerCount !== 0) {
6220 store.set("triggerCount", 0);
6221 }
6222 return;
6223 }
6224 const triggerCount = store.context.triggerElements.size;
6225 const stateUpdates = {};
6226 if (store.state.triggerCount !== triggerCount) {
6227 stateUpdates.triggerCount = triggerCount;
6228 }
6229 const activeTriggerId = store.select("activeTriggerId");
6230 let lostActiveTriggerId = null;
6231 if (activeTriggerId) {
6232 const activeTriggerElement = store.context.triggerElements.getById(activeTriggerId);
6233 if (!activeTriggerElement) {
6234 lostActiveTriggerId = activeTriggerId;
6235 } else if (activeTriggerElement !== store.state.activeTriggerElement) {
6236 stateUpdates.activeTriggerElement = activeTriggerElement;
6237 }
6238 }
6239 if (!lostActiveTriggerId && !activeTriggerId && triggerCount === 1) {
6240 const iteratorResult = store.context.triggerElements.entries().next();
6241 if (!iteratorResult.done) {
6242 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
6243 stateUpdates.activeTriggerId = implicitTriggerId;
6244 stateUpdates.activeTriggerElement = implicitTriggerElement;
6245 }
6246 }
6247 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0 || stateUpdates.activeTriggerElement !== void 0) {
6248 store.update(stateUpdates);
6249 }
6250 if (lostActiveTriggerId) {
6251 if (closeOnActiveTriggerUnmount) {
6252 queueMicrotask(() => {
6253 if (store.select("open") && store.select("activeTriggerId") === lostActiveTriggerId && !store.context.triggerElements.getById(lostActiveTriggerId)) {
6254 const eventDetails = createChangeEventDetails(reason_parts_exports.none);
6255 store.setOpen(false, eventDetails);
6256 if (!eventDetails.isCanceled) {
6257 store.update({
6258 activeTriggerId: null,
6259 activeTriggerElement: null
6260 });
6261 }
6262 }
6263 });
6264 }
6265 }
6266 }, [open, store, reactiveTriggerCount, closeOnActiveTriggerUnmount]);
6267 }
6268 function useOpenStateTransitions(open, store, onUnmount) {
6269 const {
6270 mounted,
6271 setMounted,
6272 transitionStatus
6273 } = useTransitionStatus(open);
6274 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
6275 const syncedPreventUnmountingOnClose = open ? false : preventUnmountingOnClose;
6276 store.useSyncedValues({
6277 mounted,
6278 transitionStatus,
6279 preventUnmountingOnClose: syncedPreventUnmountingOnClose
6280 });
6281 const forceUnmount = useStableCallback(() => {
6282 setMounted(false);
6283 store.update({
6284 activeTriggerId: null,
6285 activeTriggerElement: null,
6286 mounted: false,
6287 preventUnmountingOnClose: false
6288 });
6289 onUnmount?.();
6290 store.context.onOpenChangeComplete?.(false);
6291 });
6292 useOpenChangeComplete({
6293 enabled: mounted && !open && !syncedPreventUnmountingOnClose,
6294 open,
6295 ref: store.context.popupRef,
6296 onComplete() {
6297 if (!open) {
6298 forceUnmount();
6299 }
6300 }
6301 });
6302 return {
6303 forceUnmount,
6304 transitionStatus
6305 };
6306 }
6307 function usePopupInteractionProps(store, statePart) {
6308 store.useSyncedValues(statePart);
6309 useIsoLayoutEffect(() => () => {
6310 store.update({
6311 activeTriggerProps: EMPTY_OBJECT,
6312 inactiveTriggerProps: EMPTY_OBJECT,
6313 popupProps: EMPTY_OBJECT
6314 });
6315 }, [store]);
6316 }
6317
6318 // node_modules/@base-ui/react/utils/popups/popupTriggerMap.mjs
6319 var PopupTriggerMap = class {
6320 constructor() {
6321 this.elementsSet = /* @__PURE__ */ new Set();
6322 this.idMap = /* @__PURE__ */ new Map();
6323 }
6324 /**
6325 * Adds a trigger element with the given ID.
6326 *
6327 * Note: The provided element is assumed to not be registered under multiple IDs.
6328 */
6329 add(id, element) {
6330 const existingElement = this.idMap.get(id);
6331 if (existingElement === element) {
6332 return;
6333 }
6334 if (existingElement !== void 0) {
6335 this.elementsSet.delete(existingElement);
6336 }
6337 this.elementsSet.add(element);
6338 this.idMap.set(id, element);
6339 if (true) {
6340 if (this.elementsSet.size !== this.idMap.size) {
6341 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
6342 }
6343 }
6344 }
6345 /**
6346 * Removes the trigger element with the given ID.
6347 */
6348 delete(id) {
6349 const element = this.idMap.get(id);
6350 if (element) {
6351 this.elementsSet.delete(element);
6352 this.idMap.delete(id);
6353 }
6354 }
6355 /**
6356 * Whether the given element is registered as a trigger.
6357 */
6358 hasElement(element) {
6359 return this.elementsSet.has(element);
6360 }
6361 /**
6362 * Whether there is a registered trigger element matching the given predicate.
6363 */
6364 hasMatchingElement(predicate) {
6365 for (const element of this.elementsSet) {
6366 if (predicate(element)) {
6367 return true;
6368 }
6369 }
6370 return false;
6371 }
6372 /**
6373 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
6374 */
6375 getById(id) {
6376 return this.idMap.get(id);
6377 }
6378 /**
6379 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
6380 */
6381 entries() {
6382 return this.idMap.entries();
6383 }
6384 /**
6385 * Returns an iterable of all registered trigger elements.
6386 */
6387 elements() {
6388 return this.elementsSet.values();
6389 }
6390 /**
6391 * Returns the number of registered trigger elements.
6392 */
6393 get size() {
6394 return this.idMap.size;
6395 }
6396 };
6397
6398 // node_modules/@base-ui/react/floating-ui-react/utils/getEmptyRootContext.mjs
6399 function getEmptyRootContext() {
6400 return new FloatingRootStore({
6401 open: false,
6402 transitionStatus: void 0,
6403 floatingElement: null,
6404 referenceElement: null,
6405 triggerElements: new PopupTriggerMap(),
6406 floatingId: void 0,
6407 syncOnly: false,
6408 nested: false,
6409 onOpenChange: void 0
6410 });
6411 }
6412
6413 // node_modules/@base-ui/react/utils/popups/store.mjs
6414 function createInitialPopupStoreState() {
6415 return {
6416 open: false,
6417 openProp: void 0,
6418 mounted: false,
6419 transitionStatus: void 0,
6420 floatingRootContext: getEmptyRootContext(),
6421 floatingId: void 0,
6422 triggerCount: 0,
6423 preventUnmountingOnClose: false,
6424 payload: void 0,
6425 activeTriggerId: null,
6426 activeTriggerElement: null,
6427 triggerIdProp: void 0,
6428 popupElement: null,
6429 positionerElement: null,
6430 activeTriggerProps: EMPTY_OBJECT,
6431 inactiveTriggerProps: EMPTY_OBJECT,
6432 popupProps: EMPTY_OBJECT
6433 };
6434 }
6435 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) {
6436 return new FloatingRootStore({
6437 open: false,
6438 transitionStatus: void 0,
6439 floatingElement: null,
6440 referenceElement: null,
6441 triggerElements,
6442 floatingId,
6443 syncOnly: true,
6444 nested,
6445 onOpenChange: void 0
6446 });
6447 }
6448 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
6449 var openSelector = createSelector((state) => state.openProp ?? state.open);
6450 var popupIdSelector = createSelector((state) => {
6451 const popupId = state.popupElement?.id ?? state.floatingId;
6452 return popupId || void 0;
6453 });
6454 function triggerOwnsOpenPopup(state, triggerId) {
6455 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
6456 }
6457 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
6458 if (triggerOwnsOpenPopup(state, triggerId)) {
6459 return true;
6460 }
6461 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
6462 }
6463 var popupStoreSelectors = {
6464 open: openSelector,
6465 mounted: createSelector((state) => state.mounted),
6466 transitionStatus: createSelector((state) => state.transitionStatus),
6467 floatingRootContext: createSelector((state) => state.floatingRootContext),
6468 triggerCount: createSelector((state) => state.triggerCount),
6469 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
6470 payload: createSelector((state) => state.payload),
6471 activeTriggerId: activeTriggerIdSelector,
6472 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
6473 popupId: popupIdSelector,
6474 /**
6475 * Whether the trigger with the given ID was used to open the popup.
6476 */
6477 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
6478 /**
6479 * Whether the popup is open and was activated by a trigger with the given ID.
6480 */
6481 isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)),
6482 /**
6483 * Whether the popup is mounted and was activated by a trigger with the given ID.
6484 */
6485 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
6486 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
6487 /**
6488 * Popup id for the trigger that currently owns the open popup.
6489 */
6490 triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0),
6491 popupProps: createSelector((state) => state.popupProps),
6492 popupElement: createSelector((state) => state.popupElement),
6493 positionerElement: createSelector((state) => state.positionerElement)
6494 };
6495
6496 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloatingRootContext.mjs
6497 function useFloatingRootContext(options) {
6498 const {
6499 open = false,
6500 onOpenChange,
6501 elements = {}
6502 } = options;
6503 const floatingId = useId();
6504 const nested = useFloatingParentNodeId() != null;
6505 if (true) {
6506 const optionDomReference = elements.reference;
6507 if (optionDomReference && !isElement(optionDomReference)) {
6508 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
6509 }
6510 }
6511 const store = useRefWithInit(() => new FloatingRootStore({
6512 open,
6513 transitionStatus: void 0,
6514 onOpenChange,
6515 referenceElement: elements.reference ?? null,
6516 floatingElement: elements.floating ?? null,
6517 triggerElements: new PopupTriggerMap(),
6518 floatingId,
6519 syncOnly: false,
6520 nested
6521 })).current;
6522 useIsoLayoutEffect(() => {
6523 const valuesToSync = {
6524 open,
6525 floatingId
6526 };
6527 if (elements.reference !== void 0) {
6528 valuesToSync.referenceElement = elements.reference;
6529 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
6530 }
6531 if (elements.floating !== void 0) {
6532 valuesToSync.floatingElement = elements.floating;
6533 }
6534 store.update(valuesToSync);
6535 }, [open, floatingId, elements.reference, elements.floating, store]);
6536 store.context.onOpenChange = onOpenChange;
6537 store.context.nested = nested;
6538 return store;
6539 }
6540
6541 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs
6542 function useFloating2(options = {}) {
6543 const {
6544 nodeId,
6545 externalTree
6546 } = options;
6547 const internalStore = useFloatingRootContext(options);
6548 const store = options.rootContext || internalStore;
6549 const referenceElement = store.useState("referenceElement");
6550 const floatingElement = store.useState("floatingElement");
6551 const domReferenceElement = store.useState("domReferenceElement");
6552 const open = store.useState("open");
6553 const floatingId = store.useState("floatingId");
6554 const [positionReference, setPositionReferenceRaw] = React26.useState(null);
6555 const [localDomReference, setLocalDomReference] = React26.useState(void 0);
6556 const [localFloatingElement, setLocalFloatingElement] = React26.useState(void 0);
6557 const domReferenceRef = React26.useRef(null);
6558 const tree = useFloatingTree(externalTree);
6559 const storeElements = React26.useMemo(() => ({
6560 reference: referenceElement,
6561 floating: floatingElement,
6562 domReference: domReferenceElement
6563 }), [referenceElement, floatingElement, domReferenceElement]);
6564 const position = useFloating({
6565 ...options,
6566 elements: {
6567 ...storeElements,
6568 ...positionReference && {
6569 reference: positionReference
6570 }
6571 }
6572 });
6573 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
6574 const syncedFloatingElement = localFloatingElement === void 0 ? store.state.floatingElement : localFloatingElement;
6575 store.useSyncedValue("referenceElement", localDomReference ?? null);
6576 store.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement);
6577 store.useSyncedValue("floatingElement", syncedFloatingElement);
6578 const setPositionReference = React26.useCallback((node) => {
6579 const computedPositionReference = isElement(node) ? {
6580 getBoundingClientRect: () => node.getBoundingClientRect(),
6581 getClientRects: () => node.getClientRects(),
6582 contextElement: node
6583 } : node;
6584 setPositionReferenceRaw(computedPositionReference);
6585 position.refs.setReference(computedPositionReference);
6586 }, [position.refs]);
6587 const setReference = React26.useCallback((node) => {
6588 if (isElement(node) || node === null) {
6589 domReferenceRef.current = node;
6590 setLocalDomReference(node);
6591 }
6592 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
6593 // `null` to support `positionReference` + an unstable `reference`
6594 // callback ref.
6595 node !== null && !isElement(node)) {
6596 position.refs.setReference(node);
6597 }
6598 }, [position.refs, setLocalDomReference]);
6599 const setFloating = React26.useCallback((node) => {
6600 setLocalFloatingElement(node);
6601 position.refs.setFloating(node);
6602 }, [position.refs]);
6603 const refs = React26.useMemo(() => ({
6604 ...position.refs,
6605 setReference,
6606 setFloating,
6607 setPositionReference,
6608 domReference: domReferenceRef
6609 }), [position.refs, setReference, setFloating, setPositionReference]);
6610 const elements = React26.useMemo(() => ({
6611 ...position.elements,
6612 domReference: domReferenceElement
6613 }), [position.elements, domReferenceElement]);
6614 const context = React26.useMemo(() => ({
6615 ...position,
6616 dataRef: store.context.dataRef,
6617 open,
6618 onOpenChange: store.setOpen,
6619 events: store.context.events,
6620 floatingId,
6621 refs,
6622 elements,
6623 nodeId,
6624 rootStore: store
6625 }), [position, refs, elements, nodeId, store, open, floatingId]);
6626 useIsoLayoutEffect(() => {
6627 if (domReferenceElement) {
6628 domReferenceRef.current = domReferenceElement;
6629 }
6630 }, [domReferenceElement]);
6631 useIsoLayoutEffect(() => {
6632 store.context.dataRef.current.floatingContext = context;
6633 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
6634 if (node) {
6635 node.context = context;
6636 }
6637 });
6638 return React26.useMemo(() => ({
6639 ...position,
6640 context,
6641 refs,
6642 elements,
6643 rootStore: store
6644 }), [position, refs, elements, context, store]);
6645 }
6646
6647 // node_modules/@base-ui/react/floating-ui-react/hooks/useFocus.mjs
6648 var React27 = __toESM(require_react(), 1);
6649 var isMacSafari = parts_exports.os.mac && parts_exports.engine.webkit;
6650 function useFocus(context, props = {}) {
6651 const {
6652 enabled = true,
6653 delay
6654 } = props;
6655 const store = "rootStore" in context ? context.rootStore : context;
6656 const {
6657 events,
6658 dataRef
6659 } = store.context;
6660 const blockFocusRef = React27.useRef(false);
6661 const blockedReferenceRef = React27.useRef(null);
6662 const keyboardModalityRef = React27.useRef(true);
6663 const timeout = useTimeout();
6664 React27.useEffect(() => {
6665 const domReference = store.select("domReferenceElement");
6666 if (!enabled) {
6667 return void 0;
6668 }
6669 const win = getWindow(domReference);
6670 function onBlur() {
6671 const currentDomReference = store.select("domReferenceElement");
6672 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
6673 blockFocusRef.current = true;
6674 }
6675 }
6676 function onKeyDown() {
6677 keyboardModalityRef.current = true;
6678 }
6679 function onPointerDown() {
6680 keyboardModalityRef.current = false;
6681 }
6682 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
6683 }, [store, enabled]);
6684 React27.useEffect(() => {
6685 if (!enabled) {
6686 return void 0;
6687 }
6688 function onOpenChangeLocal(details) {
6689 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
6690 const referenceElement = store.select("domReferenceElement");
6691 if (isElement(referenceElement)) {
6692 blockedReferenceRef.current = referenceElement;
6693 blockFocusRef.current = true;
6694 }
6695 }
6696 }
6697 events.on("openchange", onOpenChangeLocal);
6698 return () => {
6699 events.off("openchange", onOpenChangeLocal);
6700 };
6701 }, [events, enabled, store]);
6702 const reference = React27.useMemo(() => {
6703 function resetBlockedFocus() {
6704 blockFocusRef.current = false;
6705 blockedReferenceRef.current = null;
6706 }
6707 return {
6708 onMouseLeave() {
6709 resetBlockedFocus();
6710 },
6711 onFocus(event) {
6712 const focusTarget = event.currentTarget;
6713 if (blockFocusRef.current) {
6714 if (blockedReferenceRef.current === focusTarget) {
6715 return;
6716 }
6717 resetBlockedFocus();
6718 }
6719 const target = getTarget(event.nativeEvent);
6720 if (isElement(target)) {
6721 if (isMacSafari && !event.relatedTarget) {
6722 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
6723 return;
6724 }
6725 } else if (!matchesFocusVisible(target)) {
6726 return;
6727 }
6728 }
6729 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
6730 const {
6731 nativeEvent,
6732 currentTarget
6733 } = event;
6734 const delayValue = typeof delay === "function" ? delay() : delay;
6735 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
6736 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6737 return;
6738 }
6739 timeout.start(delayValue, () => {
6740 if (blockFocusRef.current) {
6741 return;
6742 }
6743 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6744 });
6745 },
6746 onBlur(event) {
6747 resetBlockedFocus();
6748 const relatedTarget = event.relatedTarget;
6749 const nativeEvent = event.nativeEvent;
6750 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
6751 timeout.start(0, () => {
6752 const domReference = store.select("domReferenceElement");
6753 const activeEl = activeElement(ownerDocument(domReference));
6754 if (!relatedTarget && activeEl === domReference) {
6755 return;
6756 }
6757 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
6758 return;
6759 }
6760 const nextFocusedElement = relatedTarget ?? activeEl;
6761 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
6762 return;
6763 }
6764 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
6765 });
6766 }
6767 };
6768 }, [dataRef, delay, store, timeout]);
6769 return React27.useMemo(() => enabled ? {
6770 reference,
6771 trigger: reference
6772 } : {}, [enabled, reference]);
6773 }
6774
6775 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs
6776 var React28 = __toESM(require_react(), 1);
6777
6778 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverInteractionSharedState.mjs
6779 var HoverInteraction = class _HoverInteraction {
6780 constructor() {
6781 this.pointerType = void 0;
6782 this.interactedInside = false;
6783 this.handler = void 0;
6784 this.blockMouseMove = true;
6785 this.performedPointerEventsMutation = false;
6786 this.pointerEventsScopeElement = null;
6787 this.pointerEventsReferenceElement = null;
6788 this.pointerEventsFloatingElement = null;
6789 this.restTimeoutPending = false;
6790 this.openChangeTimeout = new Timeout();
6791 this.restTimeout = new Timeout();
6792 this.handleCloseOptions = void 0;
6793 }
6794 static create() {
6795 return new _HoverInteraction();
6796 }
6797 dispose = () => {
6798 this.openChangeTimeout.clear();
6799 this.restTimeout.clear();
6800 };
6801 disposeEffect = () => {
6802 return this.dispose;
6803 };
6804 };
6805 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
6806 function clearSafePolygonPointerEventsMutation(instance) {
6807 if (!instance.performedPointerEventsMutation) {
6808 return;
6809 }
6810 const scopeElement = instance.pointerEventsScopeElement;
6811 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
6812 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
6813 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
6814 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
6815 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
6816 }
6817 instance.performedPointerEventsMutation = false;
6818 instance.pointerEventsScopeElement = null;
6819 instance.pointerEventsReferenceElement = null;
6820 instance.pointerEventsFloatingElement = null;
6821 }
6822 function applySafePolygonPointerEventsMutation(instance, options) {
6823 const {
6824 scopeElement,
6825 referenceElement,
6826 floatingElement
6827 } = options;
6828 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
6829 if (existingOwner && existingOwner !== instance) {
6830 clearSafePolygonPointerEventsMutation(existingOwner);
6831 }
6832 clearSafePolygonPointerEventsMutation(instance);
6833 instance.performedPointerEventsMutation = true;
6834 instance.pointerEventsScopeElement = scopeElement;
6835 instance.pointerEventsReferenceElement = referenceElement;
6836 instance.pointerEventsFloatingElement = floatingElement;
6837 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
6838 scopeElement.style.pointerEvents = "none";
6839 referenceElement.style.pointerEvents = "auto";
6840 floatingElement.style.pointerEvents = "auto";
6841 }
6842 function useHoverInteractionSharedState(store) {
6843 const data = store.context.dataRef.current;
6844 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current;
6845 if (!data.hoverInteractionState) {
6846 data.hoverInteractionState = instance;
6847 }
6848 useOnMount(data.hoverInteractionState.disposeEffect);
6849 return data.hoverInteractionState;
6850 }
6851
6852 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs
6853 function useHoverFloatingInteraction(context, parameters = {}) {
6854 const {
6855 enabled = true,
6856 closeDelay: closeDelayProp = 0,
6857 nodeId: nodeIdProp
6858 } = parameters;
6859 const store = "rootStore" in context ? context.rootStore : context;
6860 const open = store.useState("open");
6861 const floatingElement = store.useState("floatingElement");
6862 const domReferenceElement = store.useState("domReferenceElement");
6863 const {
6864 dataRef
6865 } = store.context;
6866 const tree = useFloatingTree();
6867 const parentId = useFloatingParentNodeId();
6868 const instance = useHoverInteractionSharedState(store);
6869 const childClosedTimeout = useTimeout();
6870 const isClickLikeOpenEvent2 = useStableCallback(() => {
6871 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6872 });
6873 const isHoverOpen = useStableCallback(() => {
6874 return isHoverOpenEvent(dataRef.current.openEvent?.type);
6875 });
6876 const clearPointerEvents = useStableCallback(() => {
6877 clearSafePolygonPointerEventsMutation(instance);
6878 });
6879 useIsoLayoutEffect(() => {
6880 if (!open) {
6881 instance.pointerType = void 0;
6882 instance.restTimeoutPending = false;
6883 instance.interactedInside = false;
6884 clearPointerEvents();
6885 }
6886 }, [open, instance, clearPointerEvents]);
6887 React28.useEffect(() => {
6888 return clearPointerEvents;
6889 }, [clearPointerEvents]);
6890 useIsoLayoutEffect(() => {
6891 if (!enabled) {
6892 return void 0;
6893 }
6894 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
6895 const ref = domReferenceElement;
6896 const floatingEl = floatingElement;
6897 const doc = ownerDocument(floatingElement);
6898 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
6899 if (parentFloating) {
6900 parentFloating.style.pointerEvents = "";
6901 }
6902 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
6903 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
6904 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
6905 applySafePolygonPointerEventsMutation(instance, {
6906 scopeElement,
6907 referenceElement: ref,
6908 floatingElement: floatingEl
6909 });
6910 return () => {
6911 clearPointerEvents();
6912 };
6913 }
6914 return void 0;
6915 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
6916 React28.useEffect(() => {
6917 if (!enabled) {
6918 return void 0;
6919 }
6920 function hasParentChildren() {
6921 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0);
6922 }
6923 function closeWithDelay(event) {
6924 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
6925 const close = () => {
6926 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6927 tree?.events.emit("floating.closed", event);
6928 };
6929 if (closeDelay) {
6930 instance.openChangeTimeout.start(closeDelay, close);
6931 } else {
6932 instance.openChangeTimeout.clear();
6933 close();
6934 }
6935 }
6936 function handleInteractInside(event) {
6937 const target = getTarget(event);
6938 if (!isInteractiveElement(target)) {
6939 instance.interactedInside = false;
6940 return;
6941 }
6942 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
6943 }
6944 function onFloatingMouseEnter() {
6945 instance.openChangeTimeout.clear();
6946 childClosedTimeout.clear();
6947 tree?.events.off("floating.closed", onNodeClosed);
6948 clearPointerEvents();
6949 }
6950 function onFloatingMouseLeave(event) {
6951 if (hasParentChildren() && tree) {
6952 tree.events.on("floating.closed", onNodeClosed);
6953 return;
6954 }
6955 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
6956 return;
6957 }
6958 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
6959 const relatedTarget = event.relatedTarget;
6960 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
6961 if (isMovingIntoDescendantFloating) {
6962 return;
6963 }
6964 if (instance.handler) {
6965 instance.handler(event);
6966 return;
6967 }
6968 clearPointerEvents();
6969 if (isHoverOpen() && !isClickLikeOpenEvent2()) {
6970 closeWithDelay(event);
6971 }
6972 }
6973 function onNodeClosed(event) {
6974 if (!tree || !parentId || hasParentChildren()) {
6975 return;
6976 }
6977 childClosedTimeout.start(0, () => {
6978 tree.events.off("floating.closed", onNodeClosed);
6979 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6980 tree.events.emit("floating.closed", event);
6981 });
6982 }
6983 const floating = floatingElement;
6984 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
6985 tree?.events.off("floating.closed", onNodeClosed);
6986 });
6987 }, [enabled, floatingElement, store, dataRef, closeDelayProp, nodeIdProp, isHoverOpen, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]);
6988 }
6989
6990 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverReferenceInteraction.mjs
6991 var React29 = __toESM(require_react(), 1);
6992 var ReactDOM5 = __toESM(require_react_dom(), 1);
6993 var EMPTY_REF = {
6994 current: null
6995 };
6996 function useHoverReferenceInteraction(context, props = {}) {
6997 const {
6998 enabled = true,
6999 delay = 0,
7000 handleClose = null,
7001 mouseOnly = false,
7002 restMs = 0,
7003 move = true,
7004 triggerElementRef = EMPTY_REF,
7005 externalTree,
7006 isActiveTrigger = true,
7007 getHandleCloseContext,
7008 isClosing,
7009 shouldOpen: shouldOpenProp
7010 } = props;
7011 const store = "rootStore" in context ? context.rootStore : context;
7012 const {
7013 dataRef,
7014 events
7015 } = store.context;
7016 const tree = useFloatingTree(externalTree);
7017 const instance = useHoverInteractionSharedState(store);
7018 const isHoverCloseActiveRef = React29.useRef(false);
7019 const handleCloseRef = useValueAsRef(handleClose);
7020 const delayRef = useValueAsRef(delay);
7021 const restMsRef = useValueAsRef(restMs);
7022 const enabledRef = useValueAsRef(enabled);
7023 const shouldOpenRef = useValueAsRef(shouldOpenProp);
7024 const isClosingRef = useValueAsRef(isClosing);
7025 const isClickLikeOpenEvent2 = useStableCallback(() => {
7026 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7027 });
7028 const checkShouldOpen = useStableCallback(() => {
7029 return shouldOpenRef.current?.() !== false;
7030 });
7031 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
7032 const allTriggers = store.context.triggerElements;
7033 if (allTriggers.hasElement(currentTarget)) {
7034 return !currentDomReference || !contains(currentDomReference, currentTarget);
7035 }
7036 if (!isElement(target)) {
7037 return false;
7038 }
7039 const targetElement = target;
7040 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
7041 });
7042 const cleanupMouseMoveHandler = useStableCallback(() => {
7043 if (!instance.handler) {
7044 return;
7045 }
7046 const doc = ownerDocument(store.select("domReferenceElement"));
7047 doc.removeEventListener("mousemove", instance.handler);
7048 instance.handler = void 0;
7049 });
7050 const clearPointerEvents = useStableCallback(() => {
7051 clearSafePolygonPointerEventsMutation(instance);
7052 });
7053 if (isActiveTrigger) {
7054 instance.handleCloseOptions = handleCloseRef.current?.__options;
7055 }
7056 React29.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
7057 React29.useEffect(() => {
7058 if (!enabled) {
7059 return void 0;
7060 }
7061 function onOpenChangeLocal(details) {
7062 if (!details.open) {
7063 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
7064 cleanupMouseMoveHandler();
7065 instance.openChangeTimeout.clear();
7066 instance.restTimeout.clear();
7067 instance.blockMouseMove = true;
7068 instance.restTimeoutPending = false;
7069 } else {
7070 isHoverCloseActiveRef.current = false;
7071 }
7072 }
7073 events.on("openchange", onOpenChangeLocal);
7074 return () => {
7075 events.off("openchange", onOpenChangeLocal);
7076 };
7077 }, [enabled, events, instance, cleanupMouseMoveHandler]);
7078 React29.useEffect(() => {
7079 if (!enabled) {
7080 return void 0;
7081 }
7082 function closeWithDelay(event, runElseBranch = true) {
7083 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
7084 if (closeDelay) {
7085 instance.openChangeTimeout.start(closeDelay, () => {
7086 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7087 tree?.events.emit("floating.closed", event);
7088 });
7089 } else if (runElseBranch) {
7090 instance.openChangeTimeout.clear();
7091 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7092 tree?.events.emit("floating.closed", event);
7093 }
7094 }
7095 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
7096 if (!isElement(trigger)) {
7097 return void 0;
7098 }
7099 function onMouseEnter(event) {
7100 instance.openChangeTimeout.clear();
7101 instance.blockMouseMove = false;
7102 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7103 return;
7104 }
7105 const restMsValue = getRestMs(restMsRef.current);
7106 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
7107 const eventTarget = getTarget(event);
7108 const currentTarget = event.currentTarget ?? null;
7109 const currentDomReference = store.select("domReferenceElement");
7110 let triggerNode = currentTarget;
7111 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
7112 for (const triggerElement of store.context.triggerElements.elements()) {
7113 if (contains(triggerElement, eventTarget)) {
7114 triggerNode = triggerElement;
7115 break;
7116 }
7117 }
7118 }
7119 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
7120 triggerNode = currentDomReference;
7121 }
7122 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
7123 const isOpen = store.select("open");
7124 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
7125 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
7126 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
7127 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
7128 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
7129 const shouldOpen = !isOpen || isOverInactive;
7130 if (shouldOpenImmediately) {
7131 if (checkShouldOpen()) {
7132 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7133 }
7134 return;
7135 }
7136 if (isRestOnlyDelay) {
7137 return;
7138 }
7139 if (openDelay) {
7140 instance.openChangeTimeout.start(openDelay, () => {
7141 if (shouldOpen && checkShouldOpen()) {
7142 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7143 }
7144 });
7145 } else if (shouldOpen) {
7146 if (checkShouldOpen()) {
7147 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7148 }
7149 }
7150 }
7151 function onMouseLeave(event) {
7152 if (isClickLikeOpenEvent2()) {
7153 clearPointerEvents();
7154 return;
7155 }
7156 cleanupMouseMoveHandler();
7157 const domReferenceElement = store.select("domReferenceElement");
7158 const doc = ownerDocument(domReferenceElement);
7159 instance.restTimeout.clear();
7160 instance.restTimeoutPending = false;
7161 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
7162 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
7163 return;
7164 }
7165 if (handleCloseRef.current && handleCloseContextBase) {
7166 if (!store.select("open")) {
7167 instance.openChangeTimeout.clear();
7168 }
7169 const currentTrigger = triggerElementRef.current;
7170 instance.handler = handleCloseRef.current({
7171 ...handleCloseContextBase,
7172 tree,
7173 x: event.clientX,
7174 y: event.clientY,
7175 onClose() {
7176 clearPointerEvents();
7177 cleanupMouseMoveHandler();
7178 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
7179 closeWithDelay(event, true);
7180 }
7181 }
7182 });
7183 doc.addEventListener("mousemove", instance.handler);
7184 instance.handler(event);
7185 return;
7186 }
7187 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
7188 if (shouldClose) {
7189 closeWithDelay(event);
7190 }
7191 }
7192 if (move) {
7193 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
7194 once: true
7195 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7196 }
7197 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7198 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]);
7199 return React29.useMemo(() => {
7200 if (!enabled) {
7201 return void 0;
7202 }
7203 function setPointerRef(event) {
7204 instance.pointerType = event.pointerType;
7205 }
7206 return {
7207 onPointerDown: setPointerRef,
7208 onPointerEnter: setPointerRef,
7209 onMouseMove(event) {
7210 const {
7211 nativeEvent
7212 } = event;
7213 const trigger = event.currentTarget;
7214 const currentDomReference = store.select("domReferenceElement");
7215 const currentOpen = store.select("open");
7216 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
7217 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7218 return;
7219 }
7220 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
7221 const floatingElement = store.select("floatingElement");
7222 if (floatingElement) {
7223 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
7224 applySafePolygonPointerEventsMutation(instance, {
7225 scopeElement,
7226 referenceElement: trigger,
7227 floatingElement
7228 });
7229 }
7230 }
7231 const restMsValue = getRestMs(restMsRef.current);
7232 if (currentOpen && !isOverInactive || restMsValue === 0) {
7233 return;
7234 }
7235 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
7236 return;
7237 }
7238 instance.restTimeout.clear();
7239 function handleMouseMove() {
7240 instance.restTimeoutPending = false;
7241 if (isClickLikeOpenEvent2()) {
7242 return;
7243 }
7244 const latestOpen = store.select("open");
7245 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
7246 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
7247 }
7248 }
7249 if (instance.pointerType === "touch") {
7250 ReactDOM5.flushSync(() => {
7251 handleMouseMove();
7252 });
7253 } else if (isOverInactive && currentOpen) {
7254 handleMouseMove();
7255 } else {
7256 instance.restTimeoutPending = true;
7257 instance.restTimeout.start(restMsValue, handleMouseMove);
7258 }
7259 }
7260 };
7261 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef, checkShouldOpen]);
7262 }
7263
7264 // node_modules/@base-ui/react/floating-ui-react/safePolygon.mjs
7265 var CURSOR_SPEED_THRESHOLD = 0.1;
7266 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
7267 var POLYGON_BUFFER = 0.5;
7268 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
7269 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
7270 }
7271 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
7272 let isInsideValue = false;
7273 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
7274 isInsideValue = !isInsideValue;
7275 }
7276 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
7277 isInsideValue = !isInsideValue;
7278 }
7279 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
7280 isInsideValue = !isInsideValue;
7281 }
7282 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
7283 isInsideValue = !isInsideValue;
7284 }
7285 return isInsideValue;
7286 }
7287 function isInsideRect(pointX, pointY, rect) {
7288 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
7289 }
7290 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
7291 const minX = Math.min(x1, x2);
7292 const maxX = Math.max(x1, x2);
7293 const minY = Math.min(y1, y2);
7294 const maxY = Math.max(y1, y2);
7295 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
7296 }
7297 function safePolygon(options = {}) {
7298 const {
7299 blockPointerEvents = false
7300 } = options;
7301 const timeout = new Timeout();
7302 const fn = ({
7303 x: x2,
7304 y: y2,
7305 placement,
7306 elements,
7307 onClose,
7308 nodeId,
7309 tree
7310 }) => {
7311 const side = placement?.split("-")[0];
7312 let hasLanded = false;
7313 let lastX = null;
7314 let lastY = null;
7315 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
7316 function isCursorMovingSlowly(nextX, nextY) {
7317 const currentTime = performance.now();
7318 const elapsedTime = currentTime - lastCursorTime;
7319 if (lastX === null || lastY === null || elapsedTime === 0) {
7320 lastX = nextX;
7321 lastY = nextY;
7322 lastCursorTime = currentTime;
7323 return false;
7324 }
7325 const deltaX = nextX - lastX;
7326 const deltaY = nextY - lastY;
7327 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
7328 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
7329 lastX = nextX;
7330 lastY = nextY;
7331 lastCursorTime = currentTime;
7332 return distanceSquared < thresholdSquared;
7333 }
7334 function close() {
7335 timeout.clear();
7336 onClose();
7337 }
7338 return function onMouseMove(event) {
7339 timeout.clear();
7340 const domReference = elements.domReference;
7341 const floating = elements.floating;
7342 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
7343 return void 0;
7344 }
7345 const {
7346 clientX,
7347 clientY
7348 } = event;
7349 const target = getTarget(event);
7350 const isLeave = event.type === "mouseleave";
7351 const isOverFloatingEl = contains(floating, target);
7352 const isOverReferenceEl = contains(domReference, target);
7353 if (isOverFloatingEl) {
7354 hasLanded = true;
7355 if (!isLeave) {
7356 return void 0;
7357 }
7358 }
7359 if (isOverReferenceEl) {
7360 hasLanded = false;
7361 if (!isLeave) {
7362 hasLanded = true;
7363 return void 0;
7364 }
7365 }
7366 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
7367 return void 0;
7368 }
7369 function hasOpenChildNode() {
7370 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
7371 }
7372 function closeIfNoOpenChild() {
7373 if (!hasOpenChildNode()) {
7374 close();
7375 }
7376 }
7377 if (hasOpenChildNode()) {
7378 return void 0;
7379 }
7380 const refRect = domReference.getBoundingClientRect();
7381 const rect = floating.getBoundingClientRect();
7382 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
7383 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
7384 const isFloatingWider = rect.width > refRect.width;
7385 const isFloatingTaller = rect.height > refRect.height;
7386 const left = (isFloatingWider ? refRect : rect).left;
7387 const right = (isFloatingWider ? refRect : rect).right;
7388 const top = (isFloatingTaller ? refRect : rect).top;
7389 const bottom = (isFloatingTaller ? refRect : rect).bottom;
7390 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) {
7391 closeIfNoOpenChild();
7392 return void 0;
7393 }
7394 let isInsideTroughRect = false;
7395 switch (side) {
7396 case "top":
7397 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
7398 break;
7399 case "bottom":
7400 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
7401 break;
7402 case "left":
7403 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
7404 break;
7405 case "right":
7406 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
7407 break;
7408 default:
7409 }
7410 if (isInsideTroughRect) {
7411 return void 0;
7412 }
7413 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
7414 closeIfNoOpenChild();
7415 return void 0;
7416 }
7417 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
7418 closeIfNoOpenChild();
7419 return void 0;
7420 }
7421 let isInsidePolygon = false;
7422 switch (side) {
7423 case "top": {
7424 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7425 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7426 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7427 const cursorPointY = y2 + POLYGON_BUFFER + 1;
7428 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
7429 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
7430 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7431 break;
7432 }
7433 case "bottom": {
7434 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7435 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7436 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7437 const cursorPointY = y2 - POLYGON_BUFFER;
7438 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
7439 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
7440 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7441 break;
7442 }
7443 case "left": {
7444 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7445 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7446 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7447 const cursorPointX = x2 + POLYGON_BUFFER + 1;
7448 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
7449 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
7450 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
7451 break;
7452 }
7453 case "right": {
7454 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7455 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7456 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7457 const cursorPointX = x2 - POLYGON_BUFFER;
7458 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
7459 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
7460 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
7461 break;
7462 }
7463 default:
7464 }
7465 if (!isInsidePolygon) {
7466 closeIfNoOpenChild();
7467 } else if (!hasLanded) {
7468 timeout.start(40, closeIfNoOpenChild);
7469 }
7470 return void 0;
7471 };
7472 };
7473 fn.__options = {
7474 ...options,
7475 blockPointerEvents
7476 };
7477 return fn;
7478 }
7479
7480 // node_modules/@base-ui/react/utils/popupStateMapping.mjs
7481 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
7482 CommonPopupDataAttributes2["open"] = "data-open";
7483 CommonPopupDataAttributes2["closed"] = "data-closed";
7484 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
7485 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
7486 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
7487 CommonPopupDataAttributes2["side"] = "data-side";
7488 CommonPopupDataAttributes2["align"] = "data-align";
7489 return CommonPopupDataAttributes2;
7490 })({});
7491 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
7492 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
7493 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
7494 return CommonTriggerDataAttributes2;
7495 })({});
7496 var TRIGGER_HOOK = {
7497 [CommonTriggerDataAttributes.popupOpen]: ""
7498 };
7499 var PRESSABLE_TRIGGER_HOOK = {
7500 [CommonTriggerDataAttributes.popupOpen]: "",
7501 [CommonTriggerDataAttributes.pressed]: ""
7502 };
7503 var POPUP_OPEN_HOOK = {
7504 [CommonPopupDataAttributes.open]: ""
7505 };
7506 var POPUP_CLOSED_HOOK = {
7507 [CommonPopupDataAttributes.closed]: ""
7508 };
7509 var ANCHOR_HIDDEN_HOOK = {
7510 [CommonPopupDataAttributes.anchorHidden]: ""
7511 };
7512 var triggerOpenStateMapping = {
7513 open(value) {
7514 if (value) {
7515 return TRIGGER_HOOK;
7516 }
7517 return null;
7518 }
7519 };
7520 var popupStateMapping = {
7521 open(value) {
7522 if (value) {
7523 return POPUP_OPEN_HOOK;
7524 }
7525 return POPUP_CLOSED_HOOK;
7526 },
7527 anchorHidden(value) {
7528 if (value) {
7529 return ANCHOR_HIDDEN_HOOK;
7530 }
7531 return null;
7532 }
7533 };
7534
7535 // node_modules/@base-ui/utils/inertValue.mjs
7536 function inertValue(value) {
7537 if (isReactVersionAtLeast(19)) {
7538 return value;
7539 }
7540 return value ? "true" : void 0;
7541 }
7542
7543 // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs
7544 var React30 = __toESM(require_react(), 1);
7545
7546 // node_modules/@base-ui/react/floating-ui-react/middleware/arrow.mjs
7547 var baseArrow = (options) => ({
7548 name: "arrow",
7549 options,
7550 async fn(state) {
7551 const {
7552 x: x2,
7553 y: y2,
7554 placement,
7555 rects,
7556 platform: platform3,
7557 elements,
7558 middlewareData
7559 } = state;
7560 const {
7561 element,
7562 padding = 0,
7563 offsetParent = "real"
7564 } = evaluate(options, state) || {};
7565 if (element == null) {
7566 return {};
7567 }
7568 const paddingObject = getPaddingObject(padding);
7569 const coords = {
7570 x: x2,
7571 y: y2
7572 };
7573 const axis = getAlignmentAxis(placement);
7574 const length = getAxisLength(axis);
7575 const arrowDimensions = await platform3.getDimensions(element);
7576 const isYAxis = axis === "y";
7577 const minProp = isYAxis ? "top" : "left";
7578 const maxProp = isYAxis ? "bottom" : "right";
7579 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
7580 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
7581 const startDiff = coords[axis] - rects.reference[axis];
7582 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
7583 let clientSize = elements.floating[clientProp] || rects.floating[length];
7584 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
7585 clientSize = elements.floating[clientProp] || rects.floating[length];
7586 }
7587 const centerToReference = endDiff / 2 - startDiff / 2;
7588 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
7589 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
7590 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
7591 const min2 = minPadding;
7592 const max2 = clientSize - arrowDimensions[length] - maxPadding;
7593 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
7594 const offset4 = clamp(min2, center, max2);
7595 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
7596 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
7597 return {
7598 [axis]: coords[axis] + alignmentOffset,
7599 data: {
7600 [axis]: offset4,
7601 centerOffset: center - offset4 - alignmentOffset,
7602 ...shouldAddOffset && {
7603 alignmentOffset
7604 }
7605 },
7606 reset: shouldAddOffset
7607 };
7608 }
7609 });
7610 var arrow4 = (options, deps) => ({
7611 ...baseArrow(options),
7612 options: [options, deps]
7613 });
7614
7615 // node_modules/@base-ui/react/utils/hideMiddleware.mjs
7616 var nativeHideFn = hide3().fn;
7617 var hide4 = {
7618 name: "hide",
7619 async fn(state) {
7620 const {
7621 width,
7622 height,
7623 x: x2,
7624 y: y2
7625 } = state.rects.reference;
7626 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
7627 const nativeHideResult = await nativeHideFn(state);
7628 return {
7629 data: {
7630 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
7631 }
7632 };
7633 }
7634 };
7635
7636 // node_modules/@base-ui/react/utils/adaptiveOriginMiddleware.mjs
7637 var DEFAULT_SIDES = {
7638 sideX: "left",
7639 sideY: "top"
7640 };
7641 var adaptiveOrigin = {
7642 name: "adaptiveOrigin",
7643 async fn(state) {
7644 const {
7645 x: rawX,
7646 y: rawY,
7647 rects: {
7648 floating: floatRect
7649 },
7650 elements: {
7651 floating
7652 },
7653 platform: platform3,
7654 strategy,
7655 placement
7656 } = state;
7657 const win = getWindow(floating);
7658 const styles = win.getComputedStyle(floating);
7659 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
7660 if (!hasTransition) {
7661 return {
7662 x: rawX,
7663 y: rawY,
7664 data: DEFAULT_SIDES
7665 };
7666 }
7667 const offsetParent = await platform3.getOffsetParent?.(floating);
7668 let offsetDimensions = {
7669 width: 0,
7670 height: 0
7671 };
7672 if (strategy === "fixed" && win?.visualViewport) {
7673 offsetDimensions = {
7674 width: win.visualViewport.width,
7675 height: win.visualViewport.height
7676 };
7677 } else if (offsetParent === win) {
7678 const doc = ownerDocument(floating);
7679 offsetDimensions = {
7680 width: doc.documentElement.clientWidth,
7681 height: doc.documentElement.clientHeight
7682 };
7683 } else if (await platform3.isElement?.(offsetParent)) {
7684 offsetDimensions = await platform3.getDimensions(offsetParent);
7685 }
7686 const currentSide = getSide(placement);
7687 let x2 = rawX;
7688 let y2 = rawY;
7689 if (currentSide === "left") {
7690 x2 = offsetDimensions.width - (rawX + floatRect.width);
7691 }
7692 if (currentSide === "top") {
7693 y2 = offsetDimensions.height - (rawY + floatRect.height);
7694 }
7695 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
7696 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
7697 return {
7698 x: x2,
7699 y: y2,
7700 data: {
7701 sideX,
7702 sideY
7703 }
7704 };
7705 }
7706 };
7707
7708 // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs
7709 function getLogicalSide(sideParam, renderedSide, isRtl) {
7710 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
7711 const logicalRight = isRtl ? "inline-start" : "inline-end";
7712 const logicalLeft = isRtl ? "inline-end" : "inline-start";
7713 return {
7714 top: "top",
7715 right: isLogicalSideParam ? logicalRight : "right",
7716 bottom: "bottom",
7717 left: isLogicalSideParam ? logicalLeft : "left"
7718 }[renderedSide];
7719 }
7720 function getOffsetData(state, sideParam, isRtl) {
7721 const {
7722 rects,
7723 placement
7724 } = state;
7725 const data = {
7726 side: getLogicalSide(sideParam, getSide(placement), isRtl),
7727 align: getAlignment(placement) || "center",
7728 anchor: {
7729 width: rects.reference.width,
7730 height: rects.reference.height
7731 },
7732 positioner: {
7733 width: rects.floating.width,
7734 height: rects.floating.height
7735 }
7736 };
7737 return data;
7738 }
7739 function useAnchorPositioning(params) {
7740 const {
7741 // Public parameters
7742 anchor,
7743 positionMethod = "absolute",
7744 side: sideParam = "bottom",
7745 sideOffset = 0,
7746 align = "center",
7747 alignOffset = 0,
7748 collisionBoundary,
7749 collisionPadding: collisionPaddingParam = 5,
7750 sticky = false,
7751 arrowPadding = 5,
7752 disableAnchorTracking = false,
7753 inline: inlineMiddleware,
7754 // Private parameters
7755 keepMounted = false,
7756 floatingRootContext,
7757 mounted,
7758 collisionAvoidance,
7759 shiftCrossAxis = false,
7760 nodeId,
7761 adaptiveOrigin: adaptiveOrigin2,
7762 lazyFlip = false,
7763 externalTree
7764 } = params;
7765 const [mountSide, setMountSide] = React30.useState(null);
7766 if (!mounted && mountSide !== null) {
7767 setMountSide(null);
7768 }
7769 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
7770 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
7771 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
7772 const anchorFn = typeof anchor === "function" ? anchor : void 0;
7773 const anchorFnCallback = useStableCallback(anchorFn);
7774 const anchorDep = anchorFn ? anchorFnCallback : anchor;
7775 const anchorValueRef = useValueAsRef(anchor);
7776 const mountedRef = useValueAsRef(mounted);
7777 const direction = useDirection();
7778 const isRtl = direction === "rtl";
7779 const side = mountSide || {
7780 top: "top",
7781 right: "right",
7782 bottom: "bottom",
7783 left: "left",
7784 "inline-end": isRtl ? "left" : "right",
7785 "inline-start": isRtl ? "right" : "left"
7786 }[sideParam];
7787 const placement = align === "center" ? side : `${side}-${align}`;
7788 let collisionPadding = collisionPaddingParam;
7789 const bias = 1;
7790 const biasTop = sideParam === "bottom" ? bias : 0;
7791 const biasBottom = sideParam === "top" ? bias : 0;
7792 const biasLeft = sideParam === "right" ? bias : 0;
7793 const biasRight = sideParam === "left" ? bias : 0;
7794 if (typeof collisionPadding === "number") {
7795 collisionPadding = {
7796 top: collisionPadding + biasTop,
7797 right: collisionPadding + biasRight,
7798 bottom: collisionPadding + biasBottom,
7799 left: collisionPadding + biasLeft
7800 };
7801 } else if (collisionPadding) {
7802 collisionPadding = {
7803 top: (collisionPadding.top || 0) + biasTop,
7804 right: (collisionPadding.right || 0) + biasRight,
7805 bottom: (collisionPadding.bottom || 0) + biasBottom,
7806 left: (collisionPadding.left || 0) + biasLeft
7807 };
7808 }
7809 const commonCollisionProps = {
7810 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
7811 padding: collisionPadding
7812 };
7813 const arrowRef = React30.useRef(null);
7814 const sideOffsetRef = useValueAsRef(sideOffset);
7815 const alignOffsetRef = useValueAsRef(alignOffset);
7816 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
7817 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
7818 const middleware = [];
7819 if (inlineMiddleware) {
7820 middleware.push(inlineMiddleware);
7821 }
7822 middleware.push(offset3((state) => {
7823 const data = getOffsetData(state, sideParam, isRtl);
7824 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
7825 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
7826 return {
7827 mainAxis: sideAxis,
7828 crossAxis: alignAxis,
7829 alignmentAxis: alignAxis
7830 };
7831 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
7832 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
7833 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
7834 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
7835 ...commonCollisionProps,
7836 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
7837 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
7838 padding: {
7839 top: collisionPadding.top + bias,
7840 right: collisionPadding.right + bias,
7841 bottom: collisionPadding.bottom + bias,
7842 left: collisionPadding.left + bias
7843 },
7844 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
7845 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
7846 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
7847 });
7848 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
7849 const html = ownerDocument(data.elements.floating).documentElement;
7850 return {
7851 ...commonCollisionProps,
7852 // Use the Layout Viewport to avoid shifting around when pinch-zooming
7853 // for context menus.
7854 rootBoundary: shiftCrossAxis ? {
7855 x: 0,
7856 y: 0,
7857 width: html.clientWidth,
7858 height: html.clientHeight
7859 } : void 0,
7860 mainAxis: collisionAvoidanceAlign !== "none",
7861 crossAxis: crossAxisShiftEnabled,
7862 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
7863 if (!arrowRef.current) {
7864 return {};
7865 }
7866 const {
7867 width,
7868 height
7869 } = arrowRef.current.getBoundingClientRect();
7870 const sideAxis = getSideAxis(getSide(limitData.placement));
7871 const arrowSize = sideAxis === "y" ? width : height;
7872 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
7873 return {
7874 offset: arrowSize / 2 + offsetAmount / 2
7875 };
7876 })
7877 };
7878 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
7879 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
7880 middleware.push(shiftMiddleware, flipMiddleware);
7881 } else {
7882 middleware.push(flipMiddleware, shiftMiddleware);
7883 }
7884 middleware.push(size3({
7885 ...commonCollisionProps,
7886 apply({
7887 elements: {
7888 floating
7889 },
7890 availableWidth,
7891 availableHeight,
7892 rects
7893 }) {
7894 if (!mountedRef.current) {
7895 return;
7896 }
7897 const floatingStyle = floating.style;
7898 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
7899 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
7900 const dpr = getWindow(floating).devicePixelRatio || 1;
7901 const {
7902 x: x3,
7903 y: y3,
7904 width,
7905 height
7906 } = rects.reference;
7907 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
7908 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
7909 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
7910 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
7911 }
7912 }), arrow4((state) => ({
7913 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
7914 // we'll create a fake element.
7915 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"),
7916 padding: arrowPadding,
7917 offsetParent: "floating"
7918 }), [arrowPadding]), {
7919 name: "transformOrigin",
7920 fn(state) {
7921 const {
7922 elements: elements2,
7923 middlewareData: middlewareData2,
7924 placement: renderedPlacement2,
7925 rects,
7926 y: y3
7927 } = state;
7928 const currentRenderedSide = getSide(renderedPlacement2);
7929 const currentRenderedAxis = getSideAxis(currentRenderedSide);
7930 const arrowEl = arrowRef.current;
7931 const arrowX = middlewareData2.arrow?.x || 0;
7932 const arrowY = middlewareData2.arrow?.y || 0;
7933 const arrowWidth = arrowEl?.clientWidth || 0;
7934 const arrowHeight = arrowEl?.clientHeight || 0;
7935 const transformX = arrowX + arrowWidth / 2;
7936 const transformY = arrowY + arrowHeight / 2;
7937 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
7938 const halfAnchorHeight = rects.reference.height / 2;
7939 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
7940 const isOverlappingAnchor = shiftY > sideOffsetValue;
7941 const adjacentTransformOrigin = {
7942 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
7943 bottom: `${transformX}px ${-sideOffsetValue}px`,
7944 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
7945 right: `${-sideOffsetValue}px ${transformY}px`
7946 }[currentRenderedSide];
7947 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
7948 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
7949 return {};
7950 }
7951 }, hide4, adaptiveOrigin2);
7952 useIsoLayoutEffect(() => {
7953 if (!mounted && floatingRootContext) {
7954 floatingRootContext.update({
7955 referenceElement: null,
7956 floatingElement: null,
7957 domReferenceElement: null,
7958 positionReference: null
7959 });
7960 }
7961 }, [mounted, floatingRootContext]);
7962 const autoUpdateOptions = React30.useMemo(() => ({
7963 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
7964 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
7965 }), [disableAnchorTracking]);
7966 const {
7967 refs,
7968 elements,
7969 x: x2,
7970 y: y2,
7971 middlewareData,
7972 update: update2,
7973 placement: renderedPlacement,
7974 context,
7975 isPositioned,
7976 floatingStyles: originalFloatingStyles
7977 } = useFloating2({
7978 rootContext: floatingRootContext,
7979 open: keepMounted ? mounted : void 0,
7980 placement,
7981 middleware,
7982 strategy: positionMethod,
7983 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
7984 nodeId,
7985 externalTree
7986 });
7987 const {
7988 sideX,
7989 sideY
7990 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
7991 const resolvedPosition = isPositioned ? positionMethod : "fixed";
7992 const floatingStyles = React30.useMemo(() => {
7993 const base = adaptiveOrigin2 ? {
7994 position: resolvedPosition,
7995 [sideX]: x2,
7996 [sideY]: y2
7997 } : {
7998 position: resolvedPosition,
7999 ...originalFloatingStyles
8000 };
8001 if (!isPositioned) {
8002 base.opacity = 0;
8003 }
8004 return base;
8005 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
8006 const registeredPositionReferenceRef = React30.useRef(null);
8007 useIsoLayoutEffect(() => {
8008 if (!mounted) {
8009 return;
8010 }
8011 const anchorValue = anchorValueRef.current;
8012 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
8013 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
8014 const finalAnchor = unwrappedElement || null;
8015 if (finalAnchor !== registeredPositionReferenceRef.current) {
8016 refs.setPositionReference(finalAnchor);
8017 registeredPositionReferenceRef.current = finalAnchor;
8018 }
8019 }, [mounted, refs, anchorDep, anchorValueRef]);
8020 React30.useEffect(() => {
8021 if (!mounted) {
8022 return;
8023 }
8024 const anchorValue = anchorValueRef.current;
8025 if (typeof anchorValue === "function") {
8026 return;
8027 }
8028 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
8029 refs.setPositionReference(anchorValue.current);
8030 registeredPositionReferenceRef.current = anchorValue.current;
8031 }
8032 }, [mounted, refs, anchorDep, anchorValueRef]);
8033 React30.useEffect(() => {
8034 if (keepMounted && mounted && elements.reference && elements.floating) {
8035 return autoUpdate(elements.reference, elements.floating, update2, autoUpdateOptions);
8036 }
8037 return void 0;
8038 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
8039 const renderedSide = getSide(renderedPlacement);
8040 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
8041 const renderedAlign = getAlignment(renderedPlacement) || "center";
8042 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
8043 useIsoLayoutEffect(() => {
8044 if (lazyFlip && mounted && isPositioned) {
8045 setMountSide(renderedSide);
8046 }
8047 }, [lazyFlip, mounted, isPositioned, renderedSide]);
8048 const arrowStyles = React30.useMemo(() => ({
8049 position: "absolute",
8050 top: middlewareData.arrow?.y,
8051 left: middlewareData.arrow?.x
8052 }), [middlewareData.arrow]);
8053 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
8054 return React30.useMemo(() => ({
8055 positionerStyles: floatingStyles,
8056 arrowStyles,
8057 arrowRef,
8058 arrowUncentered,
8059 side: logicalRenderedSide,
8060 align: renderedAlign,
8061 physicalSide: renderedSide,
8062 anchorHidden,
8063 refs,
8064 context,
8065 isPositioned,
8066 update: update2
8067 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
8068 }
8069 function isRef(param) {
8070 return param != null && "current" in param;
8071 }
8072
8073 // node_modules/@base-ui/react/utils/getDisabledMountTransitionStyles.mjs
8074 function getDisabledMountTransitionStyles(transitionStatus) {
8075 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
8076 }
8077
8078 // node_modules/@base-ui/react/utils/usePositioner.mjs
8079 function usePositioner(componentProps, state, {
8080 styles,
8081 transitionStatus,
8082 props,
8083 refs,
8084 hidden,
8085 inert = false
8086 }) {
8087 const style = {
8088 ...styles
8089 };
8090 if (inert) {
8091 style.pointerEvents = "none";
8092 }
8093 return useRenderElement("div", componentProps, {
8094 state,
8095 ref: refs,
8096 props: [{
8097 role: "presentation",
8098 hidden,
8099 style
8100 }, getDisabledMountTransitionStyles(transitionStatus), props],
8101 stateAttributesMapping: popupStateMapping
8102 });
8103 }
8104
8105 // node_modules/@base-ui/react/utils/usePopupViewport.mjs
8106 var React33 = __toESM(require_react(), 1);
8107 var ReactDOM6 = __toESM(require_react_dom(), 1);
8108
8109 // node_modules/@base-ui/utils/usePreviousValue.mjs
8110 var React31 = __toESM(require_react(), 1);
8111 function usePreviousValue(value) {
8112 const [state, setState] = React31.useState({
8113 current: value,
8114 previous: null
8115 });
8116 if (value !== state.current) {
8117 setState({
8118 current: value,
8119 previous: state.current
8120 });
8121 }
8122 return state.previous;
8123 }
8124
8125 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs
8126 var React32 = __toESM(require_react(), 1);
8127
8128 // node_modules/@base-ui/react/utils/getCssDimensions.mjs
8129 function getCssDimensions2(element) {
8130 const css = getComputedStyle2(element);
8131 let width = parseFloat(css.width) || 0;
8132 let height = parseFloat(css.height) || 0;
8133 const hasOffset = isHTMLElement(element);
8134 const offsetWidth = hasOffset ? element.offsetWidth : width;
8135 const offsetHeight = hasOffset ? element.offsetHeight : height;
8136 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
8137 if (shouldFallback) {
8138 width = offsetWidth;
8139 height = offsetHeight;
8140 }
8141 return {
8142 width,
8143 height
8144 };
8145 }
8146
8147 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs
8148 function usePopupAutoResize(parameters) {
8149 const {
8150 popupElement,
8151 positionerElement,
8152 content,
8153 mounted,
8154 onMeasureLayout: onMeasureLayoutParam,
8155 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
8156 side,
8157 direction
8158 } = parameters;
8159 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
8160 const animationFrame = useAnimationFrame();
8161 const committedDimensionsRef = React32.useRef(null);
8162 const isInitialRenderRef = React32.useRef(true);
8163 const restoreAnchoringStylesRef = React32.useRef(NOOP);
8164 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
8165 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
8166 const anchoringStyles = React32.useMemo(() => {
8167 let isOriginSide = side === "top";
8168 let isPhysicalLeft = side === "left";
8169 if (direction === "rtl") {
8170 isOriginSide = isOriginSide || side === "inline-end";
8171 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
8172 } else {
8173 isOriginSide = isOriginSide || side === "inline-start";
8174 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
8175 }
8176 return isOriginSide ? {
8177 position: "absolute",
8178 [side === "top" ? "bottom" : "top"]: "0",
8179 [isPhysicalLeft ? "right" : "left"]: "0"
8180 } : EMPTY_OBJECT;
8181 }, [side, direction]);
8182 useIsoLayoutEffect(() => {
8183 if (!mounted) {
8184 restoreAnchoringStylesRef.current = NOOP;
8185 isInitialRenderRef.current = true;
8186 committedDimensionsRef.current = null;
8187 return void 0;
8188 }
8189 if (!popupElement || !positionerElement) {
8190 return void 0;
8191 }
8192 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
8193 setPopupCssSize(popupElement, "auto");
8194 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
8195 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
8196 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
8197 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
8198 "--available-width": "max-content",
8199 "--available-height": "max-content"
8200 });
8201 function restoreMeasurementOverrides() {
8202 restorePopupPosition();
8203 restorePopupTransform();
8204 restorePositionerAvailableSize();
8205 }
8206 function restoreMeasurementOverridesIncludingScale() {
8207 restoreMeasurementOverrides();
8208 restorePopupScale();
8209 }
8210 onMeasureLayout?.();
8211 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
8212 setPositionerCssSize(positionerElement, "max-content");
8213 const dimensions = getCssDimensions2(popupElement);
8214 committedDimensionsRef.current = dimensions;
8215 setPositionerCssSize(positionerElement, dimensions);
8216 restoreMeasurementOverridesIncludingScale();
8217 onMeasureLayoutComplete?.(null, dimensions);
8218 isInitialRenderRef.current = false;
8219 return () => {
8220 restoreAnchoringStylesRef.current();
8221 restoreAnchoringStylesRef.current = NOOP;
8222 };
8223 }
8224 setPositionerCssSize(positionerElement, "max-content");
8225 const previousDimensions = committedDimensionsRef.current;
8226 const newDimensions = getCssDimensions2(popupElement);
8227 committedDimensionsRef.current = newDimensions;
8228 setPopupCssSize(popupElement, previousDimensions);
8229 restoreMeasurementOverridesIncludingScale();
8230 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
8231 setPositionerCssSize(positionerElement, newDimensions);
8232 const abortController = new AbortController();
8233 animationFrame.request(() => {
8234 setPopupCssSize(popupElement, newDimensions);
8235 runOnceAnimationsFinish(() => {
8236 popupElement.style.setProperty("--popup-width", "auto");
8237 popupElement.style.setProperty("--popup-height", "auto");
8238 }, abortController.signal);
8239 });
8240 return () => {
8241 abortController.abort();
8242 animationFrame.cancel();
8243 restoreAnchoringStylesRef.current();
8244 restoreAnchoringStylesRef.current = NOOP;
8245 };
8246 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
8247 }
8248 function overrideElementStyle(element, property, value) {
8249 const originalValue = element.style.getPropertyValue(property);
8250 element.style.setProperty(property, value);
8251 return () => {
8252 element.style.setProperty(property, originalValue);
8253 };
8254 }
8255 function applyElementStyles(element, styles) {
8256 const restorers = [];
8257 for (const [key, value] of Object.entries(styles)) {
8258 restorers.push(overrideElementStyle(element, key, value));
8259 }
8260 return restorers.length ? () => {
8261 restorers.forEach((restore) => restore());
8262 } : NOOP;
8263 }
8264 function setPopupCssSize(popupElement, size4) {
8265 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
8266 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
8267 popupElement.style.setProperty("--popup-width", width);
8268 popupElement.style.setProperty("--popup-height", height);
8269 }
8270 function setPositionerCssSize(positionerElement, size4) {
8271 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
8272 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
8273 positionerElement.style.setProperty("--positioner-width", width);
8274 positionerElement.style.setProperty("--positioner-height", height);
8275 }
8276
8277 // node_modules/@base-ui/react/utils/usePopupViewport.mjs
8278 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
8279 function usePopupViewport(parameters) {
8280 const {
8281 store,
8282 side,
8283 cssVars,
8284 children
8285 } = parameters;
8286 const direction = useDirection();
8287 const activeTrigger = store.useState("activeTriggerElement");
8288 const activeTriggerId = store.useState("activeTriggerId");
8289 const open = store.useState("open");
8290 const payload = store.useState("payload");
8291 const mounted = store.useState("mounted");
8292 const popupElement = store.useState("popupElement");
8293 const positionerElement = store.useState("positionerElement");
8294 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
8295 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
8296 const capturedNodeRef = React33.useRef(null);
8297 const [previousContentNode, setPreviousContentNode] = React33.useState(null);
8298 const [newTriggerOffset, setNewTriggerOffset] = React33.useState(null);
8299 const currentContainerRef = React33.useRef(null);
8300 const previousContainerRef = React33.useRef(null);
8301 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
8302 const cleanupFrame = useAnimationFrame();
8303 const [previousContentDimensions, setPreviousContentDimensions] = React33.useState(null);
8304 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React33.useState(false);
8305 useIsoLayoutEffect(() => {
8306 store.set("hasViewport", true);
8307 return () => {
8308 store.set("hasViewport", false);
8309 };
8310 }, [store]);
8311 const handleMeasureLayout = useStableCallback(() => {
8312 currentContainerRef.current?.style.setProperty("animation", "none");
8313 currentContainerRef.current?.style.setProperty("transition", "none");
8314 previousContainerRef.current?.style.setProperty("display", "none");
8315 });
8316 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
8317 currentContainerRef.current?.style.removeProperty("animation");
8318 currentContainerRef.current?.style.removeProperty("transition");
8319 previousContainerRef.current?.style.removeProperty("display");
8320 if (previousDimensions) {
8321 setPreviousContentDimensions(previousDimensions);
8322 }
8323 });
8324 const lastHandledTriggerRef = React33.useRef(null);
8325 useIsoLayoutEffect(() => {
8326 if (!open || !mounted) {
8327 lastHandledTriggerRef.current = null;
8328 }
8329 }, [open, mounted]);
8330 useIsoLayoutEffect(() => {
8331 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
8332 setPreviousContentNode(capturedNodeRef.current);
8333 setShowStartingStyleAttribute(true);
8334 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
8335 setNewTriggerOffset(offset4);
8336 cleanupFrame.request(() => {
8337 ReactDOM6.flushSync(() => {
8338 setShowStartingStyleAttribute(false);
8339 });
8340 onAnimationsFinished(() => {
8341 setPreviousContentNode(null);
8342 setPreviousContentDimensions(null);
8343 capturedNodeRef.current = null;
8344 });
8345 });
8346 lastHandledTriggerRef.current = activeTrigger;
8347 }
8348 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
8349 useIsoLayoutEffect(() => {
8350 const source = currentContainerRef.current;
8351 if (!source) {
8352 return;
8353 }
8354 const wrapper = ownerDocument(source).createElement("div");
8355 for (const child of Array.from(source.childNodes)) {
8356 wrapper.appendChild(child.cloneNode(true));
8357 }
8358 capturedNodeRef.current = wrapper;
8359 });
8360 const isTransitioning = previousContentNode != null;
8361 let childrenToRender;
8362 if (!isTransitioning) {
8363 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
8364 "data-current": true,
8365 ref: currentContainerRef,
8366 children
8367 }, currentContentKey);
8368 } else {
8369 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(React33.Fragment, {
8370 children: [/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
8371 "data-previous": true,
8372 inert: inertValue(true),
8373 ref: previousContainerRef,
8374 style: {
8375 ...previousContentDimensions ? {
8376 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
8377 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
8378 } : null,
8379 position: "absolute"
8380 },
8381 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
8382 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
8383 "data-current": true,
8384 ref: currentContainerRef,
8385 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
8386 children
8387 }, currentContentKey)]
8388 });
8389 }
8390 useIsoLayoutEffect(() => {
8391 const container = previousContainerRef.current;
8392 if (!container || !previousContentNode) {
8393 return;
8394 }
8395 container.replaceChildren(...Array.from(previousContentNode.childNodes));
8396 }, [previousContentNode]);
8397 usePopupAutoResize({
8398 popupElement,
8399 positionerElement,
8400 mounted,
8401 content: payload,
8402 onMeasureLayout: handleMeasureLayout,
8403 onMeasureLayoutComplete: handleMeasureLayoutComplete,
8404 side,
8405 direction
8406 });
8407 const state = {
8408 activationDirection: getActivationDirection(newTriggerOffset),
8409 transitioning: isTransitioning
8410 };
8411 return {
8412 children: childrenToRender,
8413 state
8414 };
8415 }
8416 function getActivationDirection(offset4) {
8417 if (!offset4) {
8418 return void 0;
8419 }
8420 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
8421 }
8422 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
8423 if (value > tolerance) {
8424 return positiveLabel;
8425 }
8426 if (value < -tolerance) {
8427 return negativeLabel;
8428 }
8429 return "";
8430 }
8431 function calculateRelativePosition(from, to) {
8432 const fromRect = from.getBoundingClientRect();
8433 const toRect = to.getBoundingClientRect();
8434 const fromCenter = {
8435 x: fromRect.left + fromRect.width / 2,
8436 y: fromRect.top + fromRect.height / 2
8437 };
8438 const toCenter = {
8439 x: toRect.left + toRect.width / 2,
8440 y: toRect.top + toRect.height / 2
8441 };
8442 return {
8443 horizontal: toCenter.x - fromCenter.x,
8444 vertical: toCenter.y - fromCenter.y
8445 };
8446 }
8447 function usePopupContentKey(activeTriggerId, payload) {
8448 const [contentKey, setContentKey] = React33.useState(0);
8449 const previousActiveTriggerIdRef = React33.useRef(activeTriggerId);
8450 const previousPayloadRef = React33.useRef(payload);
8451 const pendingPayloadUpdateRef = React33.useRef(false);
8452 useIsoLayoutEffect(() => {
8453 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
8454 const previousPayload = previousPayloadRef.current;
8455 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
8456 const payloadChanged = payload !== previousPayload;
8457 if (triggerIdChanged) {
8458 setContentKey((value) => value + 1);
8459 pendingPayloadUpdateRef.current = !payloadChanged;
8460 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
8461 setContentKey((value) => value + 1);
8462 pendingPayloadUpdateRef.current = false;
8463 }
8464 previousActiveTriggerIdRef.current = activeTriggerId;
8465 previousPayloadRef.current = payload;
8466 }, [activeTriggerId, payload]);
8467 return `${activeTriggerId ?? "current"}-${contentKey}`;
8468 }
8469
8470 // node_modules/@base-ui/react/utils/FloatingPortalLite.mjs
8471 var React34 = __toESM(require_react(), 1);
8472 var ReactDOM7 = __toESM(require_react_dom(), 1);
8473 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
8474 var FloatingPortalLite = /* @__PURE__ */ React34.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
8475 const {
8476 children,
8477 container,
8478 className,
8479 render: render4,
8480 style,
8481 ...elementProps
8482 } = componentProps;
8483 const {
8484 portalNode,
8485 portalSubtree
8486 } = useFloatingPortalNode({
8487 container,
8488 ref: forwardedRef,
8489 componentProps,
8490 elementProps
8491 });
8492 if (!portalSubtree && !portalNode) {
8493 return null;
8494 }
8495 return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React34.Fragment, {
8496 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM7.createPortal(children, portalNode)]
8497 });
8498 });
8499 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
8500
8501 // node_modules/@base-ui/react/tooltip/index.parts.mjs
8502 var index_parts_exports = {};
8503 __export(index_parts_exports, {
8504 Arrow: () => TooltipArrow,
8505 Handle: () => TooltipHandle,
8506 Popup: () => TooltipPopup,
8507 Portal: () => TooltipPortal,
8508 Positioner: () => TooltipPositioner,
8509 Provider: () => TooltipProvider,
8510 Root: () => TooltipRoot,
8511 Trigger: () => TooltipTrigger,
8512 Viewport: () => TooltipViewport,
8513 createHandle: () => createTooltipHandle
8514 });
8515
8516 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs
8517 var React37 = __toESM(require_react(), 1);
8518
8519 // node_modules/@base-ui/react/tooltip/root/TooltipRootContext.mjs
8520 var React35 = __toESM(require_react(), 1);
8521 var TooltipRootContext = /* @__PURE__ */ React35.createContext(void 0);
8522 if (true) TooltipRootContext.displayName = "TooltipRootContext";
8523 function useTooltipRootContext(optional) {
8524 const context = React35.useContext(TooltipRootContext);
8525 if (context === void 0 && !optional) {
8526 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
8527 }
8528 return context;
8529 }
8530
8531 // node_modules/@base-ui/react/tooltip/store/TooltipStore.mjs
8532 var React36 = __toESM(require_react(), 1);
8533 var selectors2 = {
8534 ...popupStoreSelectors,
8535 disabled: createSelector((state) => state.disabled),
8536 instantType: createSelector((state) => state.instantType),
8537 isInstantPhase: createSelector((state) => state.isInstantPhase),
8538 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
8539 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
8540 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
8541 closeOnClick: createSelector((state) => state.closeOnClick),
8542 closeDelay: createSelector((state) => state.closeDelay),
8543 hasViewport: createSelector((state) => state.hasViewport)
8544 };
8545 var TooltipStore = class _TooltipStore extends ReactStore {
8546 constructor(initialState, floatingId, nested = false) {
8547 const triggerElements = new PopupTriggerMap();
8548 const state = {
8549 ...createInitialState(),
8550 ...initialState
8551 };
8552 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
8553 super(state, {
8554 popupRef: /* @__PURE__ */ React36.createRef(),
8555 onOpenChange: void 0,
8556 onOpenChangeComplete: void 0,
8557 triggerElements
8558 }, selectors2);
8559 }
8560 setOpen = (nextOpen, eventDetails) => {
8561 applyPopupOpenChange(this, nextOpen, eventDetails, {
8562 extraState: {
8563 openChangeReason: eventDetails.reason
8564 }
8565 });
8566 };
8567 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change.
8568 cancelPendingOpen(event) {
8569 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event));
8570 }
8571 static useStore(externalStore, initialState) {
8572 const store = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store;
8573 return store;
8574 }
8575 };
8576 function createInitialState() {
8577 return {
8578 ...createInitialPopupStoreState(),
8579 disabled: false,
8580 instantType: void 0,
8581 isInstantPhase: false,
8582 trackCursorAxis: "none",
8583 disableHoverablePopup: false,
8584 openChangeReason: null,
8585 closeOnClick: true,
8586 closeDelay: 0,
8587 hasViewport: false
8588 };
8589 }
8590
8591 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs
8592 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
8593 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
8594 const {
8595 disabled: disabled2 = false,
8596 defaultOpen = false,
8597 open: openProp,
8598 disableHoverablePopup = false,
8599 trackCursorAxis = "none",
8600 actionsRef,
8601 onOpenChange,
8602 onOpenChangeComplete,
8603 handle,
8604 triggerId: triggerIdProp,
8605 defaultTriggerId: defaultTriggerIdProp = null,
8606 children
8607 } = props;
8608 const store = TooltipStore.useStore(handle?.store, {
8609 open: defaultOpen,
8610 openProp,
8611 activeTriggerId: defaultTriggerIdProp,
8612 triggerIdProp
8613 });
8614 useInitialOpenSync(store, openProp, defaultOpen, defaultTriggerIdProp);
8615 store.useControlledProp("openProp", openProp);
8616 store.useControlledProp("triggerIdProp", triggerIdProp);
8617 store.useContextCallback("onOpenChange", onOpenChange);
8618 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
8619 const openState = store.useState("open");
8620 const open = !disabled2 && openState;
8621 const activeTriggerId = store.useState("activeTriggerId");
8622 const mounted = store.useState("mounted");
8623 const payload = store.useState("payload");
8624 store.useSyncedValues({
8625 trackCursorAxis,
8626 disableHoverablePopup
8627 });
8628 store.useSyncedValue("disabled", disabled2);
8629 useImplicitActiveTrigger(store, {
8630 closeOnActiveTriggerUnmount: true
8631 });
8632 const {
8633 forceUnmount,
8634 transitionStatus
8635 } = useOpenStateTransitions(open, store);
8636 const isInstantPhase = store.useState("isInstantPhase");
8637 const instantType = store.useState("instantType");
8638 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
8639 const previousInstantTypeRef = React37.useRef(null);
8640 useIsoLayoutEffect(() => {
8641 if (openState && disabled2) {
8642 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
8643 }
8644 }, [openState, disabled2, store]);
8645 useIsoLayoutEffect(() => {
8646 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
8647 if (instantType !== "delay") {
8648 previousInstantTypeRef.current = instantType;
8649 }
8650 store.set("instantType", "delay");
8651 } else if (previousInstantTypeRef.current !== null) {
8652 store.set("instantType", previousInstantTypeRef.current);
8653 previousInstantTypeRef.current = null;
8654 }
8655 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
8656 useIsoLayoutEffect(() => {
8657 if (open) {
8658 if (activeTriggerId == null) {
8659 store.set("payload", void 0);
8660 }
8661 }
8662 }, [store, activeTriggerId, open]);
8663 const handleImperativeClose = React37.useCallback(() => {
8664 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
8665 }, [store]);
8666 React37.useImperativeHandle(actionsRef, () => ({
8667 unmount: forceUnmount,
8668 close: handleImperativeClose
8669 }), [forceUnmount, handleImperativeClose]);
8670 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none";
8671 return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(TooltipRootContext.Provider, {
8672 value: store,
8673 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TooltipInteractions, {
8674 store,
8675 disabled: disabled2,
8676 trackCursorAxis
8677 }), typeof children === "function" ? children({
8678 payload
8679 }) : children]
8680 });
8681 });
8682 if (true) TooltipRoot.displayName = "TooltipRoot";
8683 function TooltipInteractions({
8684 store,
8685 disabled: disabled2,
8686 trackCursorAxis
8687 }) {
8688 const floatingRootContext = store.useState("floatingRootContext");
8689 const dismiss = useDismiss(floatingRootContext, {
8690 enabled: !disabled2,
8691 referencePress: () => store.select("closeOnClick")
8692 });
8693 const clientPoint = useClientPoint(floatingRootContext, {
8694 enabled: !disabled2 && trackCursorAxis !== "none",
8695 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
8696 });
8697 const activeTriggerProps = React37.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]);
8698 const inactiveTriggerProps = React37.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]);
8699 const popupProps = React37.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]);
8700 usePopupInteractionProps(store, {
8701 activeTriggerProps,
8702 inactiveTriggerProps,
8703 popupProps
8704 });
8705 return null;
8706 }
8707
8708 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs
8709 var React39 = __toESM(require_react(), 1);
8710
8711 // node_modules/@base-ui/react/tooltip/provider/TooltipProviderContext.mjs
8712 var React38 = __toESM(require_react(), 1);
8713 var TooltipProviderContext = /* @__PURE__ */ React38.createContext(void 0);
8714 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
8715 function useTooltipProviderContext() {
8716 return React38.useContext(TooltipProviderContext);
8717 }
8718
8719 // node_modules/@base-ui/react/tooltip/trigger/TooltipTriggerDataAttributes.mjs
8720 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
8721 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
8722 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
8723 return TooltipTriggerDataAttributes2;
8724 })({});
8725
8726 // node_modules/@base-ui/react/tooltip/utils/constants.mjs
8727 var OPEN_DELAY = 600;
8728
8729 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs
8730 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger";
8731 function getTargetElement(event) {
8732 if ("composedPath" in event) {
8733 const path = event.composedPath();
8734 for (let i2 = 0; i2 < path.length; i2 += 1) {
8735 const element = path[i2];
8736 if (isElement(element)) {
8737 return element;
8738 }
8739 }
8740 }
8741 const target = event.target;
8742 if (isElement(target)) {
8743 return target;
8744 }
8745 return null;
8746 }
8747 function closestEnabledTooltipTrigger(element) {
8748 let current = element;
8749 while (current) {
8750 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) {
8751 return current;
8752 }
8753 const parentElement = current.parentElement;
8754 if (parentElement) {
8755 current = parentElement;
8756 continue;
8757 }
8758 const root = current.getRootNode();
8759 current = "host" in root && isElement(root.host) ? root.host : null;
8760 }
8761 return null;
8762 }
8763 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
8764 const {
8765 render: render4,
8766 className,
8767 style,
8768 handle,
8769 payload,
8770 disabled: disabledProp,
8771 delay,
8772 closeOnClick = true,
8773 closeDelay,
8774 id: idProp,
8775 ...elementProps
8776 } = componentProps;
8777 const rootContext = useTooltipRootContext(true);
8778 const store = handle?.store ?? rootContext;
8779 if (!store) {
8780 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));
8781 }
8782 const thisTriggerId = useBaseUiId(idProp);
8783 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
8784 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
8785 const floatingRootContext = store.useState("floatingRootContext");
8786 const triggerElementRef = React39.useRef(null);
8787 const delayWithDefault = delay ?? OPEN_DELAY;
8788 const closeDelayWithDefault = closeDelay ?? 0;
8789 const {
8790 registerTrigger,
8791 isMountedByThisTrigger
8792 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
8793 payload,
8794 closeOnClick,
8795 closeDelay: closeDelayWithDefault
8796 });
8797 const providerContext = useTooltipProviderContext();
8798 const {
8799 delayRef,
8800 isInstantPhase,
8801 hasProvider
8802 } = useDelayGroup(floatingRootContext, {
8803 open: isOpenedByThisTrigger
8804 });
8805 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext);
8806 store.useSyncedValue("isInstantPhase", isInstantPhase);
8807 const rootDisabled = store.useState("disabled");
8808 const disabled2 = disabledProp ?? rootDisabled;
8809 const disabledRef = useValueAsRef(disabled2);
8810 const trackCursorAxis = store.useState("trackCursorAxis");
8811 const disableHoverablePopup = store.useState("disableHoverablePopup");
8812 const isNestedTriggerHoveredRef = React39.useRef(false);
8813 const nestedTriggerOpenTimeout = useTimeout();
8814 const pointerTypeRef = React39.useRef(void 0);
8815 function getOpenDelay() {
8816 const providerDelay = providerContext?.delay;
8817 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
8818 let computedOpenDelay = delayWithDefault;
8819 if (hasProvider) {
8820 if (groupOpenValue !== 0) {
8821 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault;
8822 } else {
8823 computedOpenDelay = 0;
8824 }
8825 }
8826 return computedOpenDelay;
8827 }
8828 function isEnabledNestedTriggerTarget(target) {
8829 const triggerEl = triggerElementRef.current;
8830 if (!triggerEl || !target) {
8831 return false;
8832 }
8833 const nearestTrigger = closestEnabledTooltipTrigger(target);
8834 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger);
8835 }
8836 function detectNestedTriggerHover(target) {
8837 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target);
8838 isNestedTriggerHoveredRef.current = nestedTriggerHovered;
8839 if (nestedTriggerHovered) {
8840 hoverInteraction.openChangeTimeout.clear();
8841 hoverInteraction.restTimeout.clear();
8842 hoverInteraction.restTimeoutPending = false;
8843 nestedTriggerOpenTimeout.clear();
8844 }
8845 return nestedTriggerHovered;
8846 }
8847 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
8848 enabled: !disabled2,
8849 mouseOnly: true,
8850 move: false,
8851 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
8852 restMs: getOpenDelay,
8853 delay() {
8854 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
8855 let computedCloseDelay = closeDelayWithDefault;
8856 if (closeDelay == null && hasProvider) {
8857 computedCloseDelay = closeValue;
8858 }
8859 return {
8860 close: computedCloseDelay
8861 };
8862 },
8863 triggerElementRef,
8864 isActiveTrigger: isTriggerActive,
8865 isClosing: () => store.select("transitionStatus") === "ending",
8866 shouldOpen() {
8867 return !isNestedTriggerHoveredRef.current;
8868 }
8869 });
8870 const focusProps = useFocus(floatingRootContext, {
8871 enabled: !disabled2
8872 }).reference;
8873 const handleNestedTriggerHover = (event) => {
8874 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current;
8875 const target = getTargetElement(event);
8876 const nestedTriggerHovered = detectNestedTriggerHover(target);
8877 const triggerEl = triggerElementRef.current;
8878 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target);
8879 if (nestedTriggerHovered && store.select("open") && store.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) {
8880 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
8881 return;
8882 }
8883 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences.
8884 isMouseLikePointerType(pointerTypeRef.current)) {
8885 const open = () => {
8886 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store.select("open")) {
8887 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl));
8888 }
8889 };
8890 const openDelay = getOpenDelay();
8891 if (openDelay === 0) {
8892 nestedTriggerOpenTimeout.clear();
8893 open();
8894 } else {
8895 nestedTriggerOpenTimeout.start(openDelay, open);
8896 }
8897 }
8898 };
8899 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
8900 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none";
8901 const state = {
8902 open: isOpenedByThisTrigger
8903 };
8904 const element = useRenderElement("button", componentProps, {
8905 state,
8906 ref: [forwardedRef, registerTrigger, triggerElementRef],
8907 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, {
8908 onMouseOver(event) {
8909 handleNestedTriggerHover(event.nativeEvent);
8910 },
8911 onFocus(event) {
8912 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) {
8913 event.preventBaseUIHandler();
8914 }
8915 },
8916 onMouseLeave() {
8917 isNestedTriggerHoveredRef.current = false;
8918 nestedTriggerOpenTimeout.clear();
8919 pointerTypeRef.current = void 0;
8920 },
8921 onPointerEnter(event) {
8922 pointerTypeRef.current = event.pointerType;
8923 },
8924 onPointerDown(event) {
8925 pointerTypeRef.current = event.pointerType;
8926 store.set("closeOnClick", closeOnClick);
8927 if (closeOnClick && !store.select("open")) {
8928 store.cancelPendingOpen(event.nativeEvent);
8929 }
8930 },
8931 onClick(event) {
8932 if (closeOnClick && !store.select("open")) {
8933 store.cancelPendingOpen(event.nativeEvent);
8934 }
8935 },
8936 id: thisTriggerId,
8937 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0,
8938 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : ""
8939 }, elementProps],
8940 stateAttributesMapping: triggerOpenStateMapping
8941 });
8942 return element;
8943 });
8944 if (true) TooltipTrigger.displayName = "TooltipTrigger";
8945
8946 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs
8947 var React41 = __toESM(require_react(), 1);
8948
8949 // node_modules/@base-ui/react/tooltip/portal/TooltipPortalContext.mjs
8950 var React40 = __toESM(require_react(), 1);
8951 var TooltipPortalContext = /* @__PURE__ */ React40.createContext(void 0);
8952 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
8953 function useTooltipPortalContext() {
8954 const value = React40.useContext(TooltipPortalContext);
8955 if (value === void 0) {
8956 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
8957 }
8958 return value;
8959 }
8960
8961 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs
8962 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
8963 var TooltipPortal = /* @__PURE__ */ React41.forwardRef(function TooltipPortal2(props, forwardedRef) {
8964 const {
8965 keepMounted = false,
8966 ...portalProps
8967 } = props;
8968 const store = useTooltipRootContext();
8969 const mounted = store.useState("mounted");
8970 const shouldRender = mounted || keepMounted;
8971 if (!shouldRender) {
8972 return null;
8973 }
8974 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipPortalContext.Provider, {
8975 value: keepMounted,
8976 children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FloatingPortalLite, {
8977 ref: forwardedRef,
8978 ...portalProps
8979 })
8980 });
8981 });
8982 if (true) TooltipPortal.displayName = "TooltipPortal";
8983
8984 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs
8985 var React43 = __toESM(require_react(), 1);
8986
8987 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositionerContext.mjs
8988 var React42 = __toESM(require_react(), 1);
8989 var TooltipPositionerContext = /* @__PURE__ */ React42.createContext(void 0);
8990 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
8991 function useTooltipPositionerContext() {
8992 const context = React42.useContext(TooltipPositionerContext);
8993 if (context === void 0) {
8994 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
8995 }
8996 return context;
8997 }
8998
8999 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs
9000 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
9001 var TooltipPositioner = /* @__PURE__ */ React43.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
9002 const {
9003 render: render4,
9004 className,
9005 anchor,
9006 positionMethod = "absolute",
9007 side = "top",
9008 align = "center",
9009 sideOffset = 0,
9010 alignOffset = 0,
9011 collisionBoundary = "clipping-ancestors",
9012 collisionPadding = 5,
9013 arrowPadding = 5,
9014 sticky = false,
9015 disableAnchorTracking = false,
9016 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
9017 style,
9018 ...elementProps
9019 } = componentProps;
9020 const store = useTooltipRootContext();
9021 const keepMounted = useTooltipPortalContext();
9022 const open = store.useState("open");
9023 const mounted = store.useState("mounted");
9024 const trackCursorAxis = store.useState("trackCursorAxis");
9025 const disableHoverablePopup = store.useState("disableHoverablePopup");
9026 const floatingRootContext = store.useState("floatingRootContext");
9027 const instantType = store.useState("instantType");
9028 const transitionStatus = store.useState("transitionStatus");
9029 const hasViewport = store.useState("hasViewport");
9030 const positioning = useAnchorPositioning({
9031 anchor,
9032 positionMethod,
9033 floatingRootContext,
9034 mounted,
9035 side,
9036 sideOffset,
9037 align,
9038 alignOffset,
9039 collisionBoundary,
9040 collisionPadding,
9041 sticky,
9042 arrowPadding,
9043 disableAnchorTracking,
9044 keepMounted,
9045 collisionAvoidance,
9046 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
9047 });
9048 const state = React43.useMemo(() => ({
9049 open,
9050 side: positioning.side,
9051 align: positioning.align,
9052 anchorHidden: positioning.anchorHidden,
9053 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
9054 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
9055 const element = usePositioner(componentProps, state, {
9056 styles: positioning.positionerStyles,
9057 transitionStatus,
9058 props: elementProps,
9059 refs: [forwardedRef, store.useStateSetter("positionerElement")],
9060 hidden: !mounted,
9061 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
9062 });
9063 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPositionerContext.Provider, {
9064 value: positioning,
9065 children: element
9066 });
9067 });
9068 if (true) TooltipPositioner.displayName = "TooltipPositioner";
9069
9070 // node_modules/@base-ui/react/tooltip/popup/TooltipPopup.mjs
9071 var React44 = __toESM(require_react(), 1);
9072 var stateAttributesMapping = {
9073 ...popupStateMapping,
9074 ...transitionStatusMapping
9075 };
9076 var TooltipPopup = /* @__PURE__ */ React44.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
9077 const {
9078 render: render4,
9079 className,
9080 style,
9081 ...elementProps
9082 } = componentProps;
9083 const store = useTooltipRootContext();
9084 const {
9085 side,
9086 align
9087 } = useTooltipPositionerContext();
9088 const open = store.useState("open");
9089 const instantType = store.useState("instantType");
9090 const transitionStatus = store.useState("transitionStatus");
9091 const popupProps = store.useState("popupProps");
9092 const floatingContext = store.useState("floatingRootContext");
9093 const disabled2 = store.useState("disabled");
9094 const closeDelay = store.useState("closeDelay");
9095 useOpenChangeComplete({
9096 open,
9097 ref: store.context.popupRef,
9098 onComplete() {
9099 if (open) {
9100 store.context.onOpenChangeComplete?.(true);
9101 }
9102 }
9103 });
9104 useHoverFloatingInteraction(floatingContext, {
9105 enabled: !disabled2,
9106 closeDelay
9107 });
9108 const setPopupElement = store.useStateSetter("popupElement");
9109 const state = {
9110 open,
9111 side,
9112 align,
9113 instant: instantType,
9114 transitionStatus
9115 };
9116 const element = useRenderElement("div", componentProps, {
9117 state,
9118 ref: [forwardedRef, store.context.popupRef, setPopupElement],
9119 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
9120 stateAttributesMapping
9121 });
9122 return element;
9123 });
9124 if (true) TooltipPopup.displayName = "TooltipPopup";
9125
9126 // node_modules/@base-ui/react/tooltip/arrow/TooltipArrow.mjs
9127 var React45 = __toESM(require_react(), 1);
9128 var TooltipArrow = /* @__PURE__ */ React45.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
9129 const {
9130 render: render4,
9131 className,
9132 style,
9133 ...elementProps
9134 } = componentProps;
9135 const store = useTooltipRootContext();
9136 const {
9137 arrowRef,
9138 side,
9139 align,
9140 arrowUncentered,
9141 arrowStyles
9142 } = useTooltipPositionerContext();
9143 const open = store.useState("open");
9144 const instantType = store.useState("instantType");
9145 const state = {
9146 open,
9147 side,
9148 align,
9149 uncentered: arrowUncentered,
9150 instant: instantType
9151 };
9152 const element = useRenderElement("div", componentProps, {
9153 state,
9154 ref: [forwardedRef, arrowRef],
9155 props: [{
9156 style: arrowStyles,
9157 "aria-hidden": true
9158 }, elementProps],
9159 stateAttributesMapping: popupStateMapping
9160 });
9161 return element;
9162 });
9163 if (true) TooltipArrow.displayName = "TooltipArrow";
9164
9165 // node_modules/@base-ui/react/tooltip/provider/TooltipProvider.mjs
9166 var React46 = __toESM(require_react(), 1);
9167 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
9168 var TooltipProvider = function TooltipProvider2(props) {
9169 const {
9170 delay,
9171 closeDelay,
9172 timeout = 400
9173 } = props;
9174 const contextValue = React46.useMemo(() => ({
9175 delay,
9176 closeDelay
9177 }), [delay, closeDelay]);
9178 const delayValue = React46.useMemo(() => ({
9179 open: delay,
9180 close: closeDelay
9181 }), [delay, closeDelay]);
9182 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipProviderContext.Provider, {
9183 value: contextValue,
9184 children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FloatingDelayGroup, {
9185 delay: delayValue,
9186 timeoutMs: timeout,
9187 children: props.children
9188 })
9189 });
9190 };
9191 if (true) TooltipProvider.displayName = "TooltipProvider";
9192
9193 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs
9194 var React47 = __toESM(require_react(), 1);
9195
9196 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewportCssVars.mjs
9197 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
9198 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
9199 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
9200 return TooltipViewportCssVars2;
9201 })({});
9202
9203 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs
9204 var stateAttributesMapping2 = {
9205 activationDirection: (value) => value ? {
9206 "data-activation-direction": value
9207 } : null
9208 };
9209 var TooltipViewport = /* @__PURE__ */ React47.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
9210 const {
9211 render: render4,
9212 className,
9213 style,
9214 children,
9215 ...elementProps
9216 } = componentProps;
9217 const store = useTooltipRootContext();
9218 const positioner = useTooltipPositionerContext();
9219 const instantType = store.useState("instantType");
9220 const {
9221 children: childrenToRender,
9222 state: viewportState
9223 } = usePopupViewport({
9224 store,
9225 side: positioner.side,
9226 cssVars: TooltipViewportCssVars,
9227 children
9228 });
9229 const state = {
9230 activationDirection: viewportState.activationDirection,
9231 transitioning: viewportState.transitioning,
9232 instant: instantType
9233 };
9234 return useRenderElement("div", componentProps, {
9235 state,
9236 ref: forwardedRef,
9237 props: [elementProps, {
9238 children: childrenToRender
9239 }],
9240 stateAttributesMapping: stateAttributesMapping2
9241 });
9242 });
9243 if (true) TooltipViewport.displayName = "TooltipViewport";
9244
9245 // node_modules/@base-ui/react/tooltip/store/TooltipHandle.mjs
9246 var TooltipHandle = class {
9247 /**
9248 * Internal store holding the tooltip state.
9249 * @internal
9250 */
9251 constructor() {
9252 this.store = new TooltipStore();
9253 }
9254 /**
9255 * Opens the tooltip and associates it with the trigger with the given ID.
9256 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
9257 *
9258 * This method should only be called in an event handler or an effect (not during rendering).
9259 *
9260 * @param triggerId ID of the trigger to associate with the tooltip.
9261 */
9262 open(triggerId) {
9263 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
9264 if (triggerId && !triggerElement) {
9265 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
9266 }
9267 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
9268 }
9269 /**
9270 * Closes the tooltip.
9271 */
9272 close() {
9273 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
9274 }
9275 /**
9276 * Indicates whether the tooltip is currently open.
9277 */
9278 get isOpen() {
9279 return this.store.select("open");
9280 }
9281 };
9282 function createTooltipHandle() {
9283 return new TooltipHandle();
9284 }
9285
9286 // node_modules/@base-ui/react/use-render/useRender.mjs
9287 function useRender(params) {
9288 return useRenderElement(params.defaultTagName ?? "div", params, params);
9289 }
9290
9291 // packages/ui/build-module/text/text.mjs
9292 var import_element11 = __toESM(require_element(), 1);
9293 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
9294 function getRuntime() {
9295 const globalScope = globalThis;
9296 if (globalScope.__wpStyleRuntime) {
9297 return globalScope.__wpStyleRuntime;
9298 }
9299 globalScope.__wpStyleRuntime = {
9300 documents: /* @__PURE__ */ new Map(),
9301 styles: /* @__PURE__ */ new Map(),
9302 injectedStyles: /* @__PURE__ */ new WeakMap()
9303 };
9304 if (typeof document !== "undefined") {
9305 registerDocument(document);
9306 }
9307 return globalScope.__wpStyleRuntime;
9308 }
9309 function documentContainsStyleHash(targetDocument, hash) {
9310 if (!targetDocument.head) {
9311 return false;
9312 }
9313 for (const style of targetDocument.head.querySelectorAll(
9314 `style[${STYLE_HASH_ATTRIBUTE}]`
9315 )) {
9316 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
9317 return true;
9318 }
9319 }
9320 return false;
9321 }
9322 function injectStyle(targetDocument, hash, css) {
9323 if (!targetDocument.head) {
9324 return;
9325 }
9326 const runtime = getRuntime();
9327 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9328 if (!injectedStyles) {
9329 injectedStyles = /* @__PURE__ */ new Set();
9330 runtime.injectedStyles.set(targetDocument, injectedStyles);
9331 }
9332 if (injectedStyles.has(hash)) {
9333 return;
9334 }
9335 if (documentContainsStyleHash(targetDocument, hash)) {
9336 injectedStyles.add(hash);
9337 return;
9338 }
9339 const style = targetDocument.createElement("style");
9340 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
9341 style.appendChild(targetDocument.createTextNode(css));
9342 targetDocument.head.appendChild(style);
9343 injectedStyles.add(hash);
9344 }
9345 function registerDocument(targetDocument) {
9346 const runtime = getRuntime();
9347 runtime.documents.set(
9348 targetDocument,
9349 (runtime.documents.get(targetDocument) ?? 0) + 1
9350 );
9351 for (const [hash, css] of runtime.styles) {
9352 injectStyle(targetDocument, hash, css);
9353 }
9354 return () => {
9355 const count = runtime.documents.get(targetDocument);
9356 if (count === void 0) {
9357 return;
9358 }
9359 if (count <= 1) {
9360 runtime.documents.delete(targetDocument);
9361 return;
9362 }
9363 runtime.documents.set(targetDocument, count - 1);
9364 };
9365 }
9366 function registerStyle(hash, css) {
9367 const runtime = getRuntime();
9368 runtime.styles.set(hash, css);
9369 for (const targetDocument of runtime.documents.keys()) {
9370 injectStyle(targetDocument, hash, css);
9371 }
9372 }
9373 if (typeof process === "undefined" || true) {
9374 registerStyle("a495f9d138", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._83ed8a8da5dd50ea__text{margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-p-line-height:var(--wpds-typography-line-height-2xl,40px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-emphasis,600)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-default,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-default,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}}');
9375 }
9376 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" };
9377 if (typeof process === "undefined" || true) {
9378 registerStyle("af6d9984a6", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}");
9379 }
9380 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" };
9381 var Text = (0, import_element11.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
9382 const element = useRender({
9383 render: render4,
9384 defaultTagName: "span",
9385 ref,
9386 props: mergeProps(props, {
9387 className: clsx_default(
9388 style_default.text,
9389 global_css_defense_default.heading,
9390 global_css_defense_default.p,
9391 style_default[variant],
9392 className
9393 )
9394 })
9395 });
9396 return element;
9397 });
9398
9399 // packages/icons/build-module/library/arrow-down.mjs
9400 var import_primitives = __toESM(require_primitives(), 1);
9401 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
9402 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", fill: "currentColor", 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" }) });
9403
9404 // packages/icons/build-module/library/arrow-left.mjs
9405 var import_primitives2 = __toESM(require_primitives(), 1);
9406 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
9407 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", fill: "currentColor", 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" }) });
9408
9409 // packages/icons/build-module/library/arrow-right.mjs
9410 var import_primitives3 = __toESM(require_primitives(), 1);
9411 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
9412 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", fill: "currentColor", 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" }) });
9413
9414 // packages/icons/build-module/library/arrow-up.mjs
9415 var import_primitives4 = __toESM(require_primitives(), 1);
9416 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
9417 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", fill: "currentColor", 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" }) });
9418
9419 // packages/icons/build-module/library/block-table.mjs
9420 var import_primitives5 = __toESM(require_primitives(), 1);
9421 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
9422 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", fill: "currentColor", 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" }) });
9423
9424 // packages/icons/build-module/library/category.mjs
9425 var import_primitives6 = __toESM(require_primitives(), 1);
9426 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
9427 var category_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives6.Path, { 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" }) });
9428
9429 // packages/icons/build-module/library/check.mjs
9430 var import_primitives7 = __toESM(require_primitives(), 1);
9431 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
9432 var check_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives7.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
9433
9434 // packages/icons/build-module/library/close-small.mjs
9435 var import_primitives8 = __toESM(require_primitives(), 1);
9436 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
9437 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", fill: "currentColor", 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" }) });
9438
9439 // packages/icons/build-module/library/cog.mjs
9440 var import_primitives9 = __toESM(require_primitives(), 1);
9441 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
9442 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives9.Path, { 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" }) });
9443
9444 // packages/icons/build-module/library/envelope.mjs
9445 var import_primitives10 = __toESM(require_primitives(), 1);
9446 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
9447 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives10.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "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" }) });
9448
9449 // packages/icons/build-module/library/error.mjs
9450 var import_primitives11 = __toESM(require_primitives(), 1);
9451 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
9452 var error_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives11.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "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" }) });
9453
9454 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
9455 var import_primitives12 = __toESM(require_primitives(), 1);
9456 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
9457 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", fill: "currentColor", 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" }) });
9458
9459 // packages/icons/build-module/library/format-list-bullets.mjs
9460 var import_primitives13 = __toESM(require_primitives(), 1);
9461 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
9462 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", fill: "currentColor", 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" }) });
9463
9464 // packages/icons/build-module/library/funnel.mjs
9465 var import_primitives14 = __toESM(require_primitives(), 1);
9466 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
9467 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives14.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
9468
9469 // packages/icons/build-module/library/link.mjs
9470 var import_primitives15 = __toESM(require_primitives(), 1);
9471 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
9472 var link_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives15.Path, { d: "M10 17.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" }) });
9473
9474 // packages/icons/build-module/library/mobile.mjs
9475 var import_primitives16 = __toESM(require_primitives(), 1);
9476 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
9477 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives16.Path, { d: "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" }) });
9478
9479 // packages/icons/build-module/library/more-vertical.mjs
9480 var import_primitives17 = __toESM(require_primitives(), 1);
9481 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
9482 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", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives17.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
9483
9484 // packages/icons/build-module/library/next.mjs
9485 var import_primitives18 = __toESM(require_primitives(), 1);
9486 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
9487 var next_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives18.Path, { d: "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" }) });
9488
9489 // packages/icons/build-module/library/previous.mjs
9490 var import_primitives19 = __toESM(require_primitives(), 1);
9491 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
9492 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives19.Path, { d: "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" }) });
9493
9494 // packages/icons/build-module/library/scheduled.mjs
9495 var import_primitives20 = __toESM(require_primitives(), 1);
9496 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
9497 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives20.Path, { 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" }) });
9498
9499 // packages/icons/build-module/library/search.mjs
9500 var import_primitives21 = __toESM(require_primitives(), 1);
9501 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
9502 var search_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives21.Path, { d: "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" }) });
9503
9504 // packages/icons/build-module/library/seen.mjs
9505 var import_primitives22 = __toESM(require_primitives(), 1);
9506 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
9507 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives22.Path, { d: "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" }) });
9508
9509 // packages/icons/build-module/library/unseen.mjs
9510 var import_primitives23 = __toESM(require_primitives(), 1);
9511 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
9512 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives23.Path, { 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" }) });
9513
9514 // packages/ui/build-module/utils/render-slot-with-children.mjs
9515 var import_element12 = __toESM(require_element(), 1);
9516 function renderSlotWithChildren(slot, defaultSlot, children) {
9517 return (0, import_element12.cloneElement)(slot ?? defaultSlot, { children });
9518 }
9519
9520 // packages/ui/build-module/utils/theme-provider.mjs
9521 var theme = __toESM(require_theme(), 1);
9522
9523 // packages/ui/build-module/lock-unlock.mjs
9524 var import_private_apis2 = __toESM(require_private_apis(), 1);
9525 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
9526 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
9527 "@wordpress/ui"
9528 );
9529
9530 // packages/ui/build-module/utils/theme-provider.mjs
9531 function getThemeProvider() {
9532 const themePackage = theme;
9533 if (themePackage.ThemeProvider) {
9534 return themePackage.ThemeProvider;
9535 }
9536 if (!themePackage.privateApis) {
9537 throw new Error(
9538 "@wordpress/ui: @wordpress/theme must expose `ThemeProvider` or `privateApis.ThemeProvider`."
9539 );
9540 }
9541 return unlock2(
9542 themePackage.privateApis
9543 ).ThemeProvider;
9544 }
9545 var ThemeProvider = getThemeProvider();
9546
9547 // packages/ui/build-module/stack/stack.mjs
9548 var import_element13 = __toESM(require_element(), 1);
9549 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
9550 function getRuntime2() {
9551 const globalScope = globalThis;
9552 if (globalScope.__wpStyleRuntime) {
9553 return globalScope.__wpStyleRuntime;
9554 }
9555 globalScope.__wpStyleRuntime = {
9556 documents: /* @__PURE__ */ new Map(),
9557 styles: /* @__PURE__ */ new Map(),
9558 injectedStyles: /* @__PURE__ */ new WeakMap()
9559 };
9560 if (typeof document !== "undefined") {
9561 registerDocument2(document);
9562 }
9563 return globalScope.__wpStyleRuntime;
9564 }
9565 function documentContainsStyleHash2(targetDocument, hash) {
9566 if (!targetDocument.head) {
9567 return false;
9568 }
9569 for (const style of targetDocument.head.querySelectorAll(
9570 `style[${STYLE_HASH_ATTRIBUTE2}]`
9571 )) {
9572 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
9573 return true;
9574 }
9575 }
9576 return false;
9577 }
9578 function injectStyle2(targetDocument, hash, css) {
9579 if (!targetDocument.head) {
9580 return;
9581 }
9582 const runtime = getRuntime2();
9583 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9584 if (!injectedStyles) {
9585 injectedStyles = /* @__PURE__ */ new Set();
9586 runtime.injectedStyles.set(targetDocument, injectedStyles);
9587 }
9588 if (injectedStyles.has(hash)) {
9589 return;
9590 }
9591 if (documentContainsStyleHash2(targetDocument, hash)) {
9592 injectedStyles.add(hash);
9593 return;
9594 }
9595 const style = targetDocument.createElement("style");
9596 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
9597 style.appendChild(targetDocument.createTextNode(css));
9598 targetDocument.head.appendChild(style);
9599 injectedStyles.add(hash);
9600 }
9601 function registerDocument2(targetDocument) {
9602 const runtime = getRuntime2();
9603 runtime.documents.set(
9604 targetDocument,
9605 (runtime.documents.get(targetDocument) ?? 0) + 1
9606 );
9607 for (const [hash, css] of runtime.styles) {
9608 injectStyle2(targetDocument, hash, css);
9609 }
9610 return () => {
9611 const count = runtime.documents.get(targetDocument);
9612 if (count === void 0) {
9613 return;
9614 }
9615 if (count <= 1) {
9616 runtime.documents.delete(targetDocument);
9617 return;
9618 }
9619 runtime.documents.set(targetDocument, count - 1);
9620 };
9621 }
9622 function registerStyle2(hash, css) {
9623 const runtime = getRuntime2();
9624 runtime.styles.set(hash, css);
9625 for (const targetDocument of runtime.documents.keys()) {
9626 injectStyle2(targetDocument, hash, css);
9627 }
9628 }
9629 if (typeof process === "undefined" || true) {
9630 registerStyle2("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}");
9631 }
9632 var style_default2 = { "stack": "_19ce0419607e1896__stack" };
9633 var gapTokens = {
9634 xs: "var(--wpds-dimension-gap-xs, 4px)",
9635 sm: "var(--wpds-dimension-gap-sm, 8px)",
9636 md: "var(--wpds-dimension-gap-md, 12px)",
9637 lg: "var(--wpds-dimension-gap-lg, 16px)",
9638 xl: "var(--wpds-dimension-gap-xl, 24px)",
9639 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
9640 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
9641 };
9642 var Stack = (0, import_element13.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
9643 const style = {
9644 gap: gap && gapTokens[gap],
9645 alignItems: align,
9646 justifyContent: justify,
9647 flexDirection: direction,
9648 flexWrap: wrap
9649 };
9650 const element = useRender({
9651 render: render4,
9652 ref,
9653 props: mergeProps(props, { style, className: style_default2.stack })
9654 });
9655 return element;
9656 });
9657
9658 // packages/ui/build-module/tooltip/index.mjs
9659 var tooltip_exports = {};
9660 __export(tooltip_exports, {
9661 Popup: () => Popup,
9662 Portal: () => Portal,
9663 Positioner: () => Positioner,
9664 Provider: () => Provider,
9665 Root: () => Root,
9666 Trigger: () => Trigger
9667 });
9668
9669 // packages/ui/build-module/tooltip/popup.mjs
9670 var import_element16 = __toESM(require_element(), 1);
9671
9672 // packages/ui/build-module/tooltip/portal.mjs
9673 var import_element14 = __toESM(require_element(), 1);
9674
9675 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
9676 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
9677 function getRuntime3() {
9678 const globalScope = globalThis;
9679 if (globalScope.__wpStyleRuntime) {
9680 return globalScope.__wpStyleRuntime;
9681 }
9682 globalScope.__wpStyleRuntime = {
9683 documents: /* @__PURE__ */ new Map(),
9684 styles: /* @__PURE__ */ new Map(),
9685 injectedStyles: /* @__PURE__ */ new WeakMap()
9686 };
9687 if (typeof document !== "undefined") {
9688 registerDocument3(document);
9689 }
9690 return globalScope.__wpStyleRuntime;
9691 }
9692 function documentContainsStyleHash3(targetDocument, hash) {
9693 if (!targetDocument.head) {
9694 return false;
9695 }
9696 for (const style of targetDocument.head.querySelectorAll(
9697 `style[${STYLE_HASH_ATTRIBUTE3}]`
9698 )) {
9699 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
9700 return true;
9701 }
9702 }
9703 return false;
9704 }
9705 function injectStyle3(targetDocument, hash, css) {
9706 if (!targetDocument.head) {
9707 return;
9708 }
9709 const runtime = getRuntime3();
9710 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9711 if (!injectedStyles) {
9712 injectedStyles = /* @__PURE__ */ new Set();
9713 runtime.injectedStyles.set(targetDocument, injectedStyles);
9714 }
9715 if (injectedStyles.has(hash)) {
9716 return;
9717 }
9718 if (documentContainsStyleHash3(targetDocument, hash)) {
9719 injectedStyles.add(hash);
9720 return;
9721 }
9722 const style = targetDocument.createElement("style");
9723 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
9724 style.appendChild(targetDocument.createTextNode(css));
9725 targetDocument.head.appendChild(style);
9726 injectedStyles.add(hash);
9727 }
9728 function registerDocument3(targetDocument) {
9729 const runtime = getRuntime3();
9730 runtime.documents.set(
9731 targetDocument,
9732 (runtime.documents.get(targetDocument) ?? 0) + 1
9733 );
9734 for (const [hash, css] of runtime.styles) {
9735 injectStyle3(targetDocument, hash, css);
9736 }
9737 return () => {
9738 const count = runtime.documents.get(targetDocument);
9739 if (count === void 0) {
9740 return;
9741 }
9742 if (count <= 1) {
9743 runtime.documents.delete(targetDocument);
9744 return;
9745 }
9746 runtime.documents.set(targetDocument, count - 1);
9747 };
9748 }
9749 function registerStyle3(hash, css) {
9750 const runtime = getRuntime3();
9751 runtime.styles.set(hash, css);
9752 for (const targetDocument of runtime.documents.keys()) {
9753 injectStyle3(targetDocument, hash, css);
9754 }
9755 }
9756 if (typeof process === "undefined" || true) {
9757 registerStyle3("be37f31c1e", "._11fc52b637ff8a7e__slot{inset:0;isolation:isolate;pointer-events:none;position:fixed;z-index:1000000003}@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._11fc52b637ff8a7e__slot>*{pointer-events:auto}}}");
9758 }
9759 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
9760 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
9761 function resolveOwnerDocument() {
9762 return typeof document === "undefined" ? null : document;
9763 }
9764 function isInWordPressEnvironment() {
9765 let topWp;
9766 try {
9767 topWp = window.top?.wp;
9768 } catch {
9769 }
9770 const wp = topWp ?? window.wp;
9771 return typeof wp?.components === "object" && wp.components !== null;
9772 }
9773 var cachedSlot = null;
9774 function ensureSlotIsAccessible(element) {
9775 element.setAttribute("aria-hidden", "false");
9776 return element;
9777 }
9778 function createSlot(ownerDocument2) {
9779 const element = ownerDocument2.createElement("div");
9780 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
9781 if (wp_compat_overlay_slot_default.slot) {
9782 element.classList.add(wp_compat_overlay_slot_default.slot);
9783 }
9784 ownerDocument2.body.appendChild(element);
9785 return element;
9786 }
9787 function getWpCompatOverlaySlot() {
9788 if (typeof window === "undefined") {
9789 return void 0;
9790 }
9791 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
9792 return void 0;
9793 }
9794 const ownerDocument2 = resolveOwnerDocument();
9795 if (!ownerDocument2 || !ownerDocument2.body) {
9796 return void 0;
9797 }
9798 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
9799 return ensureSlotIsAccessible(cachedSlot);
9800 }
9801 const existing = ownerDocument2.querySelector(
9802 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
9803 );
9804 if (existing instanceof HTMLDivElement) {
9805 cachedSlot = ensureSlotIsAccessible(existing);
9806 return cachedSlot;
9807 }
9808 if (cachedSlot?.isConnected) {
9809 cachedSlot.remove();
9810 }
9811 cachedSlot = ensureSlotIsAccessible(createSlot(ownerDocument2));
9812 return cachedSlot;
9813 }
9814
9815 // packages/ui/build-module/tooltip/portal.mjs
9816 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
9817 var Portal = (0, import_element14.forwardRef)(
9818 function TooltipPortal3({ container, ...restProps }, ref) {
9819 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
9820 index_parts_exports.Portal,
9821 {
9822 container: container ?? getWpCompatOverlaySlot(),
9823 ...restProps,
9824 ref
9825 }
9826 );
9827 }
9828 );
9829
9830 // packages/ui/build-module/tooltip/positioner.mjs
9831 var import_element15 = __toESM(require_element(), 1);
9832 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
9833 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
9834 function getRuntime4() {
9835 const globalScope = globalThis;
9836 if (globalScope.__wpStyleRuntime) {
9837 return globalScope.__wpStyleRuntime;
9838 }
9839 globalScope.__wpStyleRuntime = {
9840 documents: /* @__PURE__ */ new Map(),
9841 styles: /* @__PURE__ */ new Map(),
9842 injectedStyles: /* @__PURE__ */ new WeakMap()
9843 };
9844 if (typeof document !== "undefined") {
9845 registerDocument4(document);
9846 }
9847 return globalScope.__wpStyleRuntime;
9848 }
9849 function documentContainsStyleHash4(targetDocument, hash) {
9850 if (!targetDocument.head) {
9851 return false;
9852 }
9853 for (const style of targetDocument.head.querySelectorAll(
9854 `style[${STYLE_HASH_ATTRIBUTE4}]`
9855 )) {
9856 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
9857 return true;
9858 }
9859 }
9860 return false;
9861 }
9862 function injectStyle4(targetDocument, hash, css) {
9863 if (!targetDocument.head) {
9864 return;
9865 }
9866 const runtime = getRuntime4();
9867 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9868 if (!injectedStyles) {
9869 injectedStyles = /* @__PURE__ */ new Set();
9870 runtime.injectedStyles.set(targetDocument, injectedStyles);
9871 }
9872 if (injectedStyles.has(hash)) {
9873 return;
9874 }
9875 if (documentContainsStyleHash4(targetDocument, hash)) {
9876 injectedStyles.add(hash);
9877 return;
9878 }
9879 const style = targetDocument.createElement("style");
9880 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
9881 style.appendChild(targetDocument.createTextNode(css));
9882 targetDocument.head.appendChild(style);
9883 injectedStyles.add(hash);
9884 }
9885 function registerDocument4(targetDocument) {
9886 const runtime = getRuntime4();
9887 runtime.documents.set(
9888 targetDocument,
9889 (runtime.documents.get(targetDocument) ?? 0) + 1
9890 );
9891 for (const [hash, css] of runtime.styles) {
9892 injectStyle4(targetDocument, hash, css);
9893 }
9894 return () => {
9895 const count = runtime.documents.get(targetDocument);
9896 if (count === void 0) {
9897 return;
9898 }
9899 if (count <= 1) {
9900 runtime.documents.delete(targetDocument);
9901 return;
9902 }
9903 runtime.documents.set(targetDocument, count - 1);
9904 };
9905 }
9906 function registerStyle4(hash, css) {
9907 const runtime = getRuntime4();
9908 runtime.styles.set(hash, css);
9909 for (const targetDocument of runtime.documents.keys()) {
9910 injectStyle4(targetDocument, hash, css);
9911 }
9912 }
9913 if (typeof process === "undefined" || true) {
9914 registerStyle4("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
9915 }
9916 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
9917 if (typeof process === "undefined" || true) {
9918 registerStyle4("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}');
9919 }
9920 var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9921 var Positioner = (0, import_element15.forwardRef)(
9922 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
9923 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
9924 index_parts_exports.Positioner,
9925 {
9926 ref,
9927 align,
9928 side,
9929 sideOffset,
9930 ...props,
9931 className: clsx_default(
9932 resets_default["box-sizing"],
9933 style_default3.positioner,
9934 className
9935 )
9936 }
9937 );
9938 }
9939 );
9940
9941 // packages/ui/build-module/tooltip/popup.mjs
9942 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
9943 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
9944 function getRuntime5() {
9945 const globalScope = globalThis;
9946 if (globalScope.__wpStyleRuntime) {
9947 return globalScope.__wpStyleRuntime;
9948 }
9949 globalScope.__wpStyleRuntime = {
9950 documents: /* @__PURE__ */ new Map(),
9951 styles: /* @__PURE__ */ new Map(),
9952 injectedStyles: /* @__PURE__ */ new WeakMap()
9953 };
9954 if (typeof document !== "undefined") {
9955 registerDocument5(document);
9956 }
9957 return globalScope.__wpStyleRuntime;
9958 }
9959 function documentContainsStyleHash5(targetDocument, hash) {
9960 if (!targetDocument.head) {
9961 return false;
9962 }
9963 for (const style of targetDocument.head.querySelectorAll(
9964 `style[${STYLE_HASH_ATTRIBUTE5}]`
9965 )) {
9966 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
9967 return true;
9968 }
9969 }
9970 return false;
9971 }
9972 function injectStyle5(targetDocument, hash, css) {
9973 if (!targetDocument.head) {
9974 return;
9975 }
9976 const runtime = getRuntime5();
9977 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9978 if (!injectedStyles) {
9979 injectedStyles = /* @__PURE__ */ new Set();
9980 runtime.injectedStyles.set(targetDocument, injectedStyles);
9981 }
9982 if (injectedStyles.has(hash)) {
9983 return;
9984 }
9985 if (documentContainsStyleHash5(targetDocument, hash)) {
9986 injectedStyles.add(hash);
9987 return;
9988 }
9989 const style = targetDocument.createElement("style");
9990 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
9991 style.appendChild(targetDocument.createTextNode(css));
9992 targetDocument.head.appendChild(style);
9993 injectedStyles.add(hash);
9994 }
9995 function registerDocument5(targetDocument) {
9996 const runtime = getRuntime5();
9997 runtime.documents.set(
9998 targetDocument,
9999 (runtime.documents.get(targetDocument) ?? 0) + 1
10000 );
10001 for (const [hash, css] of runtime.styles) {
10002 injectStyle5(targetDocument, hash, css);
10003 }
10004 return () => {
10005 const count = runtime.documents.get(targetDocument);
10006 if (count === void 0) {
10007 return;
10008 }
10009 if (count <= 1) {
10010 runtime.documents.delete(targetDocument);
10011 return;
10012 }
10013 runtime.documents.set(targetDocument, count - 1);
10014 };
10015 }
10016 function registerStyle5(hash, css) {
10017 const runtime = getRuntime5();
10018 runtime.styles.set(hash, css);
10019 for (const targetDocument of runtime.documents.keys()) {
10020 injectStyle5(targetDocument, hash, css);
10021 }
10022 }
10023 if (typeof process === "undefined" || true) {
10024 registerStyle5("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}');
10025 }
10026 var style_default4 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
10027 var POPUP_COLOR = { background: "#1e1e1e" };
10028 var Popup = (0, import_element16.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
10029 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
10030 index_parts_exports.Popup,
10031 {
10032 ref,
10033 className: clsx_default(style_default4.popup, className),
10034 ...props,
10035 children
10036 }
10037 ) });
10038 const positionedPopup = renderSlotWithChildren(
10039 positioner,
10040 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Positioner, {}),
10041 popupContent
10042 );
10043 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Portal, {}), positionedPopup);
10044 });
10045
10046 // packages/ui/build-module/tooltip/trigger.mjs
10047 var import_element17 = __toESM(require_element(), 1);
10048 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
10049 var Trigger = (0, import_element17.forwardRef)(
10050 function TooltipTrigger3(props, ref) {
10051 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(index_parts_exports.Trigger, { ref, ...props });
10052 }
10053 );
10054
10055 // packages/ui/build-module/tooltip/root.mjs
10056 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
10057 function Root(props) {
10058 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(index_parts_exports.Root, { ...props });
10059 }
10060
10061 // packages/ui/build-module/tooltip/provider.mjs
10062 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
10063 function Provider({ ...props }) {
10064 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(index_parts_exports.Provider, { ...props });
10065 }
10066
10067 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
10068 var import_element18 = __toESM(require_element(), 1);
10069 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
10070 function getRuntime6() {
10071 const globalScope = globalThis;
10072 if (globalScope.__wpStyleRuntime) {
10073 return globalScope.__wpStyleRuntime;
10074 }
10075 globalScope.__wpStyleRuntime = {
10076 documents: /* @__PURE__ */ new Map(),
10077 styles: /* @__PURE__ */ new Map(),
10078 injectedStyles: /* @__PURE__ */ new WeakMap()
10079 };
10080 if (typeof document !== "undefined") {
10081 registerDocument6(document);
10082 }
10083 return globalScope.__wpStyleRuntime;
10084 }
10085 function documentContainsStyleHash6(targetDocument, hash) {
10086 if (!targetDocument.head) {
10087 return false;
10088 }
10089 for (const style of targetDocument.head.querySelectorAll(
10090 `style[${STYLE_HASH_ATTRIBUTE6}]`
10091 )) {
10092 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
10093 return true;
10094 }
10095 }
10096 return false;
10097 }
10098 function injectStyle6(targetDocument, hash, css) {
10099 if (!targetDocument.head) {
10100 return;
10101 }
10102 const runtime = getRuntime6();
10103 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10104 if (!injectedStyles) {
10105 injectedStyles = /* @__PURE__ */ new Set();
10106 runtime.injectedStyles.set(targetDocument, injectedStyles);
10107 }
10108 if (injectedStyles.has(hash)) {
10109 return;
10110 }
10111 if (documentContainsStyleHash6(targetDocument, hash)) {
10112 injectedStyles.add(hash);
10113 return;
10114 }
10115 const style = targetDocument.createElement("style");
10116 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
10117 style.appendChild(targetDocument.createTextNode(css));
10118 targetDocument.head.appendChild(style);
10119 injectedStyles.add(hash);
10120 }
10121 function registerDocument6(targetDocument) {
10122 const runtime = getRuntime6();
10123 runtime.documents.set(
10124 targetDocument,
10125 (runtime.documents.get(targetDocument) ?? 0) + 1
10126 );
10127 for (const [hash, css] of runtime.styles) {
10128 injectStyle6(targetDocument, hash, css);
10129 }
10130 return () => {
10131 const count = runtime.documents.get(targetDocument);
10132 if (count === void 0) {
10133 return;
10134 }
10135 if (count <= 1) {
10136 runtime.documents.delete(targetDocument);
10137 return;
10138 }
10139 runtime.documents.set(targetDocument, count - 1);
10140 };
10141 }
10142 function registerStyle6(hash, css) {
10143 const runtime = getRuntime6();
10144 runtime.styles.set(hash, css);
10145 for (const targetDocument of runtime.documents.keys()) {
10146 injectStyle6(targetDocument, hash, css);
10147 }
10148 }
10149 if (typeof process === "undefined" || true) {
10150 registerStyle6("fa606a57ae", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.f37b9e2e191ebd66__visually-hidden{word-wrap:normal;border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-break:normal}}}");
10151 }
10152 var style_default5 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
10153 var VisuallyHidden = (0, import_element18.forwardRef)(
10154 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
10155 const element = useRender({
10156 render: render4,
10157 ref,
10158 props: mergeProps(
10159 { className: style_default5["visually-hidden"] },
10160 restProps,
10161 {
10162 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
10163 "data-visually-hidden": ""
10164 }
10165 )
10166 });
10167 return element;
10168 }
10169 );
10170
10171 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10172 var import_element19 = __toESM(require_element(), 1);
10173
10174 // packages/dataviews/build-module/constants.mjs
10175 var import_i18n = __toESM(require_i18n(), 1);
10176 var OPERATOR_IS_ANY = "isAny";
10177 var OPERATOR_IS_NONE = "isNone";
10178 var OPERATOR_IS_ALL = "isAll";
10179 var OPERATOR_IS_NOT_ALL = "isNotAll";
10180 var OPERATOR_BETWEEN = "between";
10181 var OPERATOR_IN_THE_PAST = "inThePast";
10182 var OPERATOR_OVER = "over";
10183 var OPERATOR_IS = "is";
10184 var OPERATOR_IS_NOT = "isNot";
10185 var OPERATOR_LESS_THAN = "lessThan";
10186 var OPERATOR_GREATER_THAN = "greaterThan";
10187 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
10188 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
10189 var OPERATOR_BEFORE = "before";
10190 var OPERATOR_AFTER = "after";
10191 var OPERATOR_BEFORE_INC = "beforeInc";
10192 var OPERATOR_AFTER_INC = "afterInc";
10193 var OPERATOR_CONTAINS = "contains";
10194 var OPERATOR_NOT_CONTAINS = "notContains";
10195 var OPERATOR_STARTS_WITH = "startsWith";
10196 var OPERATOR_ON = "on";
10197 var OPERATOR_NOT_ON = "notOn";
10198 var SORTING_DIRECTIONS = ["asc", "desc"];
10199 var sortArrows = { asc: "\u2191", desc: "\u2193" };
10200 var sortValues = { asc: "ascending", desc: "descending" };
10201 var sortLabels = {
10202 asc: (0, import_i18n.__)("Sort ascending"),
10203 desc: (0, import_i18n.__)("Sort descending")
10204 };
10205 var sortIcons = {
10206 asc: arrow_up_default,
10207 desc: arrow_down_default
10208 };
10209 var LAYOUT_TABLE = "table";
10210 var LAYOUT_GRID = "grid";
10211 var LAYOUT_LIST = "list";
10212 var LAYOUT_ACTIVITY = "activity";
10213 var LAYOUT_PICKER_GRID = "pickerGrid";
10214 var LAYOUT_PICKER_TABLE = "pickerTable";
10215 var LAYOUT_PICKER_ACTIVITY = "pickerActivity";
10216
10217 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10218 var DataViewsContext = (0, import_element19.createContext)({
10219 view: { type: LAYOUT_TABLE },
10220 onChangeView: () => {
10221 },
10222 fields: [],
10223 data: [],
10224 paginationInfo: {
10225 totalItems: 0,
10226 totalPages: 0
10227 },
10228 selection: [],
10229 onChangeSelection: () => {
10230 },
10231 setOpenedFilter: () => {
10232 },
10233 openedFilter: null,
10234 getItemId: (item) => item.id,
10235 isItemClickable: () => true,
10236 renderItemLink: void 0,
10237 containerWidth: 0,
10238 containerRef: (0, import_element19.createRef)(),
10239 resizeObserverRef: () => {
10240 },
10241 defaultLayouts: { list: {}, grid: {}, table: {} },
10242 filters: [],
10243 isShowingFilter: false,
10244 setIsShowingFilter: () => {
10245 },
10246 hasInitiallyLoaded: false,
10247 config: {
10248 perPageSizes: []
10249 },
10250 intersectionObserver: null
10251 });
10252 DataViewsContext.displayName = "DataViewsContext";
10253 var dataviews_context_default = DataViewsContext;
10254
10255 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
10256 var import_i18n22 = __toESM(require_i18n(), 1);
10257
10258 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
10259 var import_i18n9 = __toESM(require_i18n(), 1);
10260 var import_components6 = __toESM(require_components(), 1);
10261 var import_element28 = __toESM(require_element(), 1);
10262 var import_keycodes2 = __toESM(require_keycodes(), 1);
10263
10264 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
10265 var import_components = __toESM(require_components(), 1);
10266 var import_i18n2 = __toESM(require_i18n(), 1);
10267 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
10268 var SELECTION_CHECKBOX_CLASS = "dataviews-selection-checkbox";
10269 function DataViewsSelectionCheckbox({
10270 selection,
10271 onChangeSelection,
10272 item,
10273 getItemId,
10274 titleField,
10275 disabled: disabled2,
10276 ...extraProps
10277 }) {
10278 const id = getItemId(item);
10279 const isInSelectionArray = selection.includes(id);
10280 const checked = !disabled2 && isInSelectionArray;
10281 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n2.__)("(no title)");
10282 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
10283 import_components.CheckboxControl,
10284 {
10285 className: SELECTION_CHECKBOX_CLASS,
10286 "aria-label": selectionLabel,
10287 "aria-disabled": disabled2,
10288 checked,
10289 onChange: () => {
10290 if (disabled2) {
10291 return;
10292 }
10293 onChangeSelection(
10294 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
10295 );
10296 },
10297 ...extraProps
10298 }
10299 );
10300 }
10301
10302 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10303 var import_components2 = __toESM(require_components(), 1);
10304 var import_i18n3 = __toESM(require_i18n(), 1);
10305 var import_element20 = __toESM(require_element(), 1);
10306 var import_data4 = __toESM(require_data(), 1);
10307 var import_compose = __toESM(require_compose(), 1);
10308
10309 // packages/dataviews/build-module/lock-unlock.mjs
10310 var import_private_apis3 = __toESM(require_private_apis(), 1);
10311 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
10312 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
10313 "@wordpress/dataviews"
10314 );
10315
10316 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10317 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
10318 var { Menu, kebabCase } = unlock3(import_components2.privateApis);
10319 function ButtonTrigger({
10320 action,
10321 onClick,
10322 items,
10323 variant
10324 }) {
10325 const label = typeof action.label === "string" ? action.label : action.label(items);
10326 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10327 import_components2.Button,
10328 {
10329 disabled: !!action.disabled,
10330 accessibleWhenDisabled: true,
10331 size: "compact",
10332 variant,
10333 onClick,
10334 children: label
10335 }
10336 );
10337 }
10338 function MenuItemTrigger({
10339 action,
10340 onClick,
10341 items
10342 }) {
10343 const label = typeof action.label === "string" ? action.label : action.label(items);
10344 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.ItemLabel, { children: label }) });
10345 }
10346 function ActionModal({
10347 action,
10348 items,
10349 closeModal
10350 }) {
10351 const label = typeof action.label === "string" ? action.label : action.label(items);
10352 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
10353 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10354 import_components2.Modal,
10355 {
10356 title: modalHeader || label,
10357 __experimentalHideHeader: !!action.hideModalHeader,
10358 onRequestClose: closeModal,
10359 focusOnMount: action.modalFocusOnMount ?? true,
10360 size: action.modalSize || "medium",
10361 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
10362 action.id
10363 )}`,
10364 children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(action.RenderModal, { items, closeModal })
10365 }
10366 );
10367 }
10368 function ActionsMenuGroup({
10369 actions,
10370 item,
10371 registry,
10372 setActiveModalAction
10373 }) {
10374 const { primaryActions, regularActions } = (0, import_element20.useMemo)(() => {
10375 return actions.reduce(
10376 (acc, action) => {
10377 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
10378 return acc;
10379 },
10380 {
10381 primaryActions: [],
10382 regularActions: []
10383 }
10384 );
10385 }, [actions]);
10386 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10387 MenuItemTrigger,
10388 {
10389 action,
10390 onClick: () => {
10391 if ("RenderModal" in action) {
10392 setActiveModalAction(action);
10393 return;
10394 }
10395 action.callback([item], { registry });
10396 },
10397 items: [item]
10398 },
10399 action.id
10400 ));
10401 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Menu.Group, { children: [
10402 renderActionGroup(primaryActions),
10403 renderActionGroup(regularActions)
10404 ] });
10405 }
10406 function ItemActions({
10407 item,
10408 actions,
10409 isCompact
10410 }) {
10411 const registry = (0, import_data4.useRegistry)();
10412 const { primaryActions, eligibleActions } = (0, import_element20.useMemo)(() => {
10413 const _eligibleActions = actions.filter(
10414 (action) => !action.isEligible || action.isEligible(item)
10415 );
10416 const _primaryActions = _eligibleActions.filter(
10417 (action) => action.isPrimary
10418 );
10419 return {
10420 primaryActions: _primaryActions,
10421 eligibleActions: _eligibleActions
10422 };
10423 }, [actions, item]);
10424 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10425 if (isCompact) {
10426 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10427 CompactItemActions,
10428 {
10429 item,
10430 actions: eligibleActions,
10431 isSmall: true,
10432 registry
10433 }
10434 );
10435 }
10436 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
10437 Stack,
10438 {
10439 direction: "row",
10440 justify: "flex-end",
10441 className: "dataviews-item-actions",
10442 style: {
10443 flexShrink: 0,
10444 width: "auto"
10445 },
10446 children: [
10447 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10448 PrimaryActions,
10449 {
10450 item,
10451 actions: primaryActions,
10452 registry
10453 }
10454 ),
10455 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
10456 // there if there are any actions at all.
10457 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10458 CompactItemActions,
10459 {
10460 item,
10461 actions: eligibleActions,
10462 registry
10463 }
10464 )
10465 ]
10466 }
10467 );
10468 }
10469 function CompactItemActions({
10470 item,
10471 actions,
10472 isSmall,
10473 registry
10474 }) {
10475 const [activeModalAction, setActiveModalAction] = (0, import_element20.useState)(
10476 null
10477 );
10478 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
10479 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Menu, { placement: "bottom-end", children: [
10480 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10481 Menu.TriggerButton,
10482 {
10483 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10484 import_components2.Button,
10485 {
10486 size: isSmall ? "small" : "compact",
10487 icon: more_vertical_default,
10488 label: (0, import_i18n3.__)("Actions"),
10489 accessibleWhenDisabled: true,
10490 disabled: !actions.length,
10491 className: "dataviews-all-actions-button"
10492 }
10493 )
10494 }
10495 ),
10496 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10497 ActionsMenuGroup,
10498 {
10499 actions,
10500 item,
10501 registry,
10502 setActiveModalAction
10503 }
10504 ) })
10505 ] }),
10506 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10507 ActionModal,
10508 {
10509 action: activeModalAction,
10510 items: [item],
10511 closeModal: () => setActiveModalAction(null)
10512 }
10513 )
10514 ] });
10515 }
10516 function PrimaryActions({
10517 item,
10518 actions,
10519 registry,
10520 buttonVariant
10521 }) {
10522 const [activeModalAction, setActiveModalAction] = (0, import_element20.useState)(null);
10523 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10524 if (isMobileViewport) {
10525 return null;
10526 }
10527 if (!Array.isArray(actions) || actions.length === 0) {
10528 return null;
10529 }
10530 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
10531 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10532 ButtonTrigger,
10533 {
10534 action,
10535 onClick: () => {
10536 if ("RenderModal" in action) {
10537 setActiveModalAction(action);
10538 return;
10539 }
10540 action.callback([item], { registry });
10541 },
10542 items: [item],
10543 variant: buttonVariant
10544 },
10545 action.id
10546 )),
10547 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10548 ActionModal,
10549 {
10550 action: activeModalAction,
10551 items: [item],
10552 closeModal: () => setActiveModalAction(null)
10553 }
10554 )
10555 ] });
10556 }
10557
10558 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10559 var import_components3 = __toESM(require_components(), 1);
10560 var import_i18n5 = __toESM(require_i18n(), 1);
10561 var import_element21 = __toESM(require_element(), 1);
10562 var import_data5 = __toESM(require_data(), 1);
10563 var import_compose2 = __toESM(require_compose(), 1);
10564
10565 // packages/dataviews/build-module/utils/get-footer-message.mjs
10566 var import_i18n4 = __toESM(require_i18n(), 1);
10567 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
10568 if (selectionCount > 0) {
10569 return (0, import_i18n4.sprintf)(
10570 /* translators: %d: number of items. */
10571 (0, import_i18n4._n)("%d Item selected", "%d Items selected", selectionCount),
10572 selectionCount
10573 );
10574 }
10575 if (onlyTotalCount || totalItems <= itemsCount) {
10576 return (0, import_i18n4.sprintf)(
10577 /* translators: %d: number of items. */
10578 (0, import_i18n4._n)("%d Item", "%d Items", totalItems),
10579 totalItems
10580 );
10581 }
10582 return (0, import_i18n4.sprintf)(
10583 /* translators: %1$d: number of items. %2$d: total number of items. */
10584 (0, import_i18n4._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
10585 itemsCount,
10586 totalItems
10587 );
10588 }
10589
10590 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10591 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
10592 function ActionWithModal({
10593 action,
10594 items,
10595 ActionTriggerComponent
10596 }) {
10597 const [isModalOpen, setIsModalOpen] = (0, import_element21.useState)(false);
10598 const actionTriggerProps = {
10599 action,
10600 onClick: () => {
10601 setIsModalOpen(true);
10602 },
10603 items
10604 };
10605 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
10606 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
10607 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10608 ActionModal,
10609 {
10610 action,
10611 items,
10612 closeModal: () => setIsModalOpen(false)
10613 }
10614 )
10615 ] });
10616 }
10617 function hasAPossibleBulkAction(actions, item) {
10618 return actions.some(
10619 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
10620 );
10621 }
10622 function useHasAPossibleBulkAction(actions, item) {
10623 return (0, import_element21.useMemo)(
10624 () => hasAPossibleBulkAction(actions, item),
10625 [actions, item]
10626 );
10627 }
10628 function useSomeItemHasAPossibleBulkAction(actions, data) {
10629 return (0, import_element21.useMemo)(
10630 () => data.some((item) => hasAPossibleBulkAction(actions, item)),
10631 [actions, data]
10632 );
10633 }
10634 function BulkSelectionCheckbox({
10635 selection,
10636 onChangeSelection,
10637 data,
10638 actions,
10639 getItemId,
10640 disableSelectAll = false
10641 }) {
10642 const selectableItems = (0, import_element21.useMemo)(() => {
10643 return data.filter((item) => {
10644 return actions.some(
10645 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
10646 );
10647 });
10648 }, [data, actions]);
10649 const selectedItems = data.filter(
10650 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
10651 );
10652 const hasSelection = selection.length > 0;
10653 const areAllSelected = selectedItems.length === selectableItems.length;
10654 if (disableSelectAll) {
10655 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10656 import_components3.CheckboxControl,
10657 {
10658 className: "dataviews-view-table-selection-checkbox",
10659 checked: hasSelection,
10660 disabled: !hasSelection,
10661 onChange: () => {
10662 onChangeSelection([]);
10663 },
10664 "aria-label": (0, import_i18n5.__)("Deselect all")
10665 }
10666 );
10667 }
10668 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10669 import_components3.CheckboxControl,
10670 {
10671 className: "dataviews-view-table-selection-checkbox",
10672 checked: areAllSelected,
10673 indeterminate: !areAllSelected && !!selectedItems.length,
10674 onChange: () => {
10675 if (areAllSelected) {
10676 onChangeSelection([]);
10677 } else {
10678 onChangeSelection(
10679 selectableItems.map((item) => getItemId(item))
10680 );
10681 }
10682 },
10683 "aria-label": areAllSelected ? (0, import_i18n5.__)("Deselect all") : (0, import_i18n5.__)("Select all")
10684 }
10685 );
10686 }
10687 function ActionTrigger({
10688 action,
10689 onClick,
10690 isBusy,
10691 items
10692 }) {
10693 const label = typeof action.label === "string" ? action.label : action.label(items);
10694 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
10695 if (isMobile) {
10696 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10697 import_components3.Button,
10698 {
10699 disabled: isBusy,
10700 accessibleWhenDisabled: true,
10701 label,
10702 icon: action.icon,
10703 size: "compact",
10704 onClick,
10705 isBusy
10706 }
10707 );
10708 }
10709 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10710 import_components3.Button,
10711 {
10712 disabled: isBusy,
10713 accessibleWhenDisabled: true,
10714 size: "compact",
10715 onClick,
10716 isBusy,
10717 children: label
10718 }
10719 );
10720 }
10721 var EMPTY_ARRAY2 = [];
10722 function ActionButton({
10723 action,
10724 selectedItems,
10725 actionInProgress,
10726 setActionInProgress
10727 }) {
10728 const registry = (0, import_data5.useRegistry)();
10729 const selectedEligibleItems = (0, import_element21.useMemo)(() => {
10730 return selectedItems.filter((item) => {
10731 return !action.isEligible || action.isEligible(item);
10732 });
10733 }, [action, selectedItems]);
10734 if ("RenderModal" in action) {
10735 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10736 ActionWithModal,
10737 {
10738 action,
10739 items: selectedEligibleItems,
10740 ActionTriggerComponent: ActionTrigger
10741 },
10742 action.id
10743 );
10744 }
10745 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10746 ActionTrigger,
10747 {
10748 action,
10749 onClick: async () => {
10750 setActionInProgress(action.id);
10751 await action.callback(selectedItems, {
10752 registry
10753 });
10754 setActionInProgress(null);
10755 },
10756 items: selectedEligibleItems,
10757 isBusy: actionInProgress === action.id
10758 },
10759 action.id
10760 );
10761 }
10762 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
10763 const message2 = getFooterMessage(
10764 selection.length,
10765 data.length,
10766 paginationInfo.totalItems,
10767 isInfiniteScroll
10768 );
10769 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
10770 Stack,
10771 {
10772 direction: "row",
10773 className: "dataviews-bulk-actions-footer__container",
10774 gap: "md",
10775 align: "center",
10776 children: [
10777 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10778 BulkSelectionCheckbox,
10779 {
10780 selection,
10781 onChangeSelection,
10782 data,
10783 actions,
10784 getItemId,
10785 disableSelectAll: isInfiniteScroll
10786 }
10787 ),
10788 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
10789 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
10790 Stack,
10791 {
10792 direction: "row",
10793 className: "dataviews-bulk-actions-footer__action-buttons",
10794 gap: "xs",
10795 children: [
10796 actionsToShow.map((action) => {
10797 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10798 ActionButton,
10799 {
10800 action,
10801 selectedItems,
10802 actionInProgress,
10803 setActionInProgress
10804 },
10805 action.id
10806 );
10807 }),
10808 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10809 import_components3.Button,
10810 {
10811 icon: close_small_default,
10812 showTooltip: true,
10813 tooltipPosition: "top",
10814 size: "compact",
10815 label: (0, import_i18n5.__)("Cancel"),
10816 disabled: !!actionInProgress,
10817 accessibleWhenDisabled: false,
10818 onClick: () => {
10819 onChangeSelection(EMPTY_ARRAY2);
10820 }
10821 }
10822 )
10823 ]
10824 }
10825 )
10826 ]
10827 }
10828 );
10829 }
10830 function FooterContent({
10831 selection,
10832 actions,
10833 onChangeSelection,
10834 data,
10835 getItemId,
10836 isInfiniteScroll,
10837 paginationInfo
10838 }) {
10839 const [actionInProgress, setActionInProgress] = (0, import_element21.useState)(
10840 null
10841 );
10842 const footerContentRef = (0, import_element21.useRef)(void 0);
10843 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
10844 const bulkActions = (0, import_element21.useMemo)(
10845 () => actions.filter((action) => action.supportsBulk),
10846 [actions]
10847 );
10848 const selectableItems = (0, import_element21.useMemo)(() => {
10849 return data.filter((item) => {
10850 return bulkActions.some(
10851 (action) => !action.isEligible || action.isEligible(item)
10852 );
10853 });
10854 }, [data, bulkActions]);
10855 const selectedItems = (0, import_element21.useMemo)(() => {
10856 return data.filter(
10857 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
10858 );
10859 }, [selection, data, getItemId, selectableItems]);
10860 const actionsToShow = (0, import_element21.useMemo)(
10861 () => actions.filter((action) => {
10862 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
10863 (item) => !action.isEligible || action.isEligible(item)
10864 );
10865 }),
10866 [actions, selectedItems, isMobile]
10867 );
10868 if (!actionInProgress) {
10869 if (footerContentRef.current) {
10870 footerContentRef.current = void 0;
10871 }
10872 return renderFooterContent(
10873 data,
10874 actions,
10875 getItemId,
10876 isInfiniteScroll,
10877 selection,
10878 actionsToShow,
10879 selectedItems,
10880 actionInProgress,
10881 setActionInProgress,
10882 onChangeSelection,
10883 paginationInfo
10884 );
10885 } else if (!footerContentRef.current) {
10886 footerContentRef.current = renderFooterContent(
10887 data,
10888 actions,
10889 getItemId,
10890 isInfiniteScroll,
10891 selection,
10892 actionsToShow,
10893 selectedItems,
10894 actionInProgress,
10895 setActionInProgress,
10896 onChangeSelection,
10897 paginationInfo
10898 );
10899 }
10900 return footerContentRef.current;
10901 }
10902 function BulkActionsFooter() {
10903 const {
10904 data,
10905 selection,
10906 actions = EMPTY_ARRAY2,
10907 onChangeSelection,
10908 getItemId,
10909 paginationInfo,
10910 view
10911 } = (0, import_element21.useContext)(dataviews_context_default);
10912 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10913 FooterContent,
10914 {
10915 selection,
10916 onChangeSelection,
10917 data,
10918 actions,
10919 getItemId,
10920 isInfiniteScroll: !!view.infiniteScrollEnabled,
10921 paginationInfo
10922 }
10923 );
10924 }
10925
10926 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
10927 var import_i18n6 = __toESM(require_i18n(), 1);
10928 var import_components4 = __toESM(require_components(), 1);
10929 var import_element22 = __toESM(require_element(), 1);
10930
10931 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
10932 function getHideableFields(view, fields) {
10933 const togglableFields = [
10934 view?.titleField,
10935 view?.mediaField,
10936 view?.descriptionField
10937 ].filter(Boolean);
10938 return fields.filter(
10939 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
10940 );
10941 }
10942
10943 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
10944 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
10945 var { Menu: Menu2 } = unlock3(import_components4.privateApis);
10946 function WithMenuSeparators({ children }) {
10947 return import_element22.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_element22.Fragment, { children: [
10948 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Separator, {}),
10949 child
10950 ] }, i2));
10951 }
10952 var _HeaderMenu = (0, import_element22.forwardRef)(function HeaderMenu({
10953 fieldId,
10954 view,
10955 fields,
10956 onChangeView,
10957 onHide,
10958 setOpenedFilter,
10959 canMove = true,
10960 canInsertLeft = true,
10961 canInsertRight = true
10962 }, ref) {
10963 const visibleFieldIds = view.fields ?? [];
10964 const index2 = visibleFieldIds?.indexOf(fieldId);
10965 const isSorted = view.sort?.field === fieldId;
10966 let isHidable = false;
10967 let isSortable = false;
10968 let canAddFilter = false;
10969 let operators = [];
10970 const field = fields.find((f2) => f2.id === fieldId);
10971 const { setIsShowingFilter } = (0, import_element22.useContext)(dataviews_context_default);
10972 if (!field) {
10973 return null;
10974 }
10975 isHidable = field.enableHiding !== false;
10976 isSortable = field.enableSorting !== false;
10977 const header = field.header;
10978 operators = !!field.filterBy && field.filterBy?.operators || [];
10979 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
10980 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
10981 return header;
10982 }
10983 const hiddenFields = getHideableFields(view, fields).filter(
10984 (f2) => !visibleFieldIds.includes(f2.id)
10985 );
10986 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
10987 const isRtl = (0, import_i18n6.isRTL)();
10988 return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2, { children: [
10989 /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
10990 Menu2.TriggerButton,
10991 {
10992 render: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10993 import_components4.Button,
10994 {
10995 size: "compact",
10996 className: "dataviews-view-table-header-button",
10997 ref,
10998 variant: "tertiary"
10999 }
11000 ),
11001 children: [
11002 header,
11003 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
11004 ]
11005 }
11006 ),
11007 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(WithMenuSeparators, { children: [
11008 isSortable && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
11009 (direction) => {
11010 const isChecked = view.sort && isSorted && view.sort.direction === direction;
11011 const value = `${fieldId}-${direction}`;
11012 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
11013 Menu2.RadioItem,
11014 {
11015 name: "view-table-sorting",
11016 value,
11017 checked: isChecked,
11018 onChange: () => {
11019 onChangeView({
11020 ...view,
11021 sort: {
11022 field: fieldId,
11023 direction
11024 },
11025 showLevels: false
11026 });
11027 },
11028 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
11029 },
11030 value
11031 );
11032 }
11033 ) }),
11034 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
11035 Menu2.Item,
11036 {
11037 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: funnel_default }),
11038 onClick: () => {
11039 setOpenedFilter(fieldId);
11040 setIsShowingFilter(true);
11041 onChangeView({
11042 ...view,
11043 page: 1,
11044 filters: [
11045 ...view.filters || [],
11046 {
11047 field: fieldId,
11048 value: void 0,
11049 operator: operators[0]
11050 }
11051 ]
11052 });
11053 },
11054 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Add filter") })
11055 }
11056 ) }),
11057 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2.Group, { children: [
11058 canMove && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
11059 Menu2.Item,
11060 {
11061 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: arrow_left_default }),
11062 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
11063 onClick: () => {
11064 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
11065 const newFields = [
11066 ...visibleFieldIds
11067 ];
11068 newFields.splice(index2, 1);
11069 newFields.splice(
11070 targetIndex,
11071 0,
11072 fieldId
11073 );
11074 onChangeView({
11075 ...view,
11076 fields: newFields
11077 });
11078 },
11079 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move left") })
11080 }
11081 ),
11082 canMove && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
11083 Menu2.Item,
11084 {
11085 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: arrow_right_default }),
11086 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
11087 onClick: () => {
11088 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
11089 const newFields = [
11090 ...visibleFieldIds
11091 ];
11092 newFields.splice(index2, 1);
11093 newFields.splice(
11094 targetIndex,
11095 0,
11096 fieldId
11097 );
11098 onChangeView({
11099 ...view,
11100 fields: newFields
11101 });
11102 },
11103 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move right") })
11104 }
11105 ),
11106 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2, { children: [
11107 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert left") }) }),
11108 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11109 const insertIndex = isRtl ? index2 + 1 : index2;
11110 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
11111 Menu2.Item,
11112 {
11113 onClick: () => {
11114 onChangeView({
11115 ...view,
11116 fields: [
11117 ...visibleFieldIds.slice(
11118 0,
11119 insertIndex
11120 ),
11121 hiddenField.id,
11122 ...visibleFieldIds.slice(
11123 insertIndex
11124 )
11125 ]
11126 });
11127 },
11128 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11129 },
11130 hiddenField.id
11131 );
11132 }) })
11133 ] }),
11134 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2, { children: [
11135 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert right") }) }),
11136 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11137 const insertIndex = isRtl ? index2 : index2 + 1;
11138 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
11139 Menu2.Item,
11140 {
11141 onClick: () => {
11142 onChangeView({
11143 ...view,
11144 fields: [
11145 ...visibleFieldIds.slice(
11146 0,
11147 insertIndex
11148 ),
11149 hiddenField.id,
11150 ...visibleFieldIds.slice(
11151 insertIndex
11152 )
11153 ]
11154 });
11155 },
11156 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11157 },
11158 hiddenField.id
11159 );
11160 }) })
11161 ] }),
11162 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
11163 Menu2.Item,
11164 {
11165 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: unseen_default }),
11166 onClick: () => {
11167 onHide(field);
11168 onChangeView({
11169 ...view,
11170 fields: visibleFieldIds.filter(
11171 (id) => id !== fieldId
11172 )
11173 });
11174 },
11175 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Hide column") })
11176 }
11177 )
11178 ] })
11179 ] }) })
11180 ] });
11181 });
11182 var ColumnHeaderMenu = _HeaderMenu;
11183 var column_header_menu_default = ColumnHeaderMenu;
11184
11185 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
11186 var import_element23 = __toESM(require_element(), 1);
11187 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
11188 function getClickableItemProps({
11189 item,
11190 isItemClickable,
11191 onClickItem,
11192 className
11193 }) {
11194 if (!isItemClickable(item) || !onClickItem) {
11195 return { className };
11196 }
11197 return {
11198 className: className ? `${className} ${className}--clickable` : void 0,
11199 role: "button",
11200 tabIndex: 0,
11201 onClick: (event) => {
11202 event.stopPropagation();
11203 onClickItem(item);
11204 },
11205 onKeyDown: (event) => {
11206 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11207 event.stopPropagation();
11208 onClickItem(item);
11209 }
11210 }
11211 };
11212 }
11213 function ItemClickWrapper({
11214 item,
11215 isItemClickable,
11216 onClickItem,
11217 renderItemLink,
11218 className,
11219 children,
11220 ...extraProps
11221 }) {
11222 if (!isItemClickable(item)) {
11223 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className, ...extraProps, children });
11224 }
11225 if (renderItemLink) {
11226 const renderedElement = renderItemLink({
11227 item,
11228 className: `${className} ${className}--clickable`,
11229 ...extraProps,
11230 children
11231 });
11232 return (0, import_element23.cloneElement)(renderedElement, {
11233 onClick: (event) => {
11234 event.stopPropagation();
11235 if (renderedElement.props.onClick) {
11236 renderedElement.props.onClick(event);
11237 }
11238 },
11239 onKeyDown: (event) => {
11240 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11241 event.stopPropagation();
11242 if (renderedElement.props.onKeyDown) {
11243 renderedElement.props.onKeyDown(event);
11244 }
11245 }
11246 }
11247 });
11248 }
11249 const clickProps = getClickableItemProps({
11250 item,
11251 isItemClickable,
11252 onClickItem,
11253 className
11254 });
11255 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { ...clickProps, ...extraProps, children });
11256 }
11257
11258 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
11259 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
11260 function ColumnPrimary({
11261 item,
11262 level,
11263 titleField,
11264 mediaField,
11265 descriptionField,
11266 onClickItem,
11267 renderItemLink,
11268 isItemClickable
11269 }) {
11270 return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
11271 mediaField && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
11272 ItemClickWrapper,
11273 {
11274 item,
11275 isItemClickable,
11276 onClickItem,
11277 renderItemLink,
11278 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
11279 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
11280 children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
11281 mediaField.render,
11282 {
11283 item,
11284 field: mediaField,
11285 config: { sizes: "32px" }
11286 }
11287 )
11288 }
11289 ),
11290 /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
11291 Stack,
11292 {
11293 direction: "column",
11294 align: "flex-start",
11295 className: "dataviews-view-table__primary-column-content",
11296 children: [
11297 titleField && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
11298 ItemClickWrapper,
11299 {
11300 item,
11301 isItemClickable,
11302 onClickItem,
11303 renderItemLink,
11304 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
11305 children: [
11306 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { className: "dataviews-view-table__level", children: [
11307 Array(level).fill("\u2014").join(" "),
11308 "\xA0"
11309 ] }),
11310 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(titleField.render, { item, field: titleField })
11311 ]
11312 }
11313 ),
11314 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
11315 descriptionField.render,
11316 {
11317 item,
11318 field: descriptionField
11319 }
11320 )
11321 ]
11322 }
11323 )
11324 ] });
11325 }
11326 var column_primary_default = ColumnPrimary;
11327
11328 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
11329 var import_element24 = __toESM(require_element(), 1);
11330 var import_i18n7 = __toESM(require_i18n(), 1);
11331 var isScrolledToEnd = (element) => {
11332 if ((0, import_i18n7.isRTL)()) {
11333 const scrollLeft = Math.abs(element.scrollLeft);
11334 return scrollLeft <= 1;
11335 }
11336 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
11337 };
11338 function useScrollState({
11339 scrollContainerRef,
11340 enabledHorizontal = false
11341 }) {
11342 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element24.useState)(false);
11343 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element24.useState)(false);
11344 const handleScroll = (0, import_element24.useCallback)(() => {
11345 const scrollContainer = scrollContainerRef.current;
11346 if (!scrollContainer) {
11347 return;
11348 }
11349 if (enabledHorizontal) {
11350 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
11351 }
11352 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
11353 }, [scrollContainerRef, enabledHorizontal]);
11354 (0, import_element24.useEffect)(() => {
11355 if (typeof window === "undefined" || !scrollContainerRef.current) {
11356 return () => {
11357 };
11358 }
11359 const scrollContainer = scrollContainerRef.current;
11360 handleScroll();
11361 scrollContainer.addEventListener("scroll", handleScroll);
11362 window.addEventListener("resize", handleScroll);
11363 return () => {
11364 scrollContainer.removeEventListener("scroll", handleScroll);
11365 window.removeEventListener("resize", handleScroll);
11366 };
11367 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
11368 return { isHorizontalScrollEnd, isVerticallyScrolled };
11369 }
11370
11371 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
11372 function getDataByGroup(data, groupByField) {
11373 return data.reduce((groups, item) => {
11374 const groupName = groupByField.getValue({ item });
11375 if (!groups.has(groupName)) {
11376 groups.set(groupName, []);
11377 }
11378 groups.get(groupName)?.push(item);
11379 return groups;
11380 }, /* @__PURE__ */ new Map());
11381 }
11382
11383 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-selection-props.mjs
11384 var import_element25 = __toESM(require_element(), 1);
11385 var import_keycodes = __toESM(require_keycodes(), 1);
11386 function getRange(orderedIds, fromIndex, toIndex) {
11387 return orderedIds.slice(
11388 Math.min(fromIndex, toIndex),
11389 Math.max(fromIndex, toIndex) + 1
11390 );
11391 }
11392 function getRangeSelection({
11393 anchorId,
11394 targetId,
11395 lastTargetId,
11396 orderedIds,
11397 selection
11398 }) {
11399 const targetIndex = orderedIds.indexOf(targetId);
11400 if (targetIndex === -1) {
11401 return selection;
11402 }
11403 const anchorIndex = anchorId === null ? -1 : orderedIds.indexOf(anchorId);
11404 const hasAnchor = anchorIndex !== -1;
11405 const rangeStart = hasAnchor ? anchorIndex : targetIndex;
11406 const lastTargetIndex = hasAnchor && lastTargetId !== null ? orderedIds.indexOf(lastTargetId) : -1;
11407 const lastRange = lastTargetIndex === -1 ? [] : getRange(orderedIds, rangeStart, lastTargetIndex);
11408 const base = selection.filter((id) => !lastRange.includes(id));
11409 return [
11410 .../* @__PURE__ */ new Set([
11411 ...base,
11412 ...getRange(orderedIds, rangeStart, targetIndex)
11413 ])
11414 ];
11415 }
11416 function getClosestSelectedId({
11417 targetId,
11418 orderedIds,
11419 selection
11420 }) {
11421 const targetIndex = orderedIds.indexOf(targetId);
11422 if (targetIndex === -1) {
11423 return null;
11424 }
11425 const selectedIds = new Set(selection);
11426 let closestId = null;
11427 let closestDistance = Infinity;
11428 orderedIds.forEach((id, index2) => {
11429 if (!selectedIds.has(id)) {
11430 return;
11431 }
11432 const distance = Math.abs(index2 - targetIndex);
11433 if (distance < closestDistance) {
11434 closestDistance = distance;
11435 closestId = id;
11436 }
11437 });
11438 return closestId;
11439 }
11440 function useSelectionProps({
11441 data,
11442 getItemId,
11443 isItemSelectable,
11444 selection,
11445 onChangeSelection,
11446 selectionMode,
11447 shouldSelectOnClick
11448 }) {
11449 const isMultiselect = selectionMode === "multi";
11450 const allowDeselect = selectionMode !== "single-required";
11451 const gestureRef = (0, import_element25.useRef)(null);
11452 const anchorTo = (id) => {
11453 gestureRef.current = { anchorId: id, lastTargetId: null };
11454 };
11455 const isTouchDeviceRef = (0, import_element25.useRef)(false);
11456 (0, import_element25.useEffect)(() => {
11457 const markTouchDevice = () => {
11458 isTouchDeviceRef.current = true;
11459 };
11460 document.addEventListener("touchstart", markTouchDevice, {
11461 once: true
11462 });
11463 return () => document.removeEventListener("touchstart", markTouchDevice);
11464 }, []);
11465 const selectableIds = data.filter(isItemSelectable).map(getItemId);
11466 const selectableIdSet = new Set(selectableIds);
11467 const hasSelectableItems = selectableIds.length > 0;
11468 const hasRangeGesture = hasSelectableItems && isMultiselect;
11469 const getSelectionProps = (id) => {
11470 const isSelectable = selectableIdSet.has(id);
11471 return {
11472 // When a plain click selects, that click is also what anchors the
11473 // range a following Shift+Click extends from. Modifier clicks never
11474 // reach here: `onClickCapture` stops them.
11475 ...shouldSelectOnClick && {
11476 onClick: () => {
11477 if (allowDeselect && selection.includes(id)) {
11478 onChangeSelection(
11479 selection.filter((itemId) => id !== itemId)
11480 );
11481 } else {
11482 onChangeSelection(
11483 isMultiselect ? [...selection, id] : [id]
11484 );
11485 }
11486 anchorTo(id);
11487 }
11488 },
11489 onMouseDown: (event) => {
11490 if (event.button === 0 && event.shiftKey && hasRangeGesture) {
11491 event.preventDefault();
11492 }
11493 },
11494 onClickCapture: (event) => {
11495 if (!hasRangeGesture) {
11496 return;
11497 }
11498 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11499 const isSelectionCheckboxClick = event.target instanceof Element && !!event.target.closest(`.${SELECTION_CHECKBOX_CLASS}`);
11500 if (!isModifierKeyPressed && !event.shiftKey) {
11501 if (isSelectable && isSelectionCheckboxClick) {
11502 anchorTo(id);
11503 }
11504 return;
11505 }
11506 if (isTouchDeviceRef.current || document.getSelection()?.type === "Range") {
11507 return;
11508 }
11509 event.stopPropagation();
11510 if (!isSelectionCheckboxClick) {
11511 event.preventDefault();
11512 }
11513 if (!isSelectable) {
11514 return;
11515 }
11516 if (event.shiftKey) {
11517 let gesture = gestureRef.current;
11518 if (!gesture || !selectableIdSet.has(gesture.anchorId)) {
11519 gesture = {
11520 anchorId: getClosestSelectedId({
11521 targetId: id,
11522 orderedIds: selectableIds,
11523 selection
11524 }) ?? id,
11525 lastTargetId: null
11526 };
11527 }
11528 onChangeSelection(
11529 getRangeSelection({
11530 anchorId: gesture.anchorId,
11531 targetId: id,
11532 lastTargetId: gesture.lastTargetId,
11533 orderedIds: selectableIds,
11534 selection
11535 })
11536 );
11537 gestureRef.current = {
11538 anchorId: gesture.anchorId,
11539 lastTargetId: id
11540 };
11541 } else {
11542 onChangeSelection(
11543 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
11544 );
11545 anchorTo(id);
11546 }
11547 }
11548 };
11549 };
11550 return { getSelectionProps };
11551 }
11552
11553 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
11554 var import_components5 = __toESM(require_components(), 1);
11555 var import_i18n8 = __toESM(require_i18n(), 1);
11556 var import_element26 = __toESM(require_element(), 1);
11557 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
11558 function FieldItem({
11559 field,
11560 isVisible: isVisible2,
11561 onToggleVisibility
11562 }) {
11563 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: [
11564 /* @__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 }) }),
11565 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
11566 ] }) });
11567 }
11568 function isDefined(item) {
11569 return !!item;
11570 }
11571 function PropertiesSection({
11572 showLabel = true
11573 }) {
11574 const { view, fields, onChangeView } = (0, import_element26.useContext)(dataviews_context_default);
11575 const regularFields = getHideableFields(view, fields);
11576 if (!regularFields?.length) {
11577 return null;
11578 }
11579 const titleField = fields.find((f2) => f2.id === view.titleField);
11580 const previewField2 = fields.find((f2) => f2.id === view.mediaField);
11581 const descriptionField = fields.find(
11582 (f2) => f2.id === view.descriptionField
11583 );
11584 const lockedFields = [
11585 {
11586 field: titleField,
11587 isVisibleFlag: "showTitle"
11588 },
11589 {
11590 field: previewField2,
11591 isVisibleFlag: "showMedia"
11592 },
11593 {
11594 field: descriptionField,
11595 isVisibleFlag: "showDescription"
11596 }
11597 ].filter(({ field }) => isDefined(field));
11598 const visibleFieldIds = view.fields ?? [];
11599 const visibleRegularFieldsCount = regularFields.filter(
11600 (f2) => visibleFieldIds.includes(f2.id)
11601 ).length;
11602 const visibleLockedFields = lockedFields.filter(
11603 ({ isVisibleFlag }) => (
11604 // @ts-expect-error
11605 view[isVisibleFlag] ?? true
11606 )
11607 );
11608 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
11609 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
11610 return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
11611 showLabel && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n8.__)("Properties") }),
11612 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
11613 Stack,
11614 {
11615 direction: "column",
11616 className: "dataviews-view-config__properties",
11617 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
11618 lockedFields.map(({ field, isVisibleFlag }) => {
11619 const isVisible2 = view[isVisibleFlag] ?? true;
11620 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
11621 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
11622 FieldItem,
11623 {
11624 field: fieldToRender,
11625 isVisible: isVisible2,
11626 onToggleVisibility: () => {
11627 onChangeView({
11628 ...view,
11629 [isVisibleFlag]: !isVisible2
11630 });
11631 }
11632 },
11633 field.id
11634 );
11635 }),
11636 regularFields.map((field) => {
11637 const isVisible2 = visibleFieldIds.includes(field.id);
11638 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
11639 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
11640 FieldItem,
11641 {
11642 field: fieldToRender,
11643 isVisible: isVisible2,
11644 onToggleVisibility: () => {
11645 onChangeView({
11646 ...view,
11647 fields: isVisible2 ? visibleFieldIds.filter(
11648 (fieldId) => fieldId !== field.id
11649 ) : [...visibleFieldIds, field.id]
11650 });
11651 }
11652 },
11653 field.id
11654 );
11655 })
11656 ] })
11657 }
11658 )
11659 ] });
11660 }
11661
11662 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
11663 var import_element27 = __toESM(require_element(), 1);
11664 function useDelayedLoading(isLoading, options = { delay: 400 }) {
11665 const [showLoader, setShowLoader] = (0, import_element27.useState)(false);
11666 (0, import_element27.useEffect)(() => {
11667 if (!isLoading) {
11668 return;
11669 }
11670 const timeout = setTimeout(() => {
11671 setShowLoader(true);
11672 }, options.delay);
11673 return () => {
11674 clearTimeout(timeout);
11675 setShowLoader(false);
11676 };
11677 }, [isLoading, options.delay]);
11678 return showLoader;
11679 }
11680
11681 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
11682 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
11683 function getEffectiveAlign(explicitAlign, fieldType) {
11684 if (explicitAlign) {
11685 return explicitAlign;
11686 }
11687 if (fieldType === "integer" || fieldType === "number") {
11688 return "end";
11689 }
11690 return void 0;
11691 }
11692 function TableColumnField({
11693 item,
11694 fields,
11695 column,
11696 align
11697 }) {
11698 const field = fields.find((f2) => f2.id === column);
11699 if (!field) {
11700 return null;
11701 }
11702 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
11703 "dataviews-view-table__cell-align-end": align === "end",
11704 "dataviews-view-table__cell-align-center": align === "center"
11705 });
11706 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(field.render, { item, field }) });
11707 }
11708 function TableRow({
11709 hasBulkActions,
11710 item,
11711 level,
11712 actions,
11713 fields,
11714 id,
11715 view,
11716 titleField,
11717 mediaField,
11718 descriptionField,
11719 selection,
11720 getItemId,
11721 isItemClickable,
11722 onClickItem,
11723 renderItemLink,
11724 onChangeSelection,
11725 onMouseDown,
11726 onClickCapture,
11727 isActionsColumnSticky,
11728 posinset
11729 }) {
11730 const { paginationInfo } = (0, import_element28.useContext)(dataviews_context_default);
11731 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
11732 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
11733 const {
11734 showTitle = true,
11735 showMedia = true,
11736 showDescription = true,
11737 infiniteScrollEnabled
11738 } = view;
11739 const columns = view.fields ?? [];
11740 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11741 return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
11742 "tr",
11743 {
11744 className: clsx_default("dataviews-view-table__row", {
11745 "is-selected": hasPossibleBulkAction && isSelected2,
11746 "has-bulk-actions": hasPossibleBulkAction
11747 }),
11748 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
11749 "aria-posinset": posinset,
11750 role: infiniteScrollEnabled ? "article" : void 0,
11751 onClickCapture,
11752 onMouseDown: (event) => {
11753 const isMetaClick = (0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey;
11754 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
11755 event.preventDefault();
11756 }
11757 onMouseDown(event);
11758 },
11759 children: [
11760 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)(
11761 DataViewsSelectionCheckbox,
11762 {
11763 item,
11764 selection,
11765 onChangeSelection,
11766 getItemId,
11767 titleField,
11768 disabled: !hasPossibleBulkAction
11769 }
11770 ) }) }),
11771 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11772 column_primary_default,
11773 {
11774 item,
11775 level,
11776 titleField: showTitle ? titleField : void 0,
11777 mediaField: showMedia ? mediaField : void 0,
11778 descriptionField: showDescription ? descriptionField : void 0,
11779 isItemClickable,
11780 onClickItem,
11781 renderItemLink
11782 }
11783 ) }),
11784 columns.map((column) => {
11785 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
11786 const field = fields.find((f2) => f2.id === column);
11787 const effectiveAlign = getEffectiveAlign(align, field?.type);
11788 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11789 "td",
11790 {
11791 style: {
11792 width,
11793 maxWidth,
11794 minWidth
11795 },
11796 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11797 TableColumnField,
11798 {
11799 fields,
11800 item,
11801 column,
11802 align: effectiveAlign
11803 }
11804 )
11805 },
11806 column
11807 );
11808 }),
11809 !!actions?.length && // Disable reason: we are not making the element interactive,
11810 // but preventing any click events from bubbling up to the
11811 // table row. This allows us to add a click handler to the row
11812 // itself (to toggle row selection) without erroneously
11813 // intercepting click events from ItemActions.
11814 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11815 "td",
11816 {
11817 className: clsx_default("dataviews-view-table__actions-column", {
11818 "dataviews-view-table__actions-column--sticky": true,
11819 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
11820 }),
11821 onClick: (e2) => e2.stopPropagation(),
11822 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ItemActions, { item, actions })
11823 }
11824 )
11825 ]
11826 }
11827 );
11828 }
11829 function ViewTable({
11830 actions,
11831 data,
11832 fields,
11833 getItemId,
11834 getItemLevel,
11835 isLoading = false,
11836 onChangeView,
11837 onChangeSelection,
11838 selection,
11839 setOpenedFilter,
11840 onClickItem,
11841 isItemClickable,
11842 renderItemLink,
11843 view,
11844 className,
11845 empty
11846 }) {
11847 const { containerRef } = (0, import_element28.useContext)(dataviews_context_default);
11848 const isDelayedLoading = useDelayedLoading(isLoading);
11849 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
11850 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
11851 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
11852 const { getSelectionProps } = useSelectionProps({
11853 data: orderedData,
11854 getItemId,
11855 isItemSelectable: (item) => hasAPossibleBulkAction(actions, item),
11856 selection,
11857 onChangeSelection,
11858 selectionMode: "multi",
11859 shouldSelectOnClick: false
11860 });
11861 const headerMenuRefs = (0, import_element28.useRef)(/* @__PURE__ */ new Map());
11862 const headerMenuToFocusRef = (0, import_element28.useRef)(void 0);
11863 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element28.useState)();
11864 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element28.useState)(null);
11865 (0, import_element28.useEffect)(() => {
11866 if (headerMenuToFocusRef.current) {
11867 headerMenuToFocusRef.current.focus();
11868 headerMenuToFocusRef.current = void 0;
11869 }
11870 });
11871 const tableNoticeId = (0, import_element28.useId)();
11872 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
11873 scrollContainerRef: containerRef,
11874 enabledHorizontal: !!actions?.length
11875 });
11876 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
11877 if (nextHeaderMenuToFocus) {
11878 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
11879 setNextHeaderMenuToFocus(void 0);
11880 return;
11881 }
11882 const onHide = (field) => {
11883 const hidden = headerMenuRefs.current.get(field.id);
11884 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
11885 setNextHeaderMenuToFocus(fallback?.node);
11886 };
11887 const handleHeaderContextMenu = (event) => {
11888 event.preventDefault();
11889 event.stopPropagation();
11890 const virtualAnchor = {
11891 getBoundingClientRect: () => ({
11892 x: event.clientX,
11893 y: event.clientY,
11894 top: event.clientY,
11895 left: event.clientX,
11896 right: event.clientX,
11897 bottom: event.clientY,
11898 width: 0,
11899 height: 0,
11900 toJSON: () => ({})
11901 })
11902 };
11903 window.requestAnimationFrame(() => {
11904 setContextMenuAnchor(virtualAnchor);
11905 });
11906 };
11907 const hasData = !!data?.length;
11908 const titleField = fields.find((field) => field.id === view.titleField);
11909 const mediaField = fields.find((field) => field.id === view.mediaField);
11910 const descriptionField = fields.find(
11911 (field) => field.id === view.descriptionField
11912 );
11913 const { showTitle = true, showMedia = true, showDescription = true } = view;
11914 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11915 const columns = view.fields ?? [];
11916 const headerMenuRef = (column, index2) => (node) => {
11917 if (node) {
11918 headerMenuRefs.current.set(column, {
11919 node,
11920 fallback: columns[index2 > 0 ? index2 - 1 : 1]
11921 });
11922 } else {
11923 headerMenuRefs.current.delete(column);
11924 }
11925 };
11926 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
11927 const isRtl = (0, import_i18n9.isRTL)();
11928 if (!hasData) {
11929 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11930 "div",
11931 {
11932 className: clsx_default("dataviews-no-results", {
11933 "is-refreshing": isDelayedLoading
11934 }),
11935 id: tableNoticeId,
11936 children: empty
11937 }
11938 );
11939 }
11940 return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
11941 /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
11942 "table",
11943 {
11944 className: clsx_default("dataviews-view-table", className, {
11945 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
11946 view.layout.density
11947 ),
11948 "has-bulk-actions": hasBulkActions,
11949 "is-refreshing": !isInfiniteScroll && isDelayedLoading
11950 }),
11951 "aria-busy": isLoading,
11952 "aria-describedby": tableNoticeId,
11953 role: isInfiniteScroll ? "feed" : void 0,
11954 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
11955 children: [
11956 /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("colgroup", { children: [
11957 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
11958 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
11959 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11960 "col",
11961 {
11962 className: clsx_default(
11963 `dataviews-view-table__col-${column}`,
11964 {
11965 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
11966 }
11967 )
11968 },
11969 `col-${column}`
11970 )),
11971 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("col", { className: "dataviews-view-table__col-actions" })
11972 ] }),
11973 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11974 import_components6.Popover,
11975 {
11976 anchor: contextMenuAnchor,
11977 onClose: () => setContextMenuAnchor(null),
11978 placement: "bottom-start",
11979 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(PropertiesSection, { showLabel: false })
11980 }
11981 ),
11982 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11983 "thead",
11984 {
11985 className: clsx_default({
11986 "dataviews-view-table__thead--stuck": isVerticallyScrolled
11987 }),
11988 onContextMenu: handleHeaderContextMenu,
11989 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("tr", { className: "dataviews-view-table__row", children: [
11990 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11991 "th",
11992 {
11993 className: "dataviews-view-table__checkbox-column",
11994 scope: "col",
11995 onContextMenu: handleHeaderContextMenu,
11996 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11997 BulkSelectionCheckbox,
11998 {
11999 selection,
12000 onChangeSelection,
12001 data,
12002 actions,
12003 getItemId
12004 }
12005 )
12006 }
12007 ),
12008 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
12009 column_header_menu_default,
12010 {
12011 ref: headerMenuRef(
12012 titleField.id,
12013 0
12014 ),
12015 fieldId: titleField.id,
12016 view,
12017 fields,
12018 onChangeView,
12019 onHide,
12020 setOpenedFilter,
12021 canMove: false,
12022 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
12023 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
12024 }
12025 ) }),
12026 columns.map((column, index2) => {
12027 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
12028 const field = fields.find(
12029 (f2) => f2.id === column
12030 );
12031 const effectiveAlign = getEffectiveAlign(
12032 align,
12033 field?.type
12034 );
12035 const canInsertOrMove = view.layout?.enableMoving ?? true;
12036 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
12037 "th",
12038 {
12039 style: {
12040 width,
12041 maxWidth,
12042 minWidth,
12043 textAlign: effectiveAlign
12044 },
12045 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
12046 scope: "col",
12047 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
12048 column_header_menu_default,
12049 {
12050 ref: headerMenuRef(column, index2),
12051 fieldId: column,
12052 view,
12053 fields,
12054 onChangeView,
12055 onHide,
12056 setOpenedFilter,
12057 canMove: canInsertOrMove,
12058 canInsertLeft: canInsertOrMove,
12059 canInsertRight: canInsertOrMove
12060 }
12061 )
12062 },
12063 column
12064 );
12065 }),
12066 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
12067 "th",
12068 {
12069 className: clsx_default(
12070 "dataviews-view-table__actions-column",
12071 {
12072 "dataviews-view-table__actions-column--sticky": true,
12073 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
12074 }
12075 ),
12076 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n9.__)("Actions") })
12077 }
12078 )
12079 ] })
12080 }
12081 ),
12082 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
12083 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("tbody", { children: [
12084 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
12085 "td",
12086 {
12087 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
12088 className: "dataviews-view-table__group-header-cell",
12089 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n9.sprintf)(
12090 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12091 (0, import_i18n9.__)("%1$s: %2$s"),
12092 groupField.label,
12093 groupName
12094 )
12095 }
12096 ) }),
12097 groupItems.map((item, index2) => {
12098 const id = getItemId(item) || index2.toString();
12099 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
12100 TableRow,
12101 {
12102 item,
12103 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12104 hasBulkActions,
12105 actions,
12106 fields,
12107 id,
12108 view,
12109 titleField,
12110 mediaField,
12111 descriptionField,
12112 selection,
12113 getItemId,
12114 onChangeSelection,
12115 ...getSelectionProps(id),
12116 onClickItem,
12117 renderItemLink,
12118 isItemClickable,
12119 isActionsColumnSticky: !isHorizontalScrollEnd
12120 },
12121 getItemId(item)
12122 );
12123 })
12124 ] }, `group-${groupName}`)
12125 ) : /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("tbody", { children: hasData && data.map((item, index2) => {
12126 const id = getItemId(item) || index2.toString();
12127 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
12128 TableRow,
12129 {
12130 item,
12131 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12132 hasBulkActions,
12133 actions,
12134 fields,
12135 id,
12136 view,
12137 titleField,
12138 mediaField,
12139 descriptionField,
12140 selection,
12141 getItemId,
12142 onChangeSelection,
12143 ...getSelectionProps(id),
12144 onClickItem,
12145 renderItemLink,
12146 isItemClickable,
12147 isActionsColumnSticky: !isHorizontalScrollEnd,
12148 posinset: isInfiniteScroll ? index2 + 1 : void 0
12149 },
12150 getItemId(item)
12151 );
12152 }) })
12153 ]
12154 }
12155 ),
12156 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, {}) }) })
12157 ] });
12158 }
12159 var table_default = ViewTable;
12160
12161 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12162 var import_components9 = __toESM(require_components(), 1);
12163 var import_i18n12 = __toESM(require_i18n(), 1);
12164
12165 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12166 var import_components8 = __toESM(require_components(), 1);
12167 var import_i18n11 = __toESM(require_i18n(), 1);
12168 var import_compose3 = __toESM(require_compose(), 1);
12169 var import_element32 = __toESM(require_element(), 1);
12170
12171 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
12172 var import_components7 = __toESM(require_components(), 1);
12173 var import_i18n10 = __toESM(require_i18n(), 1);
12174 var import_element29 = __toESM(require_element(), 1);
12175 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
12176 var imageSizes = [
12177 {
12178 value: 120,
12179 breakpoint: 1
12180 },
12181 {
12182 value: 170,
12183 breakpoint: 1
12184 },
12185 {
12186 value: 230,
12187 breakpoint: 1
12188 },
12189 {
12190 value: 290,
12191 breakpoint: 1112
12192 // at minimum image width, 4 images display at this container size
12193 },
12194 {
12195 value: 350,
12196 breakpoint: 1636
12197 // at minimum image width, 6 images display at this container size
12198 },
12199 {
12200 value: 430,
12201 breakpoint: 588
12202 // at minimum image width, 2 images display at this container size
12203 }
12204 ];
12205 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
12206 function useGridColumns() {
12207 const context = (0, import_element29.useContext)(dataviews_context_default);
12208 const view = context.view;
12209 return (0, import_element29.useMemo)(() => {
12210 const containerWidth = context.containerWidth;
12211 const gap = 32;
12212 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
12213 const columns = Math.floor(
12214 (containerWidth + gap) / (previewSize + gap)
12215 );
12216 return Math.max(1, columns);
12217 }, [context.containerWidth, view.layout?.previewSize]);
12218 }
12219
12220 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
12221 var import_element30 = __toESM(require_element(), 1);
12222 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
12223 var GridItems = (0, import_element30.forwardRef)(({ className, previewSize, ...props }, ref) => {
12224 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
12225 "div",
12226 {
12227 ref,
12228 className: clsx_default("dataviews-view-grid-items", className),
12229 style: {
12230 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
12231 },
12232 ...props
12233 }
12234 );
12235 });
12236
12237 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
12238 var import_element31 = __toESM(require_element(), 1);
12239 function useIntersectionObserver(elementRef, posinset) {
12240 const { intersectionObserver } = (0, import_element31.useContext)(dataviews_context_default);
12241 (0, import_element31.useEffect)(() => {
12242 const element = elementRef.current;
12243 if (!element || posinset === void 0 || !intersectionObserver) {
12244 return;
12245 }
12246 intersectionObserver.observe(element);
12247 return () => {
12248 intersectionObserver.unobserve(element);
12249 };
12250 }, [elementRef, intersectionObserver, posinset]);
12251 }
12252 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
12253 const hasData = !!data?.length;
12254 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
12255 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
12256 }
12257
12258 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12259 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
12260 var { Badge: WCBadge } = unlock3(import_components8.privateApis);
12261 function chunk(array, size4) {
12262 const chunks = [];
12263 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
12264 chunks.push(array.slice(i2, i2 + size4));
12265 }
12266 return chunks;
12267 }
12268 var GridItem = (0, import_element32.forwardRef)(
12269 function GridItem2({
12270 view,
12271 selection,
12272 onChangeSelection,
12273 onClickItem,
12274 isItemClickable,
12275 renderItemLink,
12276 getItemId,
12277 item,
12278 actions,
12279 mediaField,
12280 titleField,
12281 descriptionField,
12282 regularFields,
12283 badgeFields,
12284 hasBulkActions,
12285 config,
12286 posinset,
12287 setsize,
12288 ...props
12289 }, forwardedRef) {
12290 const {
12291 showTitle = true,
12292 showMedia = true,
12293 showDescription = true
12294 } = view;
12295 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
12296 const id = getItemId(item);
12297 const elementRef = (0, import_element32.useRef)(null);
12298 const setRefs = (0, import_element32.useCallback)(
12299 (node) => {
12300 elementRef.current = node;
12301 if (typeof forwardedRef === "function") {
12302 forwardedRef(node);
12303 } else if (forwardedRef) {
12304 forwardedRef.current = node;
12305 }
12306 },
12307 [forwardedRef]
12308 );
12309 useIntersectionObserver(elementRef, posinset);
12310 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
12311 const isSelected2 = selection.includes(id);
12312 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
12313 const rendersMediaField = showMedia && mediaField?.render;
12314 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12315 mediaField.render,
12316 {
12317 item,
12318 field: mediaField,
12319 config
12320 }
12321 ) : mediaPlaceholder;
12322 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(titleField.render, { item, field: titleField }) : null;
12323 let mediaA11yProps;
12324 let titleA11yProps;
12325 if (isItemClickable(item) && onClickItem) {
12326 if (renderedTitleField) {
12327 mediaA11yProps = {
12328 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
12329 };
12330 titleA11yProps = {
12331 id: `dataviews-view-grid__title-field-${instanceId}`
12332 };
12333 } else {
12334 mediaA11yProps = {
12335 "aria-label": (0, import_i18n11.__)("Navigate to item")
12336 };
12337 }
12338 }
12339 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
12340 Stack,
12341 {
12342 direction: "column",
12343 ...props,
12344 ref: setRefs,
12345 "aria-setsize": setsize,
12346 "aria-posinset": posinset,
12347 className: clsx_default(
12348 props.className,
12349 "dataviews-view-grid__row__gridcell",
12350 "dataviews-view-grid__card",
12351 {
12352 "is-selected": hasBulkAction && isSelected2
12353 }
12354 ),
12355 children: [
12356 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12357 ItemClickWrapper,
12358 {
12359 item,
12360 isItemClickable,
12361 onClickItem,
12362 renderItemLink,
12363 className: clsx_default("dataviews-view-grid__media", {
12364 "dataviews-view-grid__media--placeholder": !rendersMediaField
12365 }),
12366 ...mediaA11yProps,
12367 children: renderedMediaField
12368 }
12369 ),
12370 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12371 DataViewsSelectionCheckbox,
12372 {
12373 item,
12374 selection,
12375 onChangeSelection,
12376 getItemId,
12377 titleField,
12378 disabled: !hasBulkAction
12379 }
12380 ),
12381 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12382 ItemActions,
12383 {
12384 item,
12385 actions,
12386 isCompact: true
12387 }
12388 ) }),
12389 showTitle && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12390 ItemClickWrapper,
12391 {
12392 item,
12393 isItemClickable,
12394 onClickItem,
12395 renderItemLink,
12396 className: "dataviews-view-grid__title-field dataviews-title-field",
12397 ...titleA11yProps,
12398 title: titleField?.getValueFormatted({
12399 item,
12400 field: titleField
12401 }) || void 0,
12402 children: renderedTitleField
12403 }
12404 ) }),
12405 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Stack, { direction: "column", gap: "xs", children: [
12406 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12407 descriptionField.render,
12408 {
12409 item,
12410 field: descriptionField
12411 }
12412 ),
12413 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12414 Stack,
12415 {
12416 direction: "row",
12417 className: "dataviews-view-grid__badge-fields",
12418 gap: "sm",
12419 wrap: "wrap",
12420 align: "top",
12421 justify: "flex-start",
12422 children: badgeFields.map((field) => {
12423 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12424 WCBadge,
12425 {
12426 className: "dataviews-view-grid__field-value",
12427 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12428 field.render,
12429 {
12430 item,
12431 field
12432 }
12433 )
12434 },
12435 field.id
12436 );
12437 })
12438 }
12439 ),
12440 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12441 Stack,
12442 {
12443 direction: "column",
12444 className: "dataviews-view-grid__fields",
12445 gap: "xs",
12446 children: regularFields.map((field) => {
12447 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12448 import_components8.Flex,
12449 {
12450 className: "dataviews-view-grid__field",
12451 gap: 1,
12452 justify: "flex-start",
12453 expanded: true,
12454 style: { height: "auto" },
12455 direction: "row",
12456 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
12457 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(tooltip_exports.Root, { children: [
12458 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12459 tooltip_exports.Trigger,
12460 {
12461 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
12462 }
12463 ),
12464 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(tooltip_exports.Popup, { children: field.label })
12465 ] }),
12466 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12467 import_components8.FlexItem,
12468 {
12469 className: "dataviews-view-grid__field-value",
12470 style: { maxHeight: "none" },
12471 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12472 field.render,
12473 {
12474 item,
12475 field
12476 }
12477 )
12478 }
12479 )
12480 ] })
12481 },
12482 field.id
12483 );
12484 })
12485 }
12486 )
12487 ] })
12488 ]
12489 }
12490 );
12491 }
12492 );
12493 function CompositeGrid({
12494 data,
12495 isInfiniteScroll,
12496 className,
12497 inert,
12498 isLoading,
12499 view,
12500 fields,
12501 selection,
12502 onChangeSelection,
12503 onClickItem,
12504 isItemClickable,
12505 renderItemLink,
12506 getItemId,
12507 actions,
12508 getSelectionProps
12509 }) {
12510 const { paginationInfo, resizeObserverRef } = (0, import_element32.useContext)(dataviews_context_default);
12511 const gridColumns = useGridColumns();
12512 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12513 const titleField = fields.find(
12514 (field) => field.id === view?.titleField
12515 );
12516 const mediaField = fields.find(
12517 (field) => field.id === view?.mediaField
12518 );
12519 const descriptionField = fields.find(
12520 (field) => field.id === view?.descriptionField
12521 );
12522 const otherFields = view.fields ?? [];
12523 const { regularFields, badgeFields } = otherFields.reduce(
12524 (accumulator, fieldId) => {
12525 const field = fields.find((f2) => f2.id === fieldId);
12526 if (!field) {
12527 return accumulator;
12528 }
12529 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
12530 accumulator[key].push(field);
12531 return accumulator;
12532 },
12533 { regularFields: [], badgeFields: [] }
12534 );
12535 const size4 = "900px";
12536 const totalRows = Math.ceil(data.length / gridColumns);
12537 const placeholdersNeeded = usePlaceholdersNeeded(
12538 data,
12539 isInfiniteScroll,
12540 gridColumns
12541 );
12542 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, {
12543 // Render infinite scroll layout (no rows, feed semantics)
12544 children: [
12545 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
12546 import_components8.Composite,
12547 {
12548 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12549 GridItems,
12550 {
12551 className: clsx_default(
12552 "dataviews-view-grid-infinite-scroll",
12553 className,
12554 {
12555 [`has-${view.layout?.density}-density`]: view.layout?.density && [
12556 "compact",
12557 "comfortable"
12558 ].includes(view.layout.density)
12559 }
12560 ),
12561 previewSize: view.layout?.previewSize,
12562 "aria-busy": isLoading,
12563 ref: resizeObserverRef
12564 }
12565 ),
12566 role: "feed",
12567 focusWrap: true,
12568 inert,
12569 children: [
12570 Array.from({ length: placeholdersNeeded }).map(
12571 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12572 import_components8.Composite.Item,
12573 {
12574 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12575 Stack,
12576 {
12577 ...props,
12578 direction: "column",
12579 role: "article",
12580 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
12581 }
12582 ),
12583 "aria-hidden": true,
12584 tabIndex: -1
12585 },
12586 `placeholder-${index2}`
12587 )
12588 ),
12589 data.map((item) => {
12590 const itemId = getItemId(item);
12591 const selectionProps = getSelectionProps(itemId);
12592 const stablePosition = item.position;
12593 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12594 import_components8.Composite.Item,
12595 {
12596 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12597 GridItem,
12598 {
12599 ...props,
12600 id: itemId,
12601 role: "article",
12602 view,
12603 selection,
12604 onChangeSelection,
12605 onClickItem,
12606 isItemClickable,
12607 renderItemLink,
12608 getItemId,
12609 item,
12610 actions,
12611 onMouseDown: (event) => {
12612 props.onMouseDown?.(event);
12613 selectionProps.onMouseDown(
12614 event
12615 );
12616 },
12617 onClickCapture: (event) => {
12618 props.onClickCapture?.(event);
12619 selectionProps.onClickCapture(
12620 event
12621 );
12622 },
12623 mediaField,
12624 titleField,
12625 descriptionField,
12626 regularFields,
12627 badgeFields,
12628 hasBulkActions,
12629 posinset: stablePosition,
12630 setsize: paginationInfo.totalItems,
12631 config: {
12632 sizes: size4
12633 }
12634 }
12635 )
12636 },
12637 itemId
12638 );
12639 })
12640 ]
12641 }
12642 ),
12643 // Render standard grid layout (with rows, grid semantics)
12644 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12645 import_components8.Composite,
12646 {
12647 role: "grid",
12648 className: clsx_default("dataviews-view-grid", className, {
12649 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12650 view.layout.density
12651 )
12652 }),
12653 focusWrap: true,
12654 "aria-busy": isLoading,
12655 "aria-rowcount": totalRows,
12656 ref: resizeObserverRef,
12657 inert,
12658 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12659 import_components8.Composite.Row,
12660 {
12661 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12662 "div",
12663 {
12664 role: "row",
12665 "aria-rowindex": i2 + 1,
12666 "aria-label": (0, import_i18n11.sprintf)(
12667 /* translators: %d: The row number in the grid */
12668 (0, import_i18n11.__)("Row %d"),
12669 i2 + 1
12670 ),
12671 className: "dataviews-view-grid__row",
12672 style: {
12673 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
12674 }
12675 }
12676 ),
12677 children: row.map((item) => {
12678 const itemId = getItemId(item);
12679 const selectionProps = getSelectionProps(itemId);
12680 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12681 import_components8.Composite.Item,
12682 {
12683 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12684 GridItem,
12685 {
12686 ...props,
12687 id: itemId,
12688 role: "gridcell",
12689 view,
12690 selection,
12691 onChangeSelection,
12692 onClickItem,
12693 isItemClickable,
12694 renderItemLink,
12695 getItemId,
12696 item,
12697 actions,
12698 onMouseDown: (event) => {
12699 props.onMouseDown?.(
12700 event
12701 );
12702 selectionProps.onMouseDown(
12703 event
12704 );
12705 },
12706 onClickCapture: (event) => {
12707 props.onClickCapture?.(
12708 event
12709 );
12710 selectionProps.onClickCapture(
12711 event
12712 );
12713 },
12714 mediaField,
12715 titleField,
12716 descriptionField,
12717 regularFields,
12718 badgeFields,
12719 hasBulkActions,
12720 config: {
12721 sizes: size4
12722 }
12723 }
12724 )
12725 },
12726 itemId
12727 );
12728 })
12729 },
12730 i2
12731 ))
12732 }
12733 )
12734 ]
12735 });
12736 }
12737
12738 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12739 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
12740 function ViewGrid({
12741 actions,
12742 data,
12743 fields,
12744 getItemId,
12745 isLoading,
12746 onChangeSelection,
12747 onClickItem,
12748 isItemClickable,
12749 renderItemLink,
12750 selection,
12751 view,
12752 className,
12753 empty
12754 }) {
12755 const isDelayedLoading = useDelayedLoading(!!isLoading);
12756 const hasData = !!data?.length;
12757 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12758 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12759 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12760 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
12761 const { getSelectionProps } = useSelectionProps({
12762 data: orderedData,
12763 getItemId,
12764 isItemSelectable: (item) => hasAPossibleBulkAction(actions, item),
12765 selection,
12766 onChangeSelection,
12767 selectionMode: "multi",
12768 shouldSelectOnClick: false
12769 });
12770 if (!hasData) {
12771 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
12772 "div",
12773 {
12774 className: clsx_default("dataviews-no-results", {
12775 "is-refreshing": isDelayedLoading
12776 }),
12777 children: empty
12778 }
12779 );
12780 }
12781 const gridProps = {
12782 className: clsx_default(className, {
12783 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12784 }),
12785 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
12786 isLoading,
12787 view,
12788 fields,
12789 selection,
12790 onChangeSelection,
12791 onClickItem,
12792 isItemClickable,
12793 renderItemLink,
12794 getItemId,
12795 actions,
12796 getSelectionProps
12797 };
12798 return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_jsx_runtime51.Fragment, {
12799 // Render multiple groups.
12800 children: [
12801 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
12802 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
12803 Stack,
12804 {
12805 direction: "column",
12806 gap: "sm",
12807 children: [
12808 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n12.sprintf)(
12809 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12810 (0, import_i18n12.__)("%1$s: %2$s"),
12811 groupField.label,
12812 groupName
12813 ) }),
12814 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
12815 CompositeGrid,
12816 {
12817 ...gridProps,
12818 data: groupItems,
12819 isInfiniteScroll: false
12820 }
12821 )
12822 ]
12823 },
12824 groupName
12825 )
12826 ) }),
12827 // Render a single grid with all data.
12828 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
12829 CompositeGrid,
12830 {
12831 ...gridProps,
12832 data,
12833 isInfiniteScroll: !!isInfiniteScroll
12834 }
12835 ),
12836 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components9.Spinner, {}) })
12837 ]
12838 });
12839 }
12840 var grid_default = ViewGrid;
12841
12842 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
12843 var import_compose4 = __toESM(require_compose(), 1);
12844 var import_components10 = __toESM(require_components(), 1);
12845 var import_element33 = __toESM(require_element(), 1);
12846 var import_i18n13 = __toESM(require_i18n(), 1);
12847 var import_data6 = __toESM(require_data(), 1);
12848 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
12849 var { Menu: Menu3 } = unlock3(import_components10.privateApis);
12850 function generateItemWrapperCompositeId(idPrefix) {
12851 return `${idPrefix}-item-wrapper`;
12852 }
12853 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
12854 return `${idPrefix}-primary-action-${primaryActionId}`;
12855 }
12856 function generateDropdownTriggerCompositeId(idPrefix) {
12857 return `${idPrefix}-dropdown`;
12858 }
12859 function PrimaryActionGridCell({
12860 idPrefix,
12861 primaryAction,
12862 item
12863 }) {
12864 const registry = (0, import_data6.useRegistry)();
12865 const [isModalOpen, setIsModalOpen] = (0, import_element33.useState)(false);
12866 const compositeItemId = generatePrimaryActionCompositeId(
12867 idPrefix,
12868 primaryAction.id
12869 );
12870 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
12871 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12872 import_components10.Composite.Item,
12873 {
12874 id: compositeItemId,
12875 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12876 import_components10.Button,
12877 {
12878 disabled: !!primaryAction.disabled,
12879 accessibleWhenDisabled: true,
12880 text: label,
12881 size: "small",
12882 onClick: () => setIsModalOpen(true)
12883 }
12884 ),
12885 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12886 ActionModal,
12887 {
12888 action: primaryAction,
12889 items: [item],
12890 closeModal: () => setIsModalOpen(false)
12891 }
12892 )
12893 }
12894 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12895 import_components10.Composite.Item,
12896 {
12897 id: compositeItemId,
12898 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12899 import_components10.Button,
12900 {
12901 disabled: !!primaryAction.disabled,
12902 accessibleWhenDisabled: true,
12903 size: "small",
12904 onClick: () => {
12905 primaryAction.callback([item], { registry });
12906 },
12907 children: label
12908 }
12909 )
12910 }
12911 ) }, primaryAction.id);
12912 }
12913 function ListItem({
12914 view,
12915 actions,
12916 idPrefix,
12917 isSelected: isSelected2,
12918 item,
12919 titleField,
12920 mediaField,
12921 descriptionField,
12922 selectionProps,
12923 otherFields,
12924 onDropdownTriggerKeyDown,
12925 posinset
12926 }) {
12927 const {
12928 showTitle = true,
12929 showMedia = true,
12930 showDescription = true,
12931 infiniteScrollEnabled
12932 } = view;
12933 const itemRef = (0, import_element33.useRef)(null);
12934 const labelId = `${idPrefix}-label`;
12935 const descriptionId = `${idPrefix}-description`;
12936 const registry = (0, import_data6.useRegistry)();
12937 const [isHovered, setIsHovered] = (0, import_element33.useState)(false);
12938 const [activeModalAction, setActiveModalAction] = (0, import_element33.useState)(
12939 null
12940 );
12941 const handleHover = ({ type }) => {
12942 const isHover = type === "mouseenter";
12943 setIsHovered(isHover);
12944 };
12945 const { paginationInfo } = (0, import_element33.useContext)(dataviews_context_default);
12946 (0, import_element33.useEffect)(() => {
12947 if (isSelected2) {
12948 itemRef.current?.scrollIntoView({
12949 behavior: "auto",
12950 block: "nearest",
12951 inline: "nearest"
12952 });
12953 }
12954 }, [isSelected2]);
12955 const { primaryAction, eligibleActions } = (0, import_element33.useMemo)(() => {
12956 const _eligibleActions = actions.filter(
12957 (action) => !action.isEligible || action.isEligible(item)
12958 );
12959 const _primaryActions = _eligibleActions.filter(
12960 (action) => action.isPrimary
12961 );
12962 return {
12963 primaryAction: _primaryActions[0],
12964 eligibleActions: _eligibleActions
12965 };
12966 }, [actions, item]);
12967 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
12968 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)(
12969 mediaField.render,
12970 {
12971 item,
12972 field: mediaField,
12973 config: { sizes: "52px" }
12974 }
12975 ) }) : null;
12976 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(titleField.render, { item, field: titleField }) : null;
12977 const renderDescription = showDescription && descriptionField?.render;
12978 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
12979 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12980 Stack,
12981 {
12982 direction: "row",
12983 gap: "md",
12984 className: "dataviews-view-list__item-actions",
12985 children: [
12986 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12987 PrimaryActionGridCell,
12988 {
12989 idPrefix,
12990 primaryAction,
12991 item
12992 }
12993 ),
12994 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { role: "gridcell", children: [
12995 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Menu3, { placement: "bottom-end", children: [
12996 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12997 Menu3.TriggerButton,
12998 {
12999 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13000 import_components10.Composite.Item,
13001 {
13002 id: generateDropdownTriggerCompositeId(
13003 idPrefix
13004 ),
13005 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13006 import_components10.Button,
13007 {
13008 size: "small",
13009 icon: more_vertical_default,
13010 label: (0, import_i18n13.__)("Actions"),
13011 accessibleWhenDisabled: true,
13012 disabled: !actions.length,
13013 onKeyDown: onDropdownTriggerKeyDown
13014 }
13015 )
13016 }
13017 )
13018 }
13019 ),
13020 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13021 ActionsMenuGroup,
13022 {
13023 actions: eligibleActions,
13024 item,
13025 registry,
13026 setActiveModalAction
13027 }
13028 ) })
13029 ] }),
13030 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13031 ActionModal,
13032 {
13033 action: activeModalAction,
13034 items: [item],
13035 closeModal: () => setActiveModalAction(null)
13036 }
13037 )
13038 ] })
13039 ]
13040 }
13041 );
13042 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13043 import_components10.Composite.Row,
13044 {
13045 ref: itemRef,
13046 render: (
13047 /* aria-posinset breaks Composite.Row if passed to it directly. */
13048 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13049 "div",
13050 {
13051 "aria-posinset": posinset,
13052 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
13053 }
13054 )
13055 ),
13056 role: infiniteScrollEnabled ? "article" : "row",
13057 className: clsx_default({
13058 "is-selected": isSelected2,
13059 "is-hovered": isHovered
13060 }),
13061 onMouseEnter: handleHover,
13062 onMouseLeave: handleHover,
13063 children: /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
13064 Stack,
13065 {
13066 direction: "row",
13067 className: "dataviews-view-list__item-wrapper",
13068 children: [
13069 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13070 import_components10.Composite.Item,
13071 {
13072 id: generateItemWrapperCompositeId(idPrefix),
13073 "aria-pressed": isSelected2,
13074 "aria-labelledby": labelId,
13075 "aria-describedby": descriptionId,
13076 className: "dataviews-view-list__item",
13077 ...selectionProps
13078 }
13079 ) }),
13080 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
13081 Stack,
13082 {
13083 direction: "row",
13084 gap: "md",
13085 justify: "start",
13086 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
13087 style: { flex: 1, minWidth: 0 },
13088 children: [
13089 renderedMediaField,
13090 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
13091 Stack,
13092 {
13093 direction: "column",
13094 gap: "xs",
13095 className: "dataviews-view-list__field-wrapper",
13096 children: [
13097 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Stack, { direction: "row", align: "center", children: [
13098 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13099 "div",
13100 {
13101 className: "dataviews-title-field dataviews-view-list__title-field",
13102 id: labelId,
13103 children: renderedTitleField
13104 }
13105 ),
13106 usedActions
13107 ] }),
13108 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13109 descriptionField.render,
13110 {
13111 item,
13112 field: descriptionField
13113 }
13114 ) }),
13115 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13116 "div",
13117 {
13118 className: "dataviews-view-list__fields",
13119 id: descriptionId,
13120 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
13121 "div",
13122 {
13123 className: "dataviews-view-list__field",
13124 children: [
13125 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13126 VisuallyHidden,
13127 {
13128 className: "dataviews-view-list__field-label",
13129 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", {}),
13130 children: field.label
13131 }
13132 ),
13133 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13134 field.render,
13135 {
13136 item,
13137 field
13138 }
13139 ) })
13140 ]
13141 },
13142 field.id
13143 ))
13144 }
13145 )
13146 ]
13147 }
13148 )
13149 ]
13150 }
13151 )
13152 ]
13153 }
13154 )
13155 }
13156 );
13157 }
13158 function isDefined2(item) {
13159 return !!item;
13160 }
13161 function ViewList(props) {
13162 const {
13163 actions,
13164 data,
13165 fields,
13166 getItemId,
13167 isLoading,
13168 onChangeSelection,
13169 selection,
13170 view,
13171 className,
13172 empty
13173 } = props;
13174 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
13175 const isDelayedLoading = useDelayedLoading(!!isLoading);
13176 const { paginationInfo } = (0, import_element33.useContext)(dataviews_context_default);
13177 const selectedItem = data?.findLast(
13178 (item) => selection.includes(getItemId(item))
13179 );
13180 const titleField = fields.find((field) => field.id === view.titleField);
13181 const mediaField = fields.find((field) => field.id === view.mediaField);
13182 const descriptionField = fields.find(
13183 (field) => field.id === view.descriptionField
13184 );
13185 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
13186 const { getSelectionProps } = useSelectionProps({
13187 data,
13188 getItemId,
13189 isItemSelectable: () => true,
13190 selection,
13191 onChangeSelection,
13192 selectionMode: "single-required",
13193 shouldSelectOnClick: true
13194 });
13195 const generateCompositeItemIdPrefix = (0, import_element33.useCallback)(
13196 (item) => `${baseId}-${getItemId(item)}`,
13197 [baseId, getItemId]
13198 );
13199 const isActiveCompositeItem = (0, import_element33.useCallback)(
13200 (item, idToCheck) => {
13201 return idToCheck.startsWith(
13202 generateCompositeItemIdPrefix(item)
13203 );
13204 },
13205 [generateCompositeItemIdPrefix]
13206 );
13207 const [activeCompositeId, setActiveCompositeId] = (0, import_element33.useState)(void 0);
13208 const compositeRef = (0, import_element33.useRef)(null);
13209 (0, import_element33.useEffect)(() => {
13210 if (selectedItem) {
13211 setActiveCompositeId(
13212 generateItemWrapperCompositeId(
13213 generateCompositeItemIdPrefix(selectedItem)
13214 )
13215 );
13216 }
13217 }, [selectedItem, generateCompositeItemIdPrefix]);
13218 const activeItemIndex = data.findIndex(
13219 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
13220 );
13221 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
13222 const isActiveIdInList = activeItemIndex !== -1;
13223 const selectCompositeItem = (0, import_element33.useCallback)(
13224 (targetIndex, generateCompositeId) => {
13225 const clampedIndex = Math.min(
13226 data.length - 1,
13227 Math.max(0, targetIndex)
13228 );
13229 if (!data[clampedIndex]) {
13230 return;
13231 }
13232 const itemIdPrefix = generateCompositeItemIdPrefix(
13233 data[clampedIndex]
13234 );
13235 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
13236 setActiveCompositeId(targetCompositeItemId);
13237 if (compositeRef.current?.contains(
13238 compositeRef.current.ownerDocument.activeElement
13239 )) {
13240 document.getElementById(targetCompositeItemId)?.focus();
13241 }
13242 },
13243 [data, generateCompositeItemIdPrefix]
13244 );
13245 (0, import_element33.useEffect)(() => {
13246 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
13247 if (!isActiveIdInList && wasActiveIdInList) {
13248 selectCompositeItem(
13249 previousActiveItemIndex,
13250 generateItemWrapperCompositeId
13251 );
13252 }
13253 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
13254 const onDropdownTriggerKeyDown = (0, import_element33.useCallback)(
13255 (event) => {
13256 if (event.key === "ArrowDown") {
13257 event.preventDefault();
13258 selectCompositeItem(
13259 activeItemIndex + 1,
13260 generateDropdownTriggerCompositeId
13261 );
13262 }
13263 if (event.key === "ArrowUp") {
13264 event.preventDefault();
13265 selectCompositeItem(
13266 activeItemIndex - 1,
13267 generateDropdownTriggerCompositeId
13268 );
13269 }
13270 },
13271 [selectCompositeItem, activeItemIndex]
13272 );
13273 const hasData = !!data?.length;
13274 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13275 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13276 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13277 const hasMoreItems = isInfiniteScroll && (view.startPosition ?? 1) + (view.perPage ?? 0) < paginationInfo.totalItems;
13278 const listClassName = clsx_default("dataviews-view-list", className, {
13279 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(view.layout.density),
13280 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13281 });
13282 const compositeProps = {
13283 ref: compositeRef,
13284 id: baseId,
13285 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", {}),
13286 activeId: activeCompositeId,
13287 setActiveId: setActiveCompositeId,
13288 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0
13289 };
13290 if (!hasData) {
13291 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13292 "div",
13293 {
13294 className: clsx_default("dataviews-no-results", {
13295 "is-refreshing": isDelayedLoading
13296 }),
13297 children: empty
13298 }
13299 );
13300 }
13301 if (hasData && groupField && dataByGroup) {
13302 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13303 import_components10.Composite,
13304 {
13305 ...compositeProps,
13306 className: "dataviews-view-list__group",
13307 role: "grid",
13308 children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Stack, { direction: "column", gap: "lg", className: listClassName, children: Array.from(dataByGroup.entries()).map(
13309 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Stack, { direction: "column", children: [
13310 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)(
13311 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13312 (0, import_i18n13.__)("%1$s: %2$s"),
13313 groupField.label,
13314 groupName
13315 ) }),
13316 groupItems.map((item) => {
13317 const id = generateCompositeItemIdPrefix(item);
13318 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13319 ListItem,
13320 {
13321 view,
13322 idPrefix: id,
13323 actions,
13324 item,
13325 isSelected: item === selectedItem,
13326 selectionProps: getSelectionProps(
13327 getItemId(item)
13328 ),
13329 mediaField,
13330 titleField,
13331 descriptionField,
13332 otherFields,
13333 onDropdownTriggerKeyDown
13334 },
13335 id
13336 );
13337 })
13338 ] }, groupName)
13339 ) })
13340 }
13341 );
13342 }
13343 return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_jsx_runtime52.Fragment, { children: [
13344 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13345 import_components10.Composite,
13346 {
13347 ...compositeProps,
13348 className: listClassName,
13349 role: view.infiniteScrollEnabled ? "feed" : "grid",
13350 children: data.map((item, index2) => {
13351 const id = generateCompositeItemIdPrefix(item);
13352 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13353 ListItem,
13354 {
13355 view,
13356 idPrefix: id,
13357 actions,
13358 item,
13359 isSelected: item === selectedItem,
13360 selectionProps: getSelectionProps(
13361 getItemId(item)
13362 ),
13363 mediaField,
13364 titleField,
13365 descriptionField,
13366 otherFields,
13367 onDropdownTriggerKeyDown,
13368 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13369 },
13370 id
13371 );
13372 })
13373 }
13374 ),
13375 (hasMoreItems || isInfiniteScroll && isLoading) && // Keep the spinner's height reserved while loading more so the
13376 // scroll position doesn't bounce. Hidden, and silent to a11y,
13377 // while idle.
13378 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13379 "p",
13380 {
13381 className: "dataviews-loading-more",
13382 "aria-hidden": !isLoading,
13383 children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_components10.Spinner, {})
13384 }
13385 )
13386 ] });
13387 }
13388
13389 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13390 var import_components11 = __toESM(require_components(), 1);
13391
13392 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
13393 var import_i18n14 = __toESM(require_i18n(), 1);
13394 var import_element34 = __toESM(require_element(), 1);
13395 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
13396 function ActivityGroup({
13397 groupName,
13398 groupData,
13399 groupField,
13400 showLabel = true,
13401 children
13402 }) {
13403 const groupHeader = showLabel ? (0, import_element34.createInterpolateElement)(
13404 // translators: %s: The label of the field e.g. "Status".
13405 (0, import_i18n14.sprintf)((0, import_i18n14.__)("%s: <groupName />"), groupField.label).trim(),
13406 {
13407 groupName: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
13408 groupField.render,
13409 {
13410 item: groupData[0],
13411 field: groupField
13412 }
13413 )
13414 }
13415 ) : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(groupField.render, { item: groupData[0], field: groupField });
13416 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
13417 Stack,
13418 {
13419 direction: "column",
13420 className: "dataviews-view-activity__group",
13421 children: [
13422 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
13423 children
13424 ]
13425 },
13426 groupName
13427 );
13428 }
13429
13430 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
13431 var import_element35 = __toESM(require_element(), 1);
13432 var import_data7 = __toESM(require_data(), 1);
13433 var import_compose5 = __toESM(require_compose(), 1);
13434 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
13435 function ActivityItem(props) {
13436 const {
13437 view,
13438 actions,
13439 item,
13440 titleField,
13441 mediaField,
13442 descriptionField,
13443 otherFields,
13444 posinset,
13445 onClickItem,
13446 renderItemLink,
13447 isItemClickable
13448 } = props;
13449 const {
13450 showTitle = true,
13451 showMedia = true,
13452 showDescription = true,
13453 infiniteScrollEnabled
13454 } = view;
13455 const itemRef = (0, import_element35.useRef)(null);
13456 const registry = (0, import_data7.useRegistry)();
13457 const { paginationInfo } = (0, import_element35.useContext)(dataviews_context_default);
13458 const { primaryActions, eligibleActions } = (0, import_element35.useMemo)(() => {
13459 const _eligibleActions = actions.filter(
13460 (action) => !action.isEligible || action.isEligible(item)
13461 );
13462 const _primaryActions = _eligibleActions.filter(
13463 (action) => action.isPrimary
13464 );
13465 return {
13466 primaryActions: _primaryActions,
13467 eligibleActions: _eligibleActions
13468 };
13469 }, [actions, item]);
13470 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
13471 const density = view.layout?.density ?? "balanced";
13472 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13473 mediaField.render,
13474 {
13475 item,
13476 field: mediaField,
13477 config: {
13478 sizes: density === "comfortable" ? "32px" : "24px"
13479 }
13480 }
13481 ) : null;
13482 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13483 "span",
13484 {
13485 className: "dataviews-view-activity__item-bullet",
13486 "aria-hidden": "true"
13487 }
13488 ) });
13489 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(titleField.render, { item, field: titleField }) : null;
13490 const verticalGap = (0, import_element35.useMemo)(() => {
13491 switch (density) {
13492 case "comfortable":
13493 return "md";
13494 default:
13495 return "sm";
13496 }
13497 }, [density]);
13498 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13499 "div",
13500 {
13501 ref: itemRef,
13502 role: infiniteScrollEnabled ? "article" : void 0,
13503 "aria-posinset": posinset,
13504 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
13505 className: clsx_default(
13506 "dataviews-view-activity__item",
13507 density === "compact" && "is-compact",
13508 density === "balanced" && "is-balanced",
13509 density === "comfortable" && "is-comfortable"
13510 ),
13511 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
13512 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13513 Stack,
13514 {
13515 direction: "column",
13516 gap: "xs",
13517 align: "center",
13518 className: "dataviews-view-activity__item-type",
13519 children: renderedMediaField
13520 }
13521 ),
13522 /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
13523 Stack,
13524 {
13525 direction: "column",
13526 gap: verticalGap,
13527 align: "flex-start",
13528 className: "dataviews-view-activity__item-content",
13529 children: [
13530 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13531 ItemClickWrapper,
13532 {
13533 item,
13534 isItemClickable,
13535 onClickItem,
13536 renderItemLink,
13537 className: "dataviews-view-activity__item-title",
13538 children: renderedTitleField
13539 }
13540 ),
13541 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13542 descriptionField.render,
13543 {
13544 item,
13545 field: descriptionField
13546 }
13547 ) }),
13548 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
13549 "div",
13550 {
13551 className: "dataviews-view-activity__item-field",
13552 children: [
13553 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13554 VisuallyHidden,
13555 {
13556 className: "dataviews-view-activity__item-field-label",
13557 render: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", {}),
13558 children: field.label
13559 }
13560 ),
13561 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13562 field.render,
13563 {
13564 item,
13565 field
13566 }
13567 ) })
13568 ]
13569 },
13570 field.id
13571 )) }),
13572 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13573 PrimaryActions,
13574 {
13575 item,
13576 actions: primaryActions,
13577 registry,
13578 buttonVariant: "secondary"
13579 }
13580 )
13581 ]
13582 }
13583 ),
13584 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13585 // there if there are any actions at all.
13586 isMobileViewport && // At the same time, only show the menu if there are actions to show.
13587 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13588 ItemActions,
13589 {
13590 item,
13591 actions: eligibleActions,
13592 isCompact: true
13593 }
13594 ) })
13595 ] })
13596 }
13597 );
13598 }
13599 var activity_item_default = ActivityItem;
13600
13601 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
13602 var import_react6 = __toESM(require_react(), 1);
13603 function isDefined3(item) {
13604 return !!item;
13605 }
13606 function ActivityItems(props) {
13607 const { data, fields, getItemId, view } = props;
13608 const titleField = fields.find((field) => field.id === view.titleField);
13609 const mediaField = fields.find((field) => field.id === view.mediaField);
13610 const descriptionField = fields.find(
13611 (field) => field.id === view.descriptionField
13612 );
13613 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
13614 return data.map((item, index2) => {
13615 return /* @__PURE__ */ (0, import_react6.createElement)(
13616 activity_item_default,
13617 {
13618 ...props,
13619 key: getItemId(item),
13620 item,
13621 mediaField,
13622 titleField,
13623 descriptionField,
13624 otherFields,
13625 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13626 }
13627 );
13628 });
13629 }
13630
13631 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13632 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
13633 function ViewActivity(props) {
13634 const { empty, data, fields, isLoading, view, className } = props;
13635 const isDelayedLoading = useDelayedLoading(!!isLoading);
13636 const hasData = !!data?.length;
13637 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13638 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13639 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13640 if (!hasData) {
13641 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13642 "div",
13643 {
13644 className: clsx_default("dataviews-no-results", {
13645 "is-refreshing": isDelayedLoading
13646 }),
13647 children: empty
13648 }
13649 );
13650 }
13651 const isInert = !isInfiniteScroll && !!isLoading;
13652 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
13653 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13654 });
13655 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
13656 if (hasData && groupField && dataByGroup) {
13657 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13658 Stack,
13659 {
13660 direction: "column",
13661 gap: "sm",
13662 className: wrapperClassName,
13663 inert: isInert ? "true" : void 0,
13664 children: groupedEntries.map(
13665 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13666 ActivityGroup,
13667 {
13668 groupName,
13669 groupData,
13670 groupField,
13671 showLabel: view.groupBy?.showLabel !== false,
13672 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13673 ActivityItems,
13674 {
13675 ...props,
13676 data: groupData
13677 }
13678 )
13679 },
13680 groupName
13681 )
13682 )
13683 }
13684 );
13685 }
13686 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
13687 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13688 "div",
13689 {
13690 className: wrapperClassName,
13691 role: view.infiniteScrollEnabled ? "feed" : void 0,
13692 inert: isInert ? "true" : void 0,
13693 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ActivityItems, { ...props })
13694 }
13695 ),
13696 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components11.Spinner, {}) })
13697 ] });
13698 }
13699
13700 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13701 var import_components14 = __toESM(require_components(), 1);
13702 var import_i18n17 = __toESM(require_i18n(), 1);
13703 var import_compose6 = __toESM(require_compose(), 1);
13704 var import_element38 = __toESM(require_element(), 1);
13705
13706 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13707 var import_components13 = __toESM(require_components(), 1);
13708 var import_data8 = __toESM(require_data(), 1);
13709 var import_element37 = __toESM(require_element(), 1);
13710 var import_i18n16 = __toESM(require_i18n(), 1);
13711
13712 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
13713 var import_components12 = __toESM(require_components(), 1);
13714 var import_element36 = __toESM(require_element(), 1);
13715 var import_i18n15 = __toESM(require_i18n(), 1);
13716 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
13717 function hasPaginationControls(view, paginationInfo) {
13718 return !view.infiniteScrollEnabled && paginationInfo.totalItems > 0 && paginationInfo.totalPages > 1;
13719 }
13720 function DataViewsPagination() {
13721 const { view, onChangeView, paginationInfo } = (0, import_element36.useContext)(dataviews_context_default);
13722 if (!hasPaginationControls(view, paginationInfo)) {
13723 return null;
13724 }
13725 const { totalPages } = paginationInfo;
13726 const currentPage = view.page ?? 1;
13727 const pageSelectOptions = Array.from(Array(totalPages)).map(
13728 (_, i2) => {
13729 const page = i2 + 1;
13730 return {
13731 value: page.toString(),
13732 label: page.toString(),
13733 "aria-label": currentPage === page ? (0, import_i18n15.sprintf)(
13734 // translators: 1: current page number. 2: total number of pages.
13735 (0, import_i18n15.__)("Page %1$d of %2$d"),
13736 currentPage,
13737 totalPages
13738 ) : page.toString()
13739 };
13740 }
13741 );
13742 return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
13743 Stack,
13744 {
13745 direction: "row",
13746 className: "dataviews-pagination",
13747 justify: "end",
13748 align: "center",
13749 gap: "xl",
13750 children: [
13751 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13752 Stack,
13753 {
13754 direction: "row",
13755 justify: "flex-start",
13756 align: "center",
13757 gap: "xs",
13758 className: "dataviews-pagination__page-select",
13759 children: (0, import_element36.createInterpolateElement)(
13760 (0, import_i18n15.sprintf)(
13761 // translators: 1: Current page number, 2: Total number of pages.
13762 (0, import_i18n15._x)("<div>Page</div>%1$s<div>of %2$d</div>", "paging"),
13763 "<CurrentPage />",
13764 totalPages
13765 ),
13766 {
13767 div: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { "aria-hidden": true }),
13768 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
13769 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13770 import_components12.SelectControl,
13771 {
13772 "aria-label": (0, import_i18n15.__)("Current page"),
13773 value: currentPage.toString(),
13774 options: pageSelectOptions,
13775 onChange: (newValue) => {
13776 onChangeView({
13777 ...view,
13778 page: +newValue
13779 });
13780 },
13781 size: "small",
13782 variant: "minimal"
13783 }
13784 )
13785 }
13786 )
13787 }
13788 ),
13789 /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
13790 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13791 import_components12.Button,
13792 {
13793 onClick: () => onChangeView({
13794 ...view,
13795 page: currentPage - 1
13796 }),
13797 disabled: currentPage === 1,
13798 accessibleWhenDisabled: true,
13799 label: (0, import_i18n15.__)("Previous page"),
13800 icon: (0, import_i18n15.isRTL)() ? next_default : previous_default,
13801 showTooltip: true,
13802 size: "compact",
13803 tooltipPosition: "top"
13804 }
13805 ),
13806 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13807 import_components12.Button,
13808 {
13809 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
13810 disabled: currentPage >= totalPages,
13811 accessibleWhenDisabled: true,
13812 label: (0, import_i18n15.__)("Next page"),
13813 icon: (0, import_i18n15.isRTL)() ? previous_default : next_default,
13814 showTooltip: true,
13815 size: "compact",
13816 tooltipPosition: "top"
13817 }
13818 )
13819 ] })
13820 ]
13821 }
13822 );
13823 }
13824 var dataviews_pagination_default = (0, import_element36.memo)(DataViewsPagination);
13825
13826 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13827 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
13828 function useIsMultiselectPicker(actions) {
13829 return (0, import_element37.useMemo)(() => {
13830 return !!actions?.length && actions?.every((action) => action.supportsBulk);
13831 }, [actions]);
13832 }
13833
13834 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13835 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
13836 var { Badge: WCBadge2 } = unlock3(import_components14.privateApis);
13837 function GridItem3({
13838 view,
13839 selection,
13840 onChangeSelection,
13841 selectionProps,
13842 getItemId,
13843 item,
13844 mediaField,
13845 titleField,
13846 descriptionField,
13847 regularFields,
13848 badgeFields,
13849 config,
13850 posinset,
13851 setsize
13852 }) {
13853 const { showTitle = true, showMedia = true, showDescription = true } = view;
13854 const id = getItemId(item);
13855 const elementRef = (0, import_element38.useRef)(null);
13856 const isSelected2 = selection.includes(id);
13857 useIntersectionObserver(elementRef, posinset);
13858 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13859 mediaField.render,
13860 {
13861 item,
13862 field: mediaField,
13863 config
13864 }
13865 ) : null;
13866 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(titleField.render, { item, field: titleField }) : null;
13867 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
13868 import_components14.Composite.Item,
13869 {
13870 ref: elementRef,
13871 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n17.__)("(no title)") : void 0,
13872 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Stack, { direction: "column", children, ...props }),
13873 role: "option",
13874 "aria-posinset": posinset,
13875 "aria-setsize": setsize,
13876 className: clsx_default("dataviews-view-picker-grid__card", {
13877 "is-selected": isSelected2
13878 }),
13879 "aria-selected": isSelected2,
13880 ...selectionProps,
13881 children: [
13882 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
13883 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13884 DataViewsSelectionCheckbox,
13885 {
13886 item,
13887 selection,
13888 onChangeSelection,
13889 getItemId,
13890 titleField,
13891 disabled: false,
13892 "aria-hidden": true,
13893 tabIndex: -1
13894 }
13895 ),
13896 showTitle && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13897 Stack,
13898 {
13899 direction: "row",
13900 justify: "space-between",
13901 className: "dataviews-view-picker-grid__title-actions",
13902 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
13903 }
13904 ),
13905 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(Stack, { direction: "column", gap: "xs", children: [
13906 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13907 descriptionField.render,
13908 {
13909 item,
13910 field: descriptionField
13911 }
13912 ),
13913 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13914 Stack,
13915 {
13916 direction: "row",
13917 className: "dataviews-view-picker-grid__badge-fields",
13918 gap: "sm",
13919 wrap: "wrap",
13920 align: "top",
13921 justify: "flex-start",
13922 children: badgeFields.map((field) => {
13923 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13924 WCBadge2,
13925 {
13926 className: "dataviews-view-picker-grid__field-value",
13927 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13928 field.render,
13929 {
13930 item,
13931 field
13932 }
13933 )
13934 },
13935 field.id
13936 );
13937 })
13938 }
13939 ),
13940 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13941 Stack,
13942 {
13943 direction: "column",
13944 className: "dataviews-view-picker-grid__fields",
13945 gap: "xs",
13946 children: regularFields.map((field) => {
13947 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13948 import_components14.Flex,
13949 {
13950 className: "dataviews-view-picker-grid__field",
13951 gap: 1,
13952 justify: "flex-start",
13953 expanded: true,
13954 style: { height: "auto" },
13955 direction: "row",
13956 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
13957 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
13958 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13959 import_components14.FlexItem,
13960 {
13961 className: "dataviews-view-picker-grid__field-value",
13962 style: { maxHeight: "none" },
13963 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13964 field.render,
13965 {
13966 item,
13967 field
13968 }
13969 )
13970 }
13971 )
13972 ] })
13973 },
13974 field.id
13975 );
13976 })
13977 }
13978 )
13979 ] })
13980 ]
13981 },
13982 id
13983 );
13984 }
13985 function GridGroup({
13986 groupName,
13987 groupField,
13988 showLabel = true,
13989 children
13990 }) {
13991 const headerId = (0, import_compose6.useInstanceId)(
13992 GridGroup,
13993 "dataviews-view-picker-grid-group__header"
13994 );
13995 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
13996 Stack,
13997 {
13998 direction: "column",
13999 gap: "sm",
14000 role: "group",
14001 "aria-labelledby": headerId,
14002 children: [
14003 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
14004 "h3",
14005 {
14006 className: "dataviews-view-picker-grid-group__header",
14007 id: headerId,
14008 children: showLabel ? (0, import_i18n17.sprintf)(
14009 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14010 (0, import_i18n17.__)("%1$s: %2$s"),
14011 groupField.label,
14012 groupName
14013 ) : groupName
14014 }
14015 ),
14016 children
14017 ]
14018 },
14019 groupName
14020 );
14021 }
14022 function ViewPickerGrid({
14023 actions,
14024 data,
14025 fields,
14026 getItemId,
14027 isLoading,
14028 onChangeSelection,
14029 selection,
14030 view,
14031 className,
14032 empty
14033 }) {
14034 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element38.useContext)(dataviews_context_default);
14035 const titleField = fields.find(
14036 (field) => field.id === view?.titleField
14037 );
14038 const mediaField = fields.find(
14039 (field) => field.id === view?.mediaField
14040 );
14041 const descriptionField = fields.find(
14042 (field) => field.id === view?.descriptionField
14043 );
14044 const otherFields = view.fields ?? [];
14045 const { regularFields, badgeFields } = otherFields.reduce(
14046 (accumulator, fieldId) => {
14047 const field = fields.find((f2) => f2.id === fieldId);
14048 if (!field) {
14049 return accumulator;
14050 }
14051 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
14052 accumulator[key].push(field);
14053 return accumulator;
14054 },
14055 { regularFields: [], badgeFields: [] }
14056 );
14057 const hasData = !!data?.length;
14058 const usedPreviewSize = view.layout?.previewSize;
14059 const isMultiselect = useIsMultiselectPicker(actions);
14060 const size4 = "900px";
14061 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14062 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14063 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
14064 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
14065 const { getSelectionProps } = useSelectionProps({
14066 data: orderedData,
14067 getItemId,
14068 isItemSelectable: () => true,
14069 selection,
14070 onChangeSelection,
14071 selectionMode: isMultiselect ? "multi" : "single-clearable",
14072 shouldSelectOnClick: true
14073 });
14074 const currentPage = view?.page ?? 1;
14075 const perPage = view?.perPage ?? 0;
14076 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
14077 const gridColumns = useGridColumns();
14078 const placeholdersNeeded = usePlaceholdersNeeded(
14079 data,
14080 isInfiniteScroll,
14081 gridColumns
14082 );
14083 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, {
14084 // Render multiple groups.
14085 children: [
14086 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
14087 import_components14.Composite,
14088 {
14089 virtualFocus: true,
14090 orientation: "horizontal",
14091 role: "listbox",
14092 "aria-multiselectable": isMultiselect,
14093 className: clsx_default(
14094 "dataviews-view-picker-grid",
14095 className,
14096 {
14097 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14098 view.layout.density
14099 )
14100 }
14101 ),
14102 "aria-label": itemListLabel,
14103 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
14104 Stack,
14105 {
14106 direction: "column",
14107 gap: "lg",
14108 children,
14109 ...props
14110 }
14111 ),
14112 children: Array.from(dataByGroup.entries()).map(
14113 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
14114 GridGroup,
14115 {
14116 groupName,
14117 groupField,
14118 showLabel: view.groupBy?.showLabel !== false,
14119 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
14120 GridItems,
14121 {
14122 previewSize: usedPreviewSize,
14123 style: {
14124 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
14125 },
14126 "aria-busy": isLoading,
14127 ref: resizeObserverRef,
14128 children: groupItems.map((item) => {
14129 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
14130 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
14131 GridItem3,
14132 {
14133 view,
14134 selection,
14135 onChangeSelection,
14136 selectionProps: getSelectionProps(
14137 getItemId(item)
14138 ),
14139 getItemId,
14140 item,
14141 mediaField,
14142 titleField,
14143 descriptionField,
14144 regularFields,
14145 badgeFields,
14146 config: {
14147 sizes: size4
14148 },
14149 posinset: posInSet,
14150 setsize: setSize
14151 },
14152 getItemId(item)
14153 );
14154 })
14155 }
14156 )
14157 },
14158 groupName
14159 )
14160 )
14161 }
14162 ),
14163 // Render a single grid with all data.
14164 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
14165 import_components14.Composite,
14166 {
14167 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
14168 GridItems,
14169 {
14170 className: clsx_default(
14171 "dataviews-view-picker-grid",
14172 className,
14173 {
14174 [`has-${view.layout?.density}-density`]: view.layout?.density && [
14175 "compact",
14176 "comfortable"
14177 ].includes(view.layout.density)
14178 }
14179 ),
14180 previewSize: usedPreviewSize,
14181 "aria-busy": isLoading,
14182 ref: resizeObserverRef
14183 }
14184 ),
14185 virtualFocus: true,
14186 orientation: "horizontal",
14187 role: "listbox",
14188 "aria-multiselectable": isMultiselect,
14189 "aria-label": itemListLabel,
14190 children: [
14191 Array.from({ length: placeholdersNeeded }).map(
14192 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
14193 import_components14.Composite.Item,
14194 {
14195 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
14196 Stack,
14197 {
14198 direction: "column",
14199 children,
14200 ...props
14201 }
14202 ),
14203 role: "option",
14204 "aria-hidden": true,
14205 tabIndex: -1,
14206 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
14207 },
14208 `placeholder-${index2}`
14209 )
14210 ),
14211 data.map((item) => {
14212 const posinset = item.position;
14213 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
14214 GridItem3,
14215 {
14216 view,
14217 selection,
14218 onChangeSelection,
14219 selectionProps: getSelectionProps(
14220 getItemId(item)
14221 ),
14222 getItemId,
14223 item,
14224 mediaField,
14225 titleField,
14226 descriptionField,
14227 regularFields,
14228 badgeFields,
14229 config: {
14230 sizes: size4
14231 },
14232 posinset,
14233 setsize: setSize
14234 },
14235 getItemId(item)
14236 );
14237 })
14238 ]
14239 }
14240 ),
14241 // Render empty state.
14242 !hasData && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
14243 "div",
14244 {
14245 className: clsx_default({
14246 "dataviews-loading": isLoading,
14247 "dataviews-no-results": !isLoading
14248 }),
14249 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components14.Spinner, {}) }) : empty
14250 }
14251 ),
14252 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components14.Spinner, {}) })
14253 ]
14254 });
14255 }
14256 var picker_grid_default = ViewPickerGrid;
14257
14258 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
14259 var import_i18n18 = __toESM(require_i18n(), 1);
14260 var import_components15 = __toESM(require_components(), 1);
14261 var import_element39 = __toESM(require_element(), 1);
14262 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
14263 function TableColumnField2({
14264 item,
14265 fields,
14266 column,
14267 align
14268 }) {
14269 const field = fields.find((f2) => f2.id === column);
14270 if (!field) {
14271 return null;
14272 }
14273 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
14274 "dataviews-view-table__cell-align-end": align === "end",
14275 "dataviews-view-table__cell-align-center": align === "center"
14276 });
14277 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(field.render, { item, field }) });
14278 }
14279 function TableRow2({
14280 item,
14281 fields,
14282 id,
14283 view,
14284 titleField,
14285 mediaField,
14286 descriptionField,
14287 selection,
14288 getItemId,
14289 onChangeSelection,
14290 selectionProps,
14291 posinset
14292 }) {
14293 const { paginationInfo } = (0, import_element39.useContext)(dataviews_context_default);
14294 const isSelected2 = selection.includes(id);
14295 const [isHovered, setIsHovered] = (0, import_element39.useState)(false);
14296 const elementRef = (0, import_element39.useRef)(null);
14297 useIntersectionObserver(elementRef, posinset);
14298 const {
14299 showTitle = true,
14300 showMedia = true,
14301 showDescription = true,
14302 infiniteScrollEnabled
14303 } = view;
14304 const handleMouseEnter = () => {
14305 setIsHovered(true);
14306 };
14307 const handleMouseLeave = () => {
14308 setIsHovered(false);
14309 };
14310 const columns = view.fields ?? [];
14311 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14312 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14313 import_components15.Composite.Item,
14314 {
14315 ref: elementRef,
14316 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14317 "tr",
14318 {
14319 className: clsx_default("dataviews-view-table__row", {
14320 "is-selected": isSelected2,
14321 "is-hovered": isHovered
14322 }),
14323 onMouseEnter: handleMouseEnter,
14324 onMouseLeave: handleMouseLeave,
14325 children,
14326 ...props
14327 }
14328 ),
14329 "aria-selected": isSelected2,
14330 "aria-setsize": paginationInfo.totalItems || void 0,
14331 "aria-posinset": posinset,
14332 role: infiniteScrollEnabled ? "article" : "option",
14333 onClickCapture: selectionProps.onClickCapture,
14334 onClick: selectionProps.onClick,
14335 onMouseDown: (event) => {
14336 if (event.button !== 0) {
14337 return;
14338 }
14339 event.currentTarget.parentElement?.focus({
14340 preventScroll: true
14341 });
14342 selectionProps.onMouseDown(event);
14343 },
14344 children: [
14345 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14346 "td",
14347 {
14348 className: "dataviews-view-table__checkbox-column",
14349 role: "presentation",
14350 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14351 DataViewsSelectionCheckbox,
14352 {
14353 item,
14354 selection,
14355 onChangeSelection,
14356 getItemId,
14357 titleField,
14358 disabled: false,
14359 "aria-hidden": true,
14360 tabIndex: -1
14361 }
14362 ) })
14363 }
14364 ),
14365 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14366 "td",
14367 {
14368 role: "presentation",
14369 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14370 column_primary_default,
14371 {
14372 item,
14373 titleField: showTitle ? titleField : void 0,
14374 mediaField: showMedia ? mediaField : void 0,
14375 descriptionField: showDescription ? descriptionField : void 0,
14376 isItemClickable: () => false
14377 }
14378 )
14379 }
14380 ),
14381 columns.map((column) => {
14382 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14383 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14384 "td",
14385 {
14386 style: {
14387 width,
14388 maxWidth,
14389 minWidth
14390 },
14391 role: "presentation",
14392 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14393 TableColumnField2,
14394 {
14395 fields,
14396 item,
14397 column,
14398 align
14399 }
14400 )
14401 },
14402 column
14403 );
14404 })
14405 ]
14406 },
14407 id
14408 );
14409 }
14410 function ViewPickerTable({
14411 actions,
14412 data,
14413 fields,
14414 getItemId,
14415 isLoading = false,
14416 onChangeView,
14417 onChangeSelection,
14418 selection,
14419 setOpenedFilter,
14420 view,
14421 className,
14422 empty
14423 }) {
14424 const headerMenuRefs = (0, import_element39.useRef)(/* @__PURE__ */ new Map());
14425 const headerMenuToFocusRef = (0, import_element39.useRef)(void 0);
14426 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element39.useState)();
14427 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
14428 (0, import_element39.useEffect)(() => {
14429 if (headerMenuToFocusRef.current) {
14430 headerMenuToFocusRef.current.focus();
14431 headerMenuToFocusRef.current = void 0;
14432 }
14433 });
14434 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14435 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14436 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14437 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
14438 const { getSelectionProps } = useSelectionProps({
14439 data: orderedData,
14440 getItemId,
14441 isItemSelectable: () => true,
14442 selection,
14443 onChangeSelection,
14444 selectionMode: isMultiselect ? "multi" : "single-clearable",
14445 shouldSelectOnClick: true
14446 });
14447 const tableNoticeId = (0, import_element39.useId)();
14448 if (nextHeaderMenuToFocus) {
14449 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
14450 setNextHeaderMenuToFocus(void 0);
14451 return;
14452 }
14453 const onHide = (field) => {
14454 const hidden = headerMenuRefs.current.get(field.id);
14455 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
14456 setNextHeaderMenuToFocus(fallback?.node);
14457 };
14458 const hasData = !!data?.length;
14459 const titleField = fields.find((field) => field.id === view.titleField);
14460 const mediaField = fields.find((field) => field.id === view.mediaField);
14461 const descriptionField = fields.find(
14462 (field) => field.id === view.descriptionField
14463 );
14464 const { showTitle = true, showMedia = true, showDescription = true } = view;
14465 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14466 const columns = view.fields ?? [];
14467 const headerMenuRef = (column, index2) => (node) => {
14468 if (node) {
14469 headerMenuRefs.current.set(column, {
14470 node,
14471 fallback: columns[index2 > 0 ? index2 - 1 : 1]
14472 });
14473 } else {
14474 headerMenuRefs.current.delete(column);
14475 }
14476 };
14477 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, { children: [
14478 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14479 "table",
14480 {
14481 className: clsx_default(
14482 "dataviews-view-table",
14483 "dataviews-view-picker-table",
14484 className,
14485 {
14486 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14487 view.layout.density
14488 )
14489 }
14490 ),
14491 "aria-busy": isLoading,
14492 "aria-describedby": tableNoticeId,
14493 role: isInfiniteScroll ? "feed" : "listbox",
14494 children: [
14495 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14496 "tr",
14497 {
14498 className: "dataviews-view-table__row",
14499 role: "presentation",
14500 children: [
14501 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14502 BulkSelectionCheckbox,
14503 {
14504 selection,
14505 onChangeSelection,
14506 data,
14507 actions,
14508 getItemId,
14509 disableSelectAll: isInfiniteScroll
14510 }
14511 ) }),
14512 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14513 column_header_menu_default,
14514 {
14515 ref: headerMenuRef(
14516 titleField.id,
14517 0
14518 ),
14519 fieldId: titleField.id,
14520 view,
14521 fields,
14522 onChangeView,
14523 onHide,
14524 setOpenedFilter,
14525 canMove: false
14526 }
14527 ) }),
14528 columns.map((column, index2) => {
14529 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14530 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14531 "th",
14532 {
14533 style: {
14534 width,
14535 maxWidth,
14536 minWidth,
14537 textAlign: align
14538 },
14539 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14540 scope: "col",
14541 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14542 column_header_menu_default,
14543 {
14544 ref: headerMenuRef(column, index2),
14545 fieldId: column,
14546 view,
14547 fields,
14548 onChangeView,
14549 onHide,
14550 setOpenedFilter,
14551 canMove: view.layout?.enableMoving ?? true
14552 }
14553 )
14554 },
14555 column
14556 );
14557 })
14558 ]
14559 }
14560 ) }),
14561 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14562 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14563 import_components15.Composite,
14564 {
14565 virtualFocus: true,
14566 orientation: "vertical",
14567 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("tbody", { role: "group" }),
14568 children: [
14569 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14570 "tr",
14571 {
14572 className: "dataviews-view-table__group-header-row",
14573 role: "presentation",
14574 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14575 "td",
14576 {
14577 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
14578 className: "dataviews-view-table__group-header-cell",
14579 role: "presentation",
14580 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n18.sprintf)(
14581 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14582 (0, import_i18n18.__)("%1$s: %2$s"),
14583 groupField.label,
14584 groupName
14585 )
14586 }
14587 )
14588 }
14589 ),
14590 groupItems.map((item, index2) => {
14591 const id = getItemId(item) || index2.toString();
14592 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14593 TableRow2,
14594 {
14595 item,
14596 fields,
14597 id,
14598 view,
14599 titleField,
14600 mediaField,
14601 descriptionField,
14602 selection,
14603 getItemId,
14604 onChangeSelection,
14605 selectionProps: getSelectionProps(
14606 id
14607 )
14608 },
14609 getItemId(item)
14610 );
14611 })
14612 ]
14613 },
14614 `group-${groupName}`
14615 )
14616 ) : /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14617 import_components15.Composite,
14618 {
14619 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("tbody", { role: "presentation" }),
14620 virtualFocus: true,
14621 orientation: "vertical",
14622 children: hasData && data.map((item, index2) => {
14623 const itemId = getItemId(item);
14624 const id = itemId || index2.toString();
14625 const posinset = item.position;
14626 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14627 TableRow2,
14628 {
14629 item,
14630 fields,
14631 id,
14632 view,
14633 titleField,
14634 mediaField,
14635 descriptionField,
14636 selection,
14637 getItemId,
14638 onChangeSelection,
14639 selectionProps: getSelectionProps(
14640 id
14641 ),
14642 posinset
14643 },
14644 itemId
14645 );
14646 })
14647 }
14648 )
14649 ]
14650 }
14651 ),
14652 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14653 "div",
14654 {
14655 className: clsx_default({
14656 "dataviews-loading": isLoading,
14657 "dataviews-no-results": !hasData && !isLoading
14658 }),
14659 id: tableNoticeId,
14660 children: [
14661 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components15.Spinner, {}) }) : empty),
14662 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components15.Spinner, {}) })
14663 ]
14664 }
14665 )
14666 ] });
14667 }
14668 var picker_table_default = ViewPickerTable;
14669
14670 // packages/dataviews/build-module/components/dataviews-layouts/picker-activity/index.mjs
14671 var import_components16 = __toESM(require_components(), 1);
14672 var import_element40 = __toESM(require_element(), 1);
14673 var import_compose7 = __toESM(require_compose(), 1);
14674 var import_i18n19 = __toESM(require_i18n(), 1);
14675 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
14676 function isDefined4(item) {
14677 return !!item;
14678 }
14679 function PickerActivityItem({
14680 view,
14681 selection,
14682 selectionProps,
14683 getItemId,
14684 item,
14685 titleField,
14686 mediaField,
14687 descriptionField,
14688 otherFields,
14689 posinset,
14690 setsize
14691 }) {
14692 const elementRef = (0, import_element40.useRef)(null);
14693 useIntersectionObserver(elementRef, posinset);
14694 const { showTitle = true, showMedia = true, showDescription = true } = view;
14695 const id = getItemId(item);
14696 const isSelected2 = selection.includes(id);
14697 const density = view.layout?.density ?? "balanced";
14698 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14699 mediaField.render,
14700 {
14701 item,
14702 field: mediaField,
14703 config: {
14704 sizes: density === "comfortable" ? "32px" : "24px"
14705 }
14706 }
14707 ) : null;
14708 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-picker-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14709 "span",
14710 {
14711 className: "dataviews-view-picker-activity__item-bullet",
14712 "aria-hidden": "true"
14713 }
14714 ) });
14715 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(titleField.render, { item, field: titleField }) : null;
14716 const renderedDescriptionField = showDescription && descriptionField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(descriptionField.render, { item, field: descriptionField }) : null;
14717 const verticalGap = (0, import_element40.useMemo)(() => {
14718 switch (density) {
14719 case "comfortable":
14720 return "md";
14721 default:
14722 return "sm";
14723 }
14724 }, [density]);
14725 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14726 import_components16.Composite.Item,
14727 {
14728 ref: elementRef,
14729 role: "option",
14730 "aria-label": titleField ? titleField.getValue({ item }) || void 0 : void 0,
14731 "aria-posinset": posinset,
14732 "aria-setsize": setsize,
14733 "aria-selected": isSelected2,
14734 className: clsx_default(
14735 "dataviews-view-picker-activity__item",
14736 density === "compact" && "is-compact",
14737 density === "balanced" && "is-balanced",
14738 density === "comfortable" && "is-comfortable",
14739 isSelected2 && "is-selected"
14740 ),
14741 ...selectionProps,
14742 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", {}),
14743 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
14744 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14745 Stack,
14746 {
14747 direction: "column",
14748 gap: "xs",
14749 align: "center",
14750 className: "dataviews-view-picker-activity__item-type",
14751 children: renderedMediaField
14752 }
14753 ),
14754 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
14755 Stack,
14756 {
14757 direction: "column",
14758 gap: verticalGap,
14759 align: "flex-start",
14760 className: "dataviews-view-picker-activity__item-content",
14761 children: [
14762 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-picker-activity__item-title", children: renderedTitleField }),
14763 renderedDescriptionField && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-picker-activity__item-description", children: renderedDescriptionField }),
14764 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-picker-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
14765 "div",
14766 {
14767 className: "dataviews-view-picker-activity__item-field",
14768 children: [
14769 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14770 VisuallyHidden,
14771 {
14772 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", {}),
14773 className: "dataviews-view-picker-activity__item-field-label",
14774 children: field.label
14775 }
14776 ),
14777 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "dataviews-view-picker-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14778 field.render,
14779 {
14780 item,
14781 field
14782 }
14783 ) })
14784 ]
14785 },
14786 field.id
14787 )) })
14788 ]
14789 }
14790 )
14791 ] })
14792 }
14793 );
14794 }
14795 function PickerActivityGroup({
14796 groupName,
14797 groupField,
14798 showLabel = true,
14799 children
14800 }) {
14801 const headerId = (0, import_compose7.useInstanceId)(
14802 PickerActivityGroup,
14803 "dataviews-view-picker-activity-group__header"
14804 );
14805 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
14806 Stack,
14807 {
14808 direction: "column",
14809 role: "group",
14810 "aria-labelledby": headerId,
14811 className: "dataviews-view-picker-activity-group",
14812 children: [
14813 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14814 "h3",
14815 {
14816 className: "dataviews-view-picker-activity-group__header",
14817 id: headerId,
14818 children: showLabel ? (0, import_i18n19.sprintf)(
14819 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14820 (0, import_i18n19.__)("%1$s: %2$s"),
14821 groupField.label,
14822 groupName
14823 ) : groupName
14824 }
14825 ),
14826 children
14827 ]
14828 }
14829 );
14830 }
14831 function ViewPickerActivity({
14832 data,
14833 fields,
14834 getItemId,
14835 isLoading,
14836 onChangeSelection,
14837 selection,
14838 view,
14839 actions,
14840 className,
14841 empty
14842 }) {
14843 const { itemListLabel, paginationInfo } = (0, import_element40.useContext)(dataviews_context_default);
14844 const isMultiselect = useIsMultiselectPicker(actions);
14845 const titleField = fields.find(
14846 (field) => field.id === view?.titleField
14847 );
14848 const mediaField = fields.find(
14849 (field) => field.id === view?.mediaField
14850 );
14851 const descriptionField = fields.find(
14852 (field) => field.id === view?.descriptionField
14853 );
14854 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined4);
14855 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14856 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14857 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
14858 const setsize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
14859 const hasData = !!data?.length;
14860 const isGrouped = !!(groupField && dataByGroup);
14861 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
14862 const { getSelectionProps } = useSelectionProps({
14863 data: orderedData,
14864 getItemId,
14865 isItemSelectable: () => true,
14866 selection,
14867 onChangeSelection,
14868 selectionMode: isMultiselect ? "multi" : "single-clearable",
14869 shouldSelectOnClick: true
14870 });
14871 const renderItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14872 PickerActivityItem,
14873 {
14874 view,
14875 selection,
14876 selectionProps: getSelectionProps(getItemId(item)),
14877 getItemId,
14878 item,
14879 titleField,
14880 mediaField,
14881 descriptionField,
14882 otherFields,
14883 posinset: item.position,
14884 setsize
14885 },
14886 getItemId(item)
14887 );
14888 if (!hasData) {
14889 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14890 "div",
14891 {
14892 className: clsx_default({
14893 "dataviews-loading": isLoading,
14894 "dataviews-no-results": !isLoading
14895 }),
14896 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components16.Spinner, {}) }) : empty
14897 }
14898 );
14899 }
14900 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [
14901 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14902 import_components16.Composite,
14903 {
14904 virtualFocus: true,
14905 orientation: "vertical",
14906 role: "listbox",
14907 "aria-multiselectable": isMultiselect,
14908 "aria-label": itemListLabel,
14909 "aria-busy": isLoading,
14910 render: isGrouped ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Stack, { direction: "column", gap: "sm" }) : void 0,
14911 className: clsx_default(
14912 "dataviews-view-picker-activity",
14913 className
14914 ),
14915 children: isGrouped && dataByGroup ? Array.from(dataByGroup.entries()).map(
14916 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14917 PickerActivityGroup,
14918 {
14919 groupName,
14920 groupField,
14921 showLabel: view.groupBy?.showLabel !== false,
14922 children: groupItems.map(renderItem)
14923 },
14924 groupName
14925 )
14926 ) : data.map(renderItem)
14927 }
14928 ),
14929 isLoading && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components16.Spinner, {}) })
14930 ] });
14931 }
14932
14933 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
14934 var import_components17 = __toESM(require_components(), 1);
14935 var import_i18n20 = __toESM(require_i18n(), 1);
14936 var import_element41 = __toESM(require_element(), 1);
14937 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
14938 function DensityPicker() {
14939 const context = (0, import_element41.useContext)(dataviews_context_default);
14940 const view = context.view;
14941 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
14942 import_components17.__experimentalToggleGroupControl,
14943 {
14944 label: (0, import_i18n20.__)("Density"),
14945 value: view.layout?.density || "balanced",
14946 onChange: (value) => {
14947 context.onChangeView({
14948 ...view,
14949 layout: {
14950 ...view.layout,
14951 density: value
14952 }
14953 });
14954 },
14955 isBlock: true,
14956 children: [
14957 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
14958 import_components17.__experimentalToggleGroupControlOption,
14959 {
14960 value: "comfortable",
14961 label: (0, import_i18n20._x)(
14962 "Comfortable",
14963 "Density option for DataView layout"
14964 )
14965 },
14966 "comfortable"
14967 ),
14968 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
14969 import_components17.__experimentalToggleGroupControlOption,
14970 {
14971 value: "balanced",
14972 label: (0, import_i18n20._x)("Balanced", "Density option for DataView layout")
14973 },
14974 "balanced"
14975 ),
14976 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
14977 import_components17.__experimentalToggleGroupControlOption,
14978 {
14979 value: "compact",
14980 label: (0, import_i18n20._x)("Compact", "Density option for DataView layout")
14981 },
14982 "compact"
14983 )
14984 ]
14985 }
14986 );
14987 }
14988
14989 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
14990 var import_components18 = __toESM(require_components(), 1);
14991 var import_i18n21 = __toESM(require_i18n(), 1);
14992 var import_element42 = __toESM(require_element(), 1);
14993 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
14994 var imageSizes2 = [
14995 {
14996 value: 120,
14997 breakpoint: 1
14998 },
14999 {
15000 value: 170,
15001 breakpoint: 1
15002 },
15003 {
15004 value: 230,
15005 breakpoint: 1
15006 },
15007 {
15008 value: 290,
15009 breakpoint: 1112
15010 // at minimum image width, 4 images display at this container size
15011 },
15012 {
15013 value: 350,
15014 breakpoint: 1636
15015 // at minimum image width, 6 images display at this container size
15016 },
15017 {
15018 value: 430,
15019 breakpoint: 588
15020 // at minimum image width, 2 images display at this container size
15021 }
15022 ];
15023 function PreviewSizePicker() {
15024 const context = (0, import_element42.useContext)(dataviews_context_default);
15025 const view = context.view;
15026 const breakValues = imageSizes2.filter((size4) => {
15027 return context.containerWidth >= size4.breakpoint;
15028 });
15029 const layoutPreviewSize = view.layout?.previewSize ?? 230;
15030 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
15031 const marks = breakValues.map((size4, index2) => {
15032 return {
15033 value: index2
15034 };
15035 });
15036 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
15037 import_components18.RangeControl,
15038 {
15039 showTooltip: false,
15040 label: (0, import_i18n21.__)("Preview size"),
15041 value: previewSizeToUse,
15042 min: 0,
15043 max: breakValues.length - 1,
15044 withInputField: false,
15045 onChange: (value = 0) => {
15046 context.onChangeView({
15047 ...view,
15048 layout: {
15049 ...view.layout,
15050 previewSize: breakValues[value].value
15051 }
15052 });
15053 },
15054 step: 1,
15055 marks
15056 }
15057 );
15058 }
15059
15060 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
15061 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
15062 function GridConfigOptions() {
15063 return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
15064 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(DensityPicker, {}),
15065 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(PreviewSizePicker, {})
15066 ] });
15067 }
15068
15069 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
15070 var VIEW_LAYOUTS = [
15071 {
15072 type: LAYOUT_TABLE,
15073 label: (0, import_i18n22.__)("Table"),
15074 component: table_default,
15075 icon: block_table_default,
15076 viewConfigOptions: DensityPicker
15077 },
15078 {
15079 type: LAYOUT_GRID,
15080 label: (0, import_i18n22.__)("Grid"),
15081 component: grid_default,
15082 icon: category_default,
15083 viewConfigOptions: GridConfigOptions
15084 },
15085 {
15086 type: LAYOUT_LIST,
15087 label: (0, import_i18n22.__)("List"),
15088 component: ViewList,
15089 icon: (0, import_i18n22.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
15090 viewConfigOptions: DensityPicker
15091 },
15092 {
15093 type: LAYOUT_ACTIVITY,
15094 label: (0, import_i18n22.__)("Activity"),
15095 component: ViewActivity,
15096 icon: scheduled_default,
15097 viewConfigOptions: DensityPicker
15098 },
15099 {
15100 type: LAYOUT_PICKER_GRID,
15101 label: (0, import_i18n22.__)("Grid"),
15102 component: picker_grid_default,
15103 icon: category_default,
15104 viewConfigOptions: GridConfigOptions,
15105 isPicker: true
15106 },
15107 {
15108 type: LAYOUT_PICKER_TABLE,
15109 label: (0, import_i18n22.__)("Table"),
15110 component: picker_table_default,
15111 icon: block_table_default,
15112 viewConfigOptions: DensityPicker,
15113 isPicker: true
15114 },
15115 {
15116 type: LAYOUT_PICKER_ACTIVITY,
15117 label: (0, import_i18n22.__)("Activity"),
15118 component: ViewPickerActivity,
15119 icon: scheduled_default,
15120 viewConfigOptions: DensityPicker,
15121 isPicker: true
15122 }
15123 ];
15124
15125 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
15126 var import_element50 = __toESM(require_element(), 1);
15127
15128 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
15129 var import_components21 = __toESM(require_components(), 1);
15130 var import_i18n25 = __toESM(require_i18n(), 1);
15131 var import_element47 = __toESM(require_element(), 1);
15132
15133 // node_modules/@ariakit/react-components/dist/focusable/focusable-context.js
15134 var import_react7 = __toESM(require_react(), 1);
15135 var FocusableContext = (0, import_react7.createContext)(true);
15136
15137 // node_modules/@ariakit/utils/dist/index.js
15138 function toArray(arg) {
15139 if (Array.isArray(arg)) return arg;
15140 return typeof arg !== "undefined" ? [arg] : [];
15141 }
15142 function flatten2DArray(array) {
15143 const flattened = [];
15144 for (const row of array) flattened.push(...row);
15145 return flattened;
15146 }
15147 function reverseArray(array) {
15148 return array.slice().reverse();
15149 }
15150 function noop4(..._) {
15151 }
15152 function hasOwnProperty(object, prop) {
15153 if (typeof Object.hasOwn === "function") return Object.hasOwn(object, prop);
15154 return Object.prototype.hasOwnProperty.call(object, prop);
15155 }
15156 function chain(...fns) {
15157 return (...args) => {
15158 for (const fn of fns) if (typeof fn === "function") fn(...args);
15159 };
15160 }
15161 function normalizeString(str) {
15162 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
15163 }
15164 function omit2(object, keys) {
15165 const result = { ...object };
15166 for (const key of keys) if (hasOwnProperty(result, key)) delete result[key];
15167 return result;
15168 }
15169 function pick(object, paths) {
15170 const result = {};
15171 for (const key of paths) if (hasOwnProperty(object, key)) result[key] = object[key];
15172 return result;
15173 }
15174 function identity(value) {
15175 return value;
15176 }
15177 function afterPaint(cb = noop4) {
15178 let raf = requestAnimationFrame(() => {
15179 raf = requestAnimationFrame(cb);
15180 });
15181 return () => cancelAnimationFrame(raf);
15182 }
15183 function invariant(condition, message2) {
15184 if (condition) return;
15185 if (typeof message2 !== "string") throw new Error("Invariant failed");
15186 throw new Error(message2);
15187 }
15188 function getKeys(obj) {
15189 return Object.keys(obj);
15190 }
15191 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
15192 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
15193 if (result == null) return false;
15194 return !result;
15195 }
15196 function disabledFromProps(props) {
15197 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
15198 }
15199 function removeUndefinedValues(obj) {
15200 const result = {};
15201 for (const key in obj) if (obj[key] !== void 0) result[key] = obj[key];
15202 return result;
15203 }
15204 function defaultValue(...values) {
15205 for (const value of values) if (value !== void 0) return value;
15206 }
15207 var canUseDOM = checkIsBrowser();
15208 function checkIsBrowser() {
15209 return typeof window !== "undefined" && !!window.document?.createElement;
15210 }
15211 function getDocument(node) {
15212 if (!node) return document;
15213 if ("self" in node) return node.document;
15214 return node.ownerDocument || document;
15215 }
15216 function getActiveElement(node, activeDescendant = false) {
15217 const { activeElement: activeElement2 } = getDocument(node);
15218 if (!activeElement2?.nodeName) return null;
15219 if (isFrame(activeElement2) && activeElement2.contentDocument?.body) return getActiveElement(activeElement2.contentDocument.body, activeDescendant);
15220 if (activeDescendant) {
15221 const id = activeElement2.getAttribute("aria-activedescendant");
15222 if (id) {
15223 const element = getDocument(activeElement2).getElementById(id);
15224 if (element) return element;
15225 }
15226 }
15227 return activeElement2;
15228 }
15229 function contains2(parent, child) {
15230 return parent === child || parent.contains(child);
15231 }
15232 function isElement2(target) {
15233 return target?.nodeType === 1;
15234 }
15235 function isNode2(target) {
15236 return typeof target?.nodeType === "number";
15237 }
15238 function isFrame(element) {
15239 return element.tagName === "IFRAME";
15240 }
15241 function isButton(element) {
15242 const tagName = element.tagName.toLowerCase();
15243 if (tagName === "button") return true;
15244 if (tagName === "input" && element.type) return buttonInputTypes.indexOf(element.type) !== -1;
15245 return false;
15246 }
15247 var buttonInputTypes = [
15248 "button",
15249 "color",
15250 "file",
15251 "image",
15252 "reset",
15253 "submit"
15254 ];
15255 function isVisible(element) {
15256 if (typeof element.checkVisibility === "function") return element.checkVisibility();
15257 const htmlElement = element;
15258 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
15259 }
15260 function isTextField(element) {
15261 try {
15262 if (element.tagName === "TEXTAREA") return true;
15263 if (element.tagName !== "INPUT") return false;
15264 return element.selectionStart !== null;
15265 } catch (_error) {
15266 return false;
15267 }
15268 }
15269 function isTextbox(element) {
15270 return element.isContentEditable || isTextField(element);
15271 }
15272 function getTextboxValue(element) {
15273 if (isTextField(element)) return element.value;
15274 if (element.isContentEditable) {
15275 const range = getDocument(element).createRange();
15276 range.selectNodeContents(element);
15277 return range.toString();
15278 }
15279 return "";
15280 }
15281 function getTextboxSelection(element) {
15282 let start = 0;
15283 let end = 0;
15284 if (isTextField(element)) {
15285 start = element.selectionStart || 0;
15286 end = element.selectionEnd || 0;
15287 } else if (element.isContentEditable) {
15288 const selection = getDocument(element).getSelection();
15289 if (selection?.rangeCount && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
15290 const range = selection.getRangeAt(0);
15291 const nextRange = range.cloneRange();
15292 nextRange.selectNodeContents(element);
15293 nextRange.setEnd(range.startContainer, range.startOffset);
15294 start = nextRange.toString().length;
15295 nextRange.setEnd(range.endContainer, range.endOffset);
15296 end = nextRange.toString().length;
15297 }
15298 }
15299 return {
15300 start,
15301 end
15302 };
15303 }
15304 var allowedPopupRoles = [
15305 "dialog",
15306 "menu",
15307 "listbox",
15308 "tree",
15309 "grid"
15310 ];
15311 var itemRoleByPopupRole = {
15312 menu: "menuitem",
15313 listbox: "option",
15314 tree: "treeitem"
15315 };
15316 function getPopupRole(element, fallback) {
15317 const role = element?.getAttribute("role");
15318 if (role && allowedPopupRoles.indexOf(role) !== -1) return role;
15319 return fallback;
15320 }
15321 function getItemRoleByPopupRole(popupRole) {
15322 if (popupRole == null) return;
15323 if (!hasOwnProperty(itemRoleByPopupRole, popupRole)) return;
15324 return itemRoleByPopupRole[popupRole];
15325 }
15326 function getScrollingElement(element) {
15327 if (!element) return null;
15328 const isScrollableOverflow = (overflow) => {
15329 if (overflow === "auto") return true;
15330 if (overflow === "scroll") return true;
15331 return false;
15332 };
15333 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
15334 const { overflowY } = getComputedStyle(element);
15335 if (isScrollableOverflow(overflowY)) return element;
15336 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
15337 const { overflowX } = getComputedStyle(element);
15338 if (isScrollableOverflow(overflowX)) return element;
15339 }
15340 const doc = getDocument(element);
15341 return getScrollingElement(element.parentElement) || doc.scrollingElement || doc.body;
15342 }
15343 function setSelectionRange(element, ...args) {
15344 if (/text|search|password|tel|url/i.test(element.type)) element.setSelectionRange(...args);
15345 }
15346 function sortBasedOnDOMPosition(items, getElement) {
15347 const pairs = items.map((item, index2) => [index2, item]);
15348 let isOrderDifferent = false;
15349 pairs.sort(([indexA, a2], [indexB, b2]) => {
15350 const elementA = getElement(a2);
15351 const elementB = getElement(b2);
15352 if (elementA === elementB) return 0;
15353 if (!elementA || !elementB) return 0;
15354 if (isElementPreceding(elementA, elementB)) {
15355 if (indexA > indexB) isOrderDifferent = true;
15356 return -1;
15357 }
15358 if (indexA < indexB) isOrderDifferent = true;
15359 return 1;
15360 });
15361 if (isOrderDifferent) return pairs.map(([_, item]) => item);
15362 return items;
15363 }
15364 function isElementPreceding(a2, b2) {
15365 return Boolean(b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING);
15366 }
15367 function isTouchDevice() {
15368 return canUseDOM && !!navigator.maxTouchPoints;
15369 }
15370 function isApple() {
15371 if (!canUseDOM) return false;
15372 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
15373 }
15374 function isSafari() {
15375 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
15376 }
15377 function isFirefox() {
15378 return canUseDOM && /firefox\//i.test(navigator.userAgent);
15379 }
15380 function isPortalEvent(event) {
15381 const { currentTarget, target } = event;
15382 if (!currentTarget) return false;
15383 if (!isNode2(target)) return true;
15384 return !contains2(currentTarget, target);
15385 }
15386 function isSelfTarget(event) {
15387 return event.target === event.currentTarget;
15388 }
15389 function isActivatableNavigationTarget(element) {
15390 if (!isElement2(element)) return false;
15391 const target = element;
15392 const tagName = target.tagName.toLowerCase();
15393 if (tagName === "a") return true;
15394 if (tagName === "button" && target.type === "submit") return true;
15395 if (tagName === "input" && target.type === "submit") return true;
15396 return false;
15397 }
15398 function isOpeningInNewTab(event) {
15399 const isAppleDevice = isApple();
15400 if (isAppleDevice && !event.metaKey) return false;
15401 if (!isAppleDevice && !event.ctrlKey) return false;
15402 return isActivatableNavigationTarget(event.currentTarget);
15403 }
15404 function isDownloading(event) {
15405 if (!event.altKey) return false;
15406 return isActivatableNavigationTarget(event.currentTarget);
15407 }
15408 function fireBlurEvent(element, eventInit) {
15409 const event = new FocusEvent("blur", eventInit);
15410 const defaultAllowed = element.dispatchEvent(event);
15411 const bubbleInit = {
15412 ...eventInit,
15413 bubbles: true
15414 };
15415 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
15416 return defaultAllowed;
15417 }
15418 function fireKeyboardEvent(element, type, eventInit) {
15419 const event = new KeyboardEvent(type, eventInit);
15420 return element.dispatchEvent(event);
15421 }
15422 function fireClickEvent(element, eventInit) {
15423 const event = new MouseEvent("click", eventInit);
15424 return element.dispatchEvent(event);
15425 }
15426 function isFocusEventOutside(event, container) {
15427 const containerElement = container || event.currentTarget;
15428 const relatedTarget = event.relatedTarget;
15429 return !isNode2(relatedTarget) || !contains2(containerElement, relatedTarget);
15430 }
15431 function isInputEvent(event) {
15432 return event.type === "input";
15433 }
15434 function queueBeforeEvent(element, type, callback, timeout) {
15435 const createTimer = (callback2) => {
15436 if (timeout) {
15437 const timerId2 = setTimeout(callback2, timeout);
15438 return () => clearTimeout(timerId2);
15439 }
15440 const timerId = requestAnimationFrame(callback2);
15441 return () => cancelAnimationFrame(timerId);
15442 };
15443 const cancelTimer = createTimer(() => {
15444 element.removeEventListener(type, callSync, true);
15445 callback();
15446 });
15447 const callSync = () => {
15448 cancelTimer();
15449 callback();
15450 };
15451 element.addEventListener(type, callSync, {
15452 once: true,
15453 capture: true
15454 });
15455 return () => {
15456 cancelTimer();
15457 element.removeEventListener(type, callSync, true);
15458 };
15459 }
15460 function addGlobalEventListener(type, listener, options, scope = window) {
15461 const children = [];
15462 try {
15463 scope.document.addEventListener(type, listener, options);
15464 for (const frame of Array.from(scope.frames)) children.push(addGlobalEventListener(type, listener, options, frame));
15465 } catch {
15466 }
15467 const removeEventListener = () => {
15468 try {
15469 scope.document.removeEventListener(type, listener, options);
15470 } catch {
15471 }
15472 for (const remove of children) remove();
15473 };
15474 return removeEventListener;
15475 }
15476 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'])";
15477 function isFocusable(element) {
15478 if (!element.matches(selector)) return false;
15479 if (!isVisible(element)) return false;
15480 if (element.closest("[inert]")) return false;
15481 return true;
15482 }
15483 function hasFocus(element) {
15484 const activeElement2 = getActiveElement(element);
15485 if (!activeElement2) return false;
15486 if (activeElement2 === element) return true;
15487 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15488 if (!activeDescendant) return false;
15489 return activeDescendant === element.id;
15490 }
15491 function hasFocusWithin(element) {
15492 const activeElement2 = getActiveElement(element);
15493 if (!activeElement2) return false;
15494 if (contains2(element, activeElement2)) return true;
15495 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15496 if (!activeDescendant) return false;
15497 if (!("id" in element)) return false;
15498 if (activeDescendant === element.id) return true;
15499 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
15500 }
15501 function focusIntoView(element, options) {
15502 if (!("scrollIntoView" in element)) element.focus();
15503 else {
15504 element.focus({ preventScroll: true });
15505 element.scrollIntoView({
15506 block: "nearest",
15507 inline: "nearest",
15508 ...options
15509 });
15510 }
15511 }
15512 function createUndoCallback(callback) {
15513 return async () => {
15514 const redo = await callback?.();
15515 return createUndoCallback(async () => {
15516 await redo?.();
15517 return callback;
15518 });
15519 };
15520 }
15521 var UndoManager = createUndoManager();
15522 function createUndoManager({ limit = 100 } = {}) {
15523 const undoStack = [];
15524 let redoStack = [];
15525 let currentGroup = null;
15526 const canUndo = () => undoStack.length > 0;
15527 const canRedo = () => redoStack.length > 0;
15528 const undo = async () => {
15529 if (!canUndo()) return;
15530 currentGroup = null;
15531 redoStack.push(await undoStack.pop()?.());
15532 };
15533 const redo = async () => {
15534 if (!canRedo()) return;
15535 currentGroup = null;
15536 undoStack.push(await redoStack.pop()?.());
15537 };
15538 const execute = async (callback, group) => {
15539 if (!callback) return;
15540 const sameGroup = group === currentGroup;
15541 currentGroup = group ?? null;
15542 const nextIndex = sameGroup ? Math.max(0, undoStack.length - 1) : undoStack.length;
15543 const undoCallback = await callback();
15544 if (!undoCallback) return;
15545 redoStack = [];
15546 const currentUndo = undoStack[nextIndex];
15547 undoStack[nextIndex] = createUndoCallback(async () => {
15548 await undoCallback?.();
15549 const currentRedo = await currentUndo?.();
15550 return async () => {
15551 await currentRedo?.();
15552 await callback?.();
15553 };
15554 });
15555 while (undoStack.length > limit) undoStack.shift();
15556 };
15557 return {
15558 canUndo,
15559 canRedo,
15560 undo,
15561 redo,
15562 execute
15563 };
15564 }
15565
15566 // node_modules/@ariakit/react-utils/dist/index.js
15567 var React48 = __toESM(require_react(), 1);
15568 var import_react8 = __toESM(require_react(), 1);
15569 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
15570 function setRef(ref, value) {
15571 if (typeof ref === "function") {
15572 const cleanup = ref(value);
15573 if (typeof cleanup === "function") return cleanup;
15574 } else if (ref) ref.current = value;
15575 }
15576 function isValidElementWithRef(element) {
15577 if (!element) return false;
15578 if (!(0, import_react8.isValidElement)(element)) return false;
15579 if ("ref" in element.props) return true;
15580 if ("ref" in element) return true;
15581 return false;
15582 }
15583 function getRefProperty(element) {
15584 if (!isValidElementWithRef(element)) return null;
15585 return { ...element.props }.ref || element.ref;
15586 }
15587 function mergeProps2(base, overrides) {
15588 const props = { ...base };
15589 for (const key in overrides) {
15590 if (!hasOwnProperty(overrides, key)) continue;
15591 if (key === "className") {
15592 const prop = "className";
15593 const baseClass = base[prop];
15594 const overrideClass = overrides[prop];
15595 if (baseClass && overrideClass) props[prop] = `${baseClass} ${overrideClass}`;
15596 else props[prop] = overrideClass || baseClass;
15597 continue;
15598 }
15599 if (key === "style") {
15600 const prop = "style";
15601 props[prop] = base[prop] ? {
15602 ...base[prop],
15603 ...overrides[prop]
15604 } : overrides[prop];
15605 continue;
15606 }
15607 const overrideValue = overrides[key];
15608 if (key.startsWith("on")) {
15609 if (typeof overrideValue !== "function") continue;
15610 const baseValue = base[key];
15611 if (typeof baseValue === "function") {
15612 props[key] = (...args) => {
15613 overrideValue(...args);
15614 baseValue(...args);
15615 };
15616 continue;
15617 }
15618 }
15619 props[key] = overrideValue;
15620 }
15621 return props;
15622 }
15623 var _React = { ...React48 };
15624 var useReactId = _React.useId;
15625 var useReactDeferredValue = _React.useDeferredValue;
15626 var useReactInsertionEffect = _React.useInsertionEffect;
15627 var useSafeLayoutEffect = canUseDOM ? import_react8.useLayoutEffect : import_react8.useEffect;
15628 function useInitialValue(value) {
15629 const [initialValue] = (0, import_react8.useState)(value);
15630 return initialValue;
15631 }
15632 function useLiveRef(value) {
15633 const ref = (0, import_react8.useRef)(value);
15634 useSafeLayoutEffect(() => {
15635 ref.current = value;
15636 });
15637 return ref;
15638 }
15639 function useEvent(callback) {
15640 const ref = (0, import_react8.useRef)(() => {
15641 throw new Error("Cannot call an event handler while rendering.");
15642 });
15643 if (useReactInsertionEffect) useReactInsertionEffect(() => {
15644 ref.current = callback;
15645 });
15646 else ref.current = callback;
15647 return (0, import_react8.useCallback)((...args) => ref.current?.(...args), []);
15648 }
15649 function useTransactionState(callback) {
15650 const [state, setState] = (0, import_react8.useState)(null);
15651 useSafeLayoutEffect(() => {
15652 if (state == null) return;
15653 if (!callback) return;
15654 let prevState = null;
15655 callback((prev) => {
15656 prevState = prev;
15657 return state;
15658 });
15659 return () => {
15660 callback(prevState);
15661 };
15662 }, [state, callback]);
15663 return [state, setState];
15664 }
15665 function useMergeRefs(...refs) {
15666 return (0, import_react8.useMemo)(() => {
15667 if (!refs.some(Boolean)) return;
15668 return (value) => {
15669 const refEffects = [];
15670 for (const ref of refs) {
15671 if (!ref) continue;
15672 const cleanup = setRef(ref, value);
15673 refEffects.push({
15674 ref,
15675 cleanup: typeof cleanup === "function" ? cleanup : void 0
15676 });
15677 }
15678 if (!refEffects.some((effect) => effect.cleanup)) return;
15679 return () => {
15680 for (const { ref, cleanup } of refEffects) if (cleanup) cleanup();
15681 else setRef(ref, null);
15682 };
15683 };
15684 }, refs);
15685 }
15686 function useId4(defaultId) {
15687 if (useReactId) {
15688 const reactId = useReactId();
15689 if (defaultId) return defaultId;
15690 return reactId;
15691 }
15692 const [id, setId] = (0, import_react8.useState)(defaultId);
15693 useSafeLayoutEffect(() => {
15694 if (defaultId || id) return;
15695 setId(`id-${Math.random().toString(36).slice(2, 8)}`);
15696 }, [defaultId, id]);
15697 return defaultId || id;
15698 }
15699 function useTagName(refOrElement, type) {
15700 const stringOrUndefined = (type2) => {
15701 if (typeof type2 !== "string") return;
15702 return type2;
15703 };
15704 const [tagName, setTagName] = (0, import_react8.useState)(() => stringOrUndefined(type));
15705 useSafeLayoutEffect(() => {
15706 setTagName((refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement)?.tagName.toLowerCase() || stringOrUndefined(type));
15707 }, [refOrElement, type]);
15708 return tagName;
15709 }
15710 function useAttribute(refOrElement, attributeName, defaultValue2) {
15711 const initialValue = useInitialValue(defaultValue2);
15712 const [attribute, setAttribute] = (0, import_react8.useState)(initialValue);
15713 (0, import_react8.useEffect)(() => {
15714 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
15715 if (!element) return;
15716 const callback = () => {
15717 const value = element.getAttribute(attributeName);
15718 setAttribute(value == null ? initialValue : value);
15719 };
15720 const observer = new MutationObserver(callback);
15721 observer.observe(element, { attributeFilter: [attributeName] });
15722 callback();
15723 return () => observer.disconnect();
15724 }, [
15725 refOrElement,
15726 attributeName,
15727 initialValue
15728 ]);
15729 return attribute;
15730 }
15731 function useUpdateEffect(effect, deps) {
15732 const mounted = (0, import_react8.useRef)(false);
15733 (0, import_react8.useEffect)(() => {
15734 if (mounted.current) return effect();
15735 mounted.current = true;
15736 }, deps);
15737 (0, import_react8.useEffect)(() => () => {
15738 mounted.current = false;
15739 }, []);
15740 }
15741 function useUpdateLayoutEffect(effect, deps) {
15742 const mounted = (0, import_react8.useRef)(false);
15743 useSafeLayoutEffect(() => {
15744 if (mounted.current) return effect();
15745 mounted.current = true;
15746 }, deps);
15747 useSafeLayoutEffect(() => () => {
15748 mounted.current = false;
15749 }, []);
15750 }
15751 function useForceUpdate() {
15752 return (0, import_react8.useReducer)(() => [], []);
15753 }
15754 function useBooleanEvent(booleanOrCallback) {
15755 return useEvent(typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback);
15756 }
15757 function useWrapElement(props, callback, deps = []) {
15758 const wrapElement = (0, import_react8.useCallback)((element) => {
15759 if (props.wrapElement) element = props.wrapElement(element);
15760 return callback(element);
15761 }, [...deps, props.wrapElement]);
15762 return {
15763 ...props,
15764 wrapElement
15765 };
15766 }
15767 function useMetadataProps(props, key, value) {
15768 const parent = props.onLoadedMetadataCapture;
15769 const onLoadedMetadataCapture = (0, import_react8.useMemo)(() => {
15770 return Object.assign(() => {
15771 }, parent, ...value !== void 0 ? [{ [key]: value }] : []);
15772 }, [
15773 parent,
15774 key,
15775 value
15776 ]);
15777 return [parent?.[key], { onLoadedMetadataCapture }];
15778 }
15779 var hasInstalledGlobalEventListeners = false;
15780 function useIsMouseMoving() {
15781 (0, import_react8.useEffect)(() => {
15782 if (hasInstalledGlobalEventListeners) return;
15783 addGlobalEventListener("mousemove", setMouseMoving, true);
15784 addGlobalEventListener("mousedown", resetMouseMoving, true);
15785 addGlobalEventListener("mouseup", resetMouseMoving, true);
15786 addGlobalEventListener("keydown", resetMouseMoving, true);
15787 addGlobalEventListener("scroll", resetMouseMoving, true);
15788 hasInstalledGlobalEventListeners = true;
15789 }, []);
15790 return useEvent(() => mouseMoving);
15791 }
15792 var mouseMoving = false;
15793 var previousScreenX = 0;
15794 var previousScreenY = 0;
15795 function hasMouseMovement(event) {
15796 const movementX = event.movementX || event.screenX - previousScreenX;
15797 const movementY = event.movementY || event.screenY - previousScreenY;
15798 previousScreenX = event.screenX;
15799 previousScreenY = event.screenY;
15800 return movementX || movementY || false;
15801 }
15802 function setMouseMoving(event) {
15803 if (!hasMouseMovement(event)) return;
15804 mouseMoving = true;
15805 }
15806 function resetMouseMoving() {
15807 mouseMoving = false;
15808 }
15809 function forwardRef21(render4) {
15810 const Role = React48.forwardRef((props, ref) => render4({
15811 ...props,
15812 ref
15813 }));
15814 Role.displayName = render4.displayName || render4.name;
15815 return Role;
15816 }
15817 function memo3(Component, propsAreEqual) {
15818 return React48.memo(Component, propsAreEqual);
15819 }
15820 function createElement3(Type, props) {
15821 const { wrapElement, render: render4, ...rest } = props;
15822 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
15823 let element;
15824 if (React48.isValidElement(render4)) {
15825 const renderProps = {
15826 ...render4.props,
15827 ref: mergedRef
15828 };
15829 element = React48.cloneElement(render4, mergeProps2(rest, renderProps));
15830 } else if (render4) element = render4(rest);
15831 else element = /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Type, { ...rest });
15832 if (wrapElement) return wrapElement(element);
15833 return element;
15834 }
15835 function createHook(useProps) {
15836 const useRole = (props = {}) => {
15837 return useProps(props);
15838 };
15839 useRole.displayName = useProps.name;
15840 return useRole;
15841 }
15842 function createStoreContext(providers = [], scopedProviders = []) {
15843 const context = React48.createContext(void 0);
15844 const scopedContext = React48.createContext(void 0);
15845 const useContext38 = () => React48.useContext(context);
15846 const useScopedContext = (onlyScoped = false) => {
15847 const scoped = React48.useContext(scopedContext);
15848 const store = useContext38();
15849 if (onlyScoped) return scoped;
15850 return scoped || store;
15851 };
15852 const useProviderContext = () => {
15853 const scoped = React48.useContext(scopedContext);
15854 const store = useContext38();
15855 if (scoped && scoped === store) return;
15856 return store;
15857 };
15858 const ContextProvider = (props) => {
15859 return providers.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Provider2, {
15860 ...props,
15861 children
15862 }), /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(context.Provider, { ...props }));
15863 };
15864 const ScopedContextProvider = (props) => {
15865 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ContextProvider, {
15866 ...props,
15867 children: scopedProviders.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Provider2, {
15868 ...props,
15869 children
15870 }), /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(scopedContext.Provider, { ...props }))
15871 });
15872 };
15873 return {
15874 context,
15875 scopedContext,
15876 useContext: useContext38,
15877 useScopedContext,
15878 useProviderContext,
15879 ContextProvider,
15880 ScopedContextProvider
15881 };
15882 }
15883
15884 // node_modules/@ariakit/react-components/dist/focusable/focusable.js
15885 var import_react9 = __toESM(require_react(), 1);
15886 var TagName = "div";
15887 var accessibleWhenDisabledSymbol = /* @__PURE__ */ Symbol("accessibleWhenDisabled");
15888 var isSafariBrowser = isSafari();
15889 var alwaysFocusVisibleInputTypes = [
15890 "text",
15891 "search",
15892 "url",
15893 "tel",
15894 "email",
15895 "password",
15896 "number",
15897 "date",
15898 "month",
15899 "week",
15900 "time",
15901 "datetime",
15902 "datetime-local"
15903 ];
15904 function isAlwaysFocusVisible(element) {
15905 const { tagName, readOnly, type } = element;
15906 if (tagName === "TEXTAREA" && !readOnly) return true;
15907 if (tagName === "SELECT" && !readOnly) return true;
15908 if (tagName === "INPUT" && !readOnly) return alwaysFocusVisibleInputTypes.includes(type);
15909 if (element.isContentEditable) return true;
15910 if (element.getAttribute("role") === "combobox" && element.dataset.name) return true;
15911 return false;
15912 }
15913 function isNativeTabbable(tagName) {
15914 if (!tagName) return true;
15915 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
15916 }
15917 function supportsDisabledAttribute(tagName) {
15918 if (!tagName) return true;
15919 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
15920 }
15921 function isNativeSubmitControl(element) {
15922 if (element.tagName === "BUTTON") {
15923 const { type } = element;
15924 return type === "submit";
15925 }
15926 if (element.tagName === "INPUT") {
15927 const { type } = element;
15928 return type === "submit" || type === "image";
15929 }
15930 return false;
15931 }
15932 function getTabIndex2({ focusable: focusable2, trulyDisabled, nativeTabbable, supportsDisabled, safariTabIndex, tabIndexProp }) {
15933 if (!focusable2) return tabIndexProp;
15934 if (trulyDisabled) {
15935 if (nativeTabbable && !supportsDisabled) return -1;
15936 return;
15937 }
15938 if (nativeTabbable) {
15939 if (safariTabIndex && tabIndexProp == null) return 0;
15940 return tabIndexProp;
15941 }
15942 return tabIndexProp ?? 0;
15943 }
15944 function useDisableEvent(onEvent, disabled2) {
15945 return useEvent((event) => {
15946 onEvent?.(event);
15947 if (event.defaultPrevented) return;
15948 if (disabled2) {
15949 event.stopPropagation();
15950 event.preventDefault();
15951 }
15952 });
15953 }
15954 var hasInstalledGlobalEventListeners2 = false;
15955 var isKeyboardModality = true;
15956 function onGlobalMouseDown(event) {
15957 const target = event.target;
15958 if (isElement2(target) && !target.hasAttribute("data-focus-visible")) isKeyboardModality = false;
15959 }
15960 function onGlobalKeyDown(event) {
15961 if (event.metaKey) return;
15962 if (event.ctrlKey) return;
15963 if (event.altKey) return;
15964 isKeyboardModality = true;
15965 }
15966 var useFocusable = createHook(function useFocusable2({ focusable: focusable2 = true, accessibleWhenDisabled, autoFocus, onFocusVisible, ...props }) {
15967 const ref = (0, import_react9.useRef)(null);
15968 const [parentAccessibleWhenDisabled, metadataProps] = useMetadataProps(props, accessibleWhenDisabledSymbol, accessibleWhenDisabled);
15969 accessibleWhenDisabled ??= parentAccessibleWhenDisabled;
15970 (0, import_react9.useEffect)(() => {
15971 if (!focusable2) return;
15972 if (hasInstalledGlobalEventListeners2) return;
15973 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
15974 addGlobalEventListener("keydown", onGlobalKeyDown, true);
15975 hasInstalledGlobalEventListeners2 = true;
15976 }, [focusable2]);
15977 const disabled2 = focusable2 && disabledFromProps(props);
15978 const trulyDisabled = disabled2 && !accessibleWhenDisabled;
15979 const [focusVisible, setFocusVisible] = (0, import_react9.useState)(false);
15980 const focusVisibleRef = (0, import_react9.useRef)(false);
15981 const nativeSubmitObserverCleanupRef = (0, import_react9.useRef)(null);
15982 const cleanupFocusVisible = useEvent((element) => {
15983 nativeSubmitObserverCleanupRef.current?.();
15984 nativeSubmitObserverCleanupRef.current = null;
15985 focusVisibleRef.current = false;
15986 element?.removeAttribute("data-focus-visible");
15987 });
15988 (0, import_react9.useEffect)(() => {
15989 if (!focusable2) return;
15990 if (!trulyDisabled) return;
15991 cleanupFocusVisible(ref.current);
15992 if (focusVisible) setFocusVisible(false);
15993 }, [
15994 focusable2,
15995 trulyDisabled,
15996 focusVisible,
15997 cleanupFocusVisible
15998 ]);
15999 (0, import_react9.useEffect)(() => {
16000 if (!focusable2) return;
16001 if (!focusVisible) return;
16002 const element = ref.current;
16003 if (!element) return;
16004 if (typeof IntersectionObserver === "undefined") return;
16005 const observer = new IntersectionObserver(() => {
16006 if (!isFocusable(element)) {
16007 focusVisibleRef.current = false;
16008 setFocusVisible(false);
16009 }
16010 });
16011 observer.observe(element);
16012 return () => observer.disconnect();
16013 }, [focusable2, focusVisible]);
16014 (0, import_react9.useEffect)(() => {
16015 return () => nativeSubmitObserverCleanupRef.current?.();
16016 }, []);
16017 const onKeyPressCapture = useDisableEvent(props.onKeyPressCapture, disabled2);
16018 const onMouseDownCapture = useDisableEvent(props.onMouseDownCapture, disabled2);
16019 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
16020 const handleFocusVisible = (event, currentTarget) => {
16021 if (currentTarget) event.currentTarget = currentTarget;
16022 if (!focusable2) return;
16023 const element = event.currentTarget;
16024 if (!element) return;
16025 if (!hasFocus(element)) return;
16026 onFocusVisible?.(event);
16027 if (event.defaultPrevented) return;
16028 element.dataset.focusVisible = "true";
16029 focusVisibleRef.current = true;
16030 if (isNativeSubmitControl(element)) {
16031 nativeSubmitObserverCleanupRef.current?.();
16032 nativeSubmitObserverCleanupRef.current = null;
16033 if (typeof IntersectionObserver !== "undefined") {
16034 const observer = new IntersectionObserver(() => {
16035 if (isFocusable(element)) return;
16036 cleanupFocusVisible(element);
16037 });
16038 observer.observe(element);
16039 nativeSubmitObserverCleanupRef.current = () => observer.disconnect();
16040 }
16041 return;
16042 }
16043 setFocusVisible(true);
16044 };
16045 const onKeyDownCaptureProp = props.onKeyDownCapture;
16046 const onKeyDownCapture = useEvent((event) => {
16047 onKeyDownCaptureProp?.(event);
16048 if (event.defaultPrevented) return;
16049 if (!focusable2) return;
16050 if (focusVisible) return;
16051 if (focusVisibleRef.current) return;
16052 if (event.metaKey) return;
16053 if (event.altKey) return;
16054 if (event.ctrlKey) return;
16055 if (!isSelfTarget(event)) return;
16056 const element = event.currentTarget;
16057 const applyFocusVisible = () => handleFocusVisible(event, element);
16058 queueBeforeEvent(element, "focusout", applyFocusVisible);
16059 });
16060 const onFocusCaptureProp = props.onFocusCapture;
16061 const onFocusCapture = useEvent((event) => {
16062 onFocusCaptureProp?.(event);
16063 if (event.defaultPrevented) return;
16064 if (!focusable2) return;
16065 if (!isSelfTarget(event)) {
16066 setFocusVisible(false);
16067 return;
16068 }
16069 const element = event.currentTarget;
16070 const applyFocusVisible = () => handleFocusVisible(event, element);
16071 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) queueBeforeEvent(event.target, "focusout", applyFocusVisible);
16072 else setFocusVisible(false);
16073 });
16074 const onBlurProp = props.onBlur;
16075 const onBlur = useEvent((event) => {
16076 onBlurProp?.(event);
16077 if (!focusable2) return;
16078 if (!isFocusEventOutside(event)) return;
16079 cleanupFocusVisible(event.currentTarget);
16080 setFocusVisible(false);
16081 });
16082 const autoFocusOnShow = (0, import_react9.useContext)(FocusableContext);
16083 const autoFocusRef = useEvent((element) => {
16084 if (!focusable2) return;
16085 if (!autoFocus) return;
16086 if (!element) return;
16087 if (!autoFocusOnShow) return;
16088 queueMicrotask(() => {
16089 if (hasFocus(element)) return;
16090 if (!isFocusable(element)) return;
16091 element.focus();
16092 });
16093 });
16094 const tagName = useTagName(ref);
16095 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
16096 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
16097 const [safariTabIndex, setSafariTabIndex] = (0, import_react9.useState)(false);
16098 if (isSafariBrowser) (0, import_react9.useEffect)(() => {
16099 if (!focusable2) return;
16100 const element = ref.current;
16101 if (!element) return;
16102 const { type } = element;
16103 const isNativeCheckboxOrRadio = element.tagName === "INPUT" && (type === "checkbox" || type === "radio");
16104 setSafariTabIndex(isButton(element) || isNativeCheckboxOrRadio);
16105 }, [focusable2]);
16106 const styleProp = props.style;
16107 const style = (0, import_react9.useMemo)(() => {
16108 if (trulyDisabled) return {
16109 pointerEvents: "none",
16110 ...styleProp
16111 };
16112 return styleProp;
16113 }, [trulyDisabled, styleProp]);
16114 props = {
16115 "data-focus-visible": focusable2 && focusVisible || void 0,
16116 "data-autofocus": autoFocus || void 0,
16117 "aria-disabled": disabled2 || void 0,
16118 ...props,
16119 ...metadataProps,
16120 ref: useMergeRefs(ref, autoFocusRef, props.ref),
16121 style,
16122 tabIndex: getTabIndex2({
16123 focusable: focusable2,
16124 trulyDisabled,
16125 nativeTabbable,
16126 supportsDisabled,
16127 safariTabIndex,
16128 tabIndexProp: props.tabIndex
16129 }),
16130 disabled: supportsDisabled && trulyDisabled ? true : void 0,
16131 contentEditable: disabled2 ? void 0 : props.contentEditable,
16132 onKeyPressCapture,
16133 onClickCapture,
16134 onMouseDownCapture,
16135 onKeyDownCapture,
16136 onFocusCapture,
16137 onBlur
16138 };
16139 return removeUndefinedValues(props);
16140 });
16141 var Focusable = forwardRef21(function Focusable2(props) {
16142 return createElement3(TagName, useFocusable(props));
16143 });
16144
16145 // node_modules/@ariakit/react-components/dist/command/command.js
16146 var import_react10 = __toESM(require_react(), 1);
16147 var TagName2 = "button";
16148 function isNativeClick(event) {
16149 if (!event.isTrusted) return false;
16150 const element = event.currentTarget;
16151 if (event.key === "Enter") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
16152 if (event.key === " ") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
16153 return false;
16154 }
16155 var symbol = /* @__PURE__ */ Symbol("command");
16156 var useCommand = createHook(function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
16157 const ref = (0, import_react10.useRef)(null);
16158 const [isNativeButton, setIsNativeButton] = (0, import_react10.useState)(false);
16159 (0, import_react10.useEffect)(() => {
16160 if (!ref.current) return;
16161 setIsNativeButton(isButton(ref.current));
16162 }, []);
16163 const [active, setActive] = (0, import_react10.useState)(false);
16164 const activeRef = (0, import_react10.useRef)(false);
16165 const disabled2 = disabledFromProps(props);
16166 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
16167 useSafeLayoutEffect(() => {
16168 if (!disabled2) return;
16169 activeRef.current = false;
16170 setActive(false);
16171 }, [disabled2]);
16172 const onKeyDownProp = props.onKeyDown;
16173 const onKeyDown = useEvent((event) => {
16174 onKeyDownProp?.(event);
16175 const element = event.currentTarget;
16176 if (event.defaultPrevented) return;
16177 if (isDuplicate) return;
16178 if (disabled2) return;
16179 if (!isSelfTarget(event)) return;
16180 if (isTextField(element)) return;
16181 if (element.isContentEditable) return;
16182 const isEnter = clickOnEnter && event.key === "Enter";
16183 const isSpace = clickOnSpace && event.key === " ";
16184 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
16185 const shouldPreventSpace = event.key === " " && !clickOnSpace;
16186 if (shouldPreventEnter || shouldPreventSpace) {
16187 event.preventDefault();
16188 return;
16189 }
16190 if (isEnter || isSpace) {
16191 const nativeClick = isNativeClick(event);
16192 if (isEnter) {
16193 if (!nativeClick) {
16194 event.preventDefault();
16195 const { view, ...eventInit } = event;
16196 const click = () => fireClickEvent(element, eventInit);
16197 if (isFirefox()) queueBeforeEvent(element, "keyup", click);
16198 else queueMicrotask(click);
16199 }
16200 } else if (isSpace) {
16201 activeRef.current = true;
16202 if (!nativeClick) {
16203 event.preventDefault();
16204 setActive(true);
16205 }
16206 }
16207 }
16208 });
16209 const onKeyUpProp = props.onKeyUp;
16210 const onKeyUp = useEvent((event) => {
16211 onKeyUpProp?.(event);
16212 if (isDuplicate) return;
16213 const isSpace = clickOnSpace && event.key === " ";
16214 if (!activeRef.current || !isSpace) return;
16215 const nativeClick = isNativeClick(event);
16216 activeRef.current = false;
16217 if (!nativeClick) setActive(false);
16218 if (event.defaultPrevented) return;
16219 if (!isSelfTarget(event)) return;
16220 if (disabled2) return;
16221 if (event.metaKey) return;
16222 if (nativeClick) return;
16223 event.preventDefault();
16224 const element = event.currentTarget;
16225 const { view, ...eventInit } = event;
16226 queueMicrotask(() => fireClickEvent(element, eventInit));
16227 });
16228 const onBlurProp = props.onBlur;
16229 const onBlur = useEvent((event) => {
16230 onBlurProp?.(event);
16231 if (!activeRef.current) return;
16232 activeRef.current = false;
16233 setActive(false);
16234 });
16235 props = {
16236 "data-active": active || void 0,
16237 type: isNativeButton ? "button" : void 0,
16238 ...metadataProps,
16239 ...props,
16240 ref: useMergeRefs(ref, props.ref),
16241 onKeyDown,
16242 onKeyUp,
16243 onBlur
16244 };
16245 props = useFocusable(props);
16246 return props;
16247 });
16248 var Command = forwardRef21(function Command2(props) {
16249 return createElement3(TagName2, useCommand(props));
16250 });
16251
16252 // node_modules/@ariakit/react-components/dist/collection/collection-context.js
16253 var ctx = createStoreContext();
16254 var useCollectionContext = ctx.useContext;
16255 var useCollectionScopedContext = ctx.useScopedContext;
16256 var useCollectionProviderContext = ctx.useProviderContext;
16257 var CollectionContextProvider = ctx.ContextProvider;
16258 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
16259
16260 // node_modules/@ariakit/react-components/dist/collection/collection-item.js
16261 var import_react11 = __toESM(require_react(), 1);
16262 var TagName3 = "div";
16263 var useCollectionItem = createHook(function useCollectionItem2({ store, shouldRegisterItem = true, getItem = identity, element, ...props }) {
16264 const context = useCollectionContext();
16265 store = store || context;
16266 const id = useId4(props.id);
16267 const ref = (0, import_react11.useRef)(element);
16268 (0, import_react11.useEffect)(() => {
16269 const element2 = ref.current;
16270 if (!id) return;
16271 if (!element2) return;
16272 if (!shouldRegisterItem) return;
16273 const item = getItem({
16274 id,
16275 element: element2
16276 });
16277 return store?.renderItem(item);
16278 }, [
16279 id,
16280 shouldRegisterItem,
16281 getItem,
16282 store
16283 ]);
16284 props = {
16285 ...props,
16286 ref: useMergeRefs(ref, props.ref)
16287 };
16288 return removeUndefinedValues(props);
16289 });
16290 var CollectionItem = forwardRef21(function CollectionItem2(props) {
16291 return createElement3(TagName3, useCollectionItem(props));
16292 });
16293
16294 // node_modules/@ariakit/react-components/dist/composite/composite-context.js
16295 var import_react12 = __toESM(require_react(), 1);
16296 var ctx2 = createStoreContext([CollectionContextProvider], [CollectionScopedContextProvider]);
16297 var useCompositeContext = ctx2.useContext;
16298 var useCompositeScopedContext = ctx2.useScopedContext;
16299 var useCompositeProviderContext = ctx2.useProviderContext;
16300 var CompositeContextProvider = ctx2.ContextProvider;
16301 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
16302 var CompositeItemContext = (0, import_react12.createContext)(void 0);
16303 var CompositeRowContext = (0, import_react12.createContext)(void 0);
16304
16305 // node_modules/@ariakit/store/dist/index.js
16306 function getInternal(store, key) {
16307 const internals = store.__unstableInternals;
16308 invariant(internals, "Invalid store");
16309 return internals[key];
16310 }
16311 function hasUpdatedKey(keys, updatedKey) {
16312 if (!keys) return true;
16313 for (const currentKey of keys) if (updatedKey instanceof Set) {
16314 if (updatedKey.has(currentKey)) return true;
16315 } else if (currentKey === updatedKey) return true;
16316 return false;
16317 }
16318 function isSameValue(value, other) {
16319 return value === other || value !== value && other !== other;
16320 }
16321 function getCleanupPrevState(prevState, state, stateBeforeCleanup, updatedKey) {
16322 let cleanupPrevState;
16323 for (const key of getKeys(state)) {
16324 if (isSameValue(state[key], stateBeforeCleanup[key])) continue;
16325 if (updatedKey !== void 0 && hasUpdatedKey([key], updatedKey)) continue;
16326 cleanupPrevState ??= { ...prevState };
16327 cleanupPrevState[key] = state[key];
16328 }
16329 return cleanupPrevState;
16330 }
16331 var MAX_REPAIR_PASSES = 100;
16332 function addKeyedListener(map, keys, listener) {
16333 if (!keys) return;
16334 for (const key of keys) {
16335 let listeners = map.get(key);
16336 if (!listeners) {
16337 listeners = /* @__PURE__ */ new Set();
16338 map.set(key, listeners);
16339 }
16340 listeners.add(listener);
16341 }
16342 }
16343 function deleteKeyedListener(map, keys, listener) {
16344 if (!map) return;
16345 if (!keys) return;
16346 for (const key of keys) {
16347 const listeners = map.get(key);
16348 if (!listeners) continue;
16349 listeners.delete(listener);
16350 if (!listeners.size) map.delete(key);
16351 }
16352 }
16353 function getFastPathNotifiedListeners(frame) {
16354 const notifiedListeners = /* @__PURE__ */ new Set();
16355 const currentListener = frame.currentListener;
16356 if (!currentListener) return notifiedListeners;
16357 for (const listener of frame.keyedListeners) {
16358 notifiedListeners.add(listener);
16359 if (listener === currentListener) return notifiedListeners;
16360 }
16361 notifiedListeners.clear();
16362 notifiedListeners.add(currentListener);
16363 return notifiedListeners;
16364 }
16365 function preserveFastPathNotifiedListeners(frame) {
16366 frame.notifiedListeners ??= getFastPathNotifiedListeners(frame);
16367 }
16368 function hasFastPathPassedListener(frame, listener) {
16369 if (!frame.currentListener) return false;
16370 let foundCurrentKeyedListener = false;
16371 for (const currentListener of frame.keyedListeners) {
16372 if (currentListener === frame.currentListener) {
16373 foundCurrentKeyedListener = true;
16374 continue;
16375 }
16376 if (!foundCurrentKeyedListener) continue;
16377 if (currentListener === listener) return false;
16378 }
16379 let foundListener = false;
16380 for (const currentListener of frame.group.listeners) {
16381 if (currentListener === frame.currentListener) return foundListener;
16382 if (currentListener === listener) foundListener = true;
16383 }
16384 return false;
16385 }
16386 function preserveFastPathFrames(fastPathFrames, group, listener) {
16387 for (const frame of fastPathFrames) {
16388 if (frame.group !== group) continue;
16389 if (frame.recovering) continue;
16390 if (listener && !frame.keyedListeners.has(listener)) continue;
16391 preserveFastPathNotifiedListeners(frame);
16392 for (const currentListener of frame.group.listeners) {
16393 if (currentListener === frame.currentListener) break;
16394 if (!hasFastPathPassedListener(frame, currentListener)) continue;
16395 frame.notifiedListeners?.add(currentListener);
16396 }
16397 }
16398 }
16399 function preserveFastPathPassedListeners(fastPathFrames, group, listener) {
16400 for (const frame of fastPathFrames) {
16401 if (frame.group !== group) continue;
16402 if (frame.recovering) continue;
16403 if (!hasFastPathPassedListener(frame, listener)) continue;
16404 preserveFastPathNotifiedListeners(frame);
16405 frame.notifiedListeners?.add(listener);
16406 }
16407 }
16408 function preserveFastPathPassedKeyedListeners({ fastPathFrames, group, keys, listener }) {
16409 const wasRegistered = group.listeners.has(listener);
16410 for (const frame of fastPathFrames) {
16411 if (frame.group !== group) continue;
16412 if (frame.recovering) continue;
16413 if (!keys.includes(frame.updatedKey)) continue;
16414 if (hasFastPathPassedListener(frame, listener)) {
16415 preserveFastPathNotifiedListeners(frame);
16416 frame.notifiedListeners?.add(listener);
16417 } else if (wasRegistered) {
16418 preserveFastPathNotifiedListeners(frame);
16419 frame.recoverToLive = true;
16420 }
16421 }
16422 }
16423 function clearFastPathNotifiedListener(fastPathFrames, group, listener) {
16424 for (const frame of fastPathFrames) {
16425 if (frame.group !== group) continue;
16426 frame.notifiedListeners?.delete(listener);
16427 }
16428 }
16429 function addFastPathKeyedListener({ fastPathFrames, group, keys, listener }) {
16430 for (const frame of fastPathFrames) {
16431 if (frame.group !== group) continue;
16432 if (frame.recovering) continue;
16433 if (!keys.includes(frame.updatedKey)) continue;
16434 frame.keyedListeners.add(listener);
16435 }
16436 }
16437 function runPendingCleanup(group, listener) {
16438 if (!group.disposables.size) return;
16439 const cleanup = group.disposables.get(listener);
16440 if (!cleanup) return;
16441 group.disposables.delete(listener);
16442 cleanup();
16443 }
16444 function setListenerCleanup(group, listener, cleanup) {
16445 const currentCleanup = group.disposables.get(listener);
16446 if (!currentCleanup) {
16447 group.disposables.set(listener, cleanup);
16448 return;
16449 }
16450 group.disposables.set(listener, () => {
16451 currentCleanup();
16452 cleanup();
16453 });
16454 }
16455 function notifyStoreListener(group, listener, state, prevState, getState, updatedKey) {
16456 if (group.suspendCounts?.has(listener)) return;
16457 const { disposables } = group;
16458 const cleanup = disposables.size ? disposables.get(listener) : void 0;
16459 if (cleanup) {
16460 disposables.delete(listener);
16461 const stateBeforeCleanup = state;
16462 cleanup();
16463 state = getState?.() ?? state;
16464 if (state !== stateBeforeCleanup) prevState = getCleanupPrevState(prevState, state, stateBeforeCleanup, updatedKey) ?? prevState;
16465 }
16466 const result = listener(state, prevState);
16467 if (result) setListenerCleanup(group, listener, result);
16468 }
16469 function runLiveListeners({ group, getState, prevState, updatedKey, notifiedListeners }) {
16470 const allKeysListeners = group.allKeysListeners;
16471 for (const listener of group.listeners) {
16472 if (notifiedListeners?.has(listener)) continue;
16473 if (!allKeysListeners?.has(listener)) {
16474 if (!hasUpdatedKey(group.listenerKeys.get(listener), updatedKey)) continue;
16475 }
16476 notifiedListeners?.add(listener);
16477 notifyStoreListener(group, listener, getState(), prevState, getState, updatedKey);
16478 }
16479 }
16480 function createStore(initialState, ...stores) {
16481 let state = initialState;
16482 let prevStateBatch = state;
16483 let destroy = noop4;
16484 let batchPending = false;
16485 let inDispatch = false;
16486 let updatedKeys = /* @__PURE__ */ new Set();
16487 const instances = /* @__PURE__ */ new Set();
16488 const setups = /* @__PURE__ */ new Set();
16489 const syncListenerGroup = {
16490 listeners: /* @__PURE__ */ new Set(),
16491 disposables: /* @__PURE__ */ new Map(),
16492 listenerKeys: /* @__PURE__ */ new WeakMap()
16493 };
16494 const batchListenerGroup = {
16495 listeners: /* @__PURE__ */ new Set(),
16496 disposables: /* @__PURE__ */ new Map(),
16497 listenerKeys: /* @__PURE__ */ new WeakMap()
16498 };
16499 const storeSetup = (callback) => {
16500 setups.add(callback);
16501 return () => setups.delete(callback);
16502 };
16503 const storeInit = () => {
16504 const initializedInstances = instances.size;
16505 const instance = /* @__PURE__ */ Symbol();
16506 instances.add(instance);
16507 const maybeDestroy = () => {
16508 if (!instances.delete(instance)) return;
16509 if (instances.size) return;
16510 destroy();
16511 };
16512 if (initializedInstances) return maybeDestroy;
16513 const stateKeys = getKeys(state);
16514 const desyncs = [];
16515 for (const store of stores) {
16516 const storeState = store?.getState?.();
16517 if (!storeState) continue;
16518 const keys = stateKeys.filter((key) => hasOwnProperty(storeState, key));
16519 if (!keys.length) continue;
16520 if (stores.length === 1 || keys.length === stateKeys.length) {
16521 for (const key of keys) desyncs.push(sync(store, [key], (state2) => {
16522 setState(key, state2[key], true);
16523 }));
16524 continue;
16525 }
16526 desyncs.push(subscribe(store, keys, (state2, prevState) => {
16527 for (const key of keys) {
16528 if (state2[key] === prevState[key]) continue;
16529 setState(key, state2[key], true);
16530 }
16531 }));
16532 for (const key of keys) {
16533 const liveState = store?.getState?.();
16534 if (!liveState) continue;
16535 setState(key, liveState[key], true);
16536 }
16537 }
16538 const teardowns = [];
16539 for (const setup2 of setups) teardowns.push(setup2());
16540 const cleanups = stores.map(init);
16541 destroy = chain(...desyncs, ...teardowns, ...cleanups);
16542 return maybeDestroy;
16543 };
16544 const deleteListenerIndexes = (group, listener, keys) => {
16545 if (keys === void 0) return;
16546 if (keys) deleteKeyedListener(group.listenersByKey, keys, listener);
16547 else group.allKeysListeners?.delete(listener);
16548 };
16549 const fastPathFrames = [];
16550 const registerListener = (keys, listener, group = syncListenerGroup) => {
16551 const listenerKeysValue = keys ? [...keys] : null;
16552 const wasRegistered = group.listeners.has(listener);
16553 if (!wasRegistered) clearFastPathNotifiedListener(fastPathFrames, group, listener);
16554 if (!listenerKeysValue) {
16555 if (wasRegistered) preserveFastPathFrames(fastPathFrames, group);
16556 preserveFastPathPassedListeners(fastPathFrames, group, listener);
16557 } else preserveFastPathPassedKeyedListeners({
16558 fastPathFrames,
16559 group,
16560 keys: listenerKeysValue,
16561 listener
16562 });
16563 if (wasRegistered) {
16564 preserveFastPathFrames(fastPathFrames, group, listener);
16565 deleteListenerIndexes(group, listener, group.listenerKeys.get(listener));
16566 }
16567 group.listeners.add(listener);
16568 if (listenerKeysValue) {
16569 group.listenersByKey ??= /* @__PURE__ */ new Map();
16570 addKeyedListener(group.listenersByKey, listenerKeysValue, listener);
16571 addFastPathKeyedListener({
16572 fastPathFrames,
16573 group,
16574 keys: listenerKeysValue,
16575 listener
16576 });
16577 } else {
16578 group.allKeysListeners ??= /* @__PURE__ */ new Set();
16579 group.allKeysListeners.add(listener);
16580 }
16581 group.listenerKeys.set(listener, listenerKeysValue);
16582 return () => {
16583 const cleanup = group.disposables.get(listener);
16584 group.disposables.delete(listener);
16585 preserveFastPathFrames(fastPathFrames, group, listener);
16586 const currentKeys = group.listenerKeys.get(listener);
16587 deleteListenerIndexes(group, listener, listenerKeysValue);
16588 if (currentKeys !== listenerKeysValue) deleteListenerIndexes(group, listener, currentKeys);
16589 group.listenerKeys.delete(listener);
16590 group.listeners.delete(listener);
16591 cleanup?.();
16592 };
16593 };
16594 const storeSubscribe = (keys, listener) => registerListener(keys, listener);
16595 const runInitialListener = (group, listener, prevState) => {
16596 const shouldSuspend = group.listeners.has(listener);
16597 if (shouldSuspend) {
16598 group.suspendCounts ??= /* @__PURE__ */ new Map();
16599 const count = group.suspendCounts.get(listener) ?? 0;
16600 group.suspendCounts.set(listener, count + 1);
16601 }
16602 let cleanupPrevState;
16603 try {
16604 const stateBeforeCleanups = state;
16605 runPendingCleanup(group, listener);
16606 if (state !== stateBeforeCleanups) cleanupPrevState = getCleanupPrevState(prevState, state, stateBeforeCleanups);
16607 const cleanup = listener(state, cleanupPrevState ?? prevState);
16608 if (cleanup) setListenerCleanup(group, listener, cleanup);
16609 } finally {
16610 if (shouldSuspend) {
16611 const suspendCounts = group.suspendCounts;
16612 const count = suspendCounts?.get(listener);
16613 if (count && count > 1) suspendCounts?.set(listener, count - 1);
16614 else suspendCounts?.delete(listener);
16615 if (!suspendCounts?.size) delete group.suspendCounts;
16616 }
16617 }
16618 };
16619 const storeSync = (keys, listener) => {
16620 runInitialListener(syncListenerGroup, listener, state);
16621 return registerListener(keys, listener);
16622 };
16623 const storeBatch = (keys, listener) => {
16624 if (!batchListenerGroup.listeners.size && !inDispatch) prevStateBatch = state;
16625 runInitialListener(batchListenerGroup, listener, prevStateBatch);
16626 return registerListener(keys, listener, batchListenerGroup);
16627 };
16628 const storePick = (keys) => createStore(pick(state, keys), finalStore);
16629 const storeOmit = (keys) => createStore(omit2(state, keys), finalStore);
16630 const getState = () => state;
16631 const runListeners = (group, prevState, updatedKey) => {
16632 if (!(updatedKey instanceof Set) && !group.allKeysListeners?.size) {
16633 const keyedListeners = group.listenersByKey?.get(updatedKey);
16634 if (!keyedListeners) return;
16635 const frame = {
16636 group,
16637 keyedListeners,
16638 updatedKey,
16639 currentListener: null
16640 };
16641 fastPathFrames.push(frame);
16642 try {
16643 for (const listener of keyedListeners) {
16644 if (frame.notifiedListeners?.has(listener)) continue;
16645 frame.currentListener = listener;
16646 frame.notifiedListeners?.add(listener);
16647 notifyStoreListener(group, listener, state, prevState, getState, updatedKey);
16648 if (!group.allKeysListeners?.size && !frame.recoverToLive) continue;
16649 const notifiedListeners = frame.notifiedListeners ?? getFastPathNotifiedListeners(frame);
16650 frame.notifiedListeners = notifiedListeners;
16651 frame.recovering = true;
16652 runLiveListeners({
16653 group,
16654 getState,
16655 prevState,
16656 updatedKey,
16657 notifiedListeners
16658 });
16659 return;
16660 }
16661 } finally {
16662 fastPathFrames.pop();
16663 }
16664 return;
16665 }
16666 runLiveListeners({
16667 group,
16668 getState,
16669 prevState,
16670 updatedKey
16671 });
16672 };
16673 const setState = (key, value, fromStores = false) => {
16674 if (!hasOwnProperty(state, key)) return;
16675 const currentValue = state[key];
16676 const nextValue = typeof value === "function" ? value(currentValue) : value;
16677 if (isSameValue(nextValue, currentValue)) return;
16678 const wasInDispatch = inDispatch;
16679 inDispatch = true;
16680 const prevState = state;
16681 const nextState = {
16682 ...state,
16683 [key]: nextValue
16684 };
16685 state = nextState;
16686 let superseded = false;
16687 try {
16688 if (!fromStores && stores.length) {
16689 for (const store of stores) {
16690 store?.setState?.(key, nextValue);
16691 if (isSameValue(state[key], nextValue)) continue;
16692 superseded = true;
16693 break;
16694 }
16695 if (superseded) {
16696 let pass = 0;
16697 for (; pass < MAX_REPAIR_PASSES; pass += 1) {
16698 let changed = false;
16699 for (const store of stores) {
16700 const previousValue = state[key];
16701 store?.setState?.(key, previousValue);
16702 if (!isSameValue(state[key], previousValue)) changed = true;
16703 }
16704 if (!changed) break;
16705 }
16706 if (pass === MAX_REPAIR_PASSES) console.warn("Parent stores did not converge after a superseded fan-out; a parent listener may be rewriting this key in a cycle.");
16707 }
16708 }
16709 if (!superseded) runListeners(syncListenerGroup, state === nextState ? prevState : {
16710 ...state,
16711 [key]: prevState[key]
16712 }, key);
16713 } finally {
16714 inDispatch = wasInDispatch;
16715 }
16716 if (!batchListenerGroup.listeners.size) {
16717 if (!inDispatch) prevStateBatch = state;
16718 return;
16719 }
16720 updatedKeys.add(key);
16721 if (batchPending) return;
16722 batchPending = true;
16723 queueMicrotask(() => {
16724 batchPending = false;
16725 const snapshot = state;
16726 const updatedKeysSnapshot = updatedKeys;
16727 updatedKeys = /* @__PURE__ */ new Set();
16728 const prevStateBatchBefore = prevStateBatch;
16729 runListeners(batchListenerGroup, prevStateBatchBefore, updatedKeysSnapshot);
16730 if (prevStateBatch === prevStateBatchBefore) prevStateBatch = snapshot;
16731 });
16732 };
16733 const finalStore = {
16734 getState,
16735 setState,
16736 __unstableInternals: {
16737 setup: storeSetup,
16738 init: storeInit,
16739 subscribe: storeSubscribe,
16740 sync: storeSync,
16741 batch: storeBatch,
16742 pick: storePick,
16743 omit: storeOmit
16744 }
16745 };
16746 return finalStore;
16747 }
16748 function setup(store, ...args) {
16749 if (!store) return;
16750 return getInternal(store, "setup")(...args);
16751 }
16752 function init(store, ...args) {
16753 if (!store) return;
16754 return getInternal(store, "init")(...args);
16755 }
16756 function subscribe(store, ...args) {
16757 if (!store) return;
16758 return getInternal(store, "subscribe")(...args);
16759 }
16760 function sync(store, ...args) {
16761 if (!store) return;
16762 return getInternal(store, "sync")(...args);
16763 }
16764 function batch(store, ...args) {
16765 if (!store) return;
16766 return getInternal(store, "batch")(...args);
16767 }
16768 function omit3(store, ...args) {
16769 if (!store) return;
16770 return getInternal(store, "omit")(...args);
16771 }
16772 function pick2(store, ...args) {
16773 if (!store) return;
16774 return getInternal(store, "pick")(...args);
16775 }
16776 function mergeStore(...stores) {
16777 const initialState = {};
16778 for (const store2 of stores) {
16779 const nextState = store2?.getState?.();
16780 if (nextState) Object.assign(initialState, nextState);
16781 }
16782 const store = createStore(initialState, ...stores);
16783 return Object.assign({}, ...stores, store);
16784 }
16785 function throwOnConflictingProps(props, store) {
16786 if (false) return;
16787 if (!store) return;
16788 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
16789 const stateKey = key.replace("default", "");
16790 return `${stateKey[0]?.toLowerCase() || ""}${stateKey.slice(1)}`;
16791 });
16792 if (!defaultKeys.length) return;
16793 const storeState = store.getState();
16794 if (!defaultKeys.filter((key) => hasOwnProperty(storeState, key)).length) return;
16795 throw new Error(`Passing a store prop in conjunction with a default state is not supported.
16796
16797 const store = useSelectStore();
16798 <SelectProvider store={store} defaultValue="Apple" />
16799 ^ ^
16800
16801 Instead, pass the default state to the topmost store:
16802
16803 const store = useSelectStore({ defaultValue: "Apple" });
16804 <SelectProvider store={store} />
16805
16806 See https://github.com/ariakit/ariakit/pull/2745 for more details.
16807
16808 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
16809 `);
16810 }
16811
16812 // node_modules/@ariakit/components/dist/collection/collection-store.js
16813 function getCommonParent(items) {
16814 const firstItem = items.find((item) => !!item.element);
16815 const lastElement = [...items].reverse().find((item) => !!item.element)?.element;
16816 let parentElement = firstItem?.element?.parentElement;
16817 if (!lastElement) return getDocument(parentElement).body;
16818 while (parentElement) {
16819 if (parentElement.contains(lastElement)) return parentElement;
16820 parentElement = parentElement.parentElement;
16821 }
16822 return getDocument(parentElement).body;
16823 }
16824 function getPrivateStore(store) {
16825 return store?.__unstablePrivateStore;
16826 }
16827 function createCollectionStore(props = {}) {
16828 throwOnConflictingProps(props, props.store);
16829 const syncState = props.store?.getState();
16830 const items = defaultValue(props.items, syncState?.items, props.defaultItems, []);
16831 const itemsMap = new Map(items.map((item) => [item.id, item]));
16832 const initialState = {
16833 items,
16834 renderedItems: defaultValue(syncState?.renderedItems, [])
16835 };
16836 const syncPrivateStore = getPrivateStore(props.store);
16837 const privateStore = createStore({
16838 items,
16839 renderedItems: initialState.renderedItems
16840 }, syncPrivateStore);
16841 const collection = createStore(initialState, props.store);
16842 const sortItems = (renderedItems) => {
16843 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
16844 privateStore.setState("renderedItems", sortedItems);
16845 collection.setState("renderedItems", sortedItems);
16846 };
16847 setup(collection, () => init(privateStore));
16848 setup(privateStore, () => {
16849 return batch(privateStore, ["items"], (state) => {
16850 collection.setState("items", state.items);
16851 });
16852 });
16853 setup(privateStore, () => {
16854 return batch(privateStore, ["renderedItems"], (state) => {
16855 let firstRun = true;
16856 let raf = requestAnimationFrame(() => {
16857 const { renderedItems } = collection.getState();
16858 if (state.renderedItems === renderedItems) return;
16859 sortItems(state.renderedItems);
16860 });
16861 if (typeof IntersectionObserver !== "function") return () => cancelAnimationFrame(raf);
16862 const ioCallback = () => {
16863 if (firstRun) {
16864 firstRun = false;
16865 return;
16866 }
16867 cancelAnimationFrame(raf);
16868 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
16869 };
16870 const root = getCommonParent(state.renderedItems);
16871 const observer = new IntersectionObserver(ioCallback, { root });
16872 for (const item of state.renderedItems) {
16873 if (!item.element) continue;
16874 observer.observe(item.element);
16875 }
16876 return () => {
16877 cancelAnimationFrame(raf);
16878 observer.disconnect();
16879 };
16880 });
16881 });
16882 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
16883 let prevItem;
16884 setItems((items2) => {
16885 const index2 = items2.findIndex(({ id }) => id === item.id);
16886 const nextItems = items2.slice();
16887 if (index2 !== -1) {
16888 prevItem = items2[index2];
16889 const nextItem = {
16890 ...prevItem,
16891 ...item
16892 };
16893 nextItems[index2] = nextItem;
16894 itemsMap.set(item.id, nextItem);
16895 } else {
16896 nextItems.push(item);
16897 itemsMap.set(item.id, item);
16898 }
16899 return nextItems;
16900 });
16901 const unmergeItem = () => {
16902 setItems((items2) => {
16903 if (!prevItem) {
16904 if (canDeleteFromMap) itemsMap.delete(item.id);
16905 return items2.filter(({ id }) => id !== item.id);
16906 }
16907 const index2 = items2.findIndex(({ id }) => id === item.id);
16908 if (index2 === -1) return items2;
16909 const nextItems = items2.slice();
16910 nextItems[index2] = prevItem;
16911 itemsMap.set(item.id, prevItem);
16912 return nextItems;
16913 });
16914 };
16915 return unmergeItem;
16916 };
16917 const registerItem = (item) => mergeItem(item, (getItems) => privateStore.setState("items", getItems), true);
16918 return {
16919 ...collection,
16920 registerItem,
16921 renderItem: (item) => chain(registerItem(item), mergeItem(item, (getItems) => privateStore.setState("renderedItems", getItems))),
16922 item: (id) => {
16923 if (!id) return null;
16924 let item = itemsMap.get(id);
16925 if (!item) {
16926 const { items: items2 } = privateStore.getState();
16927 item = items2.find((item2) => item2.id === id);
16928 if (item) itemsMap.set(id, item);
16929 }
16930 return item || null;
16931 },
16932 __unstablePrivateStore: privateStore
16933 };
16934 }
16935
16936 // node_modules/@ariakit/components/dist/composite/composite-store.js
16937 var NULL_ITEM = { id: null };
16938 function findFirstEnabledItem(items, excludeId) {
16939 return items.find((item) => {
16940 if (excludeId) return !item.disabled && item.id !== excludeId;
16941 return !item.disabled;
16942 });
16943 }
16944 function getEnabledItems(items, excludeId) {
16945 return items.filter((item) => {
16946 if (excludeId) return !item.disabled && item.id !== excludeId;
16947 return !item.disabled;
16948 });
16949 }
16950 function getItemsInRow(items, rowId) {
16951 return items.filter((item) => item.rowId === rowId);
16952 }
16953 function findEnabledItemId({ items, fromIndex, step, rowId, excludeId }) {
16954 for (let i2 = fromIndex; i2 >= 0 && i2 < items.length; i2 += step) {
16955 const item = items[i2];
16956 if (!item) continue;
16957 if (item.rowId !== rowId) continue;
16958 if (item.disabled) continue;
16959 if (excludeId != null && item.id === excludeId) continue;
16960 return item.id;
16961 }
16962 }
16963 function flipItems(items, activeId, shouldInsertNullItem = false) {
16964 const index2 = items.findIndex((item) => item.id === activeId);
16965 return [
16966 ...items.slice(index2 + 1),
16967 ...shouldInsertNullItem ? [NULL_ITEM] : [],
16968 ...items.slice(0, index2)
16969 ];
16970 }
16971 function groupItemsByRows(items) {
16972 const rows = [];
16973 for (const item of items) {
16974 const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId);
16975 if (row) row.push(item);
16976 else rows.push([item]);
16977 }
16978 return rows;
16979 }
16980 function getMaxRowLength(array) {
16981 let maxLength = 0;
16982 for (const { length } of array) if (length > maxLength) maxLength = length;
16983 return maxLength;
16984 }
16985 function createEmptyItem(rowId) {
16986 return {
16987 id: "__EMPTY_ITEM__",
16988 disabled: true,
16989 rowId
16990 };
16991 }
16992 function normalizeRows(rows, activeId, focusShift) {
16993 const maxLength = getMaxRowLength(rows);
16994 for (const row of rows) for (let i2 = 0; i2 < maxLength; i2 += 1) {
16995 const item = row[i2];
16996 if (!item || focusShift && item.disabled) {
16997 const previousItem = i2 === 0 && focusShift ? findFirstEnabledItem(row) : row[i2 - 1];
16998 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem?.rowId);
16999 }
17000 }
17001 return rows;
17002 }
17003 function verticalizeItems(items) {
17004 const rows = groupItemsByRows(items);
17005 const maxLength = getMaxRowLength(rows);
17006 const verticalized = [];
17007 for (let i2 = 0; i2 < maxLength; i2 += 1) for (const row of rows) {
17008 const item = row[i2];
17009 if (item) verticalized.push({
17010 ...item,
17011 rowId: item.rowId ? `${i2}` : void 0
17012 });
17013 }
17014 return verticalized;
17015 }
17016 function createCompositeStore(props = {}) {
17017 const syncState = props.store?.getState();
17018 const collection = createCollectionStore(props);
17019 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId);
17020 const composite = createStore({
17021 ...collection.getState(),
17022 id: defaultValue(props.id, syncState?.id) ?? `id-${Math.random().toString(36).slice(2, 8)}`,
17023 activeId,
17024 baseElement: defaultValue(syncState?.baseElement, null),
17025 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, activeId === null),
17026 moves: defaultValue(syncState?.moves, 0),
17027 orientation: defaultValue(props.orientation, syncState?.orientation, "both"),
17028 rtl: defaultValue(props.rtl, syncState?.rtl, false),
17029 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, false),
17030 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, false),
17031 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, false),
17032 focusShift: defaultValue(props.focusShift, syncState?.focusShift, false)
17033 }, collection, props.store);
17034 setup(composite, () => sync(composite, ["renderedItems", "activeId"], (state) => {
17035 composite.setState("activeId", (activeId2) => {
17036 if (activeId2 !== void 0) return activeId2;
17037 return findFirstEnabledItem(state.renderedItems)?.id;
17038 });
17039 }));
17040 const getNextId = (direction = "next", options = {}) => {
17041 const defaultState = composite.getState();
17042 const { skip = 0, activeId: activeId2 = defaultState.activeId, focusShift = defaultState.focusShift, focusLoop = defaultState.focusLoop, focusWrap = defaultState.focusWrap, includesBaseElement = defaultState.includesBaseElement, renderedItems = defaultState.renderedItems, rtl = defaultState.rtl } = options;
17043 const isVerticalDirection = direction === "up" || direction === "down";
17044 const isNextDirection = direction === "next" || direction === "down";
17045 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
17046 const canShift = focusShift && !skip;
17047 if (!skip && !focusWrap && !includesBaseElement && activeId2 != null) {
17048 if (!isVerticalDirection ? true : !canShift && !renderedItems.some((item) => item.rowId != null)) {
17049 const activeIndex2 = renderedItems.findIndex((item) => item.id === activeId2);
17050 const activeItem2 = renderedItems[activeIndex2];
17051 if (activeItem2) {
17052 const step = canReverse ? -1 : 1;
17053 const nextId = findEnabledItemId({
17054 items: renderedItems,
17055 fromIndex: activeIndex2 + step,
17056 step,
17057 rowId: activeItem2.rowId,
17058 excludeId: activeId2
17059 });
17060 if (nextId !== void 0) return nextId;
17061 if (!(focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical"))) return void 0;
17062 return findEnabledItemId({
17063 items: renderedItems,
17064 fromIndex: step === 1 ? 0 : renderedItems.length - 1,
17065 step,
17066 rowId: activeItem2.rowId,
17067 excludeId: activeId2
17068 });
17069 }
17070 }
17071 }
17072 let items = !isVerticalDirection ? renderedItems : flatten2DArray(normalizeRows(groupItemsByRows(renderedItems), activeId2, canShift));
17073 items = canReverse ? reverseArray(items) : items;
17074 items = isVerticalDirection ? verticalizeItems(items) : items;
17075 if (activeId2 == null) return findFirstEnabledItem(items)?.id;
17076 const activeItem = items.find((item) => item.id === activeId2);
17077 if (!activeItem) return findFirstEnabledItem(items)?.id;
17078 const isGrid2 = items.some((item) => item.rowId);
17079 const activeIndex = items.indexOf(activeItem);
17080 const nextItems = items.slice(activeIndex + 1);
17081 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
17082 if (skip) {
17083 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
17084 return (nextEnabledItemsInRow.slice(skip)[0] || nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1])?.id;
17085 }
17086 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
17087 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
17088 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
17089 if (canLoop) return findFirstEnabledItem(flipItems(canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId), activeId2, hasNullItem), activeId2)?.id;
17090 if (canWrap) {
17091 const nextItem2 = findFirstEnabledItem(hasNullItem ? nextItemsInRow : nextItems, activeId2);
17092 return hasNullItem ? nextItem2?.id || null : nextItem2?.id;
17093 }
17094 const nextItem = findFirstEnabledItem(nextItemsInRow, activeId2);
17095 if (!nextItem && hasNullItem) return null;
17096 return nextItem?.id;
17097 };
17098 const getNextIdFromOptions = (direction, options) => {
17099 if (typeof options === "number") return getNextId(direction, { skip: options });
17100 return getNextId(direction, options);
17101 };
17102 return {
17103 ...collection,
17104 ...composite,
17105 setBaseElement: (element) => composite.setState("baseElement", element),
17106 setActiveId: (id) => composite.setState("activeId", id),
17107 move: (id) => {
17108 if (id === void 0) return;
17109 composite.setState("activeId", id);
17110 composite.setState("moves", (moves) => moves + 1);
17111 },
17112 first: () => findFirstEnabledItem(composite.getState().renderedItems)?.id,
17113 last: () => findFirstEnabledItem(reverseArray(composite.getState().renderedItems))?.id,
17114 next: (options) => getNextIdFromOptions("next", options),
17115 previous: (options) => getNextIdFromOptions("previous", options),
17116 down: (options) => getNextIdFromOptions("down", options),
17117 up: (options) => getNextIdFromOptions("up", options)
17118 };
17119 }
17120
17121 // node_modules/@ariakit/react-components/dist/composite/utils.js
17122 var findFirstEnabledItem2 = findFirstEnabledItem;
17123 var groupItemsByRows2 = groupItemsByRows;
17124 function getEnabledItem(store, id) {
17125 if (!id) return null;
17126 return store.item(id) || null;
17127 }
17128 function selectTextField(element, collapseToEnd = false) {
17129 if (isTextField(element)) element.setSelectionRange(collapseToEnd ? element.value.length : 0, element.value.length);
17130 else if (element.isContentEditable) {
17131 const selection = getDocument(element).getSelection();
17132 selection?.selectAllChildren(element);
17133 if (collapseToEnd) selection?.collapseToEnd();
17134 }
17135 }
17136 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
17137 function focusSilently(element) {
17138 element[FOCUS_SILENTLY] = true;
17139 element.focus({ preventScroll: true });
17140 }
17141 function silentlyFocused(element) {
17142 const isSilentlyFocused = element[FOCUS_SILENTLY];
17143 delete element[FOCUS_SILENTLY];
17144 return isSilentlyFocused;
17145 }
17146 function isItem(store, element, exclude) {
17147 if (!element) return false;
17148 if (element === exclude) return false;
17149 const item = store.item(element.id);
17150 if (!item) return false;
17151 if (exclude && item.element === exclude) return false;
17152 return true;
17153 }
17154
17155 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
17156 var import_react13 = __toESM(require_react(), 1);
17157 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
17158
17159 // node_modules/@ariakit/react-store/dist/index.js
17160 var React49 = __toESM(require_react(), 1);
17161 var import_shim2 = __toESM(require_shim(), 1);
17162 var noopSubscribe = () => () => {
17163 };
17164 function useStoreState(store, keyOrSelector = identity) {
17165 const storeSubscribe = React49.useCallback((callback) => {
17166 if (!store) return noopSubscribe();
17167 return subscribe(store, null, callback);
17168 }, [store]);
17169 const getSnapshot = () => {
17170 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
17171 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
17172 const state = store?.getState();
17173 if (selector2) return selector2(state);
17174 if (!state) return;
17175 if (!key) return;
17176 if (!hasOwnProperty(state, key)) return;
17177 return state[key];
17178 };
17179 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
17180 }
17181 function useStoreStateObject(store, object) {
17182 const objRef = React49.useRef({});
17183 const storeSubscribe = React49.useCallback((callback) => {
17184 if (!store) return noopSubscribe();
17185 return subscribe(store, null, callback);
17186 }, [store]);
17187 const getSnapshot = () => {
17188 const state = store?.getState();
17189 let updated = false;
17190 const obj = objRef.current;
17191 for (const prop in object) {
17192 const keyOrSelector = object[prop];
17193 if (typeof keyOrSelector === "function") {
17194 const value = keyOrSelector(state);
17195 if (!Object.is(value, obj[prop])) {
17196 obj[prop] = value;
17197 updated = true;
17198 }
17199 }
17200 if (typeof keyOrSelector === "string") {
17201 if (!state) continue;
17202 if (!hasOwnProperty(state, keyOrSelector)) continue;
17203 const value = state[keyOrSelector];
17204 if (!Object.is(value, obj[prop])) {
17205 obj[prop] = value;
17206 updated = true;
17207 }
17208 }
17209 }
17210 if (updated) objRef.current = { ...obj };
17211 return objRef.current;
17212 };
17213 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
17214 }
17215 function useStoreProps(store, props, key, setKey) {
17216 const value = hasOwnProperty(props, key) ? props[key] : void 0;
17217 const propsRef = useLiveRef({
17218 value,
17219 setValue: setKey ? props[setKey] : void 0
17220 });
17221 useSafeLayoutEffect(() => {
17222 return sync(store, [key], (state, prev) => {
17223 const { value: value2, setValue } = propsRef.current;
17224 if (!setValue) return;
17225 if (state[key] === prev[key]) return;
17226 if (state[key] === value2) return;
17227 setValue(state[key]);
17228 });
17229 }, [store, key]);
17230 useSafeLayoutEffect(() => {
17231 if (value === void 0) return;
17232 store.setState(key, value);
17233 return batch(store, [key], () => {
17234 if (value === void 0) return;
17235 store.setState(key, value);
17236 });
17237 });
17238 }
17239 function useStore2(createStore2, props) {
17240 const [store, setStore] = React49.useState(() => createStore2(props));
17241 useSafeLayoutEffect(() => init(store), [store]);
17242 const useState37 = React49.useCallback((keyOrSelector) => useStoreState(store, keyOrSelector), [store]);
17243 return [React49.useMemo(() => ({
17244 ...store,
17245 useState: useState37
17246 }), [store, useState37]), useEvent(() => {
17247 setStore((store2) => createStore2({
17248 ...props,
17249 ...store2.getState()
17250 }));
17251 })];
17252 }
17253
17254 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
17255 var TagName4 = "button";
17256 function isEditableElement(element) {
17257 if (isTextbox(element)) return true;
17258 return element.tagName === "INPUT" && !isButton(element);
17259 }
17260 function getNextPageOffset(scrollingElement, pageUp = false) {
17261 const height = scrollingElement.clientHeight;
17262 const { top } = scrollingElement.getBoundingClientRect();
17263 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
17264 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
17265 if (scrollingElement.tagName === "HTML") return pageOffset + scrollingElement.scrollTop;
17266 return pageOffset;
17267 }
17268 function getItemOffset(itemElement, pageUp = false) {
17269 const { top } = itemElement.getBoundingClientRect();
17270 if (pageUp) return top + itemElement.clientHeight;
17271 return top;
17272 }
17273 function findNextPageItemId(element, store, next, pageUp = false) {
17274 if (!store) return;
17275 if (!next) return;
17276 const { renderedItems } = store.getState();
17277 const scrollingElement = getScrollingElement(element);
17278 if (!scrollingElement) return;
17279 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
17280 let id;
17281 let prevDifference;
17282 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
17283 const previousId = id;
17284 id = next(i2);
17285 if (!id) break;
17286 if (id === previousId) continue;
17287 const itemElement = getEnabledItem(store, id)?.element;
17288 if (!itemElement) continue;
17289 const difference = getItemOffset(itemElement, pageUp) - nextPageOffset;
17290 const absDifference = Math.abs(difference);
17291 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
17292 if (prevDifference !== void 0 && prevDifference < absDifference) id = previousId;
17293 break;
17294 }
17295 prevDifference = absDifference;
17296 }
17297 return id;
17298 }
17299 function targetIsAnotherItem(event, store) {
17300 if (isSelfTarget(event)) return false;
17301 return isItem(store, event.target);
17302 }
17303 var useCompositeItem = createHook(function useCompositeItem2({ store, rowId: rowIdProp, preventScrollOnKeyDown = false, moveOnKeyPress = true, tabbable: tabbable2 = false, getItem: getItemProp, "aria-setsize": ariaSetSizeProp, "aria-posinset": ariaPosInSetProp, ...props }) {
17304 const context = useCompositeScopedContext();
17305 store = store || context;
17306 const id = useId4(props.id);
17307 const ref = (0, import_react13.useRef)(null);
17308 const row = (0, import_react13.useContext)(CompositeRowContext);
17309 const trulyDisabled = disabledFromProps(props) && !props.accessibleWhenDisabled;
17310 const shouldRegisterItem = props.shouldRegisterItem;
17311 const getRowId = (state) => {
17312 if (rowIdProp) return rowIdProp;
17313 if (!state) return;
17314 if (!row?.baseElement) return;
17315 if (row.baseElement !== state.baseElement) return;
17316 return row.id;
17317 };
17318 const { rowId, baseElement, isActiveItem, ariaSetSize, ariaPosInSet, isTabbable } = useStoreStateObject(store, {
17319 rowId: getRowId,
17320 baseElement(state) {
17321 return state?.baseElement || void 0;
17322 },
17323 isActiveItem(state) {
17324 return !!state && state.activeId === id;
17325 },
17326 ariaSetSize(state) {
17327 if (ariaSetSizeProp != null) return ariaSetSizeProp;
17328 if (!state) return;
17329 if (!row?.ariaSetSize) return;
17330 if (row.baseElement !== state.baseElement) return;
17331 return row.ariaSetSize;
17332 },
17333 ariaPosInSet(state) {
17334 if (ariaPosInSetProp != null) return ariaPosInSetProp;
17335 if (!state) return;
17336 if (!row?.ariaPosInSet) return;
17337 if (row.baseElement !== state.baseElement) return;
17338 const rowId2 = getRowId(state);
17339 const itemsInRow = state.renderedItems.filter((item) => item.rowId === rowId2);
17340 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
17341 },
17342 isTabbable(state) {
17343 if (!state?.renderedItems.length) return true;
17344 if (state.virtualFocus) return false;
17345 if (tabbable2) return true;
17346 if (state.activeId === null) return false;
17347 const item = store?.item(state.activeId);
17348 if (item?.disabled) return true;
17349 if (!item?.element) return true;
17350 return state.activeId === id;
17351 }
17352 });
17353 const getItem = (0, import_react13.useCallback)((item) => {
17354 const nextItem = {
17355 ...item,
17356 id: id || item.id,
17357 rowId,
17358 disabled: trulyDisabled,
17359 children: item.element?.textContent
17360 };
17361 if (getItemProp) return getItemProp(nextItem);
17362 return nextItem;
17363 }, [
17364 id,
17365 rowId,
17366 trulyDisabled,
17367 getItemProp
17368 ]);
17369 const onFocusProp = props.onFocus;
17370 const hasFocusedComposite = (0, import_react13.useRef)(false);
17371 const cancelScheduledFocusRedirectRef = (0, import_react13.useRef)(null);
17372 const onFocus = useEvent((event) => {
17373 onFocusProp?.(event);
17374 if (event.defaultPrevented) return;
17375 if (isPortalEvent(event)) return;
17376 if (!id) return;
17377 if (!store) return;
17378 if (targetIsAnotherItem(event, store)) return;
17379 const { virtualFocus, baseElement: baseElement2 } = store.getState();
17380 store.setActiveId(id);
17381 if (isTextbox(event.currentTarget)) selectTextField(event.currentTarget);
17382 if (!virtualFocus) return;
17383 if (!isSelfTarget(event)) return;
17384 if (isEditableElement(event.currentTarget)) return;
17385 const redirectFocusToBaseElement = (currentTarget2, relatedTarget2, baseElement3) => {
17386 if (isSafari() && currentTarget2.hasAttribute("data-autofocus")) currentTarget2.scrollIntoView({
17387 block: "nearest",
17388 inline: "nearest"
17389 });
17390 hasFocusedComposite.current = true;
17391 if (relatedTarget2 === baseElement3 || isItem(store, relatedTarget2)) focusSilently(baseElement3);
17392 else baseElement3.focus();
17393 };
17394 if (baseElement2?.isConnected) {
17395 redirectFocusToBaseElement(event.currentTarget, event.relatedTarget, baseElement2);
17396 return;
17397 }
17398 if (shouldRegisterItem === false) return;
17399 const { currentTarget, relatedTarget } = event;
17400 const cancelScheduledFocusRedirect = () => {
17401 cancelScheduledFocusRedirectRef.current?.();
17402 cancelScheduledFocusRedirectRef.current = null;
17403 };
17404 cancelScheduledFocusRedirect();
17405 cancelScheduledFocusRedirectRef.current = subscribe(store, null, () => {
17406 if (getActiveElement(currentTarget) !== currentTarget) {
17407 cancelScheduledFocusRedirect();
17408 return;
17409 }
17410 const state = store.getState();
17411 const nextBaseElement = state.baseElement;
17412 if (!nextBaseElement?.isConnected) return;
17413 cancelScheduledFocusRedirect();
17414 if (!state.virtualFocus) return;
17415 redirectFocusToBaseElement(currentTarget, relatedTarget, nextBaseElement);
17416 });
17417 });
17418 const onBlurCaptureProp = props.onBlurCapture;
17419 const onBlurCapture = useEvent((event) => {
17420 onBlurCaptureProp?.(event);
17421 if (event.defaultPrevented) return;
17422 if (store?.getState()?.virtualFocus && hasFocusedComposite.current) {
17423 hasFocusedComposite.current = false;
17424 event.preventDefault();
17425 event.stopPropagation();
17426 }
17427 });
17428 const onKeyDownProp = props.onKeyDown;
17429 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
17430 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
17431 const onKeyDown = useEvent((event) => {
17432 onKeyDownProp?.(event);
17433 if (event.defaultPrevented) return;
17434 if (!isSelfTarget(event)) return;
17435 if (!store) return;
17436 const { currentTarget } = event;
17437 const state = store.getState();
17438 const isGrid2 = !!store.item(id)?.rowId;
17439 const isVertical = state.orientation !== "horizontal";
17440 const isHorizontal = state.orientation !== "vertical";
17441 const canHomeEnd = () => {
17442 if (isGrid2) return true;
17443 if (isHorizontal) return true;
17444 if (!state.baseElement) return true;
17445 if (!isTextField(state.baseElement)) return true;
17446 return false;
17447 };
17448 const action = {
17449 ArrowUp: (isGrid2 || isVertical) && store.up,
17450 ArrowRight: (isGrid2 || isHorizontal) && store.next,
17451 ArrowDown: (isGrid2 || isVertical) && store.down,
17452 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
17453 Home: () => {
17454 if (!canHomeEnd()) return;
17455 if (!isGrid2 || event.ctrlKey) return store?.first();
17456 return store?.previous(-1);
17457 },
17458 End: () => {
17459 if (!canHomeEnd()) return;
17460 if (!isGrid2 || event.ctrlKey) return store?.last();
17461 return store?.next(-1);
17462 },
17463 PageUp: () => {
17464 return findNextPageItemId(currentTarget, store, store?.up, true);
17465 },
17466 PageDown: () => {
17467 return findNextPageItemId(currentTarget, store, store?.down);
17468 }
17469 }[event.key];
17470 if (action) {
17471 if (isTextbox(currentTarget)) {
17472 const selection = getTextboxSelection(currentTarget);
17473 const isLeft = isHorizontal && event.key === "ArrowLeft";
17474 const isRight = isHorizontal && event.key === "ArrowRight";
17475 const isUp = isVertical && event.key === "ArrowUp";
17476 const isDown = isVertical && event.key === "ArrowDown";
17477 if (isRight || isDown) {
17478 const { length: valueLength } = getTextboxValue(currentTarget);
17479 if (selection.end !== valueLength) return;
17480 } else if ((isLeft || isUp) && selection.start !== 0) return;
17481 }
17482 const nextId = action();
17483 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
17484 if (!moveOnKeyPressProp(event)) return;
17485 event.preventDefault();
17486 store.move(nextId);
17487 }
17488 }
17489 });
17490 const providerValue = (0, import_react13.useMemo)(() => ({
17491 id,
17492 baseElement
17493 }), [id, baseElement]);
17494 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(CompositeItemContext.Provider, {
17495 value: providerValue,
17496 children: element
17497 }), [providerValue]);
17498 props = {
17499 "data-active-item": isActiveItem || void 0,
17500 ...props,
17501 id,
17502 ref: useMergeRefs(ref, props.ref),
17503 tabIndex: isTabbable ? props.tabIndex : -1,
17504 onFocus,
17505 onBlurCapture,
17506 onKeyDown
17507 };
17508 props = useCommand(props);
17509 props = useCollectionItem({
17510 store,
17511 ...props,
17512 getItem,
17513 shouldRegisterItem: id ? shouldRegisterItem : false
17514 });
17515 return removeUndefinedValues({
17516 ...props,
17517 "aria-setsize": ariaSetSize,
17518 "aria-posinset": ariaPosInSet
17519 });
17520 });
17521 var CompositeItem = memo3(forwardRef21(function CompositeItem2(props) {
17522 return createElement3(TagName4, useCompositeItem(props));
17523 }));
17524
17525 // node_modules/@ariakit/react-components/dist/composite/composite.js
17526 var import_react14 = __toESM(require_react(), 1);
17527 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
17528 var TagName5 = "div";
17529 function isGrid(items) {
17530 return items.some((item) => !!item.rowId);
17531 }
17532 function isPrintableKey(event) {
17533 const target = event.target;
17534 if (target && !isTextField(target)) return false;
17535 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
17536 }
17537 function isModifierKey(event) {
17538 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
17539 }
17540 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
17541 return useEvent((event) => {
17542 onKeyboardEvent?.(event);
17543 if (event.defaultPrevented) return;
17544 if (event.isPropagationStopped()) return;
17545 if (!isSelfTarget(event)) return;
17546 if (isModifierKey(event)) return;
17547 if (isPrintableKey(event)) return;
17548 const activeElement2 = getEnabledItem(store, store.getState().activeId)?.element;
17549 if (!activeElement2) return;
17550 const { view, ...eventInit } = event;
17551 if (activeElement2 !== previousElementRef?.current) activeElement2.focus();
17552 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) event.preventDefault();
17553 if (event.currentTarget.contains(activeElement2)) event.stopPropagation();
17554 });
17555 }
17556 function findFirstEnabledItemInTheLastRow(items) {
17557 return findFirstEnabledItem2(flatten2DArray(reverseArray(groupItemsByRows2(items))));
17558 }
17559 function withBaseScrollPreserved(store, callback) {
17560 const { virtualFocus, baseElement } = store.getState();
17561 if (!virtualFocus || !baseElement || !isTextField(baseElement)) {
17562 callback();
17563 return;
17564 }
17565 const savedScrollLeft = baseElement.scrollLeft;
17566 const savedScrollTop = baseElement.scrollTop;
17567 callback();
17568 baseElement.scrollLeft = savedScrollLeft;
17569 baseElement.scrollTop = savedScrollTop;
17570 }
17571 function useScheduleFocus(store) {
17572 const [scheduled, setScheduled] = (0, import_react14.useState)(false);
17573 const schedule = (0, import_react14.useCallback)(() => setScheduled(true), []);
17574 const activeItem = useStoreState(store, (state) => scheduled ? getEnabledItem(store, state.activeId) : null);
17575 (0, import_react14.useEffect)(() => {
17576 const activeElement2 = activeItem?.element;
17577 if (!scheduled) return;
17578 if (!activeElement2) return;
17579 setScheduled(false);
17580 withBaseScrollPreserved(store, () => {
17581 activeElement2.focus({ preventScroll: true });
17582 });
17583 }, [
17584 store,
17585 activeItem,
17586 scheduled
17587 ]);
17588 return schedule;
17589 }
17590 var CompositeFocusOnMove = memo3(function CompositeFocusOnMove2({ store, focusOnMove, previousElementRef }) {
17591 const moves = useStoreState(store, "moves");
17592 const baseElement = useStoreState(store, "baseElement");
17593 (0, import_react14.useEffect)(() => {
17594 if (!moves) return;
17595 if (!focusOnMove) return;
17596 const { activeId } = store.getState();
17597 const itemElement = getEnabledItem(store, activeId)?.element;
17598 if (!itemElement) return;
17599 withBaseScrollPreserved(store, () => focusIntoView(itemElement));
17600 }, [
17601 store,
17602 moves,
17603 focusOnMove
17604 ]);
17605 useSafeLayoutEffect(() => {
17606 if (!moves) return;
17607 if (!baseElement) return;
17608 const { activeId } = store.getState();
17609 if (!(activeId === null)) return;
17610 const previousElement = previousElementRef.current;
17611 previousElementRef.current = null;
17612 if (previousElement) fireBlurEvent(previousElement, { relatedTarget: baseElement });
17613 if (!hasFocus(baseElement)) baseElement.focus();
17614 }, [
17615 store,
17616 moves,
17617 baseElement
17618 ]);
17619 return null;
17620 });
17621 var useComposite = createHook(function useComposite2({ store, composite = true, focusOnMove = composite, moveOnKeyPress = true, ...props }) {
17622 const context = useCompositeProviderContext();
17623 store = store || context;
17624 invariant(store, "Composite must receive a `store` prop or be wrapped in a CompositeProvider component.");
17625 const ref = (0, import_react14.useRef)(null);
17626 const previousElementRef = (0, import_react14.useRef)(null);
17627 const scheduleFocus = useScheduleFocus(store);
17628 const [, setBaseElement] = useTransactionState(composite ? store.setBaseElement : null);
17629 const virtualFocus = useStoreState(store, "virtualFocus");
17630 const activeId = useStoreState(store, (state) => state.virtualFocus ? state.activeId : null);
17631 useSafeLayoutEffect(() => {
17632 if (!store) return;
17633 if (!composite) return;
17634 if (!virtualFocus) return;
17635 const previousElement = previousElementRef.current;
17636 previousElementRef.current = null;
17637 if (!previousElement) return;
17638 const relatedTarget = getEnabledItem(store, activeId)?.element || getActiveElement(previousElement);
17639 if (relatedTarget === previousElement) return;
17640 fireBlurEvent(previousElement, { relatedTarget });
17641 }, [
17642 store,
17643 activeId,
17644 virtualFocus,
17645 composite
17646 ]);
17647 const onKeyDownCapture = useKeyboardEventProxy(store, props.onKeyDownCapture, previousElementRef);
17648 const onKeyUpCapture = useKeyboardEventProxy(store, props.onKeyUpCapture, previousElementRef);
17649 const onFocusCaptureProp = props.onFocusCapture;
17650 const onFocusCapture = useEvent((event) => {
17651 onFocusCaptureProp?.(event);
17652 if (event.defaultPrevented) return;
17653 if (!store) return;
17654 const { virtualFocus: virtualFocus2 } = store.getState();
17655 if (!virtualFocus2) return;
17656 const previousActiveElement = event.relatedTarget;
17657 const isSilentlyFocused = silentlyFocused(event.currentTarget);
17658 if (isSelfTarget(event) && isSilentlyFocused) {
17659 event.stopPropagation();
17660 previousElementRef.current = previousActiveElement;
17661 }
17662 });
17663 const onFocusProp = props.onFocus;
17664 const onFocus = useEvent((event) => {
17665 onFocusProp?.(event);
17666 if (event.defaultPrevented) return;
17667 if (!composite) return;
17668 if (!store) return;
17669 const { relatedTarget } = event;
17670 const { virtualFocus: virtualFocus2 } = store.getState();
17671 if (virtualFocus2) {
17672 if (isSelfTarget(event) && !isItem(store, relatedTarget)) queueMicrotask(scheduleFocus);
17673 } else if (isSelfTarget(event)) store.setActiveId(null);
17674 });
17675 const onBlurCaptureProp = props.onBlurCapture;
17676 const onBlurCapture = useEvent((event) => {
17677 onBlurCaptureProp?.(event);
17678 if (event.defaultPrevented) return;
17679 if (!store) return;
17680 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
17681 if (!virtualFocus2) return;
17682 const activeElement2 = getEnabledItem(store, activeId2)?.element;
17683 const nextActiveElement = event.relatedTarget;
17684 const nextActiveElementIsItem = isItem(store, nextActiveElement);
17685 const previousElement = previousElementRef.current;
17686 previousElementRef.current = null;
17687 if (isSelfTarget(event) && nextActiveElementIsItem) {
17688 if (nextActiveElement === activeElement2) {
17689 if (previousElement && previousElement !== nextActiveElement) fireBlurEvent(previousElement, event);
17690 } else if (activeElement2) fireBlurEvent(activeElement2, event);
17691 else if (previousElement) fireBlurEvent(previousElement, event);
17692 event.stopPropagation();
17693 } else if (!isItem(store, event.target) && activeElement2) fireBlurEvent(activeElement2, event);
17694 });
17695 const onKeyDownProp = props.onKeyDown;
17696 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
17697 const onKeyDown = useEvent((event) => {
17698 onKeyDownProp?.(event);
17699 if (event.nativeEvent.isComposing) return;
17700 if (event.defaultPrevented) return;
17701 if (!store) return;
17702 if (!isSelfTarget(event)) return;
17703 const { orientation, renderedItems, activeId: activeId2, rtl } = store.getState();
17704 if (getEnabledItem(store, activeId2)?.element?.isConnected) return;
17705 const isVertical = orientation !== "horizontal";
17706 const isHorizontal = orientation !== "vertical";
17707 const grid = isGrid(renderedItems);
17708 if ((event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End") && isTextField(event.currentTarget)) return;
17709 const up = () => {
17710 if (grid) return findFirstEnabledItemInTheLastRow(renderedItems)?.id;
17711 return store?.last();
17712 };
17713 const action = {
17714 ArrowUp: (grid || isVertical) && up,
17715 ArrowRight: (grid || isHorizontal) && (rtl ? store.last : store.first),
17716 ArrowDown: (grid || isVertical) && store.first,
17717 ArrowLeft: (grid || isHorizontal) && (rtl ? store.first : store.last),
17718 Home: store.first,
17719 End: store.last,
17720 PageUp: store.first,
17721 PageDown: store.last
17722 }[event.key];
17723 if (action) {
17724 const id = action();
17725 if (id !== void 0) {
17726 if (!moveOnKeyPressProp(event)) return;
17727 event.preventDefault();
17728 store.move(id);
17729 }
17730 }
17731 });
17732 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(CompositeScopedContextProvider, {
17733 value: store,
17734 children: [element, composite && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(CompositeFocusOnMove, {
17735 store,
17736 focusOnMove,
17737 previousElementRef
17738 })]
17739 }), [
17740 store,
17741 composite,
17742 focusOnMove
17743 ]);
17744 props = {
17745 "aria-activedescendant": useStoreState(store, (state) => {
17746 if (!store) return;
17747 if (!composite) return;
17748 if (!state.virtualFocus) return;
17749 return getEnabledItem(store, state.activeId)?.id;
17750 }),
17751 ...props,
17752 ref: useMergeRefs(ref, setBaseElement, props.ref),
17753 onKeyDownCapture,
17754 onKeyUpCapture,
17755 onFocusCapture,
17756 onFocus,
17757 onBlurCapture,
17758 onKeyDown
17759 };
17760 props = useFocusable({
17761 focusable: useStoreState(store, (state) => composite && (state.virtualFocus || state.activeId === null)),
17762 ...props
17763 });
17764 return props;
17765 });
17766 var Composite6 = forwardRef21(function Composite7(props) {
17767 return createElement3(TagName5, useComposite(props));
17768 });
17769
17770 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-context.js
17771 var ctx3 = createStoreContext();
17772 var useDisclosureContext = ctx3.useContext;
17773 var useDisclosureScopedContext = ctx3.useScopedContext;
17774 var useDisclosureProviderContext = ctx3.useProviderContext;
17775 var DisclosureContextProvider = ctx3.ContextProvider;
17776 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
17777
17778 // node_modules/@ariakit/react-components/dist/dialog/dialog-context.js
17779 var import_react15 = __toESM(require_react(), 1);
17780 var ctx4 = createStoreContext([DisclosureContextProvider], [DisclosureScopedContextProvider]);
17781 var useDialogContext = ctx4.useContext;
17782 var useDialogScopedContext = ctx4.useScopedContext;
17783 var useDialogProviderContext = ctx4.useProviderContext;
17784 var DialogContextProvider = ctx4.ContextProvider;
17785 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
17786 var DialogHeadingContext = (0, import_react15.createContext)(void 0);
17787 var DialogDescriptionContext = (0, import_react15.createContext)(void 0);
17788
17789 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-content.js
17790 var import_react16 = __toESM(require_react(), 1);
17791 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
17792 var import_react_dom4 = __toESM(require_react_dom(), 1);
17793 var TagName6 = "div";
17794 function afterTimeout(timeoutMs, cb) {
17795 const timeoutId = setTimeout(cb, timeoutMs);
17796 return () => clearTimeout(timeoutId);
17797 }
17798 function parseCSSTime(time) {
17799 const value = time?.trim() || "0s";
17800 const multiplier = value.endsWith("ms") ? 1 : 1e3;
17801 const parsed = Number.parseFloat(value) * multiplier;
17802 return Number.isNaN(parsed) ? 0 : parsed;
17803 }
17804 function getEndTime(names, delays, durations) {
17805 const nameList = names.split(",");
17806 const delayList = delays.split(",");
17807 const durationList = durations.split(",");
17808 let endTime = 0;
17809 for (const [index2, name] of nameList.entries()) {
17810 if (name.trim() === "none") continue;
17811 const delay = parseCSSTime(delayList[index2 % delayList.length]);
17812 const duration = parseCSSTime(durationList[index2 % durationList.length]);
17813 endTime = Math.max(endTime, delay + duration);
17814 }
17815 return endTime;
17816 }
17817 function getElementEndTime(element) {
17818 const { transitionProperty, transitionDuration, transitionDelay, animationName, animationDuration, animationDelay } = getComputedStyle(element);
17819 return Math.max(getEndTime(transitionProperty, transitionDelay, transitionDuration), getEndTime(animationName, animationDelay, animationDuration));
17820 }
17821 function isHidden(mounted, hidden, alwaysVisible) {
17822 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
17823 }
17824 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, unstable_otherElementRef: otherElementRef, ...props }) {
17825 const context = useDisclosureProviderContext();
17826 store = store || context;
17827 invariant(store, "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component.");
17828 const ref = (0, import_react16.useRef)(null);
17829 const id = useId4(props.id);
17830 const [transition, setTransition] = (0, import_react16.useState)(null);
17831 const open = useStoreState(store, "open");
17832 const mounted = useStoreState(store, "mounted");
17833 const animated = useStoreState(store, "animated");
17834 const contentElement = useStoreState(store, "contentElement");
17835 const otherElement = useStoreState(store.disclosure, "contentElement");
17836 const hasClosedRef = (0, import_react16.useRef)(false);
17837 useSafeLayoutEffect(() => {
17838 if (!ref.current) return;
17839 store?.setContentElement(ref.current);
17840 }, [store]);
17841 useSafeLayoutEffect(() => {
17842 let previousAnimated;
17843 store?.setState("animated", (animated2) => {
17844 previousAnimated = animated2;
17845 return true;
17846 });
17847 return () => {
17848 if (previousAnimated === void 0) return;
17849 store?.setState("animated", previousAnimated);
17850 };
17851 }, [store]);
17852 useSafeLayoutEffect(() => {
17853 if (!animated) {
17854 if (!open) {
17855 hasClosedRef.current = true;
17856 setTransition(null);
17857 } else if (hasClosedRef.current) {
17858 hasClosedRef.current = false;
17859 setTransition("enter");
17860 }
17861 return;
17862 }
17863 if (!contentElement?.isConnected) {
17864 setTransition(null);
17865 return;
17866 }
17867 return afterPaint(() => {
17868 setTransition(open ? "enter" : mounted ? "leave" : null);
17869 });
17870 }, [
17871 animated,
17872 contentElement,
17873 open,
17874 mounted
17875 ]);
17876 useSafeLayoutEffect(() => {
17877 if (!store) return;
17878 if (!animated) return;
17879 if (!transition) return;
17880 if (!contentElement) return;
17881 const stopAnimation = () => store?.setState("animating", false);
17882 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
17883 if (transition === "leave" && open) return;
17884 if (transition === "enter" && !open) return;
17885 if (typeof animated === "number") return afterTimeout(animated, stopAnimationSync);
17886 const elements = [contentElement];
17887 if (otherElement) elements.push(otherElement);
17888 const relatedElement = otherElementRef?.current;
17889 if (relatedElement) elements.push(relatedElement);
17890 const timeout = Math.max(...elements.map(getElementEndTime));
17891 if (!timeout) {
17892 if (transition === "enter") store.setState("animated", false);
17893 stopAnimation();
17894 return;
17895 }
17896 return afterTimeout(Math.max(timeout - 1e3 / 60, 0), stopAnimationSync);
17897 }, [
17898 store,
17899 animated,
17900 contentElement,
17901 otherElement,
17902 otherElementRef,
17903 open,
17904 transition
17905 ]);
17906 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(DialogScopedContextProvider, {
17907 value: store,
17908 children: element
17909 }), [store]);
17910 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
17911 const styleProp = props.style;
17912 const style = (0, import_react16.useMemo)(() => {
17913 if (hidden) return {
17914 ...styleProp,
17915 display: "none"
17916 };
17917 return styleProp;
17918 }, [hidden, styleProp]);
17919 props = {
17920 "data-open": open || void 0,
17921 "data-enter": transition === "enter" || void 0,
17922 "data-leave": transition === "leave" || void 0,
17923 hidden,
17924 ...props,
17925 id,
17926 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
17927 style
17928 };
17929 return removeUndefinedValues(props);
17930 });
17931 var DisclosureContentImpl = forwardRef21(function DisclosureContentImpl2(props) {
17932 return createElement3(TagName6, useDisclosureContent(props));
17933 });
17934 var DisclosureContent = forwardRef21(function DisclosureContent2({ unmountOnHide, ...props }) {
17935 const context = useDisclosureProviderContext();
17936 if (useStoreState(props.store || context, (state) => !unmountOnHide || state?.mounted) === false) return null;
17937 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(DisclosureContentImpl, { ...props });
17938 });
17939
17940 // node_modules/@ariakit/components/dist/disclosure/disclosure-store.js
17941 function createDisclosureStore(props = {}) {
17942 const store = mergeStore(props.store, omit3(props.disclosure, ["contentElement", "disclosureElement"]));
17943 throwOnConflictingProps(props, store);
17944 const syncState = store?.getState();
17945 const open = defaultValue(props.open, syncState?.open, props.defaultOpen, false);
17946 const animated = defaultValue(props.animated, syncState?.animated, false);
17947 const disclosure = createStore({
17948 open,
17949 animated,
17950 animating: !!animated && open,
17951 mounted: open,
17952 contentElement: defaultValue(syncState?.contentElement, null),
17953 disclosureElement: defaultValue(syncState?.disclosureElement, null)
17954 }, store);
17955 setup(disclosure, () => sync(disclosure, ["animated", "animating"], (state) => {
17956 if (state.animated) return;
17957 disclosure.setState("animating", false);
17958 }));
17959 setup(disclosure, () => subscribe(disclosure, ["open"], () => {
17960 if (!disclosure.getState().animated) return;
17961 disclosure.setState("animating", true);
17962 }));
17963 setup(disclosure, () => sync(disclosure, ["open", "animating"], (state) => {
17964 disclosure.setState("mounted", state.open || state.animating);
17965 }));
17966 return {
17967 ...disclosure,
17968 disclosure: props.disclosure,
17969 setOpen: (value) => disclosure.setState("open", value),
17970 show: () => disclosure.setState("open", true),
17971 hide: () => disclosure.setState("open", false),
17972 toggle: () => disclosure.setState("open", (open2) => !open2),
17973 stopAnimation: () => disclosure.setState("animating", false),
17974 setContentElement: (value) => disclosure.setState("contentElement", value),
17975 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
17976 };
17977 }
17978
17979 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-store.js
17980 function useDisclosureStoreProps(store, update2, props) {
17981 useUpdateEffect(update2, [props.store, props.disclosure]);
17982 useStoreProps(store, props, "open", "setOpen");
17983 useStoreProps(store, props, "mounted", "setMounted");
17984 useStoreProps(store, props, "animated");
17985 return Object.assign(store, { disclosure: props.disclosure });
17986 }
17987
17988 // node_modules/@ariakit/react-components/dist/popover/popover-context.js
17989 var ctx5 = createStoreContext([DialogContextProvider], [DialogScopedContextProvider]);
17990 var usePopoverContext = ctx5.useContext;
17991 var usePopoverScopedContext = ctx5.useScopedContext;
17992 var usePopoverProviderContext = ctx5.useProviderContext;
17993 var PopoverContextProvider = ctx5.ContextProvider;
17994 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
17995
17996 // node_modules/@ariakit/react-components/dist/combobox/combobox-context.js
17997 var import_react17 = __toESM(require_react(), 1);
17998 var ComboboxListRoleContext = (0, import_react17.createContext)(void 0);
17999 var ctx6 = createStoreContext([PopoverContextProvider, CompositeContextProvider], [PopoverScopedContextProvider, CompositeScopedContextProvider]);
18000 var useComboboxContext = ctx6.useContext;
18001 var useComboboxScopedContext = ctx6.useScopedContext;
18002 var useComboboxProviderContext = ctx6.useProviderContext;
18003 var ComboboxContextProvider = ctx6.ContextProvider;
18004 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
18005 var ComboboxItemValueContext = (0, import_react17.createContext)(void 0);
18006 var ComboboxItemCheckedContext = (0, import_react17.createContext)(false);
18007
18008 // node_modules/@ariakit/react-components/dist/collection/collection-store.js
18009 function useCollectionStoreProps(store, update2, props) {
18010 useUpdateEffect(update2, [props.store]);
18011 useStoreProps(store, props, "items", "setItems");
18012 return store;
18013 }
18014
18015 // node_modules/@ariakit/react-components/dist/composite/composite-store.js
18016 function useCompositeStoreOptions(props) {
18017 return {
18018 id: useId4(props.id),
18019 ...props
18020 };
18021 }
18022 function useCompositeStoreProps(store, update2, props) {
18023 store = useCollectionStoreProps(store, update2, props);
18024 useStoreProps(store, props, "activeId", "setActiveId");
18025 useStoreProps(store, props, "includesBaseElement");
18026 useStoreProps(store, props, "virtualFocus");
18027 useStoreProps(store, props, "orientation");
18028 useStoreProps(store, props, "rtl");
18029 useStoreProps(store, props, "focusLoop");
18030 useStoreProps(store, props, "focusWrap");
18031 useStoreProps(store, props, "focusShift");
18032 return store;
18033 }
18034
18035 // node_modules/@ariakit/components/dist/dialog/dialog-store.js
18036 function createDialogStore(props = {}) {
18037 return createDisclosureStore(props);
18038 }
18039
18040 // node_modules/@ariakit/react-components/dist/dialog/dialog-store.js
18041 function useDialogStoreProps(store, update2, props) {
18042 return useDisclosureStoreProps(store, update2, props);
18043 }
18044
18045 // node_modules/@ariakit/components/dist/popover/popover-store.js
18046 function createPopoverStore({ popover: otherPopover, ...props } = {}) {
18047 const store = mergeStore(props.store, omit3(otherPopover, [
18048 "arrowElement",
18049 "anchorElement",
18050 "contentElement",
18051 "popoverElement",
18052 "disclosureElement"
18053 ]));
18054 throwOnConflictingProps(props, store);
18055 const syncState = store?.getState();
18056 const dialog = createDialogStore({
18057 ...props,
18058 store
18059 });
18060 const placement = defaultValue(props.placement, syncState?.placement, "bottom");
18061 const popover = createStore({
18062 ...dialog.getState(),
18063 placement,
18064 currentPlacement: placement,
18065 anchorElement: defaultValue(syncState?.anchorElement, null),
18066 popoverElement: defaultValue(syncState?.popoverElement, null),
18067 arrowElement: defaultValue(syncState?.arrowElement, null),
18068 rendered: /* @__PURE__ */ Symbol("rendered")
18069 }, dialog, store);
18070 return {
18071 ...dialog,
18072 ...popover,
18073 setAnchorElement: (element) => popover.setState("anchorElement", element),
18074 setPopoverElement: (element) => popover.setState("popoverElement", element),
18075 setArrowElement: (element) => popover.setState("arrowElement", element),
18076 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
18077 };
18078 }
18079
18080 // node_modules/@ariakit/react-components/dist/popover/popover-store.js
18081 function usePopoverStoreProps(store, update2, props) {
18082 useUpdateEffect(update2, [props.popover]);
18083 useStoreProps(store, props, "placement");
18084 return useDialogStoreProps(store, update2, props);
18085 }
18086
18087 // node_modules/@ariakit/react-components/dist/popover/popover-anchor.js
18088 var TagName7 = "div";
18089 var usePopoverAnchor = createHook(function usePopoverAnchor2({ store, ...props }) {
18090 const context = usePopoverProviderContext();
18091 store = store || context;
18092 props = {
18093 ...props,
18094 ref: useMergeRefs(store?.setAnchorElement, props.ref)
18095 };
18096 return props;
18097 });
18098 var PopoverAnchor = forwardRef21(function PopoverAnchor2(props) {
18099 return createElement3(TagName7, usePopoverAnchor(props));
18100 });
18101
18102 // node_modules/@ariakit/react-components/dist/composite/composite-hover.js
18103 var import_react18 = __toESM(require_react(), 1);
18104 var TagName8 = "div";
18105 function hoveringInside(event) {
18106 const nextElement = event.relatedTarget;
18107 if (!isElement2(nextElement)) return false;
18108 return contains2(event.currentTarget, nextElement);
18109 }
18110 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
18111 function movingToAnotherItem(event) {
18112 const { relatedTarget } = event;
18113 if (!isElement2(relatedTarget)) return false;
18114 let dest = relatedTarget;
18115 do {
18116 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
18117 dest = dest.parentElement;
18118 } while (dest);
18119 return false;
18120 }
18121 var useCompositeHover = createHook(function useCompositeHover2({ store, focusOnHover = true, blurOnHoverEnd = !!focusOnHover, ...props }) {
18122 const context = useCompositeScopedContext();
18123 store = store || context;
18124 invariant(store, "CompositeHover must be wrapped in a Composite component.");
18125 const isMouseMoving = useIsMouseMoving();
18126 const onMouseMoveProp = props.onMouseMove;
18127 const focusOnHoverProp = useBooleanEvent(focusOnHover);
18128 const onMouseMove = useEvent((event) => {
18129 onMouseMoveProp?.(event);
18130 if (event.defaultPrevented) return;
18131 if (!isMouseMoving()) return;
18132 if (!focusOnHoverProp(event)) return;
18133 if (!hasFocusWithin(event.currentTarget)) {
18134 const baseElement = store?.getState().baseElement;
18135 if (baseElement && !hasFocus(baseElement)) baseElement.focus();
18136 }
18137 store?.setActiveId(event.currentTarget.id);
18138 });
18139 const onMouseLeaveProp = props.onMouseLeave;
18140 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
18141 const onMouseLeave = useEvent((event) => {
18142 onMouseLeaveProp?.(event);
18143 if (event.defaultPrevented) return;
18144 if (!isMouseMoving()) return;
18145 if (hoveringInside(event)) return;
18146 if (movingToAnotherItem(event)) return;
18147 if (!focusOnHoverProp(event)) return;
18148 if (!blurOnHoverEndProp(event)) return;
18149 store?.setActiveId(null);
18150 store?.getState().baseElement?.focus();
18151 });
18152 const ref = (0, import_react18.useCallback)((element) => {
18153 if (!element) return;
18154 element[symbol2] = true;
18155 }, []);
18156 props = {
18157 ...props,
18158 ref: useMergeRefs(ref, props.ref),
18159 onMouseMove,
18160 onMouseLeave
18161 };
18162 return removeUndefinedValues(props);
18163 });
18164 var CompositeHover = memo3(forwardRef21(function CompositeHover2(props) {
18165 return createElement3(TagName8, useCompositeHover(props));
18166 }));
18167
18168 // node_modules/@ariakit/react-components/dist/combobox/combobox.js
18169 var import_react19 = __toESM(require_react(), 1);
18170 var TagName9 = "input";
18171 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
18172 if (!autoSelect) return false;
18173 return items.find((item) => !item.disabled && item.value)?.value === activeValue;
18174 }
18175 function hasCompletionString(value, activeValue) {
18176 if (!activeValue) return false;
18177 if (value == null) return false;
18178 const normalizedValue = normalizeString(value);
18179 const normalizedActiveValue = normalizeString(activeValue);
18180 if (normalizedValue.length !== value.length) return false;
18181 if (normalizedActiveValue.length !== activeValue.length) return false;
18182 return normalizedActiveValue.length > normalizedValue.length && normalizedActiveValue.toLowerCase().startsWith(normalizedValue.toLowerCase());
18183 }
18184 function isAriaAutoCompleteValue(value) {
18185 return value === "inline" || value === "list" || value === "both" || value === "none";
18186 }
18187 function getDefaultAutoSelectId(items) {
18188 return items.find((item) => {
18189 if (item.disabled) return false;
18190 return item.element?.getAttribute("role") !== "tab";
18191 })?.id;
18192 }
18193 var useCombobox = createHook(function useCombobox2({ store, focusable: focusable2 = true, autoSelect: autoSelectProp = false, getAutoSelectId, setValueOnChange, showMinLength = 0, showOnChange, showOnMouseDown, showOnClick = showOnMouseDown, showOnKeyDown, showOnKeyPress = showOnKeyDown, blurActiveItemOnClick, setValueOnClick = true, moveOnKeyPress = true, autoComplete = "list", ...props }) {
18194 const context = useComboboxProviderContext();
18195 store = store || context;
18196 invariant(store, "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component.");
18197 const ref = (0, import_react19.useRef)(null);
18198 const [valueUpdated, forceValueUpdate] = useForceUpdate();
18199 const canAutoSelectRef = (0, import_react19.useRef)(false);
18200 const composingRef = (0, import_react19.useRef)(false);
18201 const autoSelect = useStoreState(store, (state) => state.virtualFocus && autoSelectProp);
18202 const inline4 = autoComplete === "inline" || autoComplete === "both";
18203 const [canInline, setCanInline] = (0, import_react19.useState)(inline4);
18204 useUpdateLayoutEffect(() => {
18205 if (!inline4) return;
18206 setCanInline(true);
18207 }, [inline4]);
18208 const storeValue = useStoreState(store, "value");
18209 const prevSelectedValueRef = (0, import_react19.useRef)(void 0);
18210 (0, import_react19.useEffect)(() => {
18211 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
18212 prevSelectedValueRef.current = prev.selectedValue;
18213 });
18214 }, [store]);
18215 const inlineActiveValue = useStoreState(store, (state) => {
18216 if (!inline4) return;
18217 if (!canInline) return;
18218 if (state.activeValue && Array.isArray(state.selectedValue)) {
18219 if (state.selectedValue.includes(state.activeValue)) return;
18220 if (prevSelectedValueRef.current?.includes(state.activeValue)) return;
18221 }
18222 return state.activeValue;
18223 });
18224 const items = useStoreState(store, "renderedItems");
18225 const open = useStoreState(store, "open");
18226 const contentElement = useStoreState(store, "contentElement");
18227 const value = (0, import_react19.useMemo)(() => {
18228 if (!inline4) return storeValue;
18229 if (!canInline) return storeValue;
18230 if (isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) {
18231 if (hasCompletionString(storeValue, inlineActiveValue)) return storeValue + (inlineActiveValue?.slice(storeValue.length) || "");
18232 return storeValue;
18233 }
18234 return inlineActiveValue || storeValue;
18235 }, [
18236 inline4,
18237 canInline,
18238 items,
18239 inlineActiveValue,
18240 autoSelect,
18241 storeValue
18242 ]);
18243 (0, import_react19.useEffect)(() => {
18244 const element = ref.current;
18245 if (!element) return;
18246 const onCompositeItemMove = () => setCanInline(true);
18247 element.addEventListener("combobox-item-move", onCompositeItemMove);
18248 return () => {
18249 element.removeEventListener("combobox-item-move", onCompositeItemMove);
18250 };
18251 }, []);
18252 (0, import_react19.useEffect)(() => {
18253 if (!inline4) return;
18254 if (!canInline) return;
18255 if (!inlineActiveValue) return;
18256 if (!isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) return;
18257 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
18258 let cleanup = noop4;
18259 queueMicrotask(() => {
18260 const element = ref.current;
18261 if (!element) return;
18262 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
18263 const nextStart = storeValue.length;
18264 const nextEnd = inlineActiveValue.length;
18265 setSelectionRange(element, nextStart, nextEnd);
18266 cleanup = () => {
18267 if (!hasFocus(element)) return;
18268 const { start, end } = getTextboxSelection(element);
18269 if (start !== nextStart) return;
18270 if (end !== nextEnd) return;
18271 setSelectionRange(element, prevStart, prevEnd);
18272 };
18273 });
18274 return () => cleanup();
18275 }, [
18276 valueUpdated,
18277 inline4,
18278 canInline,
18279 inlineActiveValue,
18280 items,
18281 autoSelect,
18282 storeValue
18283 ]);
18284 const getAutoSelectIdProp = useEvent(getAutoSelectId);
18285 const autoSelectIdRef = (0, import_react19.useRef)(null);
18286 const autoSelectMovedRef = (0, import_react19.useRef)(void 0);
18287 const userScrolledRef = (0, import_react19.useRef)(false);
18288 const isAutoScrollingRef = (0, import_react19.useRef)(false);
18289 (0, import_react19.useEffect)(() => {
18290 if (!open) return;
18291 if (!contentElement) return;
18292 const scrollingElement = getScrollingElement(contentElement);
18293 if (!scrollingElement) return;
18294 const onUserScroll = () => {
18295 canAutoSelectRef.current = false;
18296 userScrolledRef.current = true;
18297 };
18298 const onScroll = () => {
18299 if (!isAutoScrollingRef.current) userScrolledRef.current = true;
18300 if (!store) return;
18301 if (!canAutoSelectRef.current) return;
18302 const { activeId } = store.getState();
18303 if (activeId === null) return;
18304 if (activeId === autoSelectIdRef.current) return;
18305 canAutoSelectRef.current = false;
18306 };
18307 const options = {
18308 passive: true,
18309 capture: true
18310 };
18311 scrollingElement.addEventListener("wheel", onUserScroll, options);
18312 scrollingElement.addEventListener("touchmove", onUserScroll, options);
18313 scrollingElement.addEventListener("scroll", onScroll, options);
18314 return () => {
18315 scrollingElement.removeEventListener("wheel", onUserScroll, true);
18316 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
18317 scrollingElement.removeEventListener("scroll", onScroll, true);
18318 };
18319 }, [
18320 open,
18321 contentElement,
18322 store
18323 ]);
18324 useSafeLayoutEffect(() => {
18325 userScrolledRef.current = false;
18326 if (!storeValue) return;
18327 if (composingRef.current) return;
18328 canAutoSelectRef.current = true;
18329 }, [storeValue]);
18330 useSafeLayoutEffect(() => {
18331 if (autoSelect !== "always" && open) return;
18332 canAutoSelectRef.current = open;
18333 }, [autoSelect, open]);
18334 useSafeLayoutEffect(() => {
18335 if (open) return;
18336 autoSelectMovedRef.current = void 0;
18337 }, [open]);
18338 const resetValueOnSelect = useStoreState(store, "resetValueOnSelect");
18339 useUpdateEffect(() => {
18340 const canAutoSelect = canAutoSelectRef.current;
18341 if (!store) return;
18342 if (!open) return;
18343 if (!canAutoSelect && (!resetValueOnSelect || userScrolledRef.current)) return;
18344 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
18345 if (baseElement && !hasFocus(baseElement)) return;
18346 if (contentElement2?.hasAttribute("data-placing")) {
18347 const observer = new MutationObserver(forceValueUpdate);
18348 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
18349 return () => observer.disconnect();
18350 }
18351 if (autoSelect && canAutoSelect) {
18352 const userAutoSelectId = getAutoSelectIdProp(items);
18353 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : getDefaultAutoSelectId(items) ?? store.first();
18354 autoSelectIdRef.current = autoSelectId;
18355 const nextActiveId = autoSelectId ?? null;
18356 const nextActiveValue = store.item(nextActiveId)?.value;
18357 const moved = autoSelectMovedRef.current;
18358 if (nextActiveId !== activeId || moved?.id !== nextActiveId || moved?.value !== nextActiveValue) {
18359 autoSelectMovedRef.current = {
18360 id: nextActiveId,
18361 value: nextActiveValue
18362 };
18363 store.move(nextActiveId);
18364 } else store.setState("activeValue", nextActiveValue);
18365 } else {
18366 const element = store.item(activeId || store.first())?.element;
18367 if (element && "scrollIntoView" in element) {
18368 isAutoScrollingRef.current = true;
18369 element.scrollIntoView({
18370 block: "nearest",
18371 inline: "nearest"
18372 });
18373 requestAnimationFrame(() => {
18374 isAutoScrollingRef.current = false;
18375 });
18376 }
18377 }
18378 }, [
18379 store,
18380 open,
18381 valueUpdated,
18382 storeValue,
18383 autoSelect,
18384 resetValueOnSelect,
18385 getAutoSelectIdProp,
18386 items
18387 ]);
18388 (0, import_react19.useEffect)(() => {
18389 if (!inline4) return;
18390 const combobox = ref.current;
18391 if (!combobox) return;
18392 const elements = [combobox, contentElement].filter((value2) => !!value2);
18393 const onBlur2 = (event) => {
18394 if (elements.every((el) => isFocusEventOutside(event, el))) store?.setValue(value);
18395 };
18396 for (const element of elements) element.addEventListener("focusout", onBlur2);
18397 return () => {
18398 for (const element of elements) element.removeEventListener("focusout", onBlur2);
18399 };
18400 }, [
18401 inline4,
18402 contentElement,
18403 store,
18404 value
18405 ]);
18406 const canShow = (event) => {
18407 return event.currentTarget.value.length >= showMinLength;
18408 };
18409 const onChangeProp = props.onChange;
18410 const showOnChangeProp = useBooleanEvent(showOnChange ?? canShow);
18411 const setValueOnChangeProp = useBooleanEvent(setValueOnChange ?? !store.tag);
18412 const onChange = useEvent((event) => {
18413 onChangeProp?.(event);
18414 if (event.defaultPrevented) return;
18415 if (!store) return;
18416 const currentTarget = event.currentTarget;
18417 const { value: value2, selectionStart, selectionEnd } = currentTarget;
18418 const nativeEvent = event.nativeEvent;
18419 canAutoSelectRef.current = true;
18420 if (isInputEvent(nativeEvent)) {
18421 if (nativeEvent.isComposing) {
18422 canAutoSelectRef.current = false;
18423 composingRef.current = true;
18424 }
18425 if (inline4) {
18426 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
18427 const caretAtEnd = selectionStart === value2.length;
18428 setCanInline(textInserted && caretAtEnd);
18429 }
18430 }
18431 if (setValueOnChangeProp(event)) {
18432 const isSameValue2 = value2 === store.getState().value;
18433 store.setValue(value2);
18434 queueMicrotask(() => {
18435 setSelectionRange(currentTarget, selectionStart, selectionEnd);
18436 });
18437 if (inline4 && autoSelect && isSameValue2) forceValueUpdate();
18438 }
18439 if (showOnChangeProp(event)) store.show();
18440 if (!autoSelect || !canAutoSelectRef.current) store.setActiveId(null);
18441 });
18442 const onCompositionEndProp = props.onCompositionEnd;
18443 const onCompositionEnd = useEvent((event) => {
18444 canAutoSelectRef.current = true;
18445 composingRef.current = false;
18446 onCompositionEndProp?.(event);
18447 if (event.defaultPrevented) return;
18448 if (!autoSelect) return;
18449 forceValueUpdate();
18450 });
18451 const onMouseDownProp = props.onMouseDown;
18452 const blurActiveItemOnClickProp = useBooleanEvent(blurActiveItemOnClick ?? (() => store.getState().includesBaseElement));
18453 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18454 const showOnClickProp = useBooleanEvent(showOnClick ?? canShow);
18455 const onMouseDown = useEvent((event) => {
18456 onMouseDownProp?.(event);
18457 if (event.defaultPrevented) return;
18458 if (event.button) return;
18459 if (event.ctrlKey) return;
18460 if (!store) return;
18461 if (blurActiveItemOnClickProp(event)) store.setActiveId(null);
18462 if (setValueOnClickProp(event)) store.setValue(value);
18463 if (showOnClickProp(event)) queueBeforeEvent(event.currentTarget, "mouseup", store.show);
18464 });
18465 const onKeyDownProp = props.onKeyDown;
18466 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress ?? canShow);
18467 const onKeyDown = useEvent((event) => {
18468 onKeyDownProp?.(event);
18469 if (!event.repeat) canAutoSelectRef.current = false;
18470 if (event.defaultPrevented) return;
18471 if (!store) return;
18472 const { open: open2 } = store.getState();
18473 if (open2 && event.key === "Enter") {
18474 event.preventDefault();
18475 return;
18476 }
18477 if (event.ctrlKey) return;
18478 if (event.altKey) return;
18479 if (event.shiftKey) return;
18480 if (event.metaKey) return;
18481 if (open2) return;
18482 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
18483 if (showOnKeyPressProp(event)) {
18484 event.preventDefault();
18485 store.show();
18486 }
18487 }
18488 });
18489 const onBlurProp = props.onBlur;
18490 const onBlur = useEvent((event) => {
18491 canAutoSelectRef.current = false;
18492 onBlurProp?.(event);
18493 });
18494 const id = useId4(props.id);
18495 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
18496 const isActiveItem = useStoreState(store, (state) => state.activeId === null);
18497 props = {
18498 role: "combobox",
18499 "aria-autocomplete": ariaAutoComplete,
18500 "aria-haspopup": getPopupRole(contentElement, "listbox"),
18501 "aria-expanded": open,
18502 "aria-controls": contentElement?.id,
18503 "data-active-item": isActiveItem || void 0,
18504 value,
18505 ...props,
18506 id,
18507 ref: useMergeRefs(ref, props.ref),
18508 onChange,
18509 onCompositionEnd,
18510 onMouseDown,
18511 onKeyDown,
18512 onBlur
18513 };
18514 props = useComposite({
18515 store,
18516 focusable: focusable2,
18517 ...props,
18518 moveOnKeyPress: (event) => {
18519 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
18520 if (inline4) setCanInline(true);
18521 return true;
18522 }
18523 });
18524 props = usePopoverAnchor({
18525 store,
18526 ...props
18527 });
18528 return {
18529 autoComplete: "off",
18530 ...props
18531 };
18532 });
18533 var Combobox = forwardRef21(function Combobox2(props) {
18534 return createElement3(TagName9, useCombobox(props));
18535 });
18536
18537 // node_modules/@ariakit/react-components/dist/combobox/combobox-item.js
18538 var import_react20 = __toESM(require_react(), 1);
18539 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
18540 var TagName10 = "div";
18541 function isSelected(storeValue, itemValue) {
18542 if (itemValue == null) return;
18543 if (storeValue == null) return false;
18544 if (Array.isArray(storeValue)) return storeValue.includes(itemValue);
18545 return storeValue === itemValue;
18546 }
18547 function getItemRole(popupRole) {
18548 return getItemRoleByPopupRole(popupRole) ?? "option";
18549 }
18550 var useComboboxItem = createHook(function useComboboxItem2({ store, value, hideOnClick, setValueOnClick, selectValueOnClick = true, resetValueOnSelect, focusOnHover = false, moveOnKeyPress = true, getItem: getItemProp, ...props }) {
18551 const context = useComboboxScopedContext();
18552 store = store || context;
18553 invariant(store, "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component.");
18554 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
18555 resetValueOnSelectState: "resetValueOnSelect",
18556 multiSelectable(state) {
18557 return Array.isArray(state.selectedValue);
18558 },
18559 selected(state) {
18560 return isSelected(state.selectedValue, value);
18561 }
18562 });
18563 const getItem = (0, import_react20.useCallback)((item) => {
18564 const nextItem = {
18565 ...item,
18566 value
18567 };
18568 if (getItemProp) return getItemProp(nextItem);
18569 return nextItem;
18570 }, [value, getItemProp]);
18571 setValueOnClick = setValueOnClick ?? !multiSelectable;
18572 hideOnClick = hideOnClick ?? (value != null && !multiSelectable);
18573 const onClickProp = props.onClick;
18574 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18575 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
18576 const resetValueOnSelectProp = useBooleanEvent(resetValueOnSelect ?? resetValueOnSelectState ?? multiSelectable);
18577 const hideOnClickProp = useBooleanEvent(hideOnClick);
18578 const onClick = useEvent((event) => {
18579 onClickProp?.(event);
18580 if (event.defaultPrevented) return;
18581 if (isDownloading(event)) return;
18582 if (isOpeningInNewTab(event)) return;
18583 if (value != null) {
18584 if (selectValueOnClickProp(event)) {
18585 if (resetValueOnSelectProp(event)) store?.resetValue();
18586 store?.setSelectedValue((prevValue) => {
18587 if (!Array.isArray(prevValue)) return value;
18588 if (prevValue.includes(value)) return prevValue.filter((v2) => v2 !== value);
18589 return [...prevValue, value];
18590 });
18591 }
18592 if (setValueOnClickProp(event)) store?.setValue(value);
18593 }
18594 if (hideOnClickProp(event)) store?.hide();
18595 });
18596 const onKeyDownProp = props.onKeyDown;
18597 const onKeyDown = useEvent((event) => {
18598 onKeyDownProp?.(event);
18599 if (event.defaultPrevented) return;
18600 const baseElement = store?.getState().baseElement;
18601 if (!baseElement) return;
18602 if (hasFocus(baseElement)) return;
18603 const printable = event.key.length === 1 && !event.ctrlKey && !event.metaKey;
18604 const paste = (!isApple() ? event.ctrlKey : event.metaKey) && event.key.toLowerCase() === "v";
18605 const deleteKey = event.key === "Backspace" || event.key === "Delete";
18606 if (printable || paste || deleteKey) {
18607 queueMicrotask(() => baseElement.focus());
18608 if (isTextField(baseElement)) store?.setValue(baseElement.value);
18609 }
18610 });
18611 if (multiSelectable && selected != null) props = {
18612 "aria-selected": selected,
18613 ...props
18614 };
18615 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(ComboboxItemValueContext.Provider, {
18616 value,
18617 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(ComboboxItemCheckedContext.Provider, {
18618 value: selected ?? false,
18619 children: element
18620 })
18621 }), [value, selected]);
18622 props = {
18623 role: getItemRole((0, import_react20.useContext)(ComboboxListRoleContext)),
18624 children: value,
18625 ...props,
18626 onClick,
18627 onKeyDown
18628 };
18629 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
18630 props = useCompositeItem({
18631 store,
18632 ...props,
18633 getItem,
18634 moveOnKeyPress: (event) => {
18635 if (!moveOnKeyPressProp(event)) return false;
18636 const moveEvent = new Event("combobox-item-move");
18637 store?.getState().baseElement?.dispatchEvent(moveEvent);
18638 return true;
18639 }
18640 });
18641 props = useCompositeHover({
18642 store,
18643 focusOnHover,
18644 ...props
18645 });
18646 return props;
18647 });
18648 var ComboboxItem = memo3(forwardRef21(function ComboboxItem2(props) {
18649 return createElement3(TagName10, useComboboxItem(props));
18650 }));
18651
18652 // node_modules/@ariakit/react-components/dist/combobox/combobox-item-value.js
18653 var import_react21 = __toESM(require_react(), 1);
18654 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
18655 var TagName11 = "span";
18656 function normalizeValue(value) {
18657 return normalizeString(value).toLowerCase();
18658 }
18659 function getOffsets(string, values) {
18660 const offsets = [];
18661 for (const value of values) {
18662 if (!value) continue;
18663 let pos = 0;
18664 const length = value.length;
18665 let index2 = string.indexOf(value, pos);
18666 while (index2 !== -1) {
18667 offsets.push([index2, length]);
18668 pos = index2 + 1;
18669 index2 = string.indexOf(value, pos);
18670 }
18671 }
18672 return offsets;
18673 }
18674 function mergeOverlappingOffsets(offsets) {
18675 offsets.sort(([a2], [b2]) => a2 - b2);
18676 const merged = [];
18677 for (const [offset4, length] of offsets) {
18678 const last = merged[merged.length - 1];
18679 if (last && offset4 < last[0] + last[1]) last[1] = Math.max(last[1], offset4 + length - last[0]);
18680 else merged.push([offset4, length]);
18681 }
18682 return merged;
18683 }
18684 function getNormalizedIndexes(itemValue) {
18685 const starts = [];
18686 const ends = [];
18687 let index2 = 0;
18688 for (const char of itemValue) {
18689 const normalizedLength = normalizeValue(char).length;
18690 for (let i2 = 0; i2 < normalizedLength; i2 += 1) {
18691 starts.push(i2 === 0 ? index2 : -1);
18692 ends.push(index2);
18693 }
18694 index2 += char.length;
18695 }
18696 starts.push(itemValue.length);
18697 ends.push(itemValue.length);
18698 let nextBoundary = itemValue.length;
18699 for (let i2 = starts.length - 1; i2 >= 0; i2 -= 1) {
18700 const start = starts[i2];
18701 if (start == null) continue;
18702 if (start === -1) starts[i2] = nextBoundary;
18703 else nextBoundary = start;
18704 }
18705 return {
18706 starts,
18707 ends
18708 };
18709 }
18710 function toOriginalOffsets(itemValue, normalizedOffsets) {
18711 if (!normalizedOffsets.length) return normalizedOffsets;
18712 const { starts, ends } = getNormalizedIndexes(itemValue);
18713 const offsets = [];
18714 for (const [normalizedOffset, normalizedLength] of normalizedOffsets) {
18715 const start = starts[normalizedOffset];
18716 const end = ends[normalizedOffset + normalizedLength];
18717 if (start == null || end == null) continue;
18718 if (end <= start) continue;
18719 offsets.push([start, end - start]);
18720 }
18721 return offsets;
18722 }
18723 function splitValue(itemValue, userValue) {
18724 if (!itemValue) return itemValue;
18725 if (!userValue) return itemValue;
18726 const userValues = toArray(userValue).map(normalizeValue);
18727 const parts = [];
18728 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", {
18729 "data-autocomplete-value": autocomplete ? "" : void 0,
18730 "data-user-value": autocomplete ? void 0 : "",
18731 children: value
18732 }, parts.length);
18733 const offsets = toOriginalOffsets(itemValue, mergeOverlappingOffsets(getOffsets(normalizeValue(itemValue), new Set(userValues))));
18734 const firstEntry = offsets[0];
18735 if (!firstEntry) {
18736 parts.push(span(itemValue, true));
18737 return parts;
18738 }
18739 const [firstOffset] = firstEntry;
18740 [itemValue.slice(0, firstOffset), ...offsets.flatMap(([offset4, length], i2) => {
18741 const value = itemValue.slice(offset4, offset4 + length);
18742 const nextOffset = offsets[i2 + 1]?.[0];
18743 return [value, itemValue.slice(offset4 + length, nextOffset)];
18744 })].forEach((value, i2) => {
18745 if (!value) return;
18746 parts.push(span(value, i2 % 2 === 0));
18747 });
18748 return parts;
18749 }
18750 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
18751 const context = useComboboxScopedContext();
18752 store = store || context;
18753 const itemContext = (0, import_react21.useContext)(ComboboxItemValueContext);
18754 const itemValue = value ?? itemContext;
18755 const inputValue = useStoreState(store, (state) => userValue ?? state?.value);
18756 props = {
18757 children: (0, import_react21.useMemo)(() => {
18758 if (!itemValue) return;
18759 if (!inputValue) return itemValue;
18760 return splitValue(itemValue, inputValue);
18761 }, [itemValue, inputValue]),
18762 ...props
18763 };
18764 return removeUndefinedValues(props);
18765 });
18766 var ComboboxItemValue = forwardRef21(function ComboboxItemValue2(props) {
18767 return createElement3(TagName11, useComboboxItemValue(props));
18768 });
18769
18770 // node_modules/@ariakit/react-components/dist/combobox/combobox-label.js
18771 var TagName12 = "label";
18772 var useComboboxLabel = createHook(function useComboboxLabel2({ store, ...props }) {
18773 const context = useComboboxProviderContext();
18774 store = store || context;
18775 invariant(store, "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component.");
18776 props = {
18777 htmlFor: useStoreState(store, (state) => state.baseElement?.id),
18778 ...props
18779 };
18780 return removeUndefinedValues(props);
18781 });
18782 var ComboboxLabel = memo3(forwardRef21(function ComboboxLabel2(props) {
18783 return createElement3(TagName12, useComboboxLabel(props));
18784 }));
18785
18786 // node_modules/@ariakit/react-components/dist/combobox/combobox-list.js
18787 var import_react22 = __toESM(require_react(), 1);
18788 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
18789 var TagName13 = "div";
18790 var useComboboxList = createHook(function useComboboxList2({ store, alwaysVisible, ...props }) {
18791 const scopedContext = useComboboxScopedContext(true);
18792 const context = useComboboxContext();
18793 store = store || context;
18794 const scopedContextSameStore = !!store && store === scopedContext;
18795 invariant(store, "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component.");
18796 const ref = (0, import_react22.useRef)(null);
18797 const id = useId4(props.id);
18798 const mounted = useStoreState(store, "mounted");
18799 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
18800 const style = hidden ? {
18801 ...props.style,
18802 display: "none"
18803 } : props.style;
18804 const multiSelectable = useStoreState(store, (state) => Array.isArray(state.selectedValue));
18805 const role = useAttribute(ref, "role", props.role);
18806 const ariaMultiSelectable = role === "listbox" || role === "tree" || role === "grid" ? multiSelectable || void 0 : void 0;
18807 const [hasListboxInside, setHasListboxInside] = (0, import_react22.useState)(false);
18808 const contentElement = useStoreState(store, "contentElement");
18809 useSafeLayoutEffect(() => {
18810 if (!mounted) return;
18811 const element = ref.current;
18812 if (!element) return;
18813 if (contentElement !== element) return;
18814 const callback = () => {
18815 setHasListboxInside(!!element.querySelector("[role='listbox']"));
18816 };
18817 const observer = new MutationObserver(callback);
18818 observer.observe(element, {
18819 subtree: true,
18820 childList: true,
18821 attributeFilter: ["role"]
18822 });
18823 callback();
18824 return () => observer.disconnect();
18825 }, [mounted, contentElement]);
18826 if (!hasListboxInside) props = {
18827 role: "listbox",
18828 "aria-multiselectable": ariaMultiSelectable,
18829 ...props
18830 };
18831 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ComboboxScopedContextProvider, {
18832 value: store,
18833 children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ComboboxListRoleContext.Provider, {
18834 value: role,
18835 children: element
18836 })
18837 }), [store, role]);
18838 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
18839 props = {
18840 hidden,
18841 ...props,
18842 id,
18843 ref: useMergeRefs(setContentElement, ref, props.ref),
18844 style
18845 };
18846 return removeUndefinedValues(props);
18847 });
18848 var ComboboxList = forwardRef21(function ComboboxList2(props) {
18849 return createElement3(TagName13, useComboboxList(props));
18850 });
18851
18852 // node_modules/@ariakit/react-components/dist/tag/tag-context.js
18853 var import_react23 = __toESM(require_react(), 1);
18854 var TagValueContext = (0, import_react23.createContext)(null);
18855 var TagRemoveIdContext = (0, import_react23.createContext)(null);
18856 var ctx7 = createStoreContext([CompositeContextProvider], [CompositeScopedContextProvider]);
18857 var useTagContext = ctx7.useContext;
18858 var useTagScopedContext = ctx7.useScopedContext;
18859 var useTagProviderContext = ctx7.useProviderContext;
18860 var TagContextProvider = ctx7.ContextProvider;
18861 var TagScopedContextProvider = ctx7.ScopedContextProvider;
18862
18863 // node_modules/@ariakit/components/dist/combobox/combobox-store.js
18864 var isTouchSafari = isSafari() && isTouchDevice();
18865 function createComboboxStore({ tag, ...props } = {}) {
18866 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
18867 throwOnConflictingProps(props, store);
18868 const tagState = tag?.getState();
18869 const syncState = store?.getState();
18870 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId, null);
18871 const composite = createCompositeStore({
18872 ...props,
18873 activeId,
18874 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, true),
18875 orientation: defaultValue(props.orientation, syncState?.orientation, "vertical"),
18876 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, true),
18877 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, true),
18878 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, true)
18879 });
18880 const popover = createPopoverStore({
18881 ...props,
18882 placement: defaultValue(props.placement, syncState?.placement, "bottom-start")
18883 });
18884 const value = defaultValue(props.value, syncState?.value, props.defaultValue, "");
18885 const selectedValue = defaultValue(props.selectedValue, syncState?.selectedValue, tagState?.values, props.defaultSelectedValue, "");
18886 const multiSelectable = Array.isArray(selectedValue);
18887 const initialState = {
18888 ...composite.getState(),
18889 ...popover.getState(),
18890 value,
18891 selectedValue,
18892 resetValueOnSelect: defaultValue(props.resetValueOnSelect, syncState?.resetValueOnSelect, multiSelectable),
18893 resetValueOnHide: defaultValue(props.resetValueOnHide, syncState?.resetValueOnHide, multiSelectable && !tag),
18894 activeValue: syncState?.activeValue
18895 };
18896 const combobox = createStore(initialState, composite, popover, store);
18897 if (isTouchSafari) setup(combobox, () => sync(combobox, ["virtualFocus"], () => {
18898 combobox.setState("virtualFocus", false);
18899 }));
18900 setup(combobox, () => {
18901 if (!tag) return;
18902 return chain(sync(combobox, ["selectedValue"], (state) => {
18903 if (!Array.isArray(state.selectedValue)) return;
18904 tag.setValues(state.selectedValue);
18905 }), sync(tag, ["values"], (state) => {
18906 combobox.setState("selectedValue", state.values);
18907 }));
18908 });
18909 setup(combobox, () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
18910 if (!state.resetValueOnHide) return;
18911 if (state.mounted) return;
18912 combobox.setState("value", value);
18913 }));
18914 setup(combobox, () => sync(combobox, ["open"], (state) => {
18915 if (state.open) return;
18916 combobox.setState("activeId", activeId);
18917 combobox.setState("moves", 0);
18918 }));
18919 setup(combobox, () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
18920 if (state.moves === prevState.moves) combobox.setState("activeValue", void 0);
18921 }));
18922 setup(combobox, () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
18923 if (state.moves === prev.moves) return;
18924 const { activeId: activeId2 } = combobox.getState();
18925 const activeItem = composite.item(activeId2);
18926 combobox.setState("activeValue", activeItem?.value);
18927 }));
18928 return {
18929 ...popover,
18930 ...composite,
18931 ...combobox,
18932 tag,
18933 setValue: (value2) => combobox.setState("value", value2),
18934 resetValue: () => combobox.setState("value", initialState.value),
18935 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
18936 };
18937 }
18938
18939 // node_modules/@ariakit/react-components/dist/combobox/combobox-store.js
18940 function useComboboxStoreOptions(props) {
18941 const tag = useTagContext();
18942 props = {
18943 ...props,
18944 tag: props.tag !== void 0 ? props.tag : tag
18945 };
18946 return useCompositeStoreOptions(props);
18947 }
18948 function useComboboxStoreProps(store, update2, props) {
18949 useUpdateEffect(update2, [props.tag]);
18950 useStoreProps(store, props, "value", "setValue");
18951 useStoreProps(store, props, "selectedValue", "setSelectedValue");
18952 useStoreProps(store, props, "resetValueOnHide");
18953 useStoreProps(store, props, "resetValueOnSelect");
18954 return Object.assign(useCompositeStoreProps(usePopoverStoreProps(store, update2, props), update2, props), { tag: props.tag });
18955 }
18956 function useComboboxStore(props = {}) {
18957 props = useComboboxStoreOptions(props);
18958 const [store, update2] = useStore2(createComboboxStore, props);
18959 return useComboboxStoreProps(store, update2, props);
18960 }
18961
18962 // node_modules/@ariakit/react-components/dist/combobox/combobox-provider.js
18963 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
18964 function ComboboxProvider(props = {}) {
18965 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ComboboxContextProvider, {
18966 value: useComboboxStore(props),
18967 children: props.children
18968 });
18969 }
18970
18971 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18972 var import_remove_accents = __toESM(require_remove_accents(), 1);
18973 var import_compose8 = __toESM(require_compose(), 1);
18974 var import_i18n23 = __toESM(require_i18n(), 1);
18975 var import_element44 = __toESM(require_element(), 1);
18976 var import_components19 = __toESM(require_components(), 1);
18977
18978 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
18979 var EMPTY_ARRAY3 = [];
18980 var getCurrentValue = (filterDefinition, currentFilter) => {
18981 if (filterDefinition.singleSelection) {
18982 return currentFilter?.value;
18983 }
18984 if (Array.isArray(currentFilter?.value)) {
18985 return currentFilter.value;
18986 }
18987 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
18988 return [currentFilter.value];
18989 }
18990 return EMPTY_ARRAY3;
18991 };
18992
18993 // packages/dataviews/build-module/hooks/use-elements.mjs
18994 var import_element43 = __toESM(require_element(), 1);
18995 var EMPTY_ARRAY4 = [];
18996 function useElements({
18997 elements,
18998 getElements
18999 }) {
19000 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
19001 const [records, setRecords] = (0, import_element43.useState)(staticElements);
19002 const [isLoading, setIsLoading] = (0, import_element43.useState)(false);
19003 (0, import_element43.useEffect)(() => {
19004 if (!getElements) {
19005 setRecords(staticElements);
19006 return;
19007 }
19008 let cancelled = false;
19009 setIsLoading(true);
19010 getElements().then((fetchedElements) => {
19011 if (!cancelled) {
19012 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
19013 setRecords(dynamicElements);
19014 }
19015 }).catch(() => {
19016 if (!cancelled) {
19017 setRecords(staticElements);
19018 }
19019 }).finally(() => {
19020 if (!cancelled) {
19021 setIsLoading(false);
19022 }
19023 });
19024 return () => {
19025 cancelled = true;
19026 };
19027 }, [getElements, staticElements]);
19028 return {
19029 elements: records,
19030 isLoading
19031 };
19032 }
19033
19034 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
19035 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
19036 function normalizeSearchInput(input = "") {
19037 return (0, import_remove_accents.default)(input.trim().toLowerCase());
19038 }
19039 var getNewValue = (filterDefinition, currentFilter, value) => {
19040 if (filterDefinition.singleSelection) {
19041 return value;
19042 }
19043 if (Array.isArray(currentFilter?.value)) {
19044 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
19045 }
19046 return [value];
19047 };
19048 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
19049 return `${prefix}-${filterElementValue}`;
19050 }
19051 var MultiSelectionOption = ({ selected }) => {
19052 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19053 "span",
19054 {
19055 className: clsx_default(
19056 "dataviews-filters__search-widget-listitem-multi-selection",
19057 { "is-selected": selected }
19058 ),
19059 children: selected && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components19.Icon, { icon: check_default })
19060 }
19061 );
19062 };
19063 var SingleSelectionOption = ({ selected }) => {
19064 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19065 "span",
19066 {
19067 className: clsx_default(
19068 "dataviews-filters__search-widget-listitem-single-selection",
19069 { "is-selected": selected }
19070 )
19071 }
19072 );
19073 };
19074 function ListBox({ view, filter, onChangeView }) {
19075 const baseId = (0, import_compose8.useInstanceId)(ListBox, "dataviews-filter-list-box");
19076 const [activeCompositeId, setActiveCompositeId] = (0, import_element44.useState)(
19077 // When there are one or less operators, the first item is set as active
19078 // (by setting the initial `activeId` to `undefined`).
19079 // With 2 or more operators, the focus is moved on the operators control
19080 // (by setting the initial `activeId` to `null`), meaning that there won't
19081 // be an active item initially. Focus is then managed via the
19082 // `onFocusVisible` callback.
19083 filter.operators?.length === 1 ? void 0 : null
19084 );
19085 const currentFilter = view.filters?.find(
19086 (f2) => f2.field === filter.field
19087 );
19088 const currentValue = getCurrentValue(filter, currentFilter);
19089 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19090 import_components19.Composite,
19091 {
19092 virtualFocus: true,
19093 focusLoop: true,
19094 activeId: activeCompositeId,
19095 setActiveId: setActiveCompositeId,
19096 role: "listbox",
19097 className: "dataviews-filters__search-widget-listbox",
19098 "aria-label": (0, import_i18n23.sprintf)(
19099 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
19100 (0, import_i18n23.__)("List of: %1$s"),
19101 filter.name
19102 ),
19103 onFocusVisible: () => {
19104 if (!activeCompositeId && filter.elements.length) {
19105 setActiveCompositeId(
19106 generateFilterElementCompositeItemId(
19107 baseId,
19108 filter.elements[0].value
19109 )
19110 );
19111 }
19112 },
19113 render: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components19.Composite.Typeahead, {}),
19114 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
19115 import_components19.Composite.Hover,
19116 {
19117 render: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19118 import_components19.Composite.Item,
19119 {
19120 id: generateFilterElementCompositeItemId(
19121 baseId,
19122 element.value
19123 ),
19124 render: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19125 "div",
19126 {
19127 "aria-label": element.label,
19128 role: "option",
19129 className: "dataviews-filters__search-widget-listitem"
19130 }
19131 ),
19132 onClick: () => {
19133 const newFilters = currentFilter ? [
19134 ...(view.filters ?? []).map(
19135 (_filter) => {
19136 if (_filter.field === filter.field) {
19137 return {
19138 ..._filter,
19139 operator: currentFilter.operator || filter.operators[0],
19140 value: getNewValue(
19141 filter,
19142 currentFilter,
19143 element.value
19144 )
19145 };
19146 }
19147 return _filter;
19148 }
19149 )
19150 ] : [
19151 ...view.filters ?? [],
19152 {
19153 field: filter.field,
19154 operator: filter.operators[0],
19155 value: getNewValue(
19156 filter,
19157 currentFilter,
19158 element.value
19159 )
19160 }
19161 ];
19162 onChangeView({
19163 ...view,
19164 page: 1,
19165 filters: newFilters
19166 });
19167 }
19168 }
19169 ),
19170 children: [
19171 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19172 SingleSelectionOption,
19173 {
19174 selected: currentValue === element.value
19175 }
19176 ),
19177 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19178 MultiSelectionOption,
19179 {
19180 selected: currentValue.includes(element.value)
19181 }
19182 ),
19183 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19184 "span",
19185 {
19186 className: "dataviews-filters__search-widget-listitem-value",
19187 title: element.label,
19188 children: element.label
19189 }
19190 )
19191 ]
19192 },
19193 element.value
19194 ))
19195 }
19196 );
19197 }
19198 function ComboboxList22({ view, filter, onChangeView }) {
19199 const [searchValue, setSearchValue] = (0, import_element44.useState)("");
19200 const deferredSearchValue = (0, import_element44.useDeferredValue)(searchValue);
19201 const currentFilter = view.filters?.find(
19202 (_filter) => _filter.field === filter.field
19203 );
19204 const currentValue = getCurrentValue(filter, currentFilter);
19205 const matches = (0, import_element44.useMemo)(() => {
19206 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
19207 return filter.elements.filter(
19208 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
19209 );
19210 }, [filter.elements, deferredSearchValue]);
19211 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
19212 ComboboxProvider,
19213 {
19214 selectedValue: currentValue,
19215 setSelectedValue: (value) => {
19216 const newFilters = currentFilter ? [
19217 ...(view.filters ?? []).map((_filter) => {
19218 if (_filter.field === filter.field) {
19219 return {
19220 ..._filter,
19221 operator: currentFilter.operator || filter.operators[0],
19222 value
19223 };
19224 }
19225 return _filter;
19226 })
19227 ] : [
19228 ...view.filters ?? [],
19229 {
19230 field: filter.field,
19231 operator: filter.operators[0],
19232 value
19233 }
19234 ];
19235 onChangeView({
19236 ...view,
19237 page: 1,
19238 filters: newFilters
19239 });
19240 },
19241 setValue: setSearchValue,
19242 children: [
19243 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
19244 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ComboboxLabel, {}), children: (0, import_i18n23.__)("Search items") }),
19245 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19246 Combobox,
19247 {
19248 autoSelect: "always",
19249 placeholder: (0, import_i18n23.__)("Search"),
19250 className: "dataviews-filters__search-widget-filter-combobox__input"
19251 }
19252 ),
19253 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components19.Icon, { icon: search_default }) })
19254 ] }),
19255 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
19256 ComboboxList,
19257 {
19258 className: "dataviews-filters__search-widget-filter-combobox-list",
19259 alwaysVisible: true,
19260 children: [
19261 matches.map((element) => {
19262 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
19263 ComboboxItem,
19264 {
19265 resetValueOnSelect: false,
19266 value: element.value,
19267 className: "dataviews-filters__search-widget-listitem",
19268 hideOnClick: false,
19269 setValueOnClick: false,
19270 focusOnHover: true,
19271 children: [
19272 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19273 SingleSelectionOption,
19274 {
19275 selected: currentValue === element.value
19276 }
19277 ),
19278 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19279 MultiSelectionOption,
19280 {
19281 selected: currentValue.includes(
19282 element.value
19283 )
19284 }
19285 ),
19286 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
19287 "span",
19288 {
19289 className: "dataviews-filters__search-widget-listitem-value",
19290 title: element.label,
19291 children: [
19292 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19293 ComboboxItemValue,
19294 {
19295 className: "dataviews-filters__search-widget-filter-combobox-item-value",
19296 value: element.label
19297 }
19298 ),
19299 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
19300 ]
19301 }
19302 )
19303 ]
19304 },
19305 element.value
19306 );
19307 }),
19308 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("p", { children: (0, import_i18n23.__)("No results found") })
19309 ]
19310 }
19311 )
19312 ]
19313 }
19314 );
19315 }
19316 function SearchWidget(props) {
19317 const { elements, isLoading } = useElements({
19318 elements: props.filter.elements,
19319 getElements: props.filter.getElements
19320 });
19321 if (isLoading) {
19322 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components19.Spinner, {}) });
19323 }
19324 if (elements.length === 0) {
19325 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n23.__)("No elements found") });
19326 }
19327 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
19328 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
19329 }
19330
19331 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
19332 var import_es6 = __toESM(require_es6(), 1);
19333 var import_compose9 = __toESM(require_compose(), 1);
19334 var import_element45 = __toESM(require_element(), 1);
19335 var import_components20 = __toESM(require_components(), 1);
19336 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
19337 function InputWidget({
19338 filter,
19339 view,
19340 onChangeView,
19341 fields
19342 }) {
19343 const currentFilter = view.filters?.find(
19344 (f2) => f2.field === filter.field
19345 );
19346 const currentValue = getCurrentValue(filter, currentFilter);
19347 const field = (0, import_element45.useMemo)(() => {
19348 const currentField = fields.find((f2) => f2.id === filter.field);
19349 if (currentField) {
19350 return {
19351 ...currentField,
19352 // Deactivate validation for filters.
19353 isValid: {},
19354 // Filter controls are always enabled.
19355 isDisabled: () => false,
19356 // Filter controls are always visible.
19357 isVisible: () => true,
19358 // Configure getValue/setValue as if Item was a plain object.
19359 getValue: ({ item }) => item[currentField.id],
19360 setValue: ({ value }) => ({
19361 [currentField.id]: value
19362 })
19363 };
19364 }
19365 return currentField;
19366 }, [fields, filter.field]);
19367 const data = (0, import_element45.useMemo)(() => {
19368 return (view.filters ?? []).reduce(
19369 (acc, activeFilter) => {
19370 acc[activeFilter.field] = activeFilter.value;
19371 return acc;
19372 },
19373 {}
19374 );
19375 }, [view.filters]);
19376 const handleChange = (0, import_compose9.useEvent)((updatedData) => {
19377 if (!field || !currentFilter) {
19378 return;
19379 }
19380 const nextValue = field.getValue({ item: updatedData });
19381 if ((0, import_es6.default)(nextValue, currentValue)) {
19382 return;
19383 }
19384 onChangeView({
19385 ...view,
19386 filters: (view.filters ?? []).map(
19387 (_filter) => _filter.field === filter.field ? {
19388 ..._filter,
19389 operator: currentFilter.operator || filter.operators[0],
19390 // Consider empty strings as undefined:
19391 //
19392 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
19393 // - empty string as value means "search empty string": returns only the records that have an empty string as value
19394 //
19395 // In practice, this means the filter will not be able to find an empty string as the value.
19396 value: nextValue === "" ? void 0 : nextValue
19397 } : _filter
19398 )
19399 });
19400 });
19401 if (!field || !field.Edit || !currentFilter) {
19402 return null;
19403 }
19404 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
19405 import_components20.Flex,
19406 {
19407 className: "dataviews-filters__user-input-widget",
19408 gap: 2.5,
19409 direction: "column",
19410 children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
19411 field.Edit,
19412 {
19413 hideLabelFromVision: true,
19414 data,
19415 field,
19416 operator: currentFilter.operator,
19417 onChange: handleChange
19418 }
19419 )
19420 }
19421 );
19422 }
19423
19424 // packages/dataviews/node_modules/date-fns/constants.js
19425 var daysInYear = 365.2425;
19426 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
19427 var minTime = -maxTime;
19428 var millisecondsInWeek = 6048e5;
19429 var millisecondsInDay = 864e5;
19430 var secondsInHour = 3600;
19431 var secondsInDay = secondsInHour * 24;
19432 var secondsInWeek = secondsInDay * 7;
19433 var secondsInYear = secondsInDay * daysInYear;
19434 var secondsInMonth = secondsInYear / 12;
19435 var secondsInQuarter = secondsInMonth * 3;
19436 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
19437
19438 // packages/dataviews/node_modules/date-fns/constructFrom.js
19439 function constructFrom(date, value) {
19440 if (typeof date === "function") return date(value);
19441 if (date && typeof date === "object" && constructFromSymbol in date)
19442 return date[constructFromSymbol](value);
19443 if (date instanceof Date) return new date.constructor(value);
19444 return new Date(value);
19445 }
19446
19447 // packages/dataviews/node_modules/date-fns/toDate.js
19448 function toDate(argument, context) {
19449 return constructFrom(context || argument, argument);
19450 }
19451
19452 // packages/dataviews/node_modules/date-fns/addDays.js
19453 function addDays(date, amount, options) {
19454 const _date = toDate(date, options?.in);
19455 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19456 if (!amount) return _date;
19457 _date.setDate(_date.getDate() + amount);
19458 return _date;
19459 }
19460
19461 // packages/dataviews/node_modules/date-fns/addMonths.js
19462 function addMonths(date, amount, options) {
19463 const _date = toDate(date, options?.in);
19464 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19465 if (!amount) {
19466 return _date;
19467 }
19468 const dayOfMonth = _date.getDate();
19469 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
19470 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
19471 const daysInMonth = endOfDesiredMonth.getDate();
19472 if (dayOfMonth >= daysInMonth) {
19473 return endOfDesiredMonth;
19474 } else {
19475 _date.setFullYear(
19476 endOfDesiredMonth.getFullYear(),
19477 endOfDesiredMonth.getMonth(),
19478 dayOfMonth
19479 );
19480 return _date;
19481 }
19482 }
19483
19484 // packages/dataviews/node_modules/date-fns/_lib/defaultOptions.js
19485 var defaultOptions = {};
19486 function getDefaultOptions() {
19487 return defaultOptions;
19488 }
19489
19490 // packages/dataviews/node_modules/date-fns/startOfWeek.js
19491 function startOfWeek(date, options) {
19492 const defaultOptions2 = getDefaultOptions();
19493 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
19494 const _date = toDate(date, options?.in);
19495 const day = _date.getDay();
19496 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
19497 _date.setDate(_date.getDate() - diff);
19498 _date.setHours(0, 0, 0, 0);
19499 return _date;
19500 }
19501
19502 // packages/dataviews/node_modules/date-fns/startOfISOWeek.js
19503 function startOfISOWeek(date, options) {
19504 return startOfWeek(date, { ...options, weekStartsOn: 1 });
19505 }
19506
19507 // packages/dataviews/node_modules/date-fns/getISOWeekYear.js
19508 function getISOWeekYear(date, options) {
19509 const _date = toDate(date, options?.in);
19510 const year = _date.getFullYear();
19511 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
19512 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
19513 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
19514 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
19515 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
19516 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
19517 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
19518 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
19519 if (_date.getTime() >= startOfNextYear.getTime()) {
19520 return year + 1;
19521 } else if (_date.getTime() >= startOfThisYear.getTime()) {
19522 return year;
19523 } else {
19524 return year - 1;
19525 }
19526 }
19527
19528 // packages/dataviews/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
19529 function getTimezoneOffsetInMilliseconds(date) {
19530 const _date = toDate(date);
19531 const utcDate = new Date(
19532 Date.UTC(
19533 _date.getFullYear(),
19534 _date.getMonth(),
19535 _date.getDate(),
19536 _date.getHours(),
19537 _date.getMinutes(),
19538 _date.getSeconds(),
19539 _date.getMilliseconds()
19540 )
19541 );
19542 utcDate.setUTCFullYear(_date.getFullYear());
19543 return +date - +utcDate;
19544 }
19545
19546 // packages/dataviews/node_modules/date-fns/_lib/normalizeDates.js
19547 function normalizeDates(context, ...dates) {
19548 const normalize = constructFrom.bind(
19549 null,
19550 context || dates.find((date) => typeof date === "object")
19551 );
19552 return dates.map(normalize);
19553 }
19554
19555 // packages/dataviews/node_modules/date-fns/startOfDay.js
19556 function startOfDay(date, options) {
19557 const _date = toDate(date, options?.in);
19558 _date.setHours(0, 0, 0, 0);
19559 return _date;
19560 }
19561
19562 // packages/dataviews/node_modules/date-fns/differenceInCalendarDays.js
19563 function differenceInCalendarDays(laterDate, earlierDate, options) {
19564 const [laterDate_, earlierDate_] = normalizeDates(
19565 options?.in,
19566 laterDate,
19567 earlierDate
19568 );
19569 const laterStartOfDay = startOfDay(laterDate_);
19570 const earlierStartOfDay = startOfDay(earlierDate_);
19571 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
19572 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
19573 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
19574 }
19575
19576 // packages/dataviews/node_modules/date-fns/startOfISOWeekYear.js
19577 function startOfISOWeekYear(date, options) {
19578 const year = getISOWeekYear(date, options);
19579 const fourthOfJanuary = constructFrom(options?.in || date, 0);
19580 fourthOfJanuary.setFullYear(year, 0, 4);
19581 fourthOfJanuary.setHours(0, 0, 0, 0);
19582 return startOfISOWeek(fourthOfJanuary);
19583 }
19584
19585 // packages/dataviews/node_modules/date-fns/addWeeks.js
19586 function addWeeks(date, amount, options) {
19587 return addDays(date, amount * 7, options);
19588 }
19589
19590 // packages/dataviews/node_modules/date-fns/addYears.js
19591 function addYears(date, amount, options) {
19592 return addMonths(date, amount * 12, options);
19593 }
19594
19595 // packages/dataviews/node_modules/date-fns/isDate.js
19596 function isDate(value) {
19597 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
19598 }
19599
19600 // packages/dataviews/node_modules/date-fns/isValid.js
19601 function isValid(date) {
19602 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
19603 }
19604
19605 // packages/dataviews/node_modules/date-fns/startOfMonth.js
19606 function startOfMonth(date, options) {
19607 const _date = toDate(date, options?.in);
19608 _date.setDate(1);
19609 _date.setHours(0, 0, 0, 0);
19610 return _date;
19611 }
19612
19613 // packages/dataviews/node_modules/date-fns/startOfYear.js
19614 function startOfYear(date, options) {
19615 const date_ = toDate(date, options?.in);
19616 date_.setFullYear(date_.getFullYear(), 0, 1);
19617 date_.setHours(0, 0, 0, 0);
19618 return date_;
19619 }
19620
19621 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatDistance.js
19622 var formatDistanceLocale = {
19623 lessThanXSeconds: {
19624 one: "less than a second",
19625 other: "less than {{count}} seconds"
19626 },
19627 xSeconds: {
19628 one: "1 second",
19629 other: "{{count}} seconds"
19630 },
19631 halfAMinute: "half a minute",
19632 lessThanXMinutes: {
19633 one: "less than a minute",
19634 other: "less than {{count}} minutes"
19635 },
19636 xMinutes: {
19637 one: "1 minute",
19638 other: "{{count}} minutes"
19639 },
19640 aboutXHours: {
19641 one: "about 1 hour",
19642 other: "about {{count}} hours"
19643 },
19644 xHours: {
19645 one: "1 hour",
19646 other: "{{count}} hours"
19647 },
19648 xDays: {
19649 one: "1 day",
19650 other: "{{count}} days"
19651 },
19652 aboutXWeeks: {
19653 one: "about 1 week",
19654 other: "about {{count}} weeks"
19655 },
19656 xWeeks: {
19657 one: "1 week",
19658 other: "{{count}} weeks"
19659 },
19660 aboutXMonths: {
19661 one: "about 1 month",
19662 other: "about {{count}} months"
19663 },
19664 xMonths: {
19665 one: "1 month",
19666 other: "{{count}} months"
19667 },
19668 aboutXYears: {
19669 one: "about 1 year",
19670 other: "about {{count}} years"
19671 },
19672 xYears: {
19673 one: "1 year",
19674 other: "{{count}} years"
19675 },
19676 overXYears: {
19677 one: "over 1 year",
19678 other: "over {{count}} years"
19679 },
19680 almostXYears: {
19681 one: "almost 1 year",
19682 other: "almost {{count}} years"
19683 }
19684 };
19685 var formatDistance = (token, count, options) => {
19686 let result;
19687 const tokenValue = formatDistanceLocale[token];
19688 if (typeof tokenValue === "string") {
19689 result = tokenValue;
19690 } else if (count === 1) {
19691 result = tokenValue.one;
19692 } else {
19693 result = tokenValue.other.replace("{{count}}", count.toString());
19694 }
19695 if (options?.addSuffix) {
19696 if (options.comparison && options.comparison > 0) {
19697 return "in " + result;
19698 } else {
19699 return result + " ago";
19700 }
19701 }
19702 return result;
19703 };
19704
19705 // packages/dataviews/node_modules/date-fns/locale/_lib/buildFormatLongFn.js
19706 function buildFormatLongFn(args) {
19707 return (options = {}) => {
19708 const width = options.width ? String(options.width) : args.defaultWidth;
19709 const format6 = args.formats[width] || args.formats[args.defaultWidth];
19710 return format6;
19711 };
19712 }
19713
19714 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatLong.js
19715 var dateFormats = {
19716 full: "EEEE, MMMM do, y",
19717 long: "MMMM do, y",
19718 medium: "MMM d, y",
19719 short: "MM/dd/yyyy"
19720 };
19721 var timeFormats = {
19722 full: "h:mm:ss a zzzz",
19723 long: "h:mm:ss a z",
19724 medium: "h:mm:ss a",
19725 short: "h:mm a"
19726 };
19727 var dateTimeFormats = {
19728 full: "{{date}} 'at' {{time}}",
19729 long: "{{date}} 'at' {{time}}",
19730 medium: "{{date}}, {{time}}",
19731 short: "{{date}}, {{time}}"
19732 };
19733 var formatLong = {
19734 date: buildFormatLongFn({
19735 formats: dateFormats,
19736 defaultWidth: "full"
19737 }),
19738 time: buildFormatLongFn({
19739 formats: timeFormats,
19740 defaultWidth: "full"
19741 }),
19742 dateTime: buildFormatLongFn({
19743 formats: dateTimeFormats,
19744 defaultWidth: "full"
19745 })
19746 };
19747
19748 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatRelative.js
19749 var formatRelativeLocale = {
19750 lastWeek: "'last' eeee 'at' p",
19751 yesterday: "'yesterday at' p",
19752 today: "'today at' p",
19753 tomorrow: "'tomorrow at' p",
19754 nextWeek: "eeee 'at' p",
19755 other: "P"
19756 };
19757 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
19758
19759 // packages/dataviews/node_modules/date-fns/locale/_lib/buildLocalizeFn.js
19760 function buildLocalizeFn(args) {
19761 return (value, options) => {
19762 const context = options?.context ? String(options.context) : "standalone";
19763 let valuesArray;
19764 if (context === "formatting" && args.formattingValues) {
19765 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
19766 const width = options?.width ? String(options.width) : defaultWidth;
19767 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
19768 } else {
19769 const defaultWidth = args.defaultWidth;
19770 const width = options?.width ? String(options.width) : args.defaultWidth;
19771 valuesArray = args.values[width] || args.values[defaultWidth];
19772 }
19773 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
19774 return valuesArray[index2];
19775 };
19776 }
19777
19778 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/localize.js
19779 var eraValues = {
19780 narrow: ["B", "A"],
19781 abbreviated: ["BC", "AD"],
19782 wide: ["Before Christ", "Anno Domini"]
19783 };
19784 var quarterValues = {
19785 narrow: ["1", "2", "3", "4"],
19786 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
19787 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
19788 };
19789 var monthValues = {
19790 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
19791 abbreviated: [
19792 "Jan",
19793 "Feb",
19794 "Mar",
19795 "Apr",
19796 "May",
19797 "Jun",
19798 "Jul",
19799 "Aug",
19800 "Sep",
19801 "Oct",
19802 "Nov",
19803 "Dec"
19804 ],
19805 wide: [
19806 "January",
19807 "February",
19808 "March",
19809 "April",
19810 "May",
19811 "June",
19812 "July",
19813 "August",
19814 "September",
19815 "October",
19816 "November",
19817 "December"
19818 ]
19819 };
19820 var dayValues = {
19821 narrow: ["S", "M", "T", "W", "T", "F", "S"],
19822 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
19823 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
19824 wide: [
19825 "Sunday",
19826 "Monday",
19827 "Tuesday",
19828 "Wednesday",
19829 "Thursday",
19830 "Friday",
19831 "Saturday"
19832 ]
19833 };
19834 var dayPeriodValues = {
19835 narrow: {
19836 am: "a",
19837 pm: "p",
19838 midnight: "mi",
19839 noon: "n",
19840 morning: "morning",
19841 afternoon: "afternoon",
19842 evening: "evening",
19843 night: "night"
19844 },
19845 abbreviated: {
19846 am: "AM",
19847 pm: "PM",
19848 midnight: "midnight",
19849 noon: "noon",
19850 morning: "morning",
19851 afternoon: "afternoon",
19852 evening: "evening",
19853 night: "night"
19854 },
19855 wide: {
19856 am: "a.m.",
19857 pm: "p.m.",
19858 midnight: "midnight",
19859 noon: "noon",
19860 morning: "morning",
19861 afternoon: "afternoon",
19862 evening: "evening",
19863 night: "night"
19864 }
19865 };
19866 var formattingDayPeriodValues = {
19867 narrow: {
19868 am: "a",
19869 pm: "p",
19870 midnight: "mi",
19871 noon: "n",
19872 morning: "in the morning",
19873 afternoon: "in the afternoon",
19874 evening: "in the evening",
19875 night: "at night"
19876 },
19877 abbreviated: {
19878 am: "AM",
19879 pm: "PM",
19880 midnight: "midnight",
19881 noon: "noon",
19882 morning: "in the morning",
19883 afternoon: "in the afternoon",
19884 evening: "in the evening",
19885 night: "at night"
19886 },
19887 wide: {
19888 am: "a.m.",
19889 pm: "p.m.",
19890 midnight: "midnight",
19891 noon: "noon",
19892 morning: "in the morning",
19893 afternoon: "in the afternoon",
19894 evening: "in the evening",
19895 night: "at night"
19896 }
19897 };
19898 var ordinalNumber = (dirtyNumber, _options) => {
19899 const number = Number(dirtyNumber);
19900 const rem100 = number % 100;
19901 if (rem100 > 20 || rem100 < 10) {
19902 switch (rem100 % 10) {
19903 case 1:
19904 return number + "st";
19905 case 2:
19906 return number + "nd";
19907 case 3:
19908 return number + "rd";
19909 }
19910 }
19911 return number + "th";
19912 };
19913 var localize = {
19914 ordinalNumber,
19915 era: buildLocalizeFn({
19916 values: eraValues,
19917 defaultWidth: "wide"
19918 }),
19919 quarter: buildLocalizeFn({
19920 values: quarterValues,
19921 defaultWidth: "wide",
19922 argumentCallback: (quarter) => quarter - 1
19923 }),
19924 month: buildLocalizeFn({
19925 values: monthValues,
19926 defaultWidth: "wide"
19927 }),
19928 day: buildLocalizeFn({
19929 values: dayValues,
19930 defaultWidth: "wide"
19931 }),
19932 dayPeriod: buildLocalizeFn({
19933 values: dayPeriodValues,
19934 defaultWidth: "wide",
19935 formattingValues: formattingDayPeriodValues,
19936 defaultFormattingWidth: "wide"
19937 })
19938 };
19939
19940 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchFn.js
19941 function buildMatchFn(args) {
19942 return (string, options = {}) => {
19943 const width = options.width;
19944 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
19945 const matchResult = string.match(matchPattern);
19946 if (!matchResult) {
19947 return null;
19948 }
19949 const matchedString = matchResult[0];
19950 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
19951 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
19952 // [TODO] -- I challenge you to fix the type
19953 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
19954 );
19955 let value;
19956 value = args.valueCallback ? args.valueCallback(key) : key;
19957 value = options.valueCallback ? (
19958 // [TODO] -- I challenge you to fix the type
19959 options.valueCallback(value)
19960 ) : value;
19961 const rest = string.slice(matchedString.length);
19962 return { value, rest };
19963 };
19964 }
19965 function findKey(object, predicate) {
19966 for (const key in object) {
19967 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
19968 return key;
19969 }
19970 }
19971 return void 0;
19972 }
19973 function findIndex(array, predicate) {
19974 for (let key = 0; key < array.length; key++) {
19975 if (predicate(array[key])) {
19976 return key;
19977 }
19978 }
19979 return void 0;
19980 }
19981
19982 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
19983 function buildMatchPatternFn(args) {
19984 return (string, options = {}) => {
19985 const matchResult = string.match(args.matchPattern);
19986 if (!matchResult) return null;
19987 const matchedString = matchResult[0];
19988 const parseResult = string.match(args.parsePattern);
19989 if (!parseResult) return null;
19990 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
19991 value = options.valueCallback ? options.valueCallback(value) : value;
19992 const rest = string.slice(matchedString.length);
19993 return { value, rest };
19994 };
19995 }
19996
19997 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/match.js
19998 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
19999 var parseOrdinalNumberPattern = /\d+/i;
20000 var matchEraPatterns = {
20001 narrow: /^(b|a)/i,
20002 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
20003 wide: /^(before christ|before common era|anno domini|common era)/i
20004 };
20005 var parseEraPatterns = {
20006 any: [/^b/i, /^(a|c)/i]
20007 };
20008 var matchQuarterPatterns = {
20009 narrow: /^[1234]/i,
20010 abbreviated: /^q[1234]/i,
20011 wide: /^[1234](th|st|nd|rd)? quarter/i
20012 };
20013 var parseQuarterPatterns = {
20014 any: [/1/i, /2/i, /3/i, /4/i]
20015 };
20016 var matchMonthPatterns = {
20017 narrow: /^[jfmasond]/i,
20018 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
20019 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
20020 };
20021 var parseMonthPatterns = {
20022 narrow: [
20023 /^j/i,
20024 /^f/i,
20025 /^m/i,
20026 /^a/i,
20027 /^m/i,
20028 /^j/i,
20029 /^j/i,
20030 /^a/i,
20031 /^s/i,
20032 /^o/i,
20033 /^n/i,
20034 /^d/i
20035 ],
20036 any: [
20037 /^ja/i,
20038 /^f/i,
20039 /^mar/i,
20040 /^ap/i,
20041 /^may/i,
20042 /^jun/i,
20043 /^jul/i,
20044 /^au/i,
20045 /^s/i,
20046 /^o/i,
20047 /^n/i,
20048 /^d/i
20049 ]
20050 };
20051 var matchDayPatterns = {
20052 narrow: /^[smtwf]/i,
20053 short: /^(su|mo|tu|we|th|fr|sa)/i,
20054 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
20055 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
20056 };
20057 var parseDayPatterns = {
20058 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
20059 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
20060 };
20061 var matchDayPeriodPatterns = {
20062 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
20063 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
20064 };
20065 var parseDayPeriodPatterns = {
20066 any: {
20067 am: /^a/i,
20068 pm: /^p/i,
20069 midnight: /^mi/i,
20070 noon: /^no/i,
20071 morning: /morning/i,
20072 afternoon: /afternoon/i,
20073 evening: /evening/i,
20074 night: /night/i
20075 }
20076 };
20077 var match = {
20078 ordinalNumber: buildMatchPatternFn({
20079 matchPattern: matchOrdinalNumberPattern,
20080 parsePattern: parseOrdinalNumberPattern,
20081 valueCallback: (value) => parseInt(value, 10)
20082 }),
20083 era: buildMatchFn({
20084 matchPatterns: matchEraPatterns,
20085 defaultMatchWidth: "wide",
20086 parsePatterns: parseEraPatterns,
20087 defaultParseWidth: "any"
20088 }),
20089 quarter: buildMatchFn({
20090 matchPatterns: matchQuarterPatterns,
20091 defaultMatchWidth: "wide",
20092 parsePatterns: parseQuarterPatterns,
20093 defaultParseWidth: "any",
20094 valueCallback: (index2) => index2 + 1
20095 }),
20096 month: buildMatchFn({
20097 matchPatterns: matchMonthPatterns,
20098 defaultMatchWidth: "wide",
20099 parsePatterns: parseMonthPatterns,
20100 defaultParseWidth: "any"
20101 }),
20102 day: buildMatchFn({
20103 matchPatterns: matchDayPatterns,
20104 defaultMatchWidth: "wide",
20105 parsePatterns: parseDayPatterns,
20106 defaultParseWidth: "any"
20107 }),
20108 dayPeriod: buildMatchFn({
20109 matchPatterns: matchDayPeriodPatterns,
20110 defaultMatchWidth: "any",
20111 parsePatterns: parseDayPeriodPatterns,
20112 defaultParseWidth: "any"
20113 })
20114 };
20115
20116 // packages/dataviews/node_modules/date-fns/locale/en-US.js
20117 var enUS = {
20118 code: "en-US",
20119 formatDistance,
20120 formatLong,
20121 formatRelative,
20122 localize,
20123 match,
20124 options: {
20125 weekStartsOn: 0,
20126 firstWeekContainsDate: 1
20127 }
20128 };
20129
20130 // packages/dataviews/node_modules/date-fns/getDayOfYear.js
20131 function getDayOfYear(date, options) {
20132 const _date = toDate(date, options?.in);
20133 const diff = differenceInCalendarDays(_date, startOfYear(_date));
20134 const dayOfYear = diff + 1;
20135 return dayOfYear;
20136 }
20137
20138 // packages/dataviews/node_modules/date-fns/getISOWeek.js
20139 function getISOWeek(date, options) {
20140 const _date = toDate(date, options?.in);
20141 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
20142 return Math.round(diff / millisecondsInWeek) + 1;
20143 }
20144
20145 // packages/dataviews/node_modules/date-fns/getWeekYear.js
20146 function getWeekYear(date, options) {
20147 const _date = toDate(date, options?.in);
20148 const year = _date.getFullYear();
20149 const defaultOptions2 = getDefaultOptions();
20150 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20151 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
20152 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
20153 firstWeekOfNextYear.setHours(0, 0, 0, 0);
20154 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
20155 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
20156 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
20157 firstWeekOfThisYear.setHours(0, 0, 0, 0);
20158 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
20159 if (+_date >= +startOfNextYear) {
20160 return year + 1;
20161 } else if (+_date >= +startOfThisYear) {
20162 return year;
20163 } else {
20164 return year - 1;
20165 }
20166 }
20167
20168 // packages/dataviews/node_modules/date-fns/startOfWeekYear.js
20169 function startOfWeekYear(date, options) {
20170 const defaultOptions2 = getDefaultOptions();
20171 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20172 const year = getWeekYear(date, options);
20173 const firstWeek = constructFrom(options?.in || date, 0);
20174 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
20175 firstWeek.setHours(0, 0, 0, 0);
20176 const _date = startOfWeek(firstWeek, options);
20177 return _date;
20178 }
20179
20180 // packages/dataviews/node_modules/date-fns/getWeek.js
20181 function getWeek(date, options) {
20182 const _date = toDate(date, options?.in);
20183 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
20184 return Math.round(diff / millisecondsInWeek) + 1;
20185 }
20186
20187 // packages/dataviews/node_modules/date-fns/_lib/addLeadingZeros.js
20188 function addLeadingZeros(number, targetLength) {
20189 const sign = number < 0 ? "-" : "";
20190 const output = Math.abs(number).toString().padStart(targetLength, "0");
20191 return sign + output;
20192 }
20193
20194 // packages/dataviews/node_modules/date-fns/_lib/format/lightFormatters.js
20195 var lightFormatters = {
20196 // Year
20197 y(date, token) {
20198 const signedYear = date.getFullYear();
20199 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20200 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
20201 },
20202 // Month
20203 M(date, token) {
20204 const month = date.getMonth();
20205 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
20206 },
20207 // Day of the month
20208 d(date, token) {
20209 return addLeadingZeros(date.getDate(), token.length);
20210 },
20211 // AM or PM
20212 a(date, token) {
20213 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
20214 switch (token) {
20215 case "a":
20216 case "aa":
20217 return dayPeriodEnumValue.toUpperCase();
20218 case "aaa":
20219 return dayPeriodEnumValue;
20220 case "aaaaa":
20221 return dayPeriodEnumValue[0];
20222 case "aaaa":
20223 default:
20224 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
20225 }
20226 },
20227 // Hour [1-12]
20228 h(date, token) {
20229 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
20230 },
20231 // Hour [0-23]
20232 H(date, token) {
20233 return addLeadingZeros(date.getHours(), token.length);
20234 },
20235 // Minute
20236 m(date, token) {
20237 return addLeadingZeros(date.getMinutes(), token.length);
20238 },
20239 // Second
20240 s(date, token) {
20241 return addLeadingZeros(date.getSeconds(), token.length);
20242 },
20243 // Fraction of second
20244 S(date, token) {
20245 const numberOfDigits = token.length;
20246 const milliseconds = date.getMilliseconds();
20247 const fractionalSeconds = Math.trunc(
20248 milliseconds * Math.pow(10, numberOfDigits - 3)
20249 );
20250 return addLeadingZeros(fractionalSeconds, token.length);
20251 }
20252 };
20253
20254 // packages/dataviews/node_modules/date-fns/_lib/format/formatters.js
20255 var dayPeriodEnum = {
20256 am: "am",
20257 pm: "pm",
20258 midnight: "midnight",
20259 noon: "noon",
20260 morning: "morning",
20261 afternoon: "afternoon",
20262 evening: "evening",
20263 night: "night"
20264 };
20265 var formatters = {
20266 // Era
20267 G: function(date, token, localize2) {
20268 const era = date.getFullYear() > 0 ? 1 : 0;
20269 switch (token) {
20270 // AD, BC
20271 case "G":
20272 case "GG":
20273 case "GGG":
20274 return localize2.era(era, { width: "abbreviated" });
20275 // A, B
20276 case "GGGGG":
20277 return localize2.era(era, { width: "narrow" });
20278 // Anno Domini, Before Christ
20279 case "GGGG":
20280 default:
20281 return localize2.era(era, { width: "wide" });
20282 }
20283 },
20284 // Year
20285 y: function(date, token, localize2) {
20286 if (token === "yo") {
20287 const signedYear = date.getFullYear();
20288 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20289 return localize2.ordinalNumber(year, { unit: "year" });
20290 }
20291 return lightFormatters.y(date, token);
20292 },
20293 // Local week-numbering year
20294 Y: function(date, token, localize2, options) {
20295 const signedWeekYear = getWeekYear(date, options);
20296 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
20297 if (token === "YY") {
20298 const twoDigitYear = weekYear % 100;
20299 return addLeadingZeros(twoDigitYear, 2);
20300 }
20301 if (token === "Yo") {
20302 return localize2.ordinalNumber(weekYear, { unit: "year" });
20303 }
20304 return addLeadingZeros(weekYear, token.length);
20305 },
20306 // ISO week-numbering year
20307 R: function(date, token) {
20308 const isoWeekYear = getISOWeekYear(date);
20309 return addLeadingZeros(isoWeekYear, token.length);
20310 },
20311 // Extended year. This is a single number designating the year of this calendar system.
20312 // The main difference between `y` and `u` localizers are B.C. years:
20313 // | Year | `y` | `u` |
20314 // |------|-----|-----|
20315 // | AC 1 | 1 | 1 |
20316 // | BC 1 | 1 | 0 |
20317 // | BC 2 | 2 | -1 |
20318 // Also `yy` always returns the last two digits of a year,
20319 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
20320 u: function(date, token) {
20321 const year = date.getFullYear();
20322 return addLeadingZeros(year, token.length);
20323 },
20324 // Quarter
20325 Q: function(date, token, localize2) {
20326 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20327 switch (token) {
20328 // 1, 2, 3, 4
20329 case "Q":
20330 return String(quarter);
20331 // 01, 02, 03, 04
20332 case "QQ":
20333 return addLeadingZeros(quarter, 2);
20334 // 1st, 2nd, 3rd, 4th
20335 case "Qo":
20336 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20337 // Q1, Q2, Q3, Q4
20338 case "QQQ":
20339 return localize2.quarter(quarter, {
20340 width: "abbreviated",
20341 context: "formatting"
20342 });
20343 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20344 case "QQQQQ":
20345 return localize2.quarter(quarter, {
20346 width: "narrow",
20347 context: "formatting"
20348 });
20349 // 1st quarter, 2nd quarter, ...
20350 case "QQQQ":
20351 default:
20352 return localize2.quarter(quarter, {
20353 width: "wide",
20354 context: "formatting"
20355 });
20356 }
20357 },
20358 // Stand-alone quarter
20359 q: function(date, token, localize2) {
20360 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20361 switch (token) {
20362 // 1, 2, 3, 4
20363 case "q":
20364 return String(quarter);
20365 // 01, 02, 03, 04
20366 case "qq":
20367 return addLeadingZeros(quarter, 2);
20368 // 1st, 2nd, 3rd, 4th
20369 case "qo":
20370 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20371 // Q1, Q2, Q3, Q4
20372 case "qqq":
20373 return localize2.quarter(quarter, {
20374 width: "abbreviated",
20375 context: "standalone"
20376 });
20377 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20378 case "qqqqq":
20379 return localize2.quarter(quarter, {
20380 width: "narrow",
20381 context: "standalone"
20382 });
20383 // 1st quarter, 2nd quarter, ...
20384 case "qqqq":
20385 default:
20386 return localize2.quarter(quarter, {
20387 width: "wide",
20388 context: "standalone"
20389 });
20390 }
20391 },
20392 // Month
20393 M: function(date, token, localize2) {
20394 const month = date.getMonth();
20395 switch (token) {
20396 case "M":
20397 case "MM":
20398 return lightFormatters.M(date, token);
20399 // 1st, 2nd, ..., 12th
20400 case "Mo":
20401 return localize2.ordinalNumber(month + 1, { unit: "month" });
20402 // Jan, Feb, ..., Dec
20403 case "MMM":
20404 return localize2.month(month, {
20405 width: "abbreviated",
20406 context: "formatting"
20407 });
20408 // J, F, ..., D
20409 case "MMMMM":
20410 return localize2.month(month, {
20411 width: "narrow",
20412 context: "formatting"
20413 });
20414 // January, February, ..., December
20415 case "MMMM":
20416 default:
20417 return localize2.month(month, { width: "wide", context: "formatting" });
20418 }
20419 },
20420 // Stand-alone month
20421 L: function(date, token, localize2) {
20422 const month = date.getMonth();
20423 switch (token) {
20424 // 1, 2, ..., 12
20425 case "L":
20426 return String(month + 1);
20427 // 01, 02, ..., 12
20428 case "LL":
20429 return addLeadingZeros(month + 1, 2);
20430 // 1st, 2nd, ..., 12th
20431 case "Lo":
20432 return localize2.ordinalNumber(month + 1, { unit: "month" });
20433 // Jan, Feb, ..., Dec
20434 case "LLL":
20435 return localize2.month(month, {
20436 width: "abbreviated",
20437 context: "standalone"
20438 });
20439 // J, F, ..., D
20440 case "LLLLL":
20441 return localize2.month(month, {
20442 width: "narrow",
20443 context: "standalone"
20444 });
20445 // January, February, ..., December
20446 case "LLLL":
20447 default:
20448 return localize2.month(month, { width: "wide", context: "standalone" });
20449 }
20450 },
20451 // Local week of year
20452 w: function(date, token, localize2, options) {
20453 const week = getWeek(date, options);
20454 if (token === "wo") {
20455 return localize2.ordinalNumber(week, { unit: "week" });
20456 }
20457 return addLeadingZeros(week, token.length);
20458 },
20459 // ISO week of year
20460 I: function(date, token, localize2) {
20461 const isoWeek = getISOWeek(date);
20462 if (token === "Io") {
20463 return localize2.ordinalNumber(isoWeek, { unit: "week" });
20464 }
20465 return addLeadingZeros(isoWeek, token.length);
20466 },
20467 // Day of the month
20468 d: function(date, token, localize2) {
20469 if (token === "do") {
20470 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
20471 }
20472 return lightFormatters.d(date, token);
20473 },
20474 // Day of year
20475 D: function(date, token, localize2) {
20476 const dayOfYear = getDayOfYear(date);
20477 if (token === "Do") {
20478 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
20479 }
20480 return addLeadingZeros(dayOfYear, token.length);
20481 },
20482 // Day of week
20483 E: function(date, token, localize2) {
20484 const dayOfWeek = date.getDay();
20485 switch (token) {
20486 // Tue
20487 case "E":
20488 case "EE":
20489 case "EEE":
20490 return localize2.day(dayOfWeek, {
20491 width: "abbreviated",
20492 context: "formatting"
20493 });
20494 // T
20495 case "EEEEE":
20496 return localize2.day(dayOfWeek, {
20497 width: "narrow",
20498 context: "formatting"
20499 });
20500 // Tu
20501 case "EEEEEE":
20502 return localize2.day(dayOfWeek, {
20503 width: "short",
20504 context: "formatting"
20505 });
20506 // Tuesday
20507 case "EEEE":
20508 default:
20509 return localize2.day(dayOfWeek, {
20510 width: "wide",
20511 context: "formatting"
20512 });
20513 }
20514 },
20515 // Local day of week
20516 e: function(date, token, localize2, options) {
20517 const dayOfWeek = date.getDay();
20518 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20519 switch (token) {
20520 // Numerical value (Nth day of week with current locale or weekStartsOn)
20521 case "e":
20522 return String(localDayOfWeek);
20523 // Padded numerical value
20524 case "ee":
20525 return addLeadingZeros(localDayOfWeek, 2);
20526 // 1st, 2nd, ..., 7th
20527 case "eo":
20528 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20529 case "eee":
20530 return localize2.day(dayOfWeek, {
20531 width: "abbreviated",
20532 context: "formatting"
20533 });
20534 // T
20535 case "eeeee":
20536 return localize2.day(dayOfWeek, {
20537 width: "narrow",
20538 context: "formatting"
20539 });
20540 // Tu
20541 case "eeeeee":
20542 return localize2.day(dayOfWeek, {
20543 width: "short",
20544 context: "formatting"
20545 });
20546 // Tuesday
20547 case "eeee":
20548 default:
20549 return localize2.day(dayOfWeek, {
20550 width: "wide",
20551 context: "formatting"
20552 });
20553 }
20554 },
20555 // Stand-alone local day of week
20556 c: function(date, token, localize2, options) {
20557 const dayOfWeek = date.getDay();
20558 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20559 switch (token) {
20560 // Numerical value (same as in `e`)
20561 case "c":
20562 return String(localDayOfWeek);
20563 // Padded numerical value
20564 case "cc":
20565 return addLeadingZeros(localDayOfWeek, token.length);
20566 // 1st, 2nd, ..., 7th
20567 case "co":
20568 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20569 case "ccc":
20570 return localize2.day(dayOfWeek, {
20571 width: "abbreviated",
20572 context: "standalone"
20573 });
20574 // T
20575 case "ccccc":
20576 return localize2.day(dayOfWeek, {
20577 width: "narrow",
20578 context: "standalone"
20579 });
20580 // Tu
20581 case "cccccc":
20582 return localize2.day(dayOfWeek, {
20583 width: "short",
20584 context: "standalone"
20585 });
20586 // Tuesday
20587 case "cccc":
20588 default:
20589 return localize2.day(dayOfWeek, {
20590 width: "wide",
20591 context: "standalone"
20592 });
20593 }
20594 },
20595 // ISO day of week
20596 i: function(date, token, localize2) {
20597 const dayOfWeek = date.getDay();
20598 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
20599 switch (token) {
20600 // 2
20601 case "i":
20602 return String(isoDayOfWeek);
20603 // 02
20604 case "ii":
20605 return addLeadingZeros(isoDayOfWeek, token.length);
20606 // 2nd
20607 case "io":
20608 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
20609 // Tue
20610 case "iii":
20611 return localize2.day(dayOfWeek, {
20612 width: "abbreviated",
20613 context: "formatting"
20614 });
20615 // T
20616 case "iiiii":
20617 return localize2.day(dayOfWeek, {
20618 width: "narrow",
20619 context: "formatting"
20620 });
20621 // Tu
20622 case "iiiiii":
20623 return localize2.day(dayOfWeek, {
20624 width: "short",
20625 context: "formatting"
20626 });
20627 // Tuesday
20628 case "iiii":
20629 default:
20630 return localize2.day(dayOfWeek, {
20631 width: "wide",
20632 context: "formatting"
20633 });
20634 }
20635 },
20636 // AM or PM
20637 a: function(date, token, localize2) {
20638 const hours = date.getHours();
20639 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20640 switch (token) {
20641 case "a":
20642 case "aa":
20643 return localize2.dayPeriod(dayPeriodEnumValue, {
20644 width: "abbreviated",
20645 context: "formatting"
20646 });
20647 case "aaa":
20648 return localize2.dayPeriod(dayPeriodEnumValue, {
20649 width: "abbreviated",
20650 context: "formatting"
20651 }).toLowerCase();
20652 case "aaaaa":
20653 return localize2.dayPeriod(dayPeriodEnumValue, {
20654 width: "narrow",
20655 context: "formatting"
20656 });
20657 case "aaaa":
20658 default:
20659 return localize2.dayPeriod(dayPeriodEnumValue, {
20660 width: "wide",
20661 context: "formatting"
20662 });
20663 }
20664 },
20665 // AM, PM, midnight, noon
20666 b: function(date, token, localize2) {
20667 const hours = date.getHours();
20668 let dayPeriodEnumValue;
20669 if (hours === 12) {
20670 dayPeriodEnumValue = dayPeriodEnum.noon;
20671 } else if (hours === 0) {
20672 dayPeriodEnumValue = dayPeriodEnum.midnight;
20673 } else {
20674 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20675 }
20676 switch (token) {
20677 case "b":
20678 case "bb":
20679 return localize2.dayPeriod(dayPeriodEnumValue, {
20680 width: "abbreviated",
20681 context: "formatting"
20682 });
20683 case "bbb":
20684 return localize2.dayPeriod(dayPeriodEnumValue, {
20685 width: "abbreviated",
20686 context: "formatting"
20687 }).toLowerCase();
20688 case "bbbbb":
20689 return localize2.dayPeriod(dayPeriodEnumValue, {
20690 width: "narrow",
20691 context: "formatting"
20692 });
20693 case "bbbb":
20694 default:
20695 return localize2.dayPeriod(dayPeriodEnumValue, {
20696 width: "wide",
20697 context: "formatting"
20698 });
20699 }
20700 },
20701 // in the morning, in the afternoon, in the evening, at night
20702 B: function(date, token, localize2) {
20703 const hours = date.getHours();
20704 let dayPeriodEnumValue;
20705 if (hours >= 17) {
20706 dayPeriodEnumValue = dayPeriodEnum.evening;
20707 } else if (hours >= 12) {
20708 dayPeriodEnumValue = dayPeriodEnum.afternoon;
20709 } else if (hours >= 4) {
20710 dayPeriodEnumValue = dayPeriodEnum.morning;
20711 } else {
20712 dayPeriodEnumValue = dayPeriodEnum.night;
20713 }
20714 switch (token) {
20715 case "B":
20716 case "BB":
20717 case "BBB":
20718 return localize2.dayPeriod(dayPeriodEnumValue, {
20719 width: "abbreviated",
20720 context: "formatting"
20721 });
20722 case "BBBBB":
20723 return localize2.dayPeriod(dayPeriodEnumValue, {
20724 width: "narrow",
20725 context: "formatting"
20726 });
20727 case "BBBB":
20728 default:
20729 return localize2.dayPeriod(dayPeriodEnumValue, {
20730 width: "wide",
20731 context: "formatting"
20732 });
20733 }
20734 },
20735 // Hour [1-12]
20736 h: function(date, token, localize2) {
20737 if (token === "ho") {
20738 let hours = date.getHours() % 12;
20739 if (hours === 0) hours = 12;
20740 return localize2.ordinalNumber(hours, { unit: "hour" });
20741 }
20742 return lightFormatters.h(date, token);
20743 },
20744 // Hour [0-23]
20745 H: function(date, token, localize2) {
20746 if (token === "Ho") {
20747 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
20748 }
20749 return lightFormatters.H(date, token);
20750 },
20751 // Hour [0-11]
20752 K: function(date, token, localize2) {
20753 const hours = date.getHours() % 12;
20754 if (token === "Ko") {
20755 return localize2.ordinalNumber(hours, { unit: "hour" });
20756 }
20757 return addLeadingZeros(hours, token.length);
20758 },
20759 // Hour [1-24]
20760 k: function(date, token, localize2) {
20761 let hours = date.getHours();
20762 if (hours === 0) hours = 24;
20763 if (token === "ko") {
20764 return localize2.ordinalNumber(hours, { unit: "hour" });
20765 }
20766 return addLeadingZeros(hours, token.length);
20767 },
20768 // Minute
20769 m: function(date, token, localize2) {
20770 if (token === "mo") {
20771 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
20772 }
20773 return lightFormatters.m(date, token);
20774 },
20775 // Second
20776 s: function(date, token, localize2) {
20777 if (token === "so") {
20778 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
20779 }
20780 return lightFormatters.s(date, token);
20781 },
20782 // Fraction of second
20783 S: function(date, token) {
20784 return lightFormatters.S(date, token);
20785 },
20786 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
20787 X: function(date, token, _localize) {
20788 const timezoneOffset = date.getTimezoneOffset();
20789 if (timezoneOffset === 0) {
20790 return "Z";
20791 }
20792 switch (token) {
20793 // Hours and optional minutes
20794 case "X":
20795 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20796 // Hours, minutes and optional seconds without `:` delimiter
20797 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20798 // so this token always has the same output as `XX`
20799 case "XXXX":
20800 case "XX":
20801 return formatTimezone(timezoneOffset);
20802 // Hours, minutes and optional seconds with `:` delimiter
20803 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20804 // so this token always has the same output as `XXX`
20805 case "XXXXX":
20806 case "XXX":
20807 // Hours and minutes with `:` delimiter
20808 default:
20809 return formatTimezone(timezoneOffset, ":");
20810 }
20811 },
20812 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
20813 x: function(date, token, _localize) {
20814 const timezoneOffset = date.getTimezoneOffset();
20815 switch (token) {
20816 // Hours and optional minutes
20817 case "x":
20818 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20819 // Hours, minutes and optional seconds without `:` delimiter
20820 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20821 // so this token always has the same output as `xx`
20822 case "xxxx":
20823 case "xx":
20824 return formatTimezone(timezoneOffset);
20825 // Hours, minutes and optional seconds with `:` delimiter
20826 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20827 // so this token always has the same output as `xxx`
20828 case "xxxxx":
20829 case "xxx":
20830 // Hours and minutes with `:` delimiter
20831 default:
20832 return formatTimezone(timezoneOffset, ":");
20833 }
20834 },
20835 // Timezone (GMT)
20836 O: function(date, token, _localize) {
20837 const timezoneOffset = date.getTimezoneOffset();
20838 switch (token) {
20839 // Short
20840 case "O":
20841 case "OO":
20842 case "OOO":
20843 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20844 // Long
20845 case "OOOO":
20846 default:
20847 return "GMT" + formatTimezone(timezoneOffset, ":");
20848 }
20849 },
20850 // Timezone (specific non-location)
20851 z: function(date, token, _localize) {
20852 const timezoneOffset = date.getTimezoneOffset();
20853 switch (token) {
20854 // Short
20855 case "z":
20856 case "zz":
20857 case "zzz":
20858 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20859 // Long
20860 case "zzzz":
20861 default:
20862 return "GMT" + formatTimezone(timezoneOffset, ":");
20863 }
20864 },
20865 // Seconds timestamp
20866 t: function(date, token, _localize) {
20867 const timestamp = Math.trunc(+date / 1e3);
20868 return addLeadingZeros(timestamp, token.length);
20869 },
20870 // Milliseconds timestamp
20871 T: function(date, token, _localize) {
20872 return addLeadingZeros(+date, token.length);
20873 }
20874 };
20875 function formatTimezoneShort(offset4, delimiter = "") {
20876 const sign = offset4 > 0 ? "-" : "+";
20877 const absOffset = Math.abs(offset4);
20878 const hours = Math.trunc(absOffset / 60);
20879 const minutes = absOffset % 60;
20880 if (minutes === 0) {
20881 return sign + String(hours);
20882 }
20883 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
20884 }
20885 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
20886 if (offset4 % 60 === 0) {
20887 const sign = offset4 > 0 ? "-" : "+";
20888 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
20889 }
20890 return formatTimezone(offset4, delimiter);
20891 }
20892 function formatTimezone(offset4, delimiter = "") {
20893 const sign = offset4 > 0 ? "-" : "+";
20894 const absOffset = Math.abs(offset4);
20895 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
20896 const minutes = addLeadingZeros(absOffset % 60, 2);
20897 return sign + hours + delimiter + minutes;
20898 }
20899
20900 // packages/dataviews/node_modules/date-fns/_lib/format/longFormatters.js
20901 var dateLongFormatter = (pattern, formatLong2) => {
20902 switch (pattern) {
20903 case "P":
20904 return formatLong2.date({ width: "short" });
20905 case "PP":
20906 return formatLong2.date({ width: "medium" });
20907 case "PPP":
20908 return formatLong2.date({ width: "long" });
20909 case "PPPP":
20910 default:
20911 return formatLong2.date({ width: "full" });
20912 }
20913 };
20914 var timeLongFormatter = (pattern, formatLong2) => {
20915 switch (pattern) {
20916 case "p":
20917 return formatLong2.time({ width: "short" });
20918 case "pp":
20919 return formatLong2.time({ width: "medium" });
20920 case "ppp":
20921 return formatLong2.time({ width: "long" });
20922 case "pppp":
20923 default:
20924 return formatLong2.time({ width: "full" });
20925 }
20926 };
20927 var dateTimeLongFormatter = (pattern, formatLong2) => {
20928 const matchResult = pattern.match(/(P+)(p+)?/) || [];
20929 const datePattern = matchResult[1];
20930 const timePattern = matchResult[2];
20931 if (!timePattern) {
20932 return dateLongFormatter(pattern, formatLong2);
20933 }
20934 let dateTimeFormat;
20935 switch (datePattern) {
20936 case "P":
20937 dateTimeFormat = formatLong2.dateTime({ width: "short" });
20938 break;
20939 case "PP":
20940 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
20941 break;
20942 case "PPP":
20943 dateTimeFormat = formatLong2.dateTime({ width: "long" });
20944 break;
20945 case "PPPP":
20946 default:
20947 dateTimeFormat = formatLong2.dateTime({ width: "full" });
20948 break;
20949 }
20950 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
20951 };
20952 var longFormatters = {
20953 p: timeLongFormatter,
20954 P: dateTimeLongFormatter
20955 };
20956
20957 // packages/dataviews/node_modules/date-fns/_lib/protectedTokens.js
20958 var dayOfYearTokenRE = /^D+$/;
20959 var weekYearTokenRE = /^Y+$/;
20960 var throwTokens = ["D", "DD", "YY", "YYYY"];
20961 function isProtectedDayOfYearToken(token) {
20962 return dayOfYearTokenRE.test(token);
20963 }
20964 function isProtectedWeekYearToken(token) {
20965 return weekYearTokenRE.test(token);
20966 }
20967 function warnOrThrowProtectedError(token, format6, input) {
20968 const _message = message(token, format6, input);
20969 console.warn(_message);
20970 if (throwTokens.includes(token)) throw new RangeError(_message);
20971 }
20972 function message(token, format6, input) {
20973 const subject = token[0] === "Y" ? "years" : "days of the month";
20974 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`;
20975 }
20976
20977 // packages/dataviews/node_modules/date-fns/format.js
20978 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
20979 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
20980 var escapedStringRegExp = /^'([^]*?)'?$/;
20981 var doubleQuoteRegExp = /''/g;
20982 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
20983 function format(date, formatStr, options) {
20984 const defaultOptions2 = getDefaultOptions();
20985 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
20986 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20987 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
20988 const originalDate = toDate(date, options?.in);
20989 if (!isValid(originalDate)) {
20990 throw new RangeError("Invalid time value");
20991 }
20992 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
20993 const firstCharacter = substring[0];
20994 if (firstCharacter === "p" || firstCharacter === "P") {
20995 const longFormatter = longFormatters[firstCharacter];
20996 return longFormatter(substring, locale.formatLong);
20997 }
20998 return substring;
20999 }).join("").match(formattingTokensRegExp).map((substring) => {
21000 if (substring === "''") {
21001 return { isToken: false, value: "'" };
21002 }
21003 const firstCharacter = substring[0];
21004 if (firstCharacter === "'") {
21005 return { isToken: false, value: cleanEscapedString(substring) };
21006 }
21007 if (formatters[firstCharacter]) {
21008 return { isToken: true, value: substring };
21009 }
21010 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
21011 throw new RangeError(
21012 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
21013 );
21014 }
21015 return { isToken: false, value: substring };
21016 });
21017 if (locale.localize.preprocessor) {
21018 parts = locale.localize.preprocessor(originalDate, parts);
21019 }
21020 const formatterOptions = {
21021 firstWeekContainsDate,
21022 weekStartsOn,
21023 locale
21024 };
21025 return parts.map((part) => {
21026 if (!part.isToken) return part.value;
21027 const token = part.value;
21028 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
21029 warnOrThrowProtectedError(token, formatStr, String(date));
21030 }
21031 const formatter = formatters[token[0]];
21032 return formatter(originalDate, token, locale.localize, formatterOptions);
21033 }).join("");
21034 }
21035 function cleanEscapedString(input) {
21036 const matched = input.match(escapedStringRegExp);
21037 if (!matched) {
21038 return input;
21039 }
21040 return matched[1].replace(doubleQuoteRegExp, "'");
21041 }
21042
21043 // packages/dataviews/node_modules/date-fns/subDays.js
21044 function subDays(date, amount, options) {
21045 return addDays(date, -amount, options);
21046 }
21047
21048 // packages/dataviews/node_modules/date-fns/subMonths.js
21049 function subMonths(date, amount, options) {
21050 return addMonths(date, -amount, options);
21051 }
21052
21053 // packages/dataviews/node_modules/date-fns/subWeeks.js
21054 function subWeeks(date, amount, options) {
21055 return addWeeks(date, -amount, options);
21056 }
21057
21058 // packages/dataviews/node_modules/date-fns/subYears.js
21059 function subYears(date, amount, options) {
21060 return addYears(date, -amount, options);
21061 }
21062
21063 // packages/dataviews/build-module/utils/operators.mjs
21064 var import_i18n24 = __toESM(require_i18n(), 1);
21065 var import_element46 = __toESM(require_element(), 1);
21066 var import_date = __toESM(require_date(), 1);
21067 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
21068 var filterTextWrappers = {
21069 Name: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
21070 Value: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
21071 };
21072 function getRelativeDate(value, unit) {
21073 switch (unit) {
21074 case "days":
21075 return subDays(/* @__PURE__ */ new Date(), value);
21076 case "weeks":
21077 return subWeeks(/* @__PURE__ */ new Date(), value);
21078 case "months":
21079 return subMonths(/* @__PURE__ */ new Date(), value);
21080 case "years":
21081 return subYears(/* @__PURE__ */ new Date(), value);
21082 default:
21083 return /* @__PURE__ */ new Date();
21084 }
21085 }
21086 var isNoneOperatorDefinition = {
21087 /* translators: DataViews operator name */
21088 label: (0, import_i18n24.__)("Is none of"),
21089 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21090 (0, import_i18n24.sprintf)(
21091 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
21092 (0, import_i18n24.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
21093 filter.name,
21094 activeElements.map((element) => element.label).join(", ")
21095 ),
21096 filterTextWrappers
21097 ),
21098 filter: ((item, field, filterValue) => {
21099 if (!filterValue?.length) {
21100 return true;
21101 }
21102 const fieldValue = field.getValue({ item });
21103 if (Array.isArray(fieldValue)) {
21104 return !filterValue.some(
21105 (fv) => fieldValue.includes(fv)
21106 );
21107 } else if (typeof fieldValue === "string") {
21108 return !filterValue.includes(fieldValue);
21109 }
21110 return false;
21111 }),
21112 selection: "multi"
21113 };
21114 var OPERATORS = [
21115 {
21116 name: OPERATOR_IS_ANY,
21117 /* translators: DataViews operator name */
21118 label: (0, import_i18n24.__)("Includes"),
21119 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21120 (0, import_i18n24.sprintf)(
21121 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
21122 (0, import_i18n24.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
21123 filter.name,
21124 activeElements.map((element) => element.label).join(", ")
21125 ),
21126 filterTextWrappers
21127 ),
21128 filter(item, field, filterValue) {
21129 if (!filterValue?.length) {
21130 return true;
21131 }
21132 const fieldValue = field.getValue({ item });
21133 if (Array.isArray(fieldValue)) {
21134 return filterValue.some(
21135 (fv) => fieldValue.includes(fv)
21136 );
21137 } else if (typeof fieldValue === "string") {
21138 return filterValue.includes(fieldValue);
21139 }
21140 return false;
21141 },
21142 selection: "multi"
21143 },
21144 {
21145 name: OPERATOR_IS_NONE,
21146 ...isNoneOperatorDefinition
21147 },
21148 {
21149 name: OPERATOR_IS_ALL,
21150 /* translators: DataViews operator name */
21151 label: (0, import_i18n24.__)("Includes all"),
21152 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21153 (0, import_i18n24.sprintf)(
21154 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
21155 (0, import_i18n24.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
21156 filter.name,
21157 activeElements.map((element) => element.label).join(", ")
21158 ),
21159 filterTextWrappers
21160 ),
21161 filter(item, field, filterValue) {
21162 if (!filterValue?.length) {
21163 return true;
21164 }
21165 return filterValue.every((value) => {
21166 return field.getValue({ item })?.includes(value);
21167 });
21168 },
21169 selection: "multi"
21170 },
21171 {
21172 name: OPERATOR_IS_NOT_ALL,
21173 ...isNoneOperatorDefinition
21174 },
21175 {
21176 name: OPERATOR_BETWEEN,
21177 /* translators: DataViews operator name */
21178 label: (0, import_i18n24.__)("Between (inc)"),
21179 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21180 (0, import_i18n24.sprintf)(
21181 /* 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". */
21182 (0, import_i18n24.__)(
21183 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
21184 ),
21185 filter.name,
21186 activeElements[0].label[0],
21187 activeElements[0].label[1]
21188 ),
21189 filterTextWrappers
21190 ),
21191 filter(item, field, filterValue) {
21192 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
21193 return true;
21194 }
21195 const fieldValue = field.getValue({ item });
21196 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
21197 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
21198 }
21199 return false;
21200 },
21201 selection: "custom"
21202 },
21203 {
21204 name: OPERATOR_IN_THE_PAST,
21205 /* translators: DataViews operator name */
21206 label: (0, import_i18n24.__)("In the past"),
21207 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21208 (0, import_i18n24.sprintf)(
21209 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
21210 (0, import_i18n24.__)(
21211 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
21212 ),
21213 filter.name,
21214 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21215 ),
21216 filterTextWrappers
21217 ),
21218 filter(item, field, filterValue) {
21219 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21220 return true;
21221 }
21222 const targetDate = getRelativeDate(
21223 filterValue.value,
21224 filterValue.unit
21225 );
21226 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21227 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
21228 },
21229 selection: "custom"
21230 },
21231 {
21232 name: OPERATOR_OVER,
21233 /* translators: DataViews operator name */
21234 label: (0, import_i18n24.__)("Over"),
21235 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21236 (0, import_i18n24.sprintf)(
21237 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
21238 (0, import_i18n24.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
21239 filter.name,
21240 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21241 ),
21242 filterTextWrappers
21243 ),
21244 filter(item, field, filterValue) {
21245 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21246 return true;
21247 }
21248 const targetDate = getRelativeDate(
21249 filterValue.value,
21250 filterValue.unit
21251 );
21252 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21253 return fieldValue < targetDate;
21254 },
21255 selection: "custom"
21256 },
21257 {
21258 name: OPERATOR_IS,
21259 /* translators: DataViews operator name */
21260 label: (0, import_i18n24.__)("Is"),
21261 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21262 (0, import_i18n24.sprintf)(
21263 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
21264 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21265 filter.name,
21266 activeElements[0].label
21267 ),
21268 filterTextWrappers
21269 ),
21270 filter(item, field, filterValue) {
21271 return filterValue === field.getValue({ item }) || filterValue === void 0;
21272 },
21273 selection: "single"
21274 },
21275 {
21276 name: OPERATOR_IS_NOT,
21277 /* translators: DataViews operator name */
21278 label: (0, import_i18n24.__)("Is not"),
21279 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21280 (0, import_i18n24.sprintf)(
21281 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
21282 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21283 filter.name,
21284 activeElements[0].label
21285 ),
21286 filterTextWrappers
21287 ),
21288 filter(item, field, filterValue) {
21289 return filterValue !== field.getValue({ item });
21290 },
21291 selection: "single"
21292 },
21293 {
21294 name: OPERATOR_LESS_THAN,
21295 /* translators: DataViews operator name */
21296 label: (0, import_i18n24.__)("Less than"),
21297 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21298 (0, import_i18n24.sprintf)(
21299 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
21300 (0, import_i18n24.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
21301 filter.name,
21302 activeElements[0].label
21303 ),
21304 filterTextWrappers
21305 ),
21306 filter(item, field, filterValue) {
21307 if (filterValue === void 0) {
21308 return true;
21309 }
21310 const fieldValue = field.getValue({ item });
21311 return fieldValue < filterValue;
21312 },
21313 selection: "single"
21314 },
21315 {
21316 name: OPERATOR_GREATER_THAN,
21317 /* translators: DataViews operator name */
21318 label: (0, import_i18n24.__)("Greater than"),
21319 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21320 (0, import_i18n24.sprintf)(
21321 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
21322 (0, import_i18n24.__)(
21323 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
21324 ),
21325 filter.name,
21326 activeElements[0].label
21327 ),
21328 filterTextWrappers
21329 ),
21330 filter(item, field, filterValue) {
21331 if (filterValue === void 0) {
21332 return true;
21333 }
21334 const fieldValue = field.getValue({ item });
21335 return fieldValue > filterValue;
21336 },
21337 selection: "single"
21338 },
21339 {
21340 name: OPERATOR_LESS_THAN_OR_EQUAL,
21341 /* translators: DataViews operator name */
21342 label: (0, import_i18n24.__)("Less than or equal"),
21343 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21344 (0, import_i18n24.sprintf)(
21345 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
21346 (0, import_i18n24.__)(
21347 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
21348 ),
21349 filter.name,
21350 activeElements[0].label
21351 ),
21352 filterTextWrappers
21353 ),
21354 filter(item, field, filterValue) {
21355 if (filterValue === void 0) {
21356 return true;
21357 }
21358 const fieldValue = field.getValue({ item });
21359 return fieldValue <= filterValue;
21360 },
21361 selection: "single"
21362 },
21363 {
21364 name: OPERATOR_GREATER_THAN_OR_EQUAL,
21365 /* translators: DataViews operator name */
21366 label: (0, import_i18n24.__)("Greater than or equal"),
21367 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21368 (0, import_i18n24.sprintf)(
21369 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
21370 (0, import_i18n24.__)(
21371 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
21372 ),
21373 filter.name,
21374 activeElements[0].label
21375 ),
21376 filterTextWrappers
21377 ),
21378 filter(item, field, filterValue) {
21379 if (filterValue === void 0) {
21380 return true;
21381 }
21382 const fieldValue = field.getValue({ item });
21383 return fieldValue >= filterValue;
21384 },
21385 selection: "single"
21386 },
21387 {
21388 name: OPERATOR_BEFORE,
21389 /* translators: DataViews operator name */
21390 label: (0, import_i18n24.__)("Before"),
21391 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21392 (0, import_i18n24.sprintf)(
21393 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
21394 (0, import_i18n24.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
21395 filter.name,
21396 activeElements[0].label
21397 ),
21398 filterTextWrappers
21399 ),
21400 filter(item, field, filterValue) {
21401 if (filterValue === void 0) {
21402 return true;
21403 }
21404 const filterDate = (0, import_date.getDate)(filterValue);
21405 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21406 return fieldDate < filterDate;
21407 },
21408 selection: "single"
21409 },
21410 {
21411 name: OPERATOR_AFTER,
21412 /* translators: DataViews operator name */
21413 label: (0, import_i18n24.__)("After"),
21414 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21415 (0, import_i18n24.sprintf)(
21416 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
21417 (0, import_i18n24.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
21418 filter.name,
21419 activeElements[0].label
21420 ),
21421 filterTextWrappers
21422 ),
21423 filter(item, field, filterValue) {
21424 if (filterValue === void 0) {
21425 return true;
21426 }
21427 const filterDate = (0, import_date.getDate)(filterValue);
21428 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21429 return fieldDate > filterDate;
21430 },
21431 selection: "single"
21432 },
21433 {
21434 name: OPERATOR_BEFORE_INC,
21435 /* translators: DataViews operator name */
21436 label: (0, import_i18n24.__)("Before (inc)"),
21437 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21438 (0, import_i18n24.sprintf)(
21439 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
21440 (0, import_i18n24.__)(
21441 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
21442 ),
21443 filter.name,
21444 activeElements[0].label
21445 ),
21446 filterTextWrappers
21447 ),
21448 filter(item, field, filterValue) {
21449 if (filterValue === void 0) {
21450 return true;
21451 }
21452 const filterDate = (0, import_date.getDate)(filterValue);
21453 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21454 return fieldDate <= filterDate;
21455 },
21456 selection: "single"
21457 },
21458 {
21459 name: OPERATOR_AFTER_INC,
21460 /* translators: DataViews operator name */
21461 label: (0, import_i18n24.__)("After (inc)"),
21462 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21463 (0, import_i18n24.sprintf)(
21464 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
21465 (0, import_i18n24.__)(
21466 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
21467 ),
21468 filter.name,
21469 activeElements[0].label
21470 ),
21471 filterTextWrappers
21472 ),
21473 filter(item, field, filterValue) {
21474 if (filterValue === void 0) {
21475 return true;
21476 }
21477 const filterDate = (0, import_date.getDate)(filterValue);
21478 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21479 return fieldDate >= filterDate;
21480 },
21481 selection: "single"
21482 },
21483 {
21484 name: OPERATOR_CONTAINS,
21485 /* translators: DataViews operator name */
21486 label: (0, import_i18n24.__)("Contains"),
21487 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21488 (0, import_i18n24.sprintf)(
21489 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
21490 (0, import_i18n24.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
21491 filter.name,
21492 activeElements[0].label
21493 ),
21494 filterTextWrappers
21495 ),
21496 filter(item, field, filterValue) {
21497 if (filterValue === void 0) {
21498 return true;
21499 }
21500 const fieldValue = field.getValue({ item });
21501 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21502 },
21503 selection: "single"
21504 },
21505 {
21506 name: OPERATOR_NOT_CONTAINS,
21507 /* translators: DataViews operator name */
21508 label: (0, import_i18n24.__)("Doesn't contain"),
21509 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21510 (0, import_i18n24.sprintf)(
21511 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
21512 (0, import_i18n24.__)(
21513 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
21514 ),
21515 filter.name,
21516 activeElements[0].label
21517 ),
21518 filterTextWrappers
21519 ),
21520 filter(item, field, filterValue) {
21521 if (filterValue === void 0) {
21522 return true;
21523 }
21524 const fieldValue = field.getValue({ item });
21525 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21526 },
21527 selection: "single"
21528 },
21529 {
21530 name: OPERATOR_STARTS_WITH,
21531 /* translators: DataViews operator name */
21532 label: (0, import_i18n24.__)("Starts with"),
21533 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21534 (0, import_i18n24.sprintf)(
21535 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
21536 (0, import_i18n24.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
21537 filter.name,
21538 activeElements[0].label
21539 ),
21540 filterTextWrappers
21541 ),
21542 filter(item, field, filterValue) {
21543 if (filterValue === void 0) {
21544 return true;
21545 }
21546 const fieldValue = field.getValue({ item });
21547 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
21548 },
21549 selection: "single"
21550 },
21551 {
21552 name: OPERATOR_ON,
21553 /* translators: DataViews operator name */
21554 label: (0, import_i18n24.__)("On"),
21555 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21556 (0, import_i18n24.sprintf)(
21557 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
21558 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21559 filter.name,
21560 activeElements[0].label
21561 ),
21562 filterTextWrappers
21563 ),
21564 filter(item, field, filterValue) {
21565 if (filterValue === void 0) {
21566 return true;
21567 }
21568 const filterDate = (0, import_date.getDate)(filterValue);
21569 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21570 return filterDate.getTime() === fieldDate.getTime();
21571 },
21572 selection: "single"
21573 },
21574 {
21575 name: OPERATOR_NOT_ON,
21576 /* translators: DataViews operator name */
21577 label: (0, import_i18n24.__)("Not on"),
21578 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21579 (0, import_i18n24.sprintf)(
21580 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
21581 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21582 filter.name,
21583 activeElements[0].label
21584 ),
21585 filterTextWrappers
21586 ),
21587 filter(item, field, filterValue) {
21588 if (filterValue === void 0) {
21589 return true;
21590 }
21591 const filterDate = (0, import_date.getDate)(filterValue);
21592 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21593 return filterDate.getTime() !== fieldDate.getTime();
21594 },
21595 selection: "single"
21596 }
21597 ];
21598 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
21599 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
21600 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
21601 (op) => op.name === name
21602 );
21603 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
21604
21605 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
21606 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
21607 var ENTER = "Enter";
21608 var SPACE = " ";
21609 var FilterText = ({
21610 activeElements,
21611 filterInView,
21612 filter
21613 }) => {
21614 if (activeElements === void 0 || activeElements.length === 0) {
21615 return filter.name;
21616 }
21617 const operator = getOperatorByName(filterInView?.operator);
21618 if (operator !== void 0) {
21619 return operator.filterText(filter, activeElements);
21620 }
21621 return (0, import_i18n25.sprintf)(
21622 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
21623 (0, import_i18n25.__)("Unknown status for %1$s"),
21624 filter.name
21625 );
21626 };
21627 function OperatorSelector({
21628 filter,
21629 view,
21630 onChangeView
21631 }) {
21632 const operatorOptions = filter.operators?.map((operator) => ({
21633 value: operator,
21634 label: getOperatorByName(operator)?.label || operator
21635 }));
21636 const currentFilter = view.filters?.find(
21637 (_filter) => _filter.field === filter.field
21638 );
21639 const value = currentFilter?.operator || filter.operators[0];
21640 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
21641 Stack,
21642 {
21643 direction: "row",
21644 gap: "sm",
21645 justify: "flex-start",
21646 className: "dataviews-filters__summary-operators-container",
21647 align: "center",
21648 children: [
21649 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_components21.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
21650 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21651 import_components21.SelectControl,
21652 {
21653 className: "dataviews-filters__summary-operators-filter-select",
21654 label: (0, import_i18n25.__)("Conditions"),
21655 value,
21656 options: operatorOptions,
21657 onChange: (newValue) => {
21658 const newOperator = newValue;
21659 const currentOperator = currentFilter?.operator;
21660 const newFilters = currentFilter ? [
21661 ...(view.filters ?? []).map(
21662 (_filter) => {
21663 if (_filter.field === filter.field) {
21664 const currentOpSelectionModel = getOperatorByName(
21665 currentOperator
21666 )?.selection;
21667 const newOpSelectionModel = getOperatorByName(
21668 newOperator
21669 )?.selection;
21670 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
21671 currentOpSelectionModel,
21672 newOpSelectionModel
21673 ].includes("custom");
21674 return {
21675 ..._filter,
21676 value: shouldResetValue ? void 0 : _filter.value,
21677 operator: newOperator
21678 };
21679 }
21680 return _filter;
21681 }
21682 )
21683 ] : [
21684 ...view.filters ?? [],
21685 {
21686 field: filter.field,
21687 operator: newOperator,
21688 value: void 0
21689 }
21690 ];
21691 onChangeView({
21692 ...view,
21693 page: 1,
21694 filters: newFilters
21695 });
21696 },
21697 size: "small",
21698 variant: "minimal",
21699 hideLabelFromVision: true
21700 }
21701 )
21702 ]
21703 }
21704 );
21705 }
21706 function Filter({
21707 addFilterRef,
21708 openedFilter,
21709 fields,
21710 ...commonProps
21711 }) {
21712 const toggleRef = (0, import_element47.useRef)(null);
21713 const { filter, view, onChangeView } = commonProps;
21714 const filterInView = view.filters?.find(
21715 (f2) => f2.field === filter.field
21716 );
21717 let activeElements = [];
21718 const field = (0, import_element47.useMemo)(() => {
21719 const currentField = fields.find((f2) => f2.id === filter.field);
21720 if (currentField) {
21721 return {
21722 ...currentField,
21723 // Configure getValue as if Item was a plain object.
21724 // See related input-widget.tsx
21725 getValue: ({ item }) => item[currentField.id]
21726 };
21727 }
21728 return currentField;
21729 }, [fields, filter.field]);
21730 const { elements } = useElements({
21731 elements: filter.elements,
21732 getElements: filter.getElements
21733 });
21734 if (elements.length > 0) {
21735 activeElements = elements.filter((element) => {
21736 if (filter.singleSelection) {
21737 return element.value === filterInView?.value;
21738 }
21739 return filterInView?.value?.includes(element.value);
21740 });
21741 } else if (Array.isArray(filterInView?.value)) {
21742 const label = filterInView.value.map((v2) => {
21743 const formattedValue = field?.getValueFormatted({
21744 item: { [field.id]: v2 },
21745 field
21746 });
21747 return formattedValue || String(v2);
21748 });
21749 activeElements = [
21750 {
21751 value: filterInView.value,
21752 // @ts-ignore
21753 label
21754 }
21755 ];
21756 } else if (typeof filterInView?.value === "object") {
21757 activeElements = [
21758 { value: filterInView.value, label: filterInView.value }
21759 ];
21760 } else if (filterInView?.value !== void 0) {
21761 const label = field !== void 0 ? field.getValueFormatted({
21762 item: { [field.id]: filterInView.value },
21763 field
21764 }) : String(filterInView.value);
21765 activeElements = [
21766 {
21767 value: filterInView.value,
21768 label
21769 }
21770 ];
21771 }
21772 const isPrimary = filter.isPrimary;
21773 const isLocked = filterInView?.isLocked;
21774 const hasValues = !isLocked && filterInView?.value !== void 0;
21775 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
21776 const resetOrRemoveLabel = isPrimary ? (0, import_i18n25.__)("Reset") : (0, import_i18n25.__)("Remove");
21777 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21778 import_components21.Dropdown,
21779 {
21780 defaultOpen: openedFilter === filter.field,
21781 contentClassName: "dataviews-filters__summary-popover",
21782 popoverProps: { placement: "bottom-start", role: "dialog" },
21783 onClose: () => {
21784 toggleRef.current?.focus();
21785 },
21786 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
21787 /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(tooltip_exports.Root, { children: [
21788 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21789 tooltip_exports.Trigger,
21790 {
21791 render: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21792 "div",
21793 {
21794 className: clsx_default(
21795 "dataviews-filters__summary-chip",
21796 {
21797 "has-reset": canResetOrRemove,
21798 "has-values": hasValues,
21799 "is-not-clickable": isLocked
21800 }
21801 ),
21802 role: "button",
21803 tabIndex: isLocked ? -1 : 0,
21804 onClick: () => {
21805 if (!isLocked) {
21806 onToggle();
21807 }
21808 },
21809 onKeyDown: (event) => {
21810 if (!isLocked && [ENTER, SPACE].includes(
21811 event.key
21812 )) {
21813 onToggle();
21814 event.preventDefault();
21815 }
21816 },
21817 "aria-disabled": isLocked,
21818 "aria-pressed": isOpen,
21819 "aria-expanded": isOpen,
21820 ref: toggleRef,
21821 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21822 FilterText,
21823 {
21824 activeElements,
21825 filterInView,
21826 filter
21827 }
21828 )
21829 }
21830 )
21831 }
21832 ),
21833 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(tooltip_exports.Popup, { children: (0, import_i18n25.sprintf)(
21834 /* translators: 1: Filter name. */
21835 (0, import_i18n25.__)("Filter by: %1$s"),
21836 filter.name.toLowerCase()
21837 ) })
21838 ] }),
21839 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(tooltip_exports.Root, { children: [
21840 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21841 tooltip_exports.Trigger,
21842 {
21843 render: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21844 "button",
21845 {
21846 className: clsx_default(
21847 "dataviews-filters__summary-chip-remove",
21848 { "has-values": hasValues }
21849 ),
21850 "aria-label": resetOrRemoveLabel,
21851 onClick: () => {
21852 onChangeView({
21853 ...view,
21854 page: 1,
21855 filters: view.filters?.filter(
21856 (_filter) => _filter.field !== filter.field
21857 )
21858 });
21859 if (!isPrimary) {
21860 addFilterRef.current?.focus();
21861 } else {
21862 toggleRef.current?.focus();
21863 }
21864 },
21865 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_components21.Icon, { icon: close_small_default })
21866 }
21867 )
21868 }
21869 ),
21870 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
21871 ] })
21872 ] }),
21873 renderContent: () => {
21874 return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
21875 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(OperatorSelector, { ...commonProps }),
21876 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21877 SearchWidget,
21878 {
21879 ...commonProps,
21880 filter: {
21881 ...commonProps.filter,
21882 elements
21883 }
21884 }
21885 ) : /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(InputWidget, { ...commonProps, fields })
21886 ] });
21887 }
21888 }
21889 );
21890 }
21891
21892 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
21893 var import_components22 = __toESM(require_components(), 1);
21894 var import_i18n26 = __toESM(require_i18n(), 1);
21895 var import_element48 = __toESM(require_element(), 1);
21896 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
21897 var { Menu: Menu4 } = unlock3(import_components22.privateApis);
21898 function AddFilterMenu({
21899 filters,
21900 view,
21901 onChangeView,
21902 setOpenedFilter,
21903 triggerProps
21904 }) {
21905 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21906 return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(Menu4, { children: [
21907 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Menu4.TriggerButton, { ...triggerProps }),
21908 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
21909 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
21910 Menu4.Item,
21911 {
21912 onClick: () => {
21913 setOpenedFilter(filter.field);
21914 onChangeView({
21915 ...view,
21916 page: 1,
21917 filters: [
21918 ...view.filters || [],
21919 {
21920 field: filter.field,
21921 value: void 0,
21922 operator: filter.operators[0]
21923 }
21924 ]
21925 });
21926 },
21927 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Menu4.ItemLabel, { children: filter.name })
21928 },
21929 filter.field
21930 );
21931 }) })
21932 ] });
21933 }
21934 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
21935 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
21936 return null;
21937 }
21938 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21939 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
21940 AddFilterMenu,
21941 {
21942 triggerProps: {
21943 render: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
21944 import_components22.Button,
21945 {
21946 accessibleWhenDisabled: true,
21947 size: "compact",
21948 className: "dataviews-filters-button",
21949 variant: "tertiary",
21950 disabled: !inactiveFilters.length,
21951 ref
21952 }
21953 ),
21954 children: (0, import_i18n26.__)("Add filter")
21955 },
21956 ...{ filters, view, onChangeView, setOpenedFilter }
21957 }
21958 );
21959 }
21960 var add_filter_default = (0, import_element48.forwardRef)(AddFilter);
21961
21962 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
21963 var import_components23 = __toESM(require_components(), 1);
21964 var import_i18n27 = __toESM(require_i18n(), 1);
21965 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
21966 function ResetFilter({
21967 filters,
21968 view,
21969 onChangeView
21970 }) {
21971 const isPrimary = (field) => filters.some(
21972 (_filter) => _filter.field === field && _filter.isPrimary
21973 );
21974 const isDisabled = !view.search && !view.filters?.some(
21975 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
21976 );
21977 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
21978 import_components23.Button,
21979 {
21980 disabled: isDisabled,
21981 accessibleWhenDisabled: true,
21982 size: "compact",
21983 variant: "tertiary",
21984 className: "dataviews-filters__reset-button",
21985 onClick: () => {
21986 onChangeView({
21987 ...view,
21988 page: 1,
21989 search: "",
21990 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
21991 });
21992 },
21993 children: (0, import_i18n27.__)("Reset")
21994 }
21995 );
21996 }
21997
21998 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
21999 var import_element49 = __toESM(require_element(), 1);
22000 function useFilters(fields, view) {
22001 return (0, import_element49.useMemo)(() => {
22002 const filters = [];
22003 fields.forEach((field) => {
22004 if (field.filterBy === false || !field.hasElements && !field.Edit) {
22005 return;
22006 }
22007 const operators = field.filterBy.operators;
22008 const isPrimary = !!field.filterBy?.isPrimary;
22009 const isLocked = view.filters?.some(
22010 (f2) => f2.field === field.id && !!f2.isLocked
22011 ) ?? false;
22012 filters.push({
22013 field: field.id,
22014 name: field.label,
22015 elements: field.elements,
22016 getElements: field.getElements,
22017 hasElements: field.hasElements,
22018 singleSelection: operators.some(
22019 (op) => isSingleSelectionOperator(op)
22020 ),
22021 operators,
22022 isVisible: isLocked || isPrimary || !!view.filters?.some(
22023 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
22024 ),
22025 isPrimary,
22026 isLocked
22027 });
22028 });
22029 filters.sort((a2, b2) => {
22030 if (a2.isLocked && !b2.isLocked) {
22031 return -1;
22032 }
22033 if (!a2.isLocked && b2.isLocked) {
22034 return 1;
22035 }
22036 if (a2.isPrimary && !b2.isPrimary) {
22037 return -1;
22038 }
22039 if (!a2.isPrimary && b2.isPrimary) {
22040 return 1;
22041 }
22042 return a2.name.localeCompare(b2.name);
22043 });
22044 return filters;
22045 }, [fields, view]);
22046 }
22047 var use_filters_default = useFilters;
22048
22049 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
22050 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
22051 function Filters({ className }) {
22052 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element50.useContext)(dataviews_context_default);
22053 const addFilterRef = (0, import_element50.useRef)(null);
22054 const filters = use_filters_default(fields, view);
22055 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
22056 add_filter_default,
22057 {
22058 filters,
22059 view,
22060 onChangeView,
22061 ref: addFilterRef,
22062 setOpenedFilter
22063 },
22064 "add-filter"
22065 );
22066 const visibleFilters = filters.filter((filter) => filter.isVisible);
22067 if (visibleFilters.length === 0) {
22068 return null;
22069 }
22070 const filterComponents = [
22071 ...visibleFilters.map((filter) => {
22072 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
22073 Filter,
22074 {
22075 filter,
22076 view,
22077 fields,
22078 onChangeView,
22079 addFilterRef,
22080 openedFilter
22081 },
22082 filter.field
22083 );
22084 }),
22085 addFilter
22086 ];
22087 filterComponents.push(
22088 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
22089 ResetFilter,
22090 {
22091 filters,
22092 view,
22093 onChangeView
22094 },
22095 "reset-filters"
22096 )
22097 );
22098 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
22099 Stack,
22100 {
22101 direction: "row",
22102 justify: "flex-start",
22103 gap: "sm",
22104 style: { width: "fit-content" },
22105 wrap: "wrap",
22106 className,
22107 children: filterComponents
22108 }
22109 );
22110 }
22111 var filters_default = (0, import_element50.memo)(Filters);
22112
22113 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
22114 var import_element51 = __toESM(require_element(), 1);
22115 var import_components24 = __toESM(require_components(), 1);
22116 var import_i18n28 = __toESM(require_i18n(), 1);
22117 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
22118 function FiltersToggle() {
22119 const {
22120 filters,
22121 view,
22122 onChangeView,
22123 setOpenedFilter,
22124 isShowingFilter,
22125 setIsShowingFilter
22126 } = (0, import_element51.useContext)(dataviews_context_default);
22127 const buttonRef = (0, import_element51.useRef)(null);
22128 const onChangeViewWithFilterVisibility = (0, import_element51.useCallback)(
22129 (_view) => {
22130 onChangeView(_view);
22131 setIsShowingFilter(true);
22132 },
22133 [onChangeView, setIsShowingFilter]
22134 );
22135 if (filters.length === 0) {
22136 return null;
22137 }
22138 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
22139 const addFilterButtonProps = {
22140 label: (0, import_i18n28.__)("Add filter"),
22141 "aria-expanded": false,
22142 isPressed: false
22143 };
22144 const toggleFiltersButtonProps = {
22145 label: (0, import_i18n28._x)("Filter", "verb"),
22146 "aria-expanded": isShowingFilter,
22147 isPressed: isShowingFilter,
22148 onClick: () => {
22149 if (!isShowingFilter) {
22150 setOpenedFilter(null);
22151 }
22152 setIsShowingFilter(!isShowingFilter);
22153 }
22154 };
22155 const hasPrimaryOrLockedFilters = filters.some(
22156 (filter) => filter.isPrimary || filter.isLocked
22157 );
22158 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
22159 import_components24.Button,
22160 {
22161 ref: buttonRef,
22162 className: "dataviews-filters__visibility-toggle",
22163 size: "compact",
22164 icon: funnel_default,
22165 disabled: hasPrimaryOrLockedFilters,
22166 accessibleWhenDisabled: true,
22167 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
22168 }
22169 );
22170 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
22171 AddFilterMenu,
22172 {
22173 filters,
22174 view,
22175 onChangeView: onChangeViewWithFilterVisibility,
22176 setOpenedFilter,
22177 triggerProps: { render: buttonComponent }
22178 }
22179 ) : /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
22180 FilterVisibilityToggle,
22181 {
22182 buttonRef,
22183 filtersCount: view.filters?.length,
22184 children: buttonComponent
22185 }
22186 ) });
22187 }
22188 function FilterVisibilityToggle({
22189 buttonRef,
22190 filtersCount,
22191 children
22192 }) {
22193 (0, import_element51.useEffect)(
22194 () => () => {
22195 buttonRef.current?.focus();
22196 },
22197 [buttonRef]
22198 );
22199 return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(import_jsx_runtime79.Fragment, { children: [
22200 children,
22201 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
22202 ] });
22203 }
22204 var toggle_default = FiltersToggle;
22205
22206 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
22207 var import_element52 = __toESM(require_element(), 1);
22208 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
22209 function FiltersToggled(props) {
22210 const { isShowingFilter } = (0, import_element52.useContext)(dataviews_context_default);
22211 if (!isShowingFilter) {
22212 return null;
22213 }
22214 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(filters_default, { ...props });
22215 }
22216 var filters_toggled_default = FiltersToggled;
22217
22218 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
22219 var import_element53 = __toESM(require_element(), 1);
22220 var import_components25 = __toESM(require_components(), 1);
22221 var import_i18n29 = __toESM(require_i18n(), 1);
22222 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
22223 function DataViewsLayout({ className }) {
22224 const {
22225 actions = [],
22226 data,
22227 fields,
22228 getItemId,
22229 getItemLevel,
22230 hasInitiallyLoaded,
22231 isLoading,
22232 view,
22233 onChangeView,
22234 selection,
22235 onChangeSelection,
22236 setOpenedFilter,
22237 onClickItem,
22238 isItemClickable,
22239 renderItemLink,
22240 defaultLayouts,
22241 containerRef,
22242 empty = /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("p", { children: (0, import_i18n29.__)("No results") })
22243 } = (0, import_element53.useContext)(dataviews_context_default);
22244 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
22245 delay: 200
22246 });
22247 if (!hasInitiallyLoaded) {
22248 if (!isDelayedInitialLoading) {
22249 return null;
22250 }
22251 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components25.Spinner, {}) }) });
22252 }
22253 const ViewComponent = VIEW_LAYOUTS.find(
22254 (v2) => v2.type === view.type && defaultLayouts[v2.type]
22255 )?.component;
22256 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
22257 ViewComponent,
22258 {
22259 className,
22260 actions,
22261 data,
22262 fields,
22263 getItemId,
22264 getItemLevel,
22265 isLoading,
22266 onChangeView,
22267 onChangeSelection,
22268 selection,
22269 setOpenedFilter,
22270 onClickItem,
22271 renderItemLink,
22272 isItemClickable,
22273 view,
22274 empty
22275 }
22276 ) });
22277 }
22278
22279 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
22280 var import_element54 = __toESM(require_element(), 1);
22281 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
22282 var EMPTY_ARRAY5 = [];
22283 function DataViewsFooter() {
22284 const {
22285 view,
22286 paginationInfo: { totalItems = 0, totalPages },
22287 data,
22288 actions = EMPTY_ARRAY5,
22289 isLoading,
22290 hasInitiallyLoaded
22291 } = (0, import_element54.useContext)(dataviews_context_default);
22292 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
22293 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
22294 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
22295 const hasPagination = hasPaginationControls(view, {
22296 totalItems,
22297 totalPages
22298 });
22299 if (!totalItems || !hasBulkActions && !hasPagination) {
22300 return null;
22301 }
22302 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
22303 "div",
22304 {
22305 className: "dataviews-footer",
22306 inert: isRefreshing ? "true" : void 0,
22307 children: /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(
22308 Stack,
22309 {
22310 direction: "row",
22311 justify: "end",
22312 align: "center",
22313 className: clsx_default("dataviews-footer__content", {
22314 "is-refreshing": isDelayedRefreshing
22315 }),
22316 gap: "sm",
22317 children: [
22318 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(BulkActionsFooter, {}),
22319 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(dataviews_pagination_default, {})
22320 ]
22321 }
22322 )
22323 }
22324 );
22325 }
22326
22327 // packages/dataviews/build-module/components/dataviews-search/index.mjs
22328 var import_i18n30 = __toESM(require_i18n(), 1);
22329 var import_element55 = __toESM(require_element(), 1);
22330 var import_components26 = __toESM(require_components(), 1);
22331 var import_compose10 = __toESM(require_compose(), 1);
22332 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
22333 var DataViewsSearch = (0, import_element55.memo)(function Search({ label }) {
22334 const { view, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
22335 const [search, setSearch, debouncedSearch] = (0, import_compose10.useDebouncedInput)(
22336 view.search
22337 );
22338 (0, import_element55.useEffect)(() => {
22339 if (view.search !== debouncedSearch) {
22340 setSearch(view.search ?? "");
22341 }
22342 }, [view.search, setSearch]);
22343 const onChangeViewRef = (0, import_element55.useRef)(onChangeView);
22344 const viewRef = (0, import_element55.useRef)(view);
22345 (0, import_element55.useEffect)(() => {
22346 onChangeViewRef.current = onChangeView;
22347 viewRef.current = view;
22348 }, [onChangeView, view]);
22349 (0, import_element55.useEffect)(() => {
22350 if (debouncedSearch !== viewRef.current?.search) {
22351 onChangeViewRef.current({
22352 ...viewRef.current,
22353 page: view.page ? 1 : void 0,
22354 startPosition: view.startPosition ? 1 : void 0,
22355 search: debouncedSearch
22356 });
22357 }
22358 }, [debouncedSearch]);
22359 const searchLabel = label || (0, import_i18n30.__)("Search");
22360 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22361 import_components26.SearchControl,
22362 {
22363 className: "dataviews-search",
22364 onChange: setSearch,
22365 value: search,
22366 label: searchLabel,
22367 placeholder: searchLabel,
22368 size: "compact"
22369 }
22370 );
22371 });
22372 var dataviews_search_default = DataViewsSearch;
22373
22374 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
22375 var import_components27 = __toESM(require_components(), 1);
22376 var import_i18n31 = __toESM(require_i18n(), 1);
22377 var import_element56 = __toESM(require_element(), 1);
22378 var import_warning = __toESM(require_warning(), 1);
22379 var import_compose11 = __toESM(require_compose(), 1);
22380 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
22381 var { Menu: Menu5 } = unlock3(import_components27.privateApis);
22382 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
22383 className: "dataviews-config__popover",
22384 placement: "bottom-end",
22385 offset: 9
22386 };
22387 function ViewTypeMenu() {
22388 const { view, onChangeView, defaultLayouts } = (0, import_element56.useContext)(dataviews_context_default);
22389 const availableLayouts = Object.keys(defaultLayouts);
22390 if (availableLayouts.length <= 1) {
22391 return null;
22392 }
22393 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
22394 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(Menu5, { children: [
22395 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22396 Menu5.TriggerButton,
22397 {
22398 render: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22399 import_components27.Button,
22400 {
22401 size: "compact",
22402 icon: activeView?.icon,
22403 label: (0, import_i18n31.__)("Layout")
22404 }
22405 )
22406 }
22407 ),
22408 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
22409 const config = VIEW_LAYOUTS.find(
22410 (v2) => v2.type === layout
22411 );
22412 if (!config) {
22413 return null;
22414 }
22415 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22416 Menu5.RadioItem,
22417 {
22418 value: layout,
22419 name: "view-actions-available-view",
22420 checked: layout === view.type,
22421 hideOnClick: true,
22422 onChange: (e2) => {
22423 switch (e2.target.value) {
22424 case "list":
22425 case "grid":
22426 case "table":
22427 case "pickerGrid":
22428 case "pickerTable":
22429 case "pickerActivity":
22430 case "activity":
22431 const viewWithoutLayout = { ...view };
22432 if ("layout" in viewWithoutLayout) {
22433 delete viewWithoutLayout.layout;
22434 }
22435 return onChangeView({
22436 ...viewWithoutLayout,
22437 type: e2.target.value,
22438 ...defaultLayouts[e2.target.value]
22439 });
22440 }
22441 (0, import_warning.default)("Invalid dataview");
22442 },
22443 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu5.ItemLabel, { children: config.label })
22444 },
22445 layout
22446 );
22447 }) })
22448 ] });
22449 }
22450 function SortFieldControl() {
22451 const { view, fields, onChangeView } = (0, import_element56.useContext)(dataviews_context_default);
22452 const orderOptions = (0, import_element56.useMemo)(() => {
22453 const sortableFields = fields.filter(
22454 (field) => field.enableSorting !== false
22455 );
22456 return sortableFields.map((field) => {
22457 return {
22458 label: field.label,
22459 value: field.id
22460 };
22461 });
22462 }, [fields]);
22463 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22464 import_components27.SelectControl,
22465 {
22466 label: (0, import_i18n31.__)("Sort by"),
22467 value: view.sort?.field,
22468 options: orderOptions,
22469 onChange: (value) => {
22470 onChangeView({
22471 ...view,
22472 sort: {
22473 direction: view?.sort?.direction || "desc",
22474 field: value
22475 },
22476 showLevels: false
22477 });
22478 }
22479 }
22480 );
22481 }
22482 function SortDirectionControl() {
22483 const { view, fields, onChangeView } = (0, import_element56.useContext)(dataviews_context_default);
22484 const sortableFields = fields.filter(
22485 (field) => field.enableSorting !== false
22486 );
22487 if (sortableFields.length === 0) {
22488 return null;
22489 }
22490 let value = view.sort?.direction;
22491 if (!value && view.sort?.field) {
22492 value = "desc";
22493 }
22494 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22495 import_components27.__experimentalToggleGroupControl,
22496 {
22497 className: "dataviews-view-config__sort-direction",
22498 isBlock: true,
22499 label: (0, import_i18n31.__)("Order"),
22500 value,
22501 onChange: (newDirection) => {
22502 if (newDirection === "asc" || newDirection === "desc") {
22503 onChangeView({
22504 ...view,
22505 sort: {
22506 direction: newDirection,
22507 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
22508 fields.find(
22509 (field) => field.enableSorting !== false
22510 )?.id || ""
22511 },
22512 showLevels: false
22513 });
22514 return;
22515 }
22516 (0, import_warning.default)("Invalid direction");
22517 },
22518 children: SORTING_DIRECTIONS.map((direction) => {
22519 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22520 import_components27.__experimentalToggleGroupControlOptionIcon,
22521 {
22522 value: direction,
22523 icon: sortIcons[direction],
22524 label: sortLabels[direction]
22525 },
22526 direction
22527 );
22528 })
22529 }
22530 );
22531 }
22532 function ItemsPerPageControl() {
22533 const { view, config, onChangeView } = (0, import_element56.useContext)(dataviews_context_default);
22534 const { infiniteScrollEnabled } = view;
22535 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
22536 return null;
22537 }
22538 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22539 import_components27.__experimentalToggleGroupControl,
22540 {
22541 isBlock: true,
22542 label: (0, import_i18n31.__)("Items per page"),
22543 value: view.perPage || 10,
22544 disabled: !view?.sort?.field,
22545 onChange: (newItemsPerPage) => {
22546 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
22547 onChangeView({
22548 ...view,
22549 perPage: newItemsPerPageNumber,
22550 page: 1
22551 });
22552 },
22553 children: config.perPageSizes.map((value) => {
22554 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22555 import_components27.__experimentalToggleGroupControlOption,
22556 {
22557 value,
22558 label: value.toString()
22559 },
22560 value
22561 );
22562 })
22563 }
22564 );
22565 }
22566 function ResetViewButton() {
22567 const { onReset } = (0, import_element56.useContext)(dataviews_context_default);
22568 if (onReset === void 0) {
22569 return null;
22570 }
22571 const isDisabled = onReset === false;
22572 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22573 import_components27.Button,
22574 {
22575 variant: "tertiary",
22576 size: "compact",
22577 disabled: isDisabled,
22578 accessibleWhenDisabled: true,
22579 className: "dataviews-view-config__reset-button",
22580 onClick: () => {
22581 if (typeof onReset === "function") {
22582 onReset();
22583 }
22584 },
22585 children: (0, import_i18n31.__)("Reset view")
22586 }
22587 );
22588 }
22589 function DataviewsViewConfigDropdown() {
22590 const { view, onReset } = (0, import_element56.useContext)(dataviews_context_default);
22591 const popoverId = (0, import_compose11.useInstanceId)(
22592 _DataViewsViewConfig,
22593 "dataviews-view-config-dropdown"
22594 );
22595 const activeLayout = VIEW_LAYOUTS.find(
22596 (layout) => layout.type === view.type
22597 );
22598 const isModified = typeof onReset === "function";
22599 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22600 import_components27.Dropdown,
22601 {
22602 expandOnMobile: true,
22603 popoverProps: {
22604 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
22605 id: popoverId
22606 },
22607 renderToggle: ({ onToggle, isOpen }) => {
22608 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
22609 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22610 import_components27.Button,
22611 {
22612 size: "compact",
22613 icon: cog_default,
22614 label: (0, import_i18n31._x)(
22615 "View options",
22616 "View is used as a noun"
22617 ),
22618 onClick: onToggle,
22619 "aria-expanded": isOpen ? "true" : "false",
22620 "aria-controls": popoverId
22621 }
22622 ),
22623 isModified && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
22624 ] });
22625 },
22626 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22627 import_components27.__experimentalDropdownContentWrapper,
22628 {
22629 paddingSize: "medium",
22630 className: "dataviews-config__popover-content-wrapper",
22631 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
22632 Stack,
22633 {
22634 direction: "column",
22635 className: "dataviews-view-config",
22636 gap: "xl",
22637 children: [
22638 /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
22639 Stack,
22640 {
22641 direction: "row",
22642 justify: "space-between",
22643 align: "center",
22644 className: "dataviews-view-config__header",
22645 children: [
22646 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22647 import_components27.__experimentalHeading,
22648 {
22649 level: 2,
22650 className: "dataviews-settings-section__title",
22651 children: (0, import_i18n31.__)("Appearance")
22652 }
22653 ),
22654 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(ResetViewButton, {})
22655 ]
22656 }
22657 ),
22658 /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22659 /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
22660 Stack,
22661 {
22662 direction: "row",
22663 gap: "sm",
22664 className: "dataviews-view-config__sort-controls",
22665 children: [
22666 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(SortFieldControl, {}),
22667 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(SortDirectionControl, {})
22668 ]
22669 }
22670 ),
22671 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(activeLayout.viewConfigOptions, {}),
22672 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(ItemsPerPageControl, {}),
22673 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(PropertiesSection, {})
22674 ] })
22675 ]
22676 }
22677 )
22678 }
22679 )
22680 }
22681 );
22682 }
22683 function _DataViewsViewConfig() {
22684 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(import_jsx_runtime84.Fragment, { children: [
22685 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(ViewTypeMenu, {}),
22686 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(DataviewsViewConfigDropdown, {})
22687 ] });
22688 }
22689 var DataViewsViewConfig = (0, import_element56.memo)(_DataViewsViewConfig);
22690 var dataviews_view_config_default = DataViewsViewConfig;
22691
22692 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22693 var import_components28 = __toESM(require_components(), 1);
22694 var import_element57 = __toESM(require_element(), 1);
22695
22696 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
22697 function getCustomValidity(isValid2, validity) {
22698 let customValidity;
22699 if (isValid2?.required && validity?.required) {
22700 customValidity = validity?.required?.message ? validity.required : void 0;
22701 } else if (isValid2?.pattern && validity?.pattern) {
22702 customValidity = validity.pattern;
22703 } else if (isValid2?.min && validity?.min) {
22704 customValidity = validity.min;
22705 } else if (isValid2?.max && validity?.max) {
22706 customValidity = validity.max;
22707 } else if (isValid2?.minLength && validity?.minLength) {
22708 customValidity = validity.minLength;
22709 } else if (isValid2?.maxLength && validity?.maxLength) {
22710 customValidity = validity.maxLength;
22711 } else if (isValid2?.elements && validity?.elements) {
22712 customValidity = validity.elements;
22713 } else if (validity?.custom) {
22714 customValidity = validity.custom;
22715 }
22716 return customValidity;
22717 }
22718
22719 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22720 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
22721 var { ValidatedCheckboxControl } = unlock3(import_components28.privateApis);
22722 function Checkbox({
22723 field,
22724 onChange,
22725 data,
22726 hideLabelFromVision,
22727 markWhenOptional,
22728 validity
22729 }) {
22730 const { getValue, setValue, label, description, isValid: isValid2 } = field;
22731 const disabled2 = field.isDisabled({ item: data, field });
22732 const onChangeControl = (0, import_element57.useCallback)(() => {
22733 onChange(
22734 setValue({ item: data, value: !getValue({ item: data }) })
22735 );
22736 }, [data, getValue, onChange, setValue]);
22737 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
22738 ValidatedCheckboxControl,
22739 {
22740 required: !!field.isValid?.required,
22741 markWhenOptional,
22742 customValidity: getCustomValidity(isValid2, validity),
22743 hidden: hideLabelFromVision,
22744 label,
22745 help: description,
22746 checked: getValue({ item: data }),
22747 onChange: onChangeControl,
22748 disabled: disabled2
22749 }
22750 );
22751 }
22752
22753 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
22754 var import_components29 = __toESM(require_components(), 1);
22755 var import_element58 = __toESM(require_element(), 1);
22756 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
22757 var { ValidatedComboboxControl } = unlock3(import_components29.privateApis);
22758 function Combobox3({
22759 data,
22760 field,
22761 onChange,
22762 hideLabelFromVision,
22763 validity
22764 }) {
22765 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
22766 const value = getValue({ item: data }) ?? "";
22767 const onChangeControl = (0, import_element58.useCallback)(
22768 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
22769 [data, onChange, setValue]
22770 );
22771 const { elements, isLoading } = useElements({
22772 elements: field.elements,
22773 getElements: field.getElements
22774 });
22775 if (isLoading) {
22776 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(import_components29.Spinner, {});
22777 }
22778 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22779 ValidatedComboboxControl,
22780 {
22781 required: !!field.isValid?.required,
22782 customValidity: getCustomValidity(isValid2, validity),
22783 label,
22784 value,
22785 help: description,
22786 placeholder,
22787 options: elements,
22788 onChange: onChangeControl,
22789 hideLabelFromVision,
22790 allowReset: true,
22791 expandOnFocus: true
22792 }
22793 );
22794 }
22795
22796 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22797 var import_components31 = __toESM(require_components(), 1);
22798 var import_element61 = __toESM(require_element(), 1);
22799 var import_i18n33 = __toESM(require_i18n(), 1);
22800 var import_date3 = __toESM(require_date(), 1);
22801
22802 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
22803 var import_components30 = __toESM(require_components(), 1);
22804 var import_element59 = __toESM(require_element(), 1);
22805 var import_i18n32 = __toESM(require_i18n(), 1);
22806 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
22807 var TIME_UNITS_OPTIONS = {
22808 [OPERATOR_IN_THE_PAST]: [
22809 { value: "days", label: (0, import_i18n32.__)("Days") },
22810 { value: "weeks", label: (0, import_i18n32.__)("Weeks") },
22811 { value: "months", label: (0, import_i18n32.__)("Months") },
22812 { value: "years", label: (0, import_i18n32.__)("Years") }
22813 ],
22814 [OPERATOR_OVER]: [
22815 { value: "days", label: (0, import_i18n32.__)("Days ago") },
22816 { value: "weeks", label: (0, import_i18n32.__)("Weeks ago") },
22817 { value: "months", label: (0, import_i18n32.__)("Months ago") },
22818 { value: "years", label: (0, import_i18n32.__)("Years ago") }
22819 ]
22820 };
22821 function RelativeDateControl({
22822 className,
22823 data,
22824 field,
22825 onChange,
22826 hideLabelFromVision,
22827 operator
22828 }) {
22829 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
22830 const { id, label, description, getValue, setValue } = field;
22831 const disabled2 = field.isDisabled({ item: data, field });
22832 const fieldValue = getValue({ item: data });
22833 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
22834 const onChangeValue = (0, import_element59.useCallback)(
22835 (newValue) => onChange(
22836 setValue({
22837 item: data,
22838 value: { value: Number(newValue), unit }
22839 })
22840 ),
22841 [onChange, setValue, data, unit]
22842 );
22843 const onChangeUnit = (0, import_element59.useCallback)(
22844 (newUnit) => onChange(
22845 setValue({
22846 item: data,
22847 value: { value: relValue, unit: newUnit }
22848 })
22849 ),
22850 [onChange, setValue, data, relValue]
22851 );
22852 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22853 import_components30.BaseControl,
22854 {
22855 id,
22856 className: clsx_default(className, "dataviews-controls__relative-date"),
22857 label,
22858 hideLabelFromVision,
22859 help: description,
22860 children: /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(Stack, { direction: "row", gap: "sm", children: [
22861 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22862 import_components30.__experimentalNumberControl,
22863 {
22864 className: "dataviews-controls__relative-date-number",
22865 spinControls: "none",
22866 min: 1,
22867 step: 1,
22868 value: relValue,
22869 onChange: onChangeValue,
22870 disabled: disabled2
22871 }
22872 ),
22873 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22874 import_components30.SelectControl,
22875 {
22876 className: "dataviews-controls__relative-date-unit",
22877 label: (0, import_i18n32.__)("Unit"),
22878 value: unit,
22879 options,
22880 onChange: onChangeUnit,
22881 hideLabelFromVision: true,
22882 disabled: disabled2
22883 }
22884 )
22885 ] })
22886 }
22887 );
22888 }
22889
22890 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
22891 var import_element60 = __toESM(require_element(), 1);
22892 function useDisabledDateMatchers(isValid2, parseDateFn) {
22893 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
22894 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
22895 const disabledMatchers = (0, import_element60.useMemo)(() => {
22896 const matchers = [];
22897 if (minConstraint) {
22898 const minDate = parseDateFn(minConstraint);
22899 if (minDate) {
22900 matchers.push({ before: minDate });
22901 }
22902 }
22903 if (maxConstraint) {
22904 const maxDate = parseDateFn(maxConstraint);
22905 if (maxDate) {
22906 matchers.push({ after: maxDate });
22907 }
22908 }
22909 return matchers.length > 0 ? matchers : void 0;
22910 }, [minConstraint, maxConstraint, parseDateFn]);
22911 return { minConstraint, maxConstraint, disabledMatchers };
22912 }
22913
22914 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
22915 var import_date2 = __toESM(require_date(), 1);
22916 function parseDateTime(dateTimeString) {
22917 if (!dateTimeString) {
22918 return null;
22919 }
22920 const parsed = (0, import_date2.getDate)(dateTimeString);
22921 return parsed && isValid(parsed) ? parsed : null;
22922 }
22923
22924 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22925 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
22926 var { DateCalendar, ValidatedInputControl } = unlock3(import_components31.privateApis);
22927 var formatDateTime = (value) => {
22928 if (!value) {
22929 return "";
22930 }
22931 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
22932 };
22933 function CalendarDateTimeControl({
22934 data,
22935 field,
22936 onChange,
22937 hideLabelFromVision,
22938 markWhenOptional,
22939 validity,
22940 config
22941 }) {
22942 const { compact } = config || {};
22943 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
22944 const disabled2 = field.isDisabled({ item: data, field });
22945 const fieldValue = getValue({ item: data });
22946 const value = typeof fieldValue === "string" ? fieldValue : void 0;
22947 const [calendarMonth, setCalendarMonth] = (0, import_element61.useState)(() => {
22948 const parsedDate = parseDateTime(value);
22949 return parsedDate || /* @__PURE__ */ new Date();
22950 });
22951 const inputControlRef = (0, import_element61.useRef)(null);
22952 const validationTimeoutRef = (0, import_element61.useRef)(void 0);
22953 const previousFocusRef = (0, import_element61.useRef)(null);
22954 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
22955 const onChangeCallback = (0, import_element61.useCallback)(
22956 (newValue) => onChange(setValue({ item: data, value: newValue })),
22957 [data, onChange, setValue]
22958 );
22959 (0, import_element61.useEffect)(() => {
22960 return () => {
22961 if (validationTimeoutRef.current) {
22962 clearTimeout(validationTimeoutRef.current);
22963 }
22964 };
22965 }, []);
22966 const onSelectDate = (0, import_element61.useCallback)(
22967 (newDate) => {
22968 let dateTimeValue;
22969 if (newDate) {
22970 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
22971 let wpTime;
22972 if (value) {
22973 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
22974 } else {
22975 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
22976 }
22977 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
22978 dateTimeValue = finalDateTime.toISOString();
22979 onChangeCallback(dateTimeValue);
22980 if (validationTimeoutRef.current) {
22981 clearTimeout(validationTimeoutRef.current);
22982 }
22983 } else {
22984 onChangeCallback(void 0);
22985 }
22986 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
22987 validationTimeoutRef.current = setTimeout(() => {
22988 if (inputControlRef.current) {
22989 inputControlRef.current.focus();
22990 inputControlRef.current.blur();
22991 onChangeCallback(dateTimeValue);
22992 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
22993 previousFocusRef.current.focus();
22994 }
22995 }
22996 }, 0);
22997 },
22998 [onChangeCallback, value]
22999 );
23000 const handleManualDateTimeChange = (0, import_element61.useCallback)(
23001 (newValue) => {
23002 if (newValue) {
23003 const dateTime = (0, import_date3.getDate)(newValue);
23004 onChangeCallback(dateTime.toISOString());
23005 const parsedDate = parseDateTime(dateTime.toISOString());
23006 if (parsedDate) {
23007 setCalendarMonth(parsedDate);
23008 }
23009 } else {
23010 onChangeCallback(void 0);
23011 }
23012 },
23013 [onChangeCallback]
23014 );
23015 const { format: fieldFormat } = field;
23016 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
23017 const {
23018 timezone: { string: timezoneString }
23019 } = (0, import_date3.getSettings)();
23020 let displayLabel = label;
23021 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
23022 displayLabel = `${label} (${(0, import_i18n33.__)("Required")})`;
23023 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
23024 displayLabel = `${label} (${(0, import_i18n33.__)("Optional")})`;
23025 }
23026 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
23027 import_components31.BaseControl,
23028 {
23029 id,
23030 label: displayLabel,
23031 help: description,
23032 hideLabelFromVision,
23033 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23034 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
23035 ValidatedInputControl,
23036 {
23037 ref: inputControlRef,
23038 required: !!isValid2?.required,
23039 customValidity: getCustomValidity(isValid2, validity),
23040 type: "datetime-local",
23041 label: (0, import_i18n33.__)("Date time"),
23042 hideLabelFromVision: true,
23043 value: formatDateTime(value),
23044 onChange: handleManualDateTimeChange,
23045 disabled: disabled2,
23046 min: minConstraint ? formatDateTime(minConstraint) : void 0,
23047 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
23048 }
23049 ),
23050 !compact && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
23051 DateCalendar,
23052 {
23053 style: { width: "100%" },
23054 selected: value ? parseDateTime(value) || void 0 : void 0,
23055 onSelect: onSelectDate,
23056 month: calendarMonth,
23057 onMonthChange: setCalendarMonth,
23058 timeZone: timezoneString || void 0,
23059 weekStartsOn,
23060 disabled: disabled2 || disabledMatchers
23061 }
23062 )
23063 ] })
23064 }
23065 );
23066 }
23067 function DateTime({
23068 data,
23069 field,
23070 onChange,
23071 hideLabelFromVision,
23072 markWhenOptional,
23073 operator,
23074 validity,
23075 config
23076 }) {
23077 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23078 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
23079 RelativeDateControl,
23080 {
23081 className: "dataviews-controls__datetime",
23082 data,
23083 field,
23084 onChange,
23085 hideLabelFromVision,
23086 operator
23087 }
23088 );
23089 }
23090 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
23091 CalendarDateTimeControl,
23092 {
23093 data,
23094 field,
23095 onChange,
23096 hideLabelFromVision,
23097 markWhenOptional,
23098 validity,
23099 config
23100 }
23101 );
23102 }
23103
23104 // packages/dataviews/build-module/components/dataform-controls/date.mjs
23105 var import_components32 = __toESM(require_components(), 1);
23106 var import_element62 = __toESM(require_element(), 1);
23107 var import_i18n34 = __toESM(require_i18n(), 1);
23108 var import_date4 = __toESM(require_date(), 1);
23109 import { speak } from "@wordpress/a11y";
23110 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
23111 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock3(import_components32.privateApis);
23112 var DATE_PRESETS = [
23113 {
23114 id: "today",
23115 label: (0, import_i18n34.__)("Today"),
23116 getValue: () => (0, import_date4.getDate)(null)
23117 },
23118 {
23119 id: "yesterday",
23120 label: (0, import_i18n34.__)("Yesterday"),
23121 getValue: () => {
23122 const today = (0, import_date4.getDate)(null);
23123 return subDays(today, 1);
23124 }
23125 },
23126 {
23127 id: "past-week",
23128 label: (0, import_i18n34.__)("Past week"),
23129 getValue: () => {
23130 const today = (0, import_date4.getDate)(null);
23131 return subDays(today, 7);
23132 }
23133 },
23134 {
23135 id: "past-month",
23136 label: (0, import_i18n34.__)("Past month"),
23137 getValue: () => {
23138 const today = (0, import_date4.getDate)(null);
23139 return subMonths(today, 1);
23140 }
23141 }
23142 ];
23143 var DATE_RANGE_PRESETS = [
23144 {
23145 id: "last-7-days",
23146 label: (0, import_i18n34.__)("Last 7 days"),
23147 getValue: () => {
23148 const today = (0, import_date4.getDate)(null);
23149 return [subDays(today, 7), today];
23150 }
23151 },
23152 {
23153 id: "last-30-days",
23154 label: (0, import_i18n34.__)("Last 30 days"),
23155 getValue: () => {
23156 const today = (0, import_date4.getDate)(null);
23157 return [subDays(today, 30), today];
23158 }
23159 },
23160 {
23161 id: "month-to-date",
23162 label: (0, import_i18n34.__)("Month to date"),
23163 getValue: () => {
23164 const today = (0, import_date4.getDate)(null);
23165 return [startOfMonth(today), today];
23166 }
23167 },
23168 {
23169 id: "last-year",
23170 label: (0, import_i18n34.__)("Last year"),
23171 getValue: () => {
23172 const today = (0, import_date4.getDate)(null);
23173 return [subYears(today, 1), today];
23174 }
23175 },
23176 {
23177 id: "year-to-date",
23178 label: (0, import_i18n34.__)("Year to date"),
23179 getValue: () => {
23180 const today = (0, import_date4.getDate)(null);
23181 return [startOfYear(today), today];
23182 }
23183 }
23184 ];
23185 var parseDate = (dateString) => {
23186 if (!dateString) {
23187 return null;
23188 }
23189 const parsed = (0, import_date4.getDate)(dateString);
23190 return parsed && isValid(parsed) ? parsed : null;
23191 };
23192 var formatDate = (date) => {
23193 if (!date) {
23194 return "";
23195 }
23196 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
23197 };
23198 function ValidatedDateControl({
23199 field,
23200 validity,
23201 inputRefs,
23202 isTouched,
23203 setIsTouched,
23204 children
23205 }) {
23206 const { isValid: isValid2 } = field;
23207 const [customValidity, setCustomValidity] = (0, import_element62.useState)(void 0);
23208 const validateRefs = (0, import_element62.useCallback)(() => {
23209 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23210 for (const ref of refs) {
23211 const input = ref.current;
23212 if (input && !input.validity.valid) {
23213 setCustomValidity({
23214 type: "invalid",
23215 message: input.validationMessage
23216 });
23217 return;
23218 }
23219 }
23220 setCustomValidity(void 0);
23221 }, [inputRefs]);
23222 (0, import_element62.useEffect)(() => {
23223 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23224 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23225 for (const ref of refs) {
23226 const input = ref.current;
23227 if (input) {
23228 input.setCustomValidity(
23229 result?.type === "invalid" && result.message ? result.message : ""
23230 );
23231 }
23232 }
23233 }, [inputRefs, isValid2, validity]);
23234 (0, import_element62.useEffect)(() => {
23235 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23236 const handleInvalid = (event) => {
23237 event.preventDefault();
23238 setIsTouched(true);
23239 };
23240 for (const ref of refs) {
23241 ref.current?.addEventListener("invalid", handleInvalid);
23242 }
23243 return () => {
23244 for (const ref of refs) {
23245 ref.current?.removeEventListener("invalid", handleInvalid);
23246 }
23247 };
23248 }, [inputRefs, setIsTouched]);
23249 (0, import_element62.useEffect)(() => {
23250 if (!isTouched) {
23251 return;
23252 }
23253 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23254 if (result) {
23255 setCustomValidity(result);
23256 } else {
23257 validateRefs();
23258 }
23259 }, [isTouched, isValid2, validity, validateRefs]);
23260 (0, import_element62.useEffect)(() => {
23261 if (isTouched && customValidity?.message) {
23262 speak(customValidity.message);
23263 }
23264 }, [isTouched, customValidity?.message]);
23265 const onBlur = (event) => {
23266 if (isTouched) {
23267 return;
23268 }
23269 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
23270 setIsTouched(true);
23271 }
23272 };
23273 return /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("div", { onBlur, children: [
23274 children,
23275 customValidity && /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
23276 "p",
23277 {
23278 className: clsx_default(
23279 "components-validated-control__indicator",
23280 customValidity.type === "invalid" ? "is-invalid" : void 0
23281 ),
23282 children: [
23283 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23284 import_components32.Icon,
23285 {
23286 className: "components-validated-control__indicator-icon",
23287 icon: error_default,
23288 size: 16,
23289 fill: "currentColor"
23290 }
23291 ),
23292 customValidity.message
23293 ]
23294 }
23295 )
23296 ] });
23297 }
23298 function CalendarDateControl({
23299 data,
23300 field,
23301 onChange,
23302 hideLabelFromVision,
23303 markWhenOptional,
23304 validity
23305 }) {
23306 const {
23307 id,
23308 label,
23309 description,
23310 setValue,
23311 getValue,
23312 isValid: isValid2,
23313 format: fieldFormat
23314 } = field;
23315 const disabled2 = field.isDisabled({ item: data, field });
23316 const [selectedPresetId, setSelectedPresetId] = (0, import_element62.useState)(
23317 null
23318 );
23319 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23320 const fieldValue = getValue({ item: data });
23321 const value = typeof fieldValue === "string" ? fieldValue : void 0;
23322 const [calendarMonth, setCalendarMonth] = (0, import_element62.useState)(() => {
23323 const parsedDate = parseDate(value);
23324 return parsedDate || /* @__PURE__ */ new Date();
23325 });
23326 const [isTouched, setIsTouched] = (0, import_element62.useState)(false);
23327 const validityTargetRef = (0, import_element62.useRef)(null);
23328 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23329 const onChangeCallback = (0, import_element62.useCallback)(
23330 (newValue) => onChange(setValue({ item: data, value: newValue })),
23331 [data, onChange, setValue]
23332 );
23333 const onSelectDate = (0, import_element62.useCallback)(
23334 (newDate) => {
23335 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
23336 onChangeCallback(dateValue);
23337 setSelectedPresetId(null);
23338 setIsTouched(true);
23339 },
23340 [onChangeCallback]
23341 );
23342 const handlePresetClick = (0, import_element62.useCallback)(
23343 (preset) => {
23344 const presetDate = preset.getValue();
23345 const dateValue = formatDate(presetDate);
23346 setCalendarMonth(presetDate);
23347 onChangeCallback(dateValue);
23348 setSelectedPresetId(preset.id);
23349 setIsTouched(true);
23350 },
23351 [onChangeCallback]
23352 );
23353 const handleManualDateChange = (0, import_element62.useCallback)(
23354 (newValue) => {
23355 onChangeCallback(newValue);
23356 if (newValue) {
23357 const parsedDate = parseDate(newValue);
23358 if (parsedDate) {
23359 setCalendarMonth(parsedDate);
23360 }
23361 }
23362 setSelectedPresetId(null);
23363 setIsTouched(true);
23364 },
23365 [onChangeCallback]
23366 );
23367 const {
23368 timezone: { string: timezoneString }
23369 } = (0, import_date4.getSettings)();
23370 let displayLabel = label;
23371 if (isValid2?.required && !markWhenOptional) {
23372 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
23373 } else if (!isValid2?.required && markWhenOptional) {
23374 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
23375 }
23376 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23377 ValidatedDateControl,
23378 {
23379 field,
23380 validity,
23381 inputRefs: validityTargetRef,
23382 isTouched,
23383 setIsTouched,
23384 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23385 import_components32.BaseControl,
23386 {
23387 id,
23388 className: "dataviews-controls__date",
23389 label: displayLabel,
23390 help: description,
23391 hideLabelFromVision,
23392 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23393 /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
23394 Stack,
23395 {
23396 direction: "row",
23397 gap: "sm",
23398 wrap: "wrap",
23399 justify: "flex-start",
23400 children: [
23401 DATE_PRESETS.map((preset) => {
23402 const isSelected2 = selectedPresetId === preset.id;
23403 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23404 import_components32.Button,
23405 {
23406 className: "dataviews-controls__date-preset",
23407 variant: "tertiary",
23408 isPressed: isSelected2,
23409 size: "small",
23410 disabled: disabled2,
23411 accessibleWhenDisabled: true,
23412 onClick: () => handlePresetClick(preset),
23413 children: preset.label
23414 },
23415 preset.id
23416 );
23417 }),
23418 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23419 import_components32.Button,
23420 {
23421 className: "dataviews-controls__date-preset",
23422 variant: "tertiary",
23423 isPressed: !selectedPresetId,
23424 size: "small",
23425 disabled: !!selectedPresetId || disabled2,
23426 accessibleWhenDisabled: true,
23427 children: (0, import_i18n34.__)("Custom")
23428 }
23429 )
23430 ]
23431 }
23432 ),
23433 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23434 import_components32.__experimentalInputControl,
23435 {
23436 ref: validityTargetRef,
23437 type: "date",
23438 label: (0, import_i18n34.__)("Date"),
23439 hideLabelFromVision: true,
23440 value,
23441 onChange: handleManualDateChange,
23442 required: !!field.isValid?.required,
23443 disabled: disabled2,
23444 min: minConstraint,
23445 max: maxConstraint
23446 }
23447 ),
23448 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23449 DateCalendar2,
23450 {
23451 style: { width: "100%" },
23452 selected: value ? parseDate(value) || void 0 : void 0,
23453 onSelect: onSelectDate,
23454 month: calendarMonth,
23455 onMonthChange: setCalendarMonth,
23456 timeZone: timezoneString || void 0,
23457 weekStartsOn,
23458 disabled: disabled2 || disabledMatchers,
23459 disableNavigation: disabled2
23460 }
23461 )
23462 ] })
23463 }
23464 )
23465 }
23466 );
23467 }
23468 function CalendarDateRangeControl({
23469 data,
23470 field,
23471 onChange,
23472 hideLabelFromVision,
23473 markWhenOptional,
23474 validity
23475 }) {
23476 const {
23477 id,
23478 label,
23479 description,
23480 getValue,
23481 setValue,
23482 isValid: isValid2,
23483 format: fieldFormat
23484 } = field;
23485 const disabled2 = field.isDisabled({ item: data, field });
23486 let value;
23487 const fieldValue = getValue({ item: data });
23488 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
23489 value = fieldValue;
23490 }
23491 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23492 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23493 const onChangeCallback = (0, import_element62.useCallback)(
23494 (newValue) => {
23495 onChange(
23496 setValue({
23497 item: data,
23498 value: newValue
23499 })
23500 );
23501 },
23502 [data, onChange, setValue]
23503 );
23504 const [selectedPresetId, setSelectedPresetId] = (0, import_element62.useState)(
23505 null
23506 );
23507 const selectedRange = (0, import_element62.useMemo)(() => {
23508 if (!value) {
23509 return { from: void 0, to: void 0 };
23510 }
23511 const [from, to] = value;
23512 return {
23513 from: parseDate(from) || void 0,
23514 to: parseDate(to) || void 0
23515 };
23516 }, [value]);
23517 const [calendarMonth, setCalendarMonth] = (0, import_element62.useState)(() => {
23518 return selectedRange.from || /* @__PURE__ */ new Date();
23519 });
23520 const [isTouched, setIsTouched] = (0, import_element62.useState)(false);
23521 const fromInputRef = (0, import_element62.useRef)(null);
23522 const toInputRef = (0, import_element62.useRef)(null);
23523 const updateDateRange = (0, import_element62.useCallback)(
23524 (fromDate, toDate2) => {
23525 if (fromDate && toDate2) {
23526 onChangeCallback([
23527 formatDate(fromDate),
23528 formatDate(toDate2)
23529 ]);
23530 } else if (!fromDate && !toDate2) {
23531 onChangeCallback(void 0);
23532 }
23533 },
23534 [onChangeCallback]
23535 );
23536 const onSelectCalendarRange = (0, import_element62.useCallback)(
23537 (newRange) => {
23538 updateDateRange(newRange?.from, newRange?.to);
23539 setSelectedPresetId(null);
23540 setIsTouched(true);
23541 },
23542 [updateDateRange]
23543 );
23544 const handlePresetClick = (0, import_element62.useCallback)(
23545 (preset) => {
23546 const [startDate, endDate] = preset.getValue();
23547 setCalendarMonth(startDate);
23548 updateDateRange(startDate, endDate);
23549 setSelectedPresetId(preset.id);
23550 setIsTouched(true);
23551 },
23552 [updateDateRange]
23553 );
23554 const handleManualDateChange = (0, import_element62.useCallback)(
23555 (fromOrTo, newValue) => {
23556 const [currentFrom, currentTo] = value || [
23557 void 0,
23558 void 0
23559 ];
23560 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
23561 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
23562 updateDateRange(updatedFrom, updatedTo);
23563 if (newValue) {
23564 const parsedDate = parseDate(newValue);
23565 if (parsedDate) {
23566 setCalendarMonth(parsedDate);
23567 }
23568 }
23569 setSelectedPresetId(null);
23570 setIsTouched(true);
23571 },
23572 [value, updateDateRange]
23573 );
23574 const { timezone } = (0, import_date4.getSettings)();
23575 let displayLabel = label;
23576 if (field.isValid?.required && !markWhenOptional) {
23577 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
23578 } else if (!field.isValid?.required && markWhenOptional) {
23579 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
23580 }
23581 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23582 ValidatedDateControl,
23583 {
23584 field,
23585 validity,
23586 inputRefs: [fromInputRef, toInputRef],
23587 isTouched,
23588 setIsTouched,
23589 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23590 import_components32.BaseControl,
23591 {
23592 id,
23593 className: "dataviews-controls__date",
23594 label: displayLabel,
23595 help: description,
23596 hideLabelFromVision,
23597 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23598 /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
23599 Stack,
23600 {
23601 direction: "row",
23602 gap: "sm",
23603 wrap: "wrap",
23604 justify: "flex-start",
23605 children: [
23606 DATE_RANGE_PRESETS.map((preset) => {
23607 const isSelected2 = selectedPresetId === preset.id;
23608 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23609 import_components32.Button,
23610 {
23611 className: "dataviews-controls__date-preset",
23612 variant: "tertiary",
23613 isPressed: isSelected2,
23614 size: "small",
23615 disabled: disabled2,
23616 accessibleWhenDisabled: true,
23617 onClick: () => handlePresetClick(preset),
23618 children: preset.label
23619 },
23620 preset.id
23621 );
23622 }),
23623 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23624 import_components32.Button,
23625 {
23626 className: "dataviews-controls__date-preset",
23627 variant: "tertiary",
23628 isPressed: !selectedPresetId,
23629 size: "small",
23630 accessibleWhenDisabled: true,
23631 disabled: !!selectedPresetId || disabled2,
23632 children: (0, import_i18n34.__)("Custom")
23633 }
23634 )
23635 ]
23636 }
23637 ),
23638 /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
23639 Stack,
23640 {
23641 direction: "row",
23642 gap: "sm",
23643 justify: "space-between",
23644 className: "dataviews-controls__date-range-inputs",
23645 children: [
23646 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23647 import_components32.__experimentalInputControl,
23648 {
23649 ref: fromInputRef,
23650 type: "date",
23651 label: (0, import_i18n34.__)("From"),
23652 hideLabelFromVision: true,
23653 value: value?.[0],
23654 onChange: (newValue) => handleManualDateChange("from", newValue),
23655 required: !!field.isValid?.required,
23656 disabled: disabled2,
23657 min: minConstraint,
23658 max: maxConstraint
23659 }
23660 ),
23661 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23662 import_components32.__experimentalInputControl,
23663 {
23664 ref: toInputRef,
23665 type: "date",
23666 label: (0, import_i18n34.__)("To"),
23667 hideLabelFromVision: true,
23668 value: value?.[1],
23669 onChange: (newValue) => handleManualDateChange("to", newValue),
23670 required: !!field.isValid?.required,
23671 disabled: disabled2,
23672 min: minConstraint,
23673 max: maxConstraint
23674 }
23675 )
23676 ]
23677 }
23678 ),
23679 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23680 DateRangeCalendar,
23681 {
23682 style: { width: "100%" },
23683 selected: selectedRange,
23684 onSelect: onSelectCalendarRange,
23685 month: calendarMonth,
23686 onMonthChange: setCalendarMonth,
23687 timeZone: timezone.string || void 0,
23688 weekStartsOn,
23689 disabled: disabled2 || disabledMatchers
23690 }
23691 )
23692 ] })
23693 }
23694 )
23695 }
23696 );
23697 }
23698 function DateControl({
23699 data,
23700 field,
23701 onChange,
23702 hideLabelFromVision,
23703 markWhenOptional,
23704 operator,
23705 validity
23706 }) {
23707 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23708 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23709 RelativeDateControl,
23710 {
23711 className: "dataviews-controls__date",
23712 data,
23713 field,
23714 onChange,
23715 hideLabelFromVision,
23716 operator
23717 }
23718 );
23719 }
23720 if (operator === OPERATOR_BETWEEN) {
23721 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23722 CalendarDateRangeControl,
23723 {
23724 data,
23725 field,
23726 onChange,
23727 hideLabelFromVision,
23728 markWhenOptional,
23729 validity
23730 }
23731 );
23732 }
23733 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23734 CalendarDateControl,
23735 {
23736 data,
23737 field,
23738 onChange,
23739 hideLabelFromVision,
23740 markWhenOptional,
23741 validity
23742 }
23743 );
23744 }
23745
23746 // packages/dataviews/build-module/components/dataform-controls/select.mjs
23747 var import_components33 = __toESM(require_components(), 1);
23748 var import_element63 = __toESM(require_element(), 1);
23749 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
23750 var { ValidatedSelectControl } = unlock3(import_components33.privateApis);
23751 function Select({
23752 data,
23753 field,
23754 onChange,
23755 hideLabelFromVision,
23756 markWhenOptional,
23757 validity
23758 }) {
23759 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
23760 const disabled2 = field.isDisabled({ item: data, field });
23761 const isMultiple = type === "array";
23762 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
23763 const onChangeControl = (0, import_element63.useCallback)(
23764 (newValue) => onChange(setValue({ item: data, value: newValue })),
23765 [data, onChange, setValue]
23766 );
23767 const { elements, isLoading } = useElements({
23768 elements: field.elements,
23769 getElements: field.getElements
23770 });
23771 if (isLoading) {
23772 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_components33.Spinner, {});
23773 }
23774 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
23775 ValidatedSelectControl,
23776 {
23777 required: !!field.isValid?.required,
23778 markWhenOptional,
23779 customValidity: getCustomValidity(isValid2, validity),
23780 label,
23781 value,
23782 help: description,
23783 options: elements,
23784 onChange: onChangeControl,
23785 hideLabelFromVision,
23786 multiple: isMultiple,
23787 disabled: disabled2
23788 }
23789 );
23790 }
23791
23792 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
23793 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
23794 var ELEMENTS_THRESHOLD = 10;
23795 function AdaptiveSelect(props) {
23796 const { field } = props;
23797 const { elements } = useElements({
23798 elements: field.elements,
23799 getElements: field.getElements
23800 });
23801 if (elements.length >= ELEMENTS_THRESHOLD) {
23802 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Combobox3, { ...props });
23803 }
23804 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Select, { ...props });
23805 }
23806
23807 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23808 var import_components35 = __toESM(require_components(), 1);
23809
23810 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
23811 var import_components34 = __toESM(require_components(), 1);
23812 var import_element64 = __toESM(require_element(), 1);
23813 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
23814 var { ValidatedInputControl: ValidatedInputControl2 } = unlock3(import_components34.privateApis);
23815 function ValidatedText({
23816 data,
23817 field,
23818 onChange,
23819 hideLabelFromVision,
23820 markWhenOptional,
23821 type,
23822 prefix,
23823 suffix,
23824 validity
23825 }) {
23826 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
23827 const value = getValue({ item: data });
23828 const disabled2 = field.isDisabled({ item: data, field });
23829 const onChangeControl = (0, import_element64.useCallback)(
23830 (newValue) => onChange(
23831 setValue({
23832 item: data,
23833 value: newValue
23834 })
23835 ),
23836 [data, setValue, onChange]
23837 );
23838 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
23839 ValidatedInputControl2,
23840 {
23841 required: !!isValid2.required,
23842 markWhenOptional,
23843 customValidity: getCustomValidity(isValid2, validity),
23844 label,
23845 placeholder,
23846 value: value ?? "",
23847 help: description,
23848 onChange: onChangeControl,
23849 hideLabelFromVision,
23850 type,
23851 prefix,
23852 suffix,
23853 disabled: disabled2,
23854 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
23855 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
23856 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0
23857 }
23858 );
23859 }
23860
23861 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23862 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
23863 function Email({
23864 data,
23865 field,
23866 onChange,
23867 hideLabelFromVision,
23868 markWhenOptional,
23869 validity
23870 }) {
23871 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
23872 ValidatedText,
23873 {
23874 ...{
23875 data,
23876 field,
23877 onChange,
23878 hideLabelFromVision,
23879 markWhenOptional,
23880 validity,
23881 type: "email",
23882 prefix: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components35.Icon, { icon: envelope_default }) })
23883 }
23884 }
23885 );
23886 }
23887
23888 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
23889 var import_components36 = __toESM(require_components(), 1);
23890 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
23891 function Telephone({
23892 data,
23893 field,
23894 onChange,
23895 hideLabelFromVision,
23896 markWhenOptional,
23897 validity
23898 }) {
23899 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23900 ValidatedText,
23901 {
23902 ...{
23903 data,
23904 field,
23905 onChange,
23906 hideLabelFromVision,
23907 markWhenOptional,
23908 validity,
23909 type: "tel",
23910 prefix: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components36.Icon, { icon: mobile_default }) })
23911 }
23912 }
23913 );
23914 }
23915
23916 // packages/dataviews/build-module/components/dataform-controls/url.mjs
23917 var import_components37 = __toESM(require_components(), 1);
23918 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
23919 function Url({
23920 data,
23921 field,
23922 onChange,
23923 hideLabelFromVision,
23924 markWhenOptional,
23925 validity
23926 }) {
23927 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23928 ValidatedText,
23929 {
23930 ...{
23931 data,
23932 field,
23933 onChange,
23934 hideLabelFromVision,
23935 markWhenOptional,
23936 validity,
23937 type: "url",
23938 prefix: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(import_components37.Icon, { icon: link_default }) })
23939 }
23940 }
23941 );
23942 }
23943
23944 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
23945 var import_components38 = __toESM(require_components(), 1);
23946 var import_element65 = __toESM(require_element(), 1);
23947 var import_i18n35 = __toESM(require_i18n(), 1);
23948 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
23949 var { ValidatedNumberControl } = unlock3(import_components38.privateApis);
23950 function toNumberOrEmpty(value) {
23951 if (value === "" || value === void 0) {
23952 return "";
23953 }
23954 const number = Number(value);
23955 return Number.isFinite(number) ? number : "";
23956 }
23957 function BetweenControls({
23958 value,
23959 onChange,
23960 hideLabelFromVision,
23961 step
23962 }) {
23963 const [min2 = "", max2 = ""] = value;
23964 const onChangeMin = (0, import_element65.useCallback)(
23965 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
23966 [onChange, max2]
23967 );
23968 const onChangeMax = (0, import_element65.useCallback)(
23969 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
23970 [onChange, min2]
23971 );
23972 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23973 import_components38.BaseControl,
23974 {
23975 help: (0, import_i18n35.__)("The max. value must be greater than the min. value."),
23976 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(import_components38.Flex, { direction: "row", gap: 4, children: [
23977 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23978 import_components38.__experimentalNumberControl,
23979 {
23980 label: (0, import_i18n35.__)("Min."),
23981 value: min2,
23982 max: max2 ? Number(max2) - step : void 0,
23983 onChange: onChangeMin,
23984 hideLabelFromVision,
23985 step
23986 }
23987 ),
23988 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23989 import_components38.__experimentalNumberControl,
23990 {
23991 label: (0, import_i18n35.__)("Max."),
23992 value: max2,
23993 min: min2 ? Number(min2) + step : void 0,
23994 onChange: onChangeMax,
23995 hideLabelFromVision,
23996 step
23997 }
23998 )
23999 ] })
24000 }
24001 );
24002 }
24003 function ValidatedNumber({
24004 data,
24005 field,
24006 onChange,
24007 hideLabelFromVision,
24008 markWhenOptional,
24009 operator,
24010 validity
24011 }) {
24012 const decimals = field.format?.decimals ?? 0;
24013 const step = Math.pow(10, Math.abs(decimals) * -1);
24014 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24015 const value = getValue({ item: data }) ?? "";
24016 const disabled2 = field.isDisabled({ item: data, field });
24017 const onChangeControl = (0, import_element65.useCallback)(
24018 (newValue) => {
24019 onChange(
24020 setValue({
24021 item: data,
24022 // Do not convert an empty string or undefined to a number,
24023 // otherwise there's a mismatch between the UI control (empty)
24024 // and the data relied by onChange (0).
24025 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
24026 })
24027 );
24028 },
24029 [data, onChange, setValue]
24030 );
24031 const onChangeBetweenControls = (0, import_element65.useCallback)(
24032 (newValue) => {
24033 onChange(
24034 setValue({
24035 item: data,
24036 value: newValue
24037 })
24038 );
24039 },
24040 [data, onChange, setValue]
24041 );
24042 if (operator === OPERATOR_BETWEEN) {
24043 let valueBetween = ["", ""];
24044 if (Array.isArray(value) && value.length === 2 && value.every(
24045 (element) => typeof element === "number" || element === ""
24046 )) {
24047 valueBetween = value;
24048 }
24049 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24050 BetweenControls,
24051 {
24052 value: valueBetween,
24053 onChange: onChangeBetweenControls,
24054 hideLabelFromVision,
24055 step
24056 }
24057 );
24058 }
24059 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24060 ValidatedNumberControl,
24061 {
24062 required: !!isValid2.required,
24063 markWhenOptional,
24064 customValidity: getCustomValidity(isValid2, validity),
24065 label,
24066 help: description,
24067 value,
24068 onChange: onChangeControl,
24069 hideLabelFromVision,
24070 step,
24071 min: isValid2.min ? isValid2.min.constraint : void 0,
24072 max: isValid2.max ? isValid2.max.constraint : void 0,
24073 disabled: disabled2
24074 }
24075 );
24076 }
24077
24078 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
24079 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
24080 function Integer(props) {
24081 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(ValidatedNumber, { ...props });
24082 }
24083
24084 // packages/dataviews/build-module/components/dataform-controls/number.mjs
24085 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
24086 function Number2(props) {
24087 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(ValidatedNumber, { ...props });
24088 }
24089
24090 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
24091 var import_components39 = __toESM(require_components(), 1);
24092 var import_element66 = __toESM(require_element(), 1);
24093 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
24094 var { ValidatedRadioControl } = unlock3(import_components39.privateApis);
24095 function Radio({
24096 data,
24097 field,
24098 onChange,
24099 hideLabelFromVision,
24100 markWhenOptional,
24101 validity
24102 }) {
24103 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24104 const disabled2 = field.isDisabled({ item: data, field });
24105 const { elements, isLoading } = useElements({
24106 elements: field.elements,
24107 getElements: field.getElements
24108 });
24109 const value = getValue({ item: data });
24110 const onChangeControl = (0, import_element66.useCallback)(
24111 (newValue) => onChange(setValue({ item: data, value: newValue })),
24112 [data, onChange, setValue]
24113 );
24114 if (isLoading) {
24115 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_components39.Spinner, {});
24116 }
24117 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
24118 ValidatedRadioControl,
24119 {
24120 required: !!field.isValid?.required,
24121 markWhenOptional,
24122 customValidity: getCustomValidity(isValid2, validity),
24123 label,
24124 help: description,
24125 onChange: onChangeControl,
24126 options: elements,
24127 selected: value,
24128 hideLabelFromVision,
24129 disabled: disabled2
24130 }
24131 );
24132 }
24133
24134 // packages/dataviews/build-module/components/dataform-controls/text.mjs
24135 var import_element67 = __toESM(require_element(), 1);
24136 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
24137 function Text3({
24138 data,
24139 field,
24140 onChange,
24141 hideLabelFromVision,
24142 markWhenOptional,
24143 config,
24144 validity
24145 }) {
24146 const { prefix, suffix } = config || {};
24147 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24148 ValidatedText,
24149 {
24150 ...{
24151 data,
24152 field,
24153 onChange,
24154 hideLabelFromVision,
24155 markWhenOptional,
24156 validity,
24157 prefix: prefix ? (0, import_element67.createElement)(prefix) : void 0,
24158 suffix: suffix ? (0, import_element67.createElement)(suffix) : void 0
24159 }
24160 }
24161 );
24162 }
24163
24164 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
24165 var import_components40 = __toESM(require_components(), 1);
24166 var import_element68 = __toESM(require_element(), 1);
24167 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
24168 var { ValidatedToggleControl } = unlock3(import_components40.privateApis);
24169 function Toggle({
24170 field,
24171 onChange,
24172 data,
24173 hideLabelFromVision,
24174 markWhenOptional,
24175 validity
24176 }) {
24177 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24178 const disabled2 = field.isDisabled({ item: data, field });
24179 const onChangeControl = (0, import_element68.useCallback)(() => {
24180 onChange(
24181 setValue({ item: data, value: !getValue({ item: data }) })
24182 );
24183 }, [onChange, setValue, data, getValue]);
24184 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24185 ValidatedToggleControl,
24186 {
24187 required: !!isValid2.required,
24188 markWhenOptional,
24189 customValidity: getCustomValidity(isValid2, validity),
24190 hidden: hideLabelFromVision,
24191 label,
24192 help: description,
24193 checked: getValue({ item: data }),
24194 onChange: onChangeControl,
24195 disabled: disabled2
24196 }
24197 );
24198 }
24199
24200 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
24201 var import_components41 = __toESM(require_components(), 1);
24202 var import_element69 = __toESM(require_element(), 1);
24203 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
24204 var { ValidatedTextareaControl } = unlock3(import_components41.privateApis);
24205 function Textarea({
24206 data,
24207 field,
24208 onChange,
24209 hideLabelFromVision,
24210 markWhenOptional,
24211 config,
24212 validity
24213 }) {
24214 const { rows = 4 } = config || {};
24215 const disabled2 = field.isDisabled({ item: data, field });
24216 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24217 const value = field.getValue({ item: data });
24218 const onChangeControl = (0, import_element69.useCallback)(
24219 (newValue) => onChange(setValue({ item: data, value: newValue })),
24220 [data, onChange, setValue]
24221 );
24222 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
24223 ValidatedTextareaControl,
24224 {
24225 required: !!isValid2.required,
24226 markWhenOptional,
24227 customValidity: getCustomValidity(isValid2, validity),
24228 label,
24229 placeholder,
24230 value: value ?? "",
24231 help: description,
24232 onChange: onChangeControl,
24233 rows,
24234 disabled: disabled2,
24235 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
24236 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
24237 hideLabelFromVision
24238 }
24239 );
24240 }
24241
24242 // packages/dataviews/build-module/components/dataform-controls/richtext/index.mjs
24243 var import_element71 = __toESM(require_element(), 1);
24244
24245 // packages/dataviews/build-module/components/dataform-controls/richtext/control.mjs
24246 var import_components42 = __toESM(require_components(), 1);
24247 var import_compose12 = __toESM(require_compose(), 1);
24248 var import_element70 = __toESM(require_element(), 1);
24249 var import_rich_text2 = __toESM(require_rich_text(), 1);
24250
24251 // packages/dataviews/build-module/components/dataform-controls/richtext/utils.mjs
24252 var EMPTY_ARRAY6 = [];
24253 function getAllowedFormats({
24254 allowedFormats,
24255 disableFormats
24256 }) {
24257 if (disableFormats) {
24258 return EMPTY_ARRAY6;
24259 }
24260 return allowedFormats;
24261 }
24262
24263 // packages/dataviews/build-module/components/dataform-controls/richtext/format-edit.mjs
24264 var import_rich_text = __toESM(require_rich_text(), 1);
24265 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
24266 var import_react24 = __toESM(require_react(), 1);
24267 var EMPTY_CONTEXT = {};
24268 function Edit({
24269 onChange,
24270 onFocus,
24271 value,
24272 forwardedRef,
24273 settings,
24274 isVisible: isVisible2
24275 }) {
24276 const { name, edit: EditFunction } = settings;
24277 if (!EditFunction) {
24278 return null;
24279 }
24280 const activeFormat = (0, import_rich_text.getActiveFormat)(value, name);
24281 const isActive = activeFormat !== void 0;
24282 const activeObject = (0, import_rich_text.getActiveObject)(value);
24283 const isObjectActive = activeObject !== void 0 && activeObject.type === name;
24284 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24285 EditFunction,
24286 {
24287 isActive,
24288 isVisible: isVisible2,
24289 activeAttributes: isActive ? activeFormat.attributes || {} : {},
24290 isObjectActive,
24291 activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {},
24292 value,
24293 onChange,
24294 onFocus,
24295 contentRef: forwardedRef,
24296 context: EMPTY_CONTEXT
24297 },
24298 name
24299 );
24300 }
24301 function FormatEdit({
24302 formatTypes,
24303 ...props
24304 }) {
24305 return formatTypes.map((settings) => /* @__PURE__ */ (0, import_react24.createElement)(Edit, { settings, ...props, key: settings.name }));
24306 }
24307
24308 // packages/dataviews/build-module/components/dataform-controls/richtext/control.mjs
24309 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
24310 var {
24311 ValidatedContentEditableControl: RichTextControlShell,
24312 withIgnoreIMEEvents
24313 } = unlock3(import_components42.privateApis);
24314 var {
24315 useRichText,
24316 KeyboardShortcutContext,
24317 InputEventContext,
24318 shortcutsListener,
24319 inputEventsListener
24320 } = unlock3(import_rich_text2.privateApis);
24321 var EMPTY_COMPLETERS = [];
24322 function RichTextControl({
24323 label,
24324 value: attrValue,
24325 onChange,
24326 placeholder,
24327 id,
24328 clientId,
24329 className,
24330 hideLabelFromVision,
24331 help,
24332 disabled: disabled2,
24333 required,
24334 markWhenOptional,
24335 customValidity,
24336 allowedFormats,
24337 disableFormats,
24338 withoutInteractiveFormatting,
24339 preserveWhiteSpace,
24340 disableLineBreaks,
24341 focusOnMount,
24342 completers = EMPTY_COMPLETERS
24343 }) {
24344 const [selection, setSelection] = (0, import_element70.useState)({
24345 start: void 0,
24346 end: void 0
24347 });
24348 const [isSelected2, setIsSelected] = (0, import_element70.useState)(false);
24349 const anchorRef = (0, import_element70.useRef)(void 0);
24350 const inputEvents = (0, import_element70.useRef)(/* @__PURE__ */ new Set());
24351 const keyboardShortcuts = (0, import_element70.useRef)(
24352 /* @__PURE__ */ new Set()
24353 );
24354 const focusOutside = (0, import_compose12.__experimentalUseFocusOutside)(() => setIsSelected(false));
24355 const adjustedAllowedFormats = getAllowedFormats({
24356 allowedFormats,
24357 disableFormats
24358 });
24359 const {
24360 value,
24361 onChange: onRichTextChange,
24362 ref: richTextRef,
24363 formatTypes,
24364 getValue
24365 } = useRichText({
24366 value: attrValue,
24367 onChange,
24368 selectionStart: selection.start,
24369 selectionEnd: selection.end,
24370 onSelectionChange: (start, end) => setSelection({ start, end }),
24371 __unstableIsSelected: isSelected2,
24372 preserveWhiteSpace: !!preserveWhiteSpace,
24373 placeholder,
24374 __unstableDisableFormats: disableFormats,
24375 allowedFormats: adjustedAllowedFormats,
24376 withoutInteractiveFormatting,
24377 __unstableFormatTypeHandlerContext: (0, import_element70.useMemo)(
24378 () => ({
24379 richTextIdentifier: id,
24380 blockClientId: clientId
24381 }),
24382 [id, clientId]
24383 )
24384 });
24385 function onFocus() {
24386 anchorRef.current?.focus();
24387 }
24388 const eventListenersPropsRef = (0, import_element70.useRef)({
24389 keyboardShortcuts,
24390 inputEvents
24391 });
24392 const inputRulePropsRef = (0, import_element70.useRef)({
24393 formatTypes,
24394 getValue,
24395 onChange: onRichTextChange
24396 });
24397 (0, import_element70.useInsertionEffect)(() => {
24398 inputRulePropsRef.current = {
24399 formatTypes,
24400 getValue,
24401 onChange: onRichTextChange
24402 };
24403 });
24404 const enterRef = (0, import_compose12.useRefEffect)(
24405 (element) => {
24406 if (disabled2) {
24407 return;
24408 }
24409 const onKeyDown = withIgnoreIMEEvents((event) => {
24410 if (event.key !== "Enter" || event.defaultPrevented || event.metaKey || event.ctrlKey) {
24411 return;
24412 }
24413 event.preventDefault();
24414 if (disableLineBreaks) {
24415 return;
24416 }
24417 const { getValue: getCurrentValue2, onChange: handleChange } = inputRulePropsRef.current;
24418 const current = getCurrentValue2();
24419 handleChange(
24420 (0, import_rich_text2.insert)(
24421 current,
24422 "\n",
24423 current.start ?? current.text.length,
24424 current.end ?? current.text.length
24425 )
24426 );
24427 });
24428 element.addEventListener("keydown", onKeyDown);
24429 return () => element.removeEventListener("keydown", onKeyDown);
24430 },
24431 [disableLineBreaks, disabled2]
24432 );
24433 const eventListenersRef = (0, import_compose12.useRefEffect)(
24434 (element) => {
24435 if (!isSelected2) {
24436 return;
24437 }
24438 const cleanupShortcuts = shortcutsListener(
24439 eventListenersPropsRef
24440 )(element);
24441 const cleanupInputEvents = inputEventsListener(
24442 eventListenersPropsRef
24443 )(element);
24444 function onFormatInput(event) {
24445 if (event.inputType !== "insertText" && event.type !== "compositionend") {
24446 return;
24447 }
24448 const {
24449 formatTypes: types,
24450 getValue: getCurrentValue2,
24451 onChange: handleChange
24452 } = inputRulePropsRef.current;
24453 const current = getCurrentValue2();
24454 const transformed = types.reduce(
24455 (accumulator, {
24456 __unstableInputRule
24457 }) => __unstableInputRule ? __unstableInputRule(accumulator) : accumulator,
24458 current
24459 );
24460 if (transformed !== current) {
24461 handleChange({
24462 ...transformed,
24463 activeFormats: current.activeFormats
24464 });
24465 }
24466 }
24467 element.addEventListener("input", onFormatInput);
24468 element.addEventListener("compositionend", onFormatInput);
24469 return () => {
24470 cleanupShortcuts();
24471 cleanupInputEvents();
24472 element.removeEventListener("input", onFormatInput);
24473 element.removeEventListener("compositionend", onFormatInput);
24474 };
24475 },
24476 [isSelected2]
24477 );
24478 const { ref: autocompleteRef, ...autocompleteProps } = (0, import_components42.__unstableUseAutocompleteProps)(
24479 {
24480 completers,
24481 record: value,
24482 onChange: onRichTextChange,
24483 // This control's completers insert their completion into the value;
24484 // none replace the whole value, so the required `onReplace` is a
24485 // no-op here.
24486 onReplace: () => {
24487 }
24488 }
24489 );
24490 const focusOnMountRef = (0, import_compose12.useRefEffect)(
24491 (element) => {
24492 if (focusOnMount && !disabled2) {
24493 element.focus();
24494 }
24495 },
24496 [focusOnMount, disabled2]
24497 );
24498 const editableRef = (0, import_compose12.useMergeRefs)([
24499 richTextRef,
24500 anchorRef,
24501 eventListenersRef,
24502 enterRef,
24503 focusOnMountRef,
24504 autocompleteRef
24505 ]);
24506 return (
24507 // Focus boundary for the field's selection: `onFocus` selects on entry;
24508 // the spread `useFocusOutside` handlers deselect once focus leaves.
24509 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24510 "div",
24511 {
24512 ...focusOutside,
24513 onFocus: (event) => {
24514 setIsSelected(true);
24515 focusOutside.onFocus(event);
24516 },
24517 children: /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(import_components42.SlotFillProvider, { children: [
24518 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24519 RichTextControlShell,
24520 {
24521 label,
24522 id,
24523 className: clsx_default(
24524 "dataviews-controls__richtext",
24525 className
24526 ),
24527 placeholder,
24528 hideLabelFromVision,
24529 help,
24530 disabled: disabled2,
24531 required,
24532 markWhenOptional,
24533 customValidity,
24534 value: value.text,
24535 "aria-multiline": !disableLineBreaks,
24536 ...autocompleteProps,
24537 ref: editableRef
24538 }
24539 ),
24540 isSelected2 && !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24541 KeyboardShortcutContext.Provider,
24542 {
24543 value: keyboardShortcuts,
24544 children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(InputEventContext.Provider, { value: inputEvents, children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24545 FormatEdit,
24546 {
24547 value,
24548 onChange: onRichTextChange,
24549 onFocus,
24550 formatTypes,
24551 forwardedRef: anchorRef,
24552 isVisible: true
24553 }
24554 ) })
24555 }
24556 )
24557 ] })
24558 }
24559 )
24560 );
24561 }
24562
24563 // packages/dataviews/build-module/components/dataform-controls/richtext/index.mjs
24564 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
24565 function RichText({
24566 data,
24567 field,
24568 onChange,
24569 hideLabelFromVision,
24570 markWhenOptional,
24571 config,
24572 validity
24573 }) {
24574 const {
24575 className,
24576 clientId,
24577 allowedFormats,
24578 disableFormats,
24579 withoutInteractiveFormatting,
24580 preserveWhiteSpace,
24581 disableLineBreaks
24582 } = config || {};
24583 const disabled2 = field.isDisabled({ item: data, field });
24584 const { label, placeholder, description, id, setValue, isValid: isValid2 } = field;
24585 const value = field.getValue({ item: data }) ?? "";
24586 const onChangeControl = (0, import_element71.useCallback)(
24587 (newValue) => onChange(setValue({ item: data, value: newValue })),
24588 [data, onChange, setValue]
24589 );
24590 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
24591 RichTextControl,
24592 {
24593 label,
24594 value,
24595 onChange: onChangeControl,
24596 placeholder,
24597 id,
24598 hideLabelFromVision,
24599 help: description,
24600 disabled: disabled2,
24601 required: !!isValid2.required,
24602 markWhenOptional,
24603 customValidity: getCustomValidity(isValid2, validity),
24604 className,
24605 clientId,
24606 allowedFormats,
24607 disableFormats,
24608 withoutInteractiveFormatting,
24609 preserveWhiteSpace,
24610 disableLineBreaks
24611 }
24612 );
24613 }
24614
24615 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
24616 var import_components43 = __toESM(require_components(), 1);
24617 var import_element72 = __toESM(require_element(), 1);
24618 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
24619 var { ValidatedToggleGroupControl } = unlock3(import_components43.privateApis);
24620 function ToggleGroup({
24621 data,
24622 field,
24623 onChange,
24624 hideLabelFromVision,
24625 markWhenOptional,
24626 validity
24627 }) {
24628 const { getValue, setValue, isValid: isValid2 } = field;
24629 const disabled2 = field.isDisabled({ item: data, field });
24630 const value = getValue({ item: data });
24631 const onChangeControl = (0, import_element72.useCallback)(
24632 (newValue) => onChange(setValue({ item: data, value: newValue })),
24633 [data, onChange, setValue]
24634 );
24635 const { elements, isLoading } = useElements({
24636 elements: field.elements,
24637 getElements: field.getElements
24638 });
24639 if (isLoading) {
24640 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components43.Spinner, {});
24641 }
24642 if (elements.length === 0) {
24643 return null;
24644 }
24645 const selectedOption = elements.find((el) => el.value === value);
24646 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
24647 ValidatedToggleGroupControl,
24648 {
24649 required: !!field.isValid?.required,
24650 markWhenOptional,
24651 customValidity: getCustomValidity(isValid2, validity),
24652 isBlock: true,
24653 label: field.label,
24654 help: selectedOption?.description || field.description,
24655 onChange: onChangeControl,
24656 value,
24657 hideLabelFromVision,
24658 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
24659 import_components43.__experimentalToggleGroupControlOption,
24660 {
24661 label: el.label,
24662 value: el.value,
24663 disabled: disabled2
24664 },
24665 el.value
24666 ))
24667 }
24668 );
24669 }
24670
24671 // packages/dataviews/build-module/components/dataform-controls/array.mjs
24672 var import_components44 = __toESM(require_components(), 1);
24673 var import_element73 = __toESM(require_element(), 1);
24674 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
24675 var { ValidatedFormTokenField } = unlock3(import_components44.privateApis);
24676 function ArrayControl({
24677 data,
24678 field,
24679 onChange,
24680 hideLabelFromVision,
24681 markWhenOptional,
24682 validity
24683 }) {
24684 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
24685 const value = getValue({ item: data });
24686 const disabled2 = field.isDisabled({ item: data, field });
24687 const { elements, isLoading } = useElements({
24688 elements: field.elements,
24689 getElements: field.getElements
24690 });
24691 const arrayValueAsElements = (0, import_element73.useMemo)(
24692 () => Array.isArray(value) ? value.map((token) => {
24693 const element = elements?.find(
24694 (suggestion) => suggestion.value === token
24695 );
24696 return element || { value: token, label: token };
24697 }) : [],
24698 [value, elements]
24699 );
24700 const onChangeControl = (0, import_element73.useCallback)(
24701 (tokens) => {
24702 const valueTokens = tokens.map((token) => {
24703 if (typeof token === "object" && "value" in token) {
24704 return token.value;
24705 }
24706 return token;
24707 });
24708 onChange(setValue({ item: data, value: valueTokens }));
24709 },
24710 [onChange, setValue, data]
24711 );
24712 if (isLoading) {
24713 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_components44.Spinner, {});
24714 }
24715 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
24716 ValidatedFormTokenField,
24717 {
24718 required: !!isValid2?.required,
24719 markWhenOptional,
24720 customValidity: getCustomValidity(isValid2, validity),
24721 label: hideLabelFromVision ? void 0 : label,
24722 value: arrayValueAsElements,
24723 onChange: onChangeControl,
24724 placeholder,
24725 suggestions: elements?.map((element) => element.value),
24726 disabled: disabled2,
24727 __experimentalValidateInput: (token) => {
24728 if (field.isValid?.elements && elements) {
24729 return elements.some(
24730 (element) => element.value === token || element.label === token
24731 );
24732 }
24733 return true;
24734 },
24735 __experimentalExpandOnFocus: elements && elements.length > 0,
24736 help: description ?? (field.isValid?.elements ? "" : void 0),
24737 displayTransform: (token) => {
24738 if (typeof token === "object" && "label" in token) {
24739 return token.label;
24740 }
24741 if (typeof token === "string" && elements) {
24742 const element = elements.find(
24743 (el) => el.value === token
24744 );
24745 return element?.label || token;
24746 }
24747 return token;
24748 },
24749 __experimentalRenderItem: ({ item }) => {
24750 if (typeof item === "string" && elements) {
24751 const element = elements.find(
24752 (el) => el.value === item
24753 );
24754 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("span", { children: element?.label || item });
24755 }
24756 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("span", { children: item });
24757 }
24758 }
24759 );
24760 }
24761
24762 // node_modules/colord/index.mjs
24763 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
24764 var t = function(r3) {
24765 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
24766 };
24767 var n = function(r3, t2, n2) {
24768 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
24769 };
24770 var e = function(r3, t2, n2) {
24771 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
24772 };
24773 var u = function(r3) {
24774 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
24775 };
24776 var a = function(r3) {
24777 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
24778 };
24779 var o = function(r3) {
24780 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
24781 };
24782 var i = /^#([0-9a-f]{3,8})$/i;
24783 var s = function(r3) {
24784 var t2 = r3.toString(16);
24785 return t2.length < 2 ? "0" + t2 : t2;
24786 };
24787 var h = function(r3) {
24788 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;
24789 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
24790 };
24791 var b = function(r3) {
24792 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
24793 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
24794 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;
24795 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 };
24796 };
24797 var g = function(r3) {
24798 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
24799 };
24800 var d = function(r3) {
24801 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
24802 };
24803 var f = function(r3) {
24804 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 }));
24805 var t2, n2, e2;
24806 };
24807 var c = function(r3) {
24808 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 };
24809 var t2, n2, e2, u2;
24810 };
24811 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24812 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24813 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24814 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24815 var y = { string: [[function(r3) {
24816 var t2 = i.exec(r3);
24817 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;
24818 }, "hex"], [function(r3) {
24819 var t2 = v.exec(r3) || m.exec(r3);
24820 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;
24821 }, "rgb"], [function(t2) {
24822 var n2 = l.exec(t2) || p.exec(t2);
24823 if (!n2) return null;
24824 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) });
24825 return f(a2);
24826 }, "hsl"]], object: [[function(r3) {
24827 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
24828 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
24829 }, "rgb"], [function(r3) {
24830 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
24831 if (!t(n2) || !t(e2) || !t(u2)) return null;
24832 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
24833 return f(i2);
24834 }, "hsl"], [function(r3) {
24835 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
24836 if (!t(n2) || !t(a2) || !t(o2)) return null;
24837 var h2 = (function(r4) {
24838 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
24839 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
24840 return b(h2);
24841 }, "hsv"]] };
24842 var N = function(r3, t2) {
24843 for (var n2 = 0; n2 < t2.length; n2++) {
24844 var e2 = t2[n2][0](r3);
24845 if (e2) return [e2, t2[n2][1]];
24846 }
24847 return [null, void 0];
24848 };
24849 var x = function(r3) {
24850 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
24851 };
24852 var M = function(r3, t2) {
24853 var n2 = c(r3);
24854 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
24855 };
24856 var H = function(r3) {
24857 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
24858 };
24859 var $ = function(r3, t2) {
24860 var n2 = c(r3);
24861 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
24862 };
24863 var j = (function() {
24864 function r3(r4) {
24865 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
24866 }
24867 return r3.prototype.isValid = function() {
24868 return null !== this.parsed;
24869 }, r3.prototype.brightness = function() {
24870 return n(H(this.rgba), 2);
24871 }, r3.prototype.isDark = function() {
24872 return H(this.rgba) < 0.5;
24873 }, r3.prototype.isLight = function() {
24874 return H(this.rgba) >= 0.5;
24875 }, r3.prototype.toHex = function() {
24876 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;
24877 var r4, t2, e2, u2, a2, i2;
24878 }, r3.prototype.toRgb = function() {
24879 return o(this.rgba);
24880 }, r3.prototype.toRgbString = function() {
24881 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 + ")";
24882 var r4, t2, n2, e2, u2;
24883 }, r3.prototype.toHsl = function() {
24884 return d(c(this.rgba));
24885 }, r3.prototype.toHslString = function() {
24886 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 + "%)";
24887 var r4, t2, n2, e2, u2;
24888 }, r3.prototype.toHsv = function() {
24889 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
24890 var r4;
24891 }, r3.prototype.invert = function() {
24892 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
24893 var r4;
24894 }, r3.prototype.saturate = function(r4) {
24895 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
24896 }, r3.prototype.desaturate = function(r4) {
24897 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
24898 }, r3.prototype.grayscale = function() {
24899 return w(M(this.rgba, -1));
24900 }, r3.prototype.lighten = function(r4) {
24901 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
24902 }, r3.prototype.darken = function(r4) {
24903 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
24904 }, r3.prototype.rotate = function(r4) {
24905 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
24906 }, r3.prototype.alpha = function(r4) {
24907 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
24908 var t2;
24909 }, r3.prototype.hue = function(r4) {
24910 var t2 = c(this.rgba);
24911 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
24912 }, r3.prototype.isEqual = function(r4) {
24913 return this.toHex() === w(r4).toHex();
24914 }, r3;
24915 })();
24916 var w = function(r3) {
24917 return r3 instanceof j ? r3 : new j(r3);
24918 };
24919
24920 // packages/dataviews/build-module/components/dataform-controls/color.mjs
24921 var import_components45 = __toESM(require_components(), 1);
24922 var import_element74 = __toESM(require_element(), 1);
24923 var import_i18n36 = __toESM(require_i18n(), 1);
24924 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
24925 var { ValidatedInputControl: ValidatedInputControl3 } = unlock3(import_components45.privateApis);
24926 var ColorPickerDropdown = ({
24927 color,
24928 onColorChange,
24929 disabled: disabled2
24930 }) => {
24931 const validColor = color && w(color).isValid() ? color : "#ffffff";
24932 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24933 import_components45.Dropdown,
24934 {
24935 className: "dataviews-controls__color-picker-dropdown",
24936 popoverProps: { resize: false },
24937 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24938 import_components45.Button,
24939 {
24940 onClick: onToggle,
24941 "aria-label": (0, import_i18n36.__)("Open color picker"),
24942 size: "small",
24943 disabled: disabled2,
24944 accessibleWhenDisabled: true,
24945 icon: () => /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(import_components45.ColorIndicator, { colorValue: validColor })
24946 }
24947 ),
24948 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(import_components45.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24949 import_components45.ColorPicker,
24950 {
24951 color: validColor,
24952 onChange: onColorChange,
24953 enableAlpha: true
24954 }
24955 ) })
24956 }
24957 );
24958 };
24959 function Color({
24960 data,
24961 field,
24962 onChange,
24963 hideLabelFromVision,
24964 markWhenOptional,
24965 validity
24966 }) {
24967 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24968 const disabled2 = field.isDisabled({ item: data, field });
24969 const value = field.getValue({ item: data }) || "";
24970 const handleColorChange = (0, import_element74.useCallback)(
24971 (newColor) => {
24972 onChange(setValue({ item: data, value: newColor }));
24973 },
24974 [data, onChange, setValue]
24975 );
24976 const handleInputChange = (0, import_element74.useCallback)(
24977 (newValue) => {
24978 onChange(setValue({ item: data, value: newValue || "" }));
24979 },
24980 [data, onChange, setValue]
24981 );
24982 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24983 ValidatedInputControl3,
24984 {
24985 required: !!field.isValid?.required,
24986 markWhenOptional,
24987 customValidity: getCustomValidity(isValid2, validity),
24988 label,
24989 placeholder,
24990 value,
24991 help: description,
24992 onChange: handleInputChange,
24993 hideLabelFromVision,
24994 type: "text",
24995 disabled: disabled2,
24996 prefix: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(import_components45.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24997 ColorPickerDropdown,
24998 {
24999 color: value,
25000 onColorChange: handleColorChange,
25001 disabled: disabled2
25002 }
25003 ) })
25004 }
25005 );
25006 }
25007
25008 // packages/dataviews/build-module/components/dataform-controls/password.mjs
25009 var import_components46 = __toESM(require_components(), 1);
25010 var import_element75 = __toESM(require_element(), 1);
25011 var import_i18n37 = __toESM(require_i18n(), 1);
25012 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
25013 function Password({
25014 data,
25015 field,
25016 onChange,
25017 hideLabelFromVision,
25018 markWhenOptional,
25019 validity
25020 }) {
25021 const [isVisible2, setIsVisible] = (0, import_element75.useState)(false);
25022 const disabled2 = field.isDisabled({ item: data, field });
25023 const toggleVisibility = (0, import_element75.useCallback)(() => {
25024 setIsVisible((prev) => !prev);
25025 }, []);
25026 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25027 ValidatedText,
25028 {
25029 ...{
25030 data,
25031 field,
25032 onChange,
25033 hideLabelFromVision,
25034 markWhenOptional,
25035 validity,
25036 type: isVisible2 ? "text" : "password",
25037 suffix: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_components46.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25038 import_components46.Button,
25039 {
25040 icon: isVisible2 ? unseen_default : seen_default,
25041 onClick: toggleVisibility,
25042 size: "small",
25043 label: isVisible2 ? (0, import_i18n37.__)("Hide password") : (0, import_i18n37.__)("Show password"),
25044 disabled: disabled2,
25045 accessibleWhenDisabled: true
25046 }
25047 ) })
25048 }
25049 }
25050 );
25051 }
25052
25053 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
25054 function hasElements(field) {
25055 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
25056 }
25057
25058 // packages/dataviews/build-module/components/dataform-controls/index.mjs
25059 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
25060 var FORM_CONTROLS = {
25061 adaptiveSelect: AdaptiveSelect,
25062 array: ArrayControl,
25063 checkbox: Checkbox,
25064 color: Color,
25065 combobox: Combobox3,
25066 datetime: DateTime,
25067 date: DateControl,
25068 email: Email,
25069 telephone: Telephone,
25070 url: Url,
25071 integer: Integer,
25072 number: Number2,
25073 password: Password,
25074 radio: Radio,
25075 select: Select,
25076 text: Text3,
25077 toggle: Toggle,
25078 textarea: Textarea,
25079 richtext: RichText,
25080 toggleGroup: ToggleGroup
25081 };
25082 function isEditConfig(value) {
25083 return value && typeof value === "object" && typeof value.control === "string";
25084 }
25085 function createConfiguredControl(config) {
25086 const { control, ...controlConfig } = config;
25087 const BaseControlType = getControlByType(control);
25088 if (BaseControlType === null) {
25089 return null;
25090 }
25091 return function ConfiguredControl(props) {
25092 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(BaseControlType, { ...props, config: controlConfig });
25093 };
25094 }
25095 function getControl(field, fallback) {
25096 if (typeof field.Edit === "function") {
25097 return field.Edit;
25098 }
25099 if (typeof field.Edit === "string") {
25100 return getControlByType(field.Edit);
25101 }
25102 if (isEditConfig(field.Edit)) {
25103 return createConfiguredControl(field.Edit);
25104 }
25105 if (hasElements(field) && field.type !== "array") {
25106 return getControlByType("adaptiveSelect");
25107 }
25108 if (fallback === null) {
25109 return null;
25110 }
25111 return getControlByType(fallback);
25112 }
25113 function getControlByType(type) {
25114 if (Object.keys(FORM_CONTROLS).includes(type)) {
25115 return FORM_CONTROLS[type];
25116 }
25117 return null;
25118 }
25119
25120 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
25121 function getFilterBy(field, defaultOperators, validOperators) {
25122 if (field.filterBy === false) {
25123 return false;
25124 }
25125 const operators = field.filterBy?.operators?.filter(
25126 (op) => validOperators.includes(op)
25127 ) ?? defaultOperators;
25128 if (operators.length === 0) {
25129 return false;
25130 }
25131 return {
25132 isPrimary: !!field.filterBy?.isPrimary,
25133 operators
25134 };
25135 }
25136 var get_filter_by_default = getFilterBy;
25137
25138 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
25139 var getValueFromId = (id) => ({ item }) => {
25140 const path = id.split(".");
25141 let value = item;
25142 for (const segment of path) {
25143 if (value.hasOwnProperty(segment)) {
25144 value = value[segment];
25145 } else {
25146 value = void 0;
25147 }
25148 }
25149 return value;
25150 };
25151 var get_value_from_id_default = getValueFromId;
25152
25153 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
25154 var setValueFromId = (id) => ({ value }) => {
25155 const path = id.split(".");
25156 const result = {};
25157 let current = result;
25158 for (const segment of path.slice(0, -1)) {
25159 current[segment] = {};
25160 current = current[segment];
25161 }
25162 current[path.at(-1)] = value;
25163 return result;
25164 };
25165 var set_value_from_id_default = setValueFromId;
25166
25167 // packages/dataviews/build-module/field-types/email.mjs
25168 var import_i18n38 = __toESM(require_i18n(), 1);
25169
25170 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
25171 function RenderFromElements({
25172 item,
25173 field
25174 }) {
25175 const { elements, isLoading } = useElements({
25176 elements: field.elements,
25177 getElements: field.getElements
25178 });
25179 const value = field.getValue({ item });
25180 if (isLoading) {
25181 return value;
25182 }
25183 if (elements.length === 0) {
25184 return value;
25185 }
25186 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
25187 }
25188
25189 // packages/dataviews/build-module/field-types/utils/render-default.mjs
25190 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
25191 function render({
25192 item,
25193 field
25194 }) {
25195 if (field.hasElements) {
25196 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(RenderFromElements, { item, field });
25197 }
25198 return field.getValueFormatted({ item, field });
25199 }
25200
25201 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
25202 var sort_text_default = (a2, b2, direction) => {
25203 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
25204 };
25205
25206 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
25207 function isValidRequired(item, field) {
25208 const value = field.getValue({ item });
25209 return ![void 0, "", null].includes(value);
25210 }
25211
25212 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
25213 function isValidMinLength(item, field) {
25214 if (typeof field.isValid.minLength?.constraint !== "number") {
25215 return false;
25216 }
25217 const value = field.getValue({ item });
25218 if ([void 0, "", null].includes(value)) {
25219 return true;
25220 }
25221 return String(value).length >= field.isValid.minLength.constraint;
25222 }
25223
25224 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
25225 function isValidMaxLength(item, field) {
25226 if (typeof field.isValid.maxLength?.constraint !== "number") {
25227 return false;
25228 }
25229 const value = field.getValue({ item });
25230 if ([void 0, "", null].includes(value)) {
25231 return true;
25232 }
25233 return String(value).length <= field.isValid.maxLength.constraint;
25234 }
25235
25236 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
25237 function isValidPattern(item, field) {
25238 if (field.isValid.pattern?.constraint === void 0) {
25239 return true;
25240 }
25241 try {
25242 const regexp = new RegExp(field.isValid.pattern.constraint);
25243 const value = field.getValue({ item });
25244 if ([void 0, "", null].includes(value)) {
25245 return true;
25246 }
25247 return regexp.test(String(value));
25248 } catch {
25249 return false;
25250 }
25251 }
25252
25253 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
25254 function isValidElements(item, field) {
25255 const elements = field.elements ?? [];
25256 const validValues = elements.map((el) => el.value);
25257 if (validValues.length === 0) {
25258 return true;
25259 }
25260 const value = field.getValue({ item });
25261 return [].concat(value).every((v2) => validValues.includes(v2));
25262 }
25263
25264 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
25265 function getValueFormatted({
25266 item,
25267 field
25268 }) {
25269 return field.getValue({ item });
25270 }
25271 var get_value_formatted_default_default = getValueFormatted;
25272
25273 // packages/dataviews/build-module/field-types/email.mjs
25274 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])?)*$/;
25275 function isValidCustom(item, field) {
25276 const value = field.getValue({ item });
25277 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
25278 return (0, import_i18n38.__)("Value must be a valid email address.");
25279 }
25280 return null;
25281 }
25282 var email_default = {
25283 type: "email",
25284 render,
25285 Edit: "email",
25286 sort: sort_text_default,
25287 enableSorting: true,
25288 enableGlobalSearch: false,
25289 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25290 validOperators: [
25291 OPERATOR_IS,
25292 OPERATOR_IS_NOT,
25293 OPERATOR_CONTAINS,
25294 OPERATOR_NOT_CONTAINS,
25295 OPERATOR_STARTS_WITH,
25296 // Multiple selection
25297 OPERATOR_IS_ANY,
25298 OPERATOR_IS_NONE,
25299 OPERATOR_IS_ALL,
25300 OPERATOR_IS_NOT_ALL
25301 ],
25302 format: {},
25303 getValueFormatted: get_value_formatted_default_default,
25304 validate: {
25305 required: isValidRequired,
25306 pattern: isValidPattern,
25307 minLength: isValidMinLength,
25308 maxLength: isValidMaxLength,
25309 elements: isValidElements,
25310 custom: isValidCustom
25311 }
25312 };
25313
25314 // packages/dataviews/build-module/field-types/integer.mjs
25315 var import_i18n39 = __toESM(require_i18n(), 1);
25316
25317 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
25318 var sort_number_default = (a2, b2, direction) => {
25319 return direction === "asc" ? a2 - b2 : b2 - a2;
25320 };
25321
25322 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
25323 function isValidMin(item, field) {
25324 if (typeof field.isValid.min?.constraint !== "number") {
25325 return false;
25326 }
25327 const value = field.getValue({ item });
25328 if ([void 0, "", null].includes(value)) {
25329 return true;
25330 }
25331 return Number(value) >= field.isValid.min.constraint;
25332 }
25333
25334 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
25335 function isValidMax(item, field) {
25336 if (typeof field.isValid.max?.constraint !== "number") {
25337 return false;
25338 }
25339 const value = field.getValue({ item });
25340 if ([void 0, "", null].includes(value)) {
25341 return true;
25342 }
25343 return Number(value) <= field.isValid.max.constraint;
25344 }
25345
25346 // packages/dataviews/build-module/field-types/integer.mjs
25347 var format2 = {
25348 separatorThousand: ","
25349 };
25350 function getValueFormatted2({
25351 item,
25352 field
25353 }) {
25354 let value = field.getValue({ item });
25355 if (value === null || value === void 0) {
25356 return "";
25357 }
25358 value = Number(value);
25359 if (!Number.isFinite(value)) {
25360 return String(value);
25361 }
25362 let formatInteger;
25363 if (field.type !== "integer") {
25364 formatInteger = format2;
25365 } else {
25366 formatInteger = field.format;
25367 }
25368 const { separatorThousand } = formatInteger;
25369 const integerValue = Math.trunc(value);
25370 if (!separatorThousand) {
25371 return String(integerValue);
25372 }
25373 return String(integerValue).replace(
25374 /\B(?=(\d{3})+(?!\d))/g,
25375 separatorThousand
25376 );
25377 }
25378 function isValidCustom2(item, field) {
25379 const value = field.getValue({ item });
25380 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
25381 return (0, import_i18n39.__)("Value must be an integer.");
25382 }
25383 return null;
25384 }
25385 var integer_default = {
25386 type: "integer",
25387 render,
25388 Edit: "integer",
25389 sort: sort_number_default,
25390 enableSorting: true,
25391 enableGlobalSearch: false,
25392 defaultOperators: [
25393 OPERATOR_IS,
25394 OPERATOR_IS_NOT,
25395 OPERATOR_LESS_THAN,
25396 OPERATOR_GREATER_THAN,
25397 OPERATOR_LESS_THAN_OR_EQUAL,
25398 OPERATOR_GREATER_THAN_OR_EQUAL,
25399 OPERATOR_BETWEEN
25400 ],
25401 validOperators: [
25402 // Single-selection
25403 OPERATOR_IS,
25404 OPERATOR_IS_NOT,
25405 OPERATOR_LESS_THAN,
25406 OPERATOR_GREATER_THAN,
25407 OPERATOR_LESS_THAN_OR_EQUAL,
25408 OPERATOR_GREATER_THAN_OR_EQUAL,
25409 OPERATOR_BETWEEN,
25410 // Multiple-selection
25411 OPERATOR_IS_ANY,
25412 OPERATOR_IS_NONE,
25413 OPERATOR_IS_ALL,
25414 OPERATOR_IS_NOT_ALL
25415 ],
25416 format: format2,
25417 getValueFormatted: getValueFormatted2,
25418 validate: {
25419 required: isValidRequired,
25420 min: isValidMin,
25421 max: isValidMax,
25422 elements: isValidElements,
25423 custom: isValidCustom2
25424 }
25425 };
25426
25427 // packages/dataviews/build-module/field-types/number.mjs
25428 var import_i18n40 = __toESM(require_i18n(), 1);
25429 var format3 = {
25430 separatorThousand: ",",
25431 separatorDecimal: ".",
25432 decimals: 2
25433 };
25434 function getValueFormatted3({
25435 item,
25436 field
25437 }) {
25438 let value = field.getValue({ item });
25439 if (value === null || value === void 0) {
25440 return "";
25441 }
25442 value = Number(value);
25443 if (!Number.isFinite(value)) {
25444 return String(value);
25445 }
25446 let formatNumber;
25447 if (field.type !== "number") {
25448 formatNumber = format3;
25449 } else {
25450 formatNumber = field.format;
25451 }
25452 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
25453 const fixedValue = value.toFixed(decimals);
25454 const [integerPart, decimalPart] = fixedValue.split(".");
25455 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
25456 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
25457 }
25458 function isEmpty(value) {
25459 return value === "" || value === void 0 || value === null;
25460 }
25461 function isValidCustom3(item, field) {
25462 const value = field.getValue({ item });
25463 if (!isEmpty(value) && !Number.isFinite(value)) {
25464 return (0, import_i18n40.__)("Value must be a number.");
25465 }
25466 return null;
25467 }
25468 var number_default = {
25469 type: "number",
25470 render,
25471 Edit: "number",
25472 sort: sort_number_default,
25473 enableSorting: true,
25474 enableGlobalSearch: false,
25475 defaultOperators: [
25476 OPERATOR_IS,
25477 OPERATOR_IS_NOT,
25478 OPERATOR_LESS_THAN,
25479 OPERATOR_GREATER_THAN,
25480 OPERATOR_LESS_THAN_OR_EQUAL,
25481 OPERATOR_GREATER_THAN_OR_EQUAL,
25482 OPERATOR_BETWEEN
25483 ],
25484 validOperators: [
25485 // Single-selection
25486 OPERATOR_IS,
25487 OPERATOR_IS_NOT,
25488 OPERATOR_LESS_THAN,
25489 OPERATOR_GREATER_THAN,
25490 OPERATOR_LESS_THAN_OR_EQUAL,
25491 OPERATOR_GREATER_THAN_OR_EQUAL,
25492 OPERATOR_BETWEEN,
25493 // Multiple-selection
25494 OPERATOR_IS_ANY,
25495 OPERATOR_IS_NONE,
25496 OPERATOR_IS_ALL,
25497 OPERATOR_IS_NOT_ALL
25498 ],
25499 format: format3,
25500 getValueFormatted: getValueFormatted3,
25501 validate: {
25502 required: isValidRequired,
25503 min: isValidMin,
25504 max: isValidMax,
25505 elements: isValidElements,
25506 custom: isValidCustom3
25507 }
25508 };
25509
25510 // packages/dataviews/build-module/field-types/text.mjs
25511 var text_default = {
25512 type: "text",
25513 render,
25514 Edit: "text",
25515 sort: sort_text_default,
25516 enableSorting: true,
25517 enableGlobalSearch: false,
25518 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25519 validOperators: [
25520 // Single selection
25521 OPERATOR_IS,
25522 OPERATOR_IS_NOT,
25523 OPERATOR_CONTAINS,
25524 OPERATOR_NOT_CONTAINS,
25525 OPERATOR_STARTS_WITH,
25526 // Multiple selection
25527 OPERATOR_IS_ANY,
25528 OPERATOR_IS_NONE,
25529 OPERATOR_IS_ALL,
25530 OPERATOR_IS_NOT_ALL
25531 ],
25532 format: {},
25533 getValueFormatted: get_value_formatted_default_default,
25534 validate: {
25535 required: isValidRequired,
25536 pattern: isValidPattern,
25537 minLength: isValidMinLength,
25538 maxLength: isValidMaxLength,
25539 elements: isValidElements
25540 }
25541 };
25542
25543 // packages/dataviews/build-module/field-types/datetime.mjs
25544 var import_date7 = __toESM(require_date(), 1);
25545
25546 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
25547 var import_date6 = __toESM(require_date(), 1);
25548 function parseDateLike(value) {
25549 if (!value) {
25550 return null;
25551 }
25552 if (!isValid(new Date(value))) {
25553 return null;
25554 }
25555 const parsed = (0, import_date6.getDate)(value);
25556 return parsed && isValid(parsed) ? parsed : null;
25557 }
25558 function validateDateLikeBoundary(item, field, boundary) {
25559 const constraint = field.isValid[boundary]?.constraint;
25560 if (typeof constraint !== "string") {
25561 return false;
25562 }
25563 const value = field.getValue({ item });
25564 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
25565 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
25566 return true;
25567 }
25568 const parsedConstraint = parseDateLike(constraint);
25569 const parsedValue = parseDateLike(String(boundaryValue));
25570 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
25571 }
25572 function isValidMinDate(item, field) {
25573 return validateDateLikeBoundary(item, field, "min");
25574 }
25575 function isValidMaxDate(item, field) {
25576 return validateDateLikeBoundary(item, field, "max");
25577 }
25578
25579 // packages/dataviews/build-module/field-types/datetime.mjs
25580 var format4 = {
25581 datetime: (0, import_date7.getSettings)().formats.datetime,
25582 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
25583 };
25584 function getValueFormatted4({
25585 item,
25586 field
25587 }) {
25588 const value = field.getValue({ item });
25589 if (["", void 0, null].includes(value)) {
25590 return "";
25591 }
25592 let formatDatetime;
25593 if (field.type !== "datetime") {
25594 formatDatetime = format4;
25595 } else {
25596 formatDatetime = field.format;
25597 }
25598 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
25599 }
25600 var sort = (a2, b2, direction) => {
25601 const timeA = new Date(a2).getTime();
25602 const timeB = new Date(b2).getTime();
25603 return direction === "asc" ? timeA - timeB : timeB - timeA;
25604 };
25605 var datetime_default = {
25606 type: "datetime",
25607 render,
25608 Edit: "datetime",
25609 sort,
25610 enableSorting: true,
25611 enableGlobalSearch: false,
25612 defaultOperators: [
25613 OPERATOR_ON,
25614 OPERATOR_NOT_ON,
25615 OPERATOR_BEFORE,
25616 OPERATOR_AFTER,
25617 OPERATOR_BEFORE_INC,
25618 OPERATOR_AFTER_INC,
25619 OPERATOR_IN_THE_PAST,
25620 OPERATOR_OVER
25621 ],
25622 validOperators: [
25623 OPERATOR_ON,
25624 OPERATOR_NOT_ON,
25625 OPERATOR_BEFORE,
25626 OPERATOR_AFTER,
25627 OPERATOR_BEFORE_INC,
25628 OPERATOR_AFTER_INC,
25629 OPERATOR_IN_THE_PAST,
25630 OPERATOR_OVER
25631 ],
25632 format: format4,
25633 getValueFormatted: getValueFormatted4,
25634 validate: {
25635 required: isValidRequired,
25636 elements: isValidElements,
25637 min: isValidMinDate,
25638 max: isValidMaxDate
25639 }
25640 };
25641
25642 // packages/dataviews/build-module/field-types/date.mjs
25643 var import_date8 = __toESM(require_date(), 1);
25644 var format5 = {
25645 date: (0, import_date8.getSettings)().formats.date,
25646 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
25647 };
25648 function getValueFormatted5({
25649 item,
25650 field
25651 }) {
25652 const value = field.getValue({ item });
25653 if (["", void 0, null].includes(value)) {
25654 return "";
25655 }
25656 let formatDate2;
25657 if (field.type !== "date") {
25658 formatDate2 = format5;
25659 } else {
25660 formatDate2 = field.format;
25661 }
25662 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
25663 }
25664 var sort2 = (a2, b2, direction) => {
25665 const timeA = new Date(a2).getTime();
25666 const timeB = new Date(b2).getTime();
25667 return direction === "asc" ? timeA - timeB : timeB - timeA;
25668 };
25669 var date_default = {
25670 type: "date",
25671 render,
25672 Edit: "date",
25673 sort: sort2,
25674 enableSorting: true,
25675 enableGlobalSearch: false,
25676 defaultOperators: [
25677 OPERATOR_ON,
25678 OPERATOR_NOT_ON,
25679 OPERATOR_BEFORE,
25680 OPERATOR_AFTER,
25681 OPERATOR_BEFORE_INC,
25682 OPERATOR_AFTER_INC,
25683 OPERATOR_IN_THE_PAST,
25684 OPERATOR_OVER,
25685 OPERATOR_BETWEEN
25686 ],
25687 validOperators: [
25688 OPERATOR_ON,
25689 OPERATOR_NOT_ON,
25690 OPERATOR_BEFORE,
25691 OPERATOR_AFTER,
25692 OPERATOR_BEFORE_INC,
25693 OPERATOR_AFTER_INC,
25694 OPERATOR_IN_THE_PAST,
25695 OPERATOR_OVER,
25696 OPERATOR_BETWEEN
25697 ],
25698 format: format5,
25699 getValueFormatted: getValueFormatted5,
25700 validate: {
25701 required: isValidRequired,
25702 elements: isValidElements,
25703 min: isValidMinDate,
25704 max: isValidMaxDate
25705 }
25706 };
25707
25708 // packages/dataviews/build-module/field-types/boolean.mjs
25709 var import_i18n41 = __toESM(require_i18n(), 1);
25710
25711 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
25712 function isValidRequiredForBool(item, field) {
25713 const value = field.getValue({ item });
25714 return value === true;
25715 }
25716
25717 // packages/dataviews/build-module/field-types/boolean.mjs
25718 function getValueFormatted6({
25719 item,
25720 field
25721 }) {
25722 const value = field.getValue({ item });
25723 if (value === true) {
25724 return (0, import_i18n41.__)("True");
25725 }
25726 if (value === false) {
25727 return (0, import_i18n41.__)("False");
25728 }
25729 return "";
25730 }
25731 function isValidCustom4(item, field) {
25732 const value = field.getValue({ item });
25733 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
25734 return (0, import_i18n41.__)("Value must be true, false, or undefined");
25735 }
25736 return null;
25737 }
25738 var sort3 = (a2, b2, direction) => {
25739 const boolA = Boolean(a2);
25740 const boolB = Boolean(b2);
25741 if (boolA === boolB) {
25742 return 0;
25743 }
25744 if (direction === "asc") {
25745 return boolA ? 1 : -1;
25746 }
25747 return boolA ? -1 : 1;
25748 };
25749 var boolean_default = {
25750 type: "boolean",
25751 render,
25752 Edit: "checkbox",
25753 sort: sort3,
25754 validate: {
25755 required: isValidRequiredForBool,
25756 elements: isValidElements,
25757 custom: isValidCustom4
25758 },
25759 enableSorting: true,
25760 enableGlobalSearch: false,
25761 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25762 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25763 format: {},
25764 getValueFormatted: getValueFormatted6
25765 };
25766
25767 // packages/dataviews/build-module/field-types/media.mjs
25768 var media_default = {
25769 type: "media",
25770 render: () => null,
25771 Edit: null,
25772 sort: () => 0,
25773 enableSorting: false,
25774 enableGlobalSearch: false,
25775 defaultOperators: [],
25776 validOperators: [],
25777 format: {},
25778 getValueFormatted: get_value_formatted_default_default,
25779 // cannot validate any constraint, so
25780 // the only available validation for the field author
25781 // would be providing a custom validator.
25782 validate: {}
25783 };
25784
25785 // packages/dataviews/build-module/field-types/array.mjs
25786 var import_i18n42 = __toESM(require_i18n(), 1);
25787
25788 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
25789 function isValidRequiredForArray(item, field) {
25790 const value = field.getValue({ item });
25791 return Array.isArray(value) && value.length > 0 && value.every(
25792 (element) => ![void 0, "", null].includes(element)
25793 );
25794 }
25795
25796 // packages/dataviews/build-module/field-types/array.mjs
25797 function getValueFormatted7({
25798 item,
25799 field
25800 }) {
25801 const value = field.getValue({ item });
25802 const arr = Array.isArray(value) ? value : [];
25803 return arr.join(", ");
25804 }
25805 function render2({ item, field }) {
25806 return getValueFormatted7({ item, field });
25807 }
25808 function isValidCustom5(item, field) {
25809 const value = field.getValue({ item });
25810 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
25811 return (0, import_i18n42.__)("Value must be an array.");
25812 }
25813 if (!value.every((v2) => typeof v2 === "string")) {
25814 return (0, import_i18n42.__)("Every value must be a string.");
25815 }
25816 return null;
25817 }
25818 var sort4 = (a2, b2, direction) => {
25819 const arrA = Array.isArray(a2) ? a2 : [];
25820 const arrB = Array.isArray(b2) ? b2 : [];
25821 if (arrA.length !== arrB.length) {
25822 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
25823 }
25824 const joinedA = arrA.join(",");
25825 const joinedB = arrB.join(",");
25826 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
25827 };
25828 var array_default = {
25829 type: "array",
25830 render: render2,
25831 Edit: "array",
25832 sort: sort4,
25833 enableSorting: true,
25834 enableGlobalSearch: false,
25835 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25836 validOperators: [
25837 OPERATOR_IS_ANY,
25838 OPERATOR_IS_NONE,
25839 OPERATOR_IS_ALL,
25840 OPERATOR_IS_NOT_ALL
25841 ],
25842 format: {},
25843 getValueFormatted: getValueFormatted7,
25844 validate: {
25845 required: isValidRequiredForArray,
25846 elements: isValidElements,
25847 custom: isValidCustom5
25848 }
25849 };
25850
25851 // packages/dataviews/build-module/field-types/password.mjs
25852 function getValueFormatted8({
25853 item,
25854 field
25855 }) {
25856 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
25857 }
25858 var password_default = {
25859 type: "password",
25860 render,
25861 Edit: "password",
25862 sort: () => 0,
25863 // Passwords should not be sortable for security reasons
25864 enableSorting: false,
25865 enableGlobalSearch: false,
25866 defaultOperators: [],
25867 validOperators: [],
25868 format: {},
25869 getValueFormatted: getValueFormatted8,
25870 validate: {
25871 required: isValidRequired,
25872 pattern: isValidPattern,
25873 minLength: isValidMinLength,
25874 maxLength: isValidMaxLength,
25875 elements: isValidElements
25876 }
25877 };
25878
25879 // packages/dataviews/build-module/field-types/telephone.mjs
25880 var telephone_default = {
25881 type: "telephone",
25882 render,
25883 Edit: "telephone",
25884 sort: sort_text_default,
25885 enableSorting: true,
25886 enableGlobalSearch: false,
25887 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25888 validOperators: [
25889 OPERATOR_IS,
25890 OPERATOR_IS_NOT,
25891 OPERATOR_CONTAINS,
25892 OPERATOR_NOT_CONTAINS,
25893 OPERATOR_STARTS_WITH,
25894 // Multiple selection
25895 OPERATOR_IS_ANY,
25896 OPERATOR_IS_NONE,
25897 OPERATOR_IS_ALL,
25898 OPERATOR_IS_NOT_ALL
25899 ],
25900 format: {},
25901 getValueFormatted: get_value_formatted_default_default,
25902 validate: {
25903 required: isValidRequired,
25904 pattern: isValidPattern,
25905 minLength: isValidMinLength,
25906 maxLength: isValidMaxLength,
25907 elements: isValidElements
25908 }
25909 };
25910
25911 // packages/dataviews/build-module/field-types/color.mjs
25912 var import_i18n43 = __toESM(require_i18n(), 1);
25913 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
25914 function render3({ item, field }) {
25915 if (field.hasElements) {
25916 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(RenderFromElements, { item, field });
25917 }
25918 const value = get_value_formatted_default_default({ item, field });
25919 if (!value || !w(value).isValid()) {
25920 return value;
25921 }
25922 return /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
25923 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
25924 "div",
25925 {
25926 style: {
25927 width: "16px",
25928 height: "16px",
25929 borderRadius: "50%",
25930 backgroundColor: value,
25931 border: "1px solid #ddd",
25932 flexShrink: 0
25933 }
25934 }
25935 ),
25936 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("span", { children: value })
25937 ] });
25938 }
25939 function isValidCustom6(item, field) {
25940 const value = field.getValue({ item });
25941 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
25942 return (0, import_i18n43.__)("Value must be a valid color.");
25943 }
25944 return null;
25945 }
25946 var sort5 = (a2, b2, direction) => {
25947 const colorA = w(a2);
25948 const colorB = w(b2);
25949 if (!colorA.isValid() && !colorB.isValid()) {
25950 return 0;
25951 }
25952 if (!colorA.isValid()) {
25953 return direction === "asc" ? 1 : -1;
25954 }
25955 if (!colorB.isValid()) {
25956 return direction === "asc" ? -1 : 1;
25957 }
25958 const hslA = colorA.toHsl();
25959 const hslB = colorB.toHsl();
25960 if (hslA.h !== hslB.h) {
25961 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
25962 }
25963 if (hslA.s !== hslB.s) {
25964 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
25965 }
25966 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
25967 };
25968 var color_default = {
25969 type: "color",
25970 render: render3,
25971 Edit: "color",
25972 sort: sort5,
25973 enableSorting: true,
25974 enableGlobalSearch: false,
25975 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25976 validOperators: [
25977 OPERATOR_IS,
25978 OPERATOR_IS_NOT,
25979 OPERATOR_IS_ANY,
25980 OPERATOR_IS_NONE
25981 ],
25982 format: {},
25983 getValueFormatted: get_value_formatted_default_default,
25984 validate: {
25985 required: isValidRequired,
25986 elements: isValidElements,
25987 custom: isValidCustom6
25988 }
25989 };
25990
25991 // packages/dataviews/build-module/field-types/url.mjs
25992 var url_default = {
25993 type: "url",
25994 render,
25995 Edit: "url",
25996 sort: sort_text_default,
25997 enableSorting: true,
25998 enableGlobalSearch: false,
25999 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
26000 validOperators: [
26001 OPERATOR_IS,
26002 OPERATOR_IS_NOT,
26003 OPERATOR_CONTAINS,
26004 OPERATOR_NOT_CONTAINS,
26005 OPERATOR_STARTS_WITH,
26006 // Multiple selection
26007 OPERATOR_IS_ANY,
26008 OPERATOR_IS_NONE,
26009 OPERATOR_IS_ALL,
26010 OPERATOR_IS_NOT_ALL
26011 ],
26012 format: {},
26013 getValueFormatted: get_value_formatted_default_default,
26014 validate: {
26015 required: isValidRequired,
26016 pattern: isValidPattern,
26017 minLength: isValidMinLength,
26018 maxLength: isValidMaxLength,
26019 elements: isValidElements
26020 }
26021 };
26022
26023 // packages/dataviews/build-module/field-types/no-type.mjs
26024 var sort6 = (a2, b2, direction) => {
26025 if (typeof a2 === "number" && typeof b2 === "number") {
26026 return sort_number_default(a2, b2, direction);
26027 }
26028 return sort_text_default(a2, b2, direction);
26029 };
26030 var no_type_default = {
26031 // type: no type for this one
26032 render,
26033 Edit: null,
26034 sort: sort6,
26035 enableSorting: true,
26036 enableGlobalSearch: false,
26037 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
26038 validOperators: getAllOperatorNames(),
26039 format: {},
26040 getValueFormatted: get_value_formatted_default_default,
26041 validate: {
26042 required: isValidRequired,
26043 elements: isValidElements
26044 }
26045 };
26046
26047 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
26048 function supportsNumericRangeConstraint(type) {
26049 return type === "integer" || type === "number";
26050 }
26051 function supportsDateRangeConstraint(type) {
26052 return type === "date" || type === "datetime";
26053 }
26054 function normalizeRangeRule(value, fieldType, key) {
26055 const validator = fieldType.validate[key];
26056 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
26057 return { constraint: value, validate: validator };
26058 }
26059 return void 0;
26060 }
26061 function getIsValid(field, fieldType) {
26062 const rules = field.isValid;
26063 let required;
26064 if (rules?.required === true && fieldType.validate.required !== void 0) {
26065 required = {
26066 constraint: true,
26067 validate: fieldType.validate.required
26068 };
26069 }
26070 let elements;
26071 if ((rules?.elements === true || // elements is enabled unless the field opts-out
26072 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
26073 elements = {
26074 constraint: true,
26075 validate: fieldType.validate.elements
26076 };
26077 }
26078 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
26079 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
26080 const minLengthValue = rules?.minLength;
26081 let minLength;
26082 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
26083 minLength = {
26084 constraint: minLengthValue,
26085 validate: fieldType.validate.minLength
26086 };
26087 }
26088 const maxLengthValue = rules?.maxLength;
26089 let maxLength;
26090 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
26091 maxLength = {
26092 constraint: maxLengthValue,
26093 validate: fieldType.validate.maxLength
26094 };
26095 }
26096 const patternValue = rules?.pattern;
26097 let pattern;
26098 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
26099 pattern = {
26100 constraint: patternValue,
26101 validate: fieldType.validate.pattern
26102 };
26103 }
26104 const custom = rules?.custom ?? fieldType.validate.custom;
26105 return {
26106 required,
26107 elements,
26108 min: min2,
26109 max: max2,
26110 minLength,
26111 maxLength,
26112 pattern,
26113 custom
26114 };
26115 }
26116
26117 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
26118 function getFilter(fieldType) {
26119 return fieldType.validOperators.reduce((accumulator, operator) => {
26120 const operatorObj = getOperatorByName(operator);
26121 if (operatorObj?.filter) {
26122 accumulator[operator] = operatorObj.filter;
26123 }
26124 return accumulator;
26125 }, {});
26126 }
26127
26128 // packages/dataviews/build-module/field-types/utils/get-format.mjs
26129 function getFormat(field, fieldType) {
26130 return {
26131 ...fieldType.format,
26132 ...field.format
26133 };
26134 }
26135 var get_format_default = getFormat;
26136
26137 // packages/dataviews/build-module/field-types/index.mjs
26138 function getFieldTypeByName(type) {
26139 const found = [
26140 email_default,
26141 integer_default,
26142 number_default,
26143 text_default,
26144 datetime_default,
26145 date_default,
26146 boolean_default,
26147 media_default,
26148 array_default,
26149 password_default,
26150 telephone_default,
26151 color_default,
26152 url_default
26153 ].find((fieldType) => fieldType?.type === type);
26154 if (!!found) {
26155 return found;
26156 }
26157 return no_type_default;
26158 }
26159 function normalizeFields(fields) {
26160 return fields.map((field) => {
26161 const fieldType = getFieldTypeByName(field.type);
26162 const getValue = field.getValue || get_value_from_id_default(field.id);
26163 const sort7 = function(a2, b2, direction) {
26164 const aValue = getValue({ item: a2 });
26165 const bValue = getValue({ item: b2 });
26166 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
26167 };
26168 return {
26169 id: field.id,
26170 label: field.label || field.id,
26171 header: field.header || field.label || field.id,
26172 description: field.description,
26173 placeholder: field.placeholder,
26174 getValue,
26175 setValue: field.setValue || set_value_from_id_default(field.id),
26176 elements: field.elements,
26177 getElements: field.getElements,
26178 hasElements: hasElements(field),
26179 isVisible: field.isVisible,
26180 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
26181 enableHiding: field.enableHiding ?? true,
26182 readOnly: field.readOnly ?? false,
26183 // The type provides defaults for the following props
26184 type: fieldType.type,
26185 render: field.render ?? fieldType.render,
26186 Edit: getControl(field, fieldType.Edit),
26187 sort: sort7,
26188 enableSorting: field.enableSorting ?? fieldType.enableSorting,
26189 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
26190 isValid: getIsValid(field, fieldType),
26191 filterBy: get_filter_by_default(
26192 field,
26193 fieldType.defaultOperators,
26194 fieldType.validOperators
26195 ),
26196 filter: getFilter(fieldType),
26197 format: get_format_default(field, fieldType),
26198 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
26199 };
26200 });
26201 }
26202
26203 // packages/dataviews/build-module/hooks/use-data.mjs
26204 var import_element76 = __toESM(require_element(), 1);
26205 function useData({
26206 view,
26207 data: shownData,
26208 getItemId,
26209 isLoading,
26210 paginationInfo,
26211 selection
26212 }) {
26213 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
26214 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element76.useState)(
26215 !isLoading
26216 );
26217 (0, import_element76.useEffect)(() => {
26218 if (!isLoading) {
26219 setHasInitiallyLoaded(true);
26220 }
26221 }, [isLoading]);
26222 const previousDataRef = (0, import_element76.useRef)(shownData);
26223 const previousPaginationInfoRef = (0, import_element76.useRef)(paginationInfo);
26224 (0, import_element76.useEffect)(() => {
26225 if (!isLoading) {
26226 previousDataRef.current = shownData;
26227 previousPaginationInfoRef.current = paginationInfo;
26228 }
26229 }, [shownData, isLoading, paginationInfo]);
26230 const [visibleEntries, setVisibleEntries] = (0, import_element76.useState)([]);
26231 const positionMapRef = (0, import_element76.useRef)(/* @__PURE__ */ new Map());
26232 const allLoadedRecordsRef = (0, import_element76.useRef)([]);
26233 const prevViewParamsRef = (0, import_element76.useRef)({
26234 search: void 0,
26235 filters: void 0,
26236 perPage: void 0
26237 });
26238 const scrollDirectionRef = (0, import_element76.useRef)(void 0);
26239 const prevStartPositionRef = (0, import_element76.useRef)(void 0);
26240 const hasInitializedRef = (0, import_element76.useRef)(false);
26241 const allLoadedRecords = (0, import_element76.useMemo)(() => {
26242 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
26243 if (view.startPosition < prevStartPositionRef.current) {
26244 scrollDirectionRef.current = "up";
26245 } else if (view.startPosition > prevStartPositionRef.current) {
26246 scrollDirectionRef.current = "down";
26247 }
26248 }
26249 prevStartPositionRef.current = view.startPosition;
26250 const currentFiltersKey = JSON.stringify(view.filters ?? []);
26251 const prevFiltersKey = prevViewParamsRef.current.filters;
26252 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
26253 hasInitializedRef.current = true;
26254 prevViewParamsRef.current = {
26255 search: view.search,
26256 filters: currentFiltersKey,
26257 perPage: view.perPage
26258 };
26259 if (shouldReset) {
26260 positionMapRef.current.clear();
26261 scrollDirectionRef.current = void 0;
26262 const startPosition = view.search ? 1 : view.startPosition ?? 1;
26263 const records = shownData.map((record, index2) => {
26264 const position = startPosition + index2;
26265 positionMapRef.current.set(getItemId(record), position);
26266 return {
26267 ...record,
26268 position
26269 };
26270 });
26271 allLoadedRecordsRef.current = records;
26272 return records;
26273 }
26274 const prev = allLoadedRecordsRef.current;
26275 const shownDataIds = new Set(shownData.map(getItemId));
26276 const scrollDirection = scrollDirectionRef.current;
26277 const basePosition = view.search ? 1 : view.startPosition ?? 1;
26278 const newRecords = shownData.map((record, index2) => {
26279 const itemId = getItemId(record);
26280 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
26281 if (position !== void 0) {
26282 positionMapRef.current.set(itemId, position);
26283 }
26284 return {
26285 ...record,
26286 position
26287 };
26288 });
26289 if (newRecords.length === 0) {
26290 return prev;
26291 }
26292 const prevWithoutDuplicates = prev.filter(
26293 (record) => !shownDataIds.has(getItemId(record))
26294 );
26295 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
26296 allRecords.sort((a2, b2) => {
26297 const posA = a2.position;
26298 const posB = b2.position;
26299 return posA - posB;
26300 });
26301 let result = allRecords;
26302 if (visibleEntries.length > 0) {
26303 const visibleMin = Math.min(...visibleEntries);
26304 const visibleMax = Math.max(...visibleEntries);
26305 const buffer = 20;
26306 const recordPositions = allRecords.map(
26307 (r3) => r3.position
26308 );
26309 const minRecordPos = Math.min(...recordPositions);
26310 const maxRecordPos = Math.max(...recordPositions);
26311 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
26312 if (hasOverlap) {
26313 result = allRecords.filter((record) => {
26314 const itemId = getItemId(record);
26315 const isSelected2 = selection?.includes(itemId);
26316 if (isSelected2) {
26317 return true;
26318 }
26319 const itemPosition = record.position;
26320 if (scrollDirection === "up") {
26321 return itemPosition <= visibleMax + buffer;
26322 } else if (scrollDirection === "down") {
26323 return itemPosition >= visibleMin - buffer;
26324 }
26325 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
26326 });
26327 }
26328 }
26329 allLoadedRecordsRef.current = result;
26330 return result;
26331 }, [
26332 shownData,
26333 view.search,
26334 view.filters,
26335 view.perPage,
26336 view.startPosition,
26337 view.infiniteScrollEnabled,
26338 visibleEntries,
26339 selection,
26340 getItemId
26341 ]);
26342 if (!isInfiniteScrollEnabled) {
26343 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
26344 return {
26345 data: dataToReturn.map((item) => ({
26346 ...item,
26347 position: void 0
26348 })),
26349 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
26350 hasInitiallyLoaded,
26351 setVisibleEntries: void 0
26352 };
26353 }
26354 return {
26355 data: allLoadedRecords,
26356 paginationInfo,
26357 hasInitiallyLoaded,
26358 setVisibleEntries
26359 };
26360 }
26361
26362 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
26363 var import_element77 = __toESM(require_element(), 1);
26364 var import_compose13 = __toESM(require_compose(), 1);
26365 function captureAnchorElement(container, anchorElementRef, direction) {
26366 const containerRect = container.getBoundingClientRect();
26367 const centerY = containerRect.top + containerRect.height / 2;
26368 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
26369 if (items.length === 0) {
26370 return false;
26371 }
26372 const bestAnchor = items.reduce((best, item) => {
26373 const itemRect = item.getBoundingClientRect();
26374 const itemCenterY = itemRect.top + itemRect.height / 2;
26375 const distance = Math.abs(itemCenterY - centerY);
26376 const bestRect = best.getBoundingClientRect();
26377 const bestCenterY = bestRect.top + bestRect.height / 2;
26378 const bestDistance = Math.abs(bestCenterY - centerY);
26379 return distance < bestDistance ? item : best;
26380 });
26381 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
26382 const anchorRect = bestAnchor.getBoundingClientRect();
26383 anchorElementRef.current = {
26384 posinset,
26385 viewportOffset: anchorRect.top - containerRect.top,
26386 scrollTop: container.scrollTop,
26387 direction
26388 };
26389 return true;
26390 }
26391 function useInfiniteScroll({
26392 view,
26393 onChangeView,
26394 isLoading,
26395 paginationInfo,
26396 containerRef,
26397 setVisibleEntries
26398 }) {
26399 const anchorElementRef = (0, import_element77.useRef)(null);
26400 const viewRef = (0, import_element77.useRef)(view);
26401 const isLoadingRef = (0, import_element77.useRef)(isLoading);
26402 const onChangeViewRef = (0, import_element77.useRef)(onChangeView);
26403 const totalItemsRef = (0, import_element77.useRef)(paginationInfo.totalItems);
26404 (0, import_element77.useLayoutEffect)(() => {
26405 viewRef.current = view;
26406 isLoadingRef.current = isLoading;
26407 onChangeViewRef.current = onChangeView;
26408 totalItemsRef.current = paginationInfo.totalItems;
26409 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
26410 const intersectionObserverCallback = (0, import_element77.useCallback)(
26411 (entries) => {
26412 if (!setVisibleEntries) {
26413 return;
26414 }
26415 setVisibleEntries((prev) => {
26416 const newVisibleEntries = new Set(prev);
26417 let hasChanged = false;
26418 entries.forEach((entry) => {
26419 const posInSet = Number(
26420 entry.target?.attributes?.getNamedItem(
26421 "aria-posinset"
26422 )?.value
26423 );
26424 if (isNaN(posInSet)) {
26425 return;
26426 }
26427 if (entry.isIntersecting) {
26428 if (!newVisibleEntries.has(posInSet)) {
26429 newVisibleEntries.add(posInSet);
26430 hasChanged = true;
26431 }
26432 } else if (newVisibleEntries.has(posInSet)) {
26433 newVisibleEntries.delete(posInSet);
26434 hasChanged = true;
26435 }
26436 });
26437 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
26438 });
26439 },
26440 [setVisibleEntries]
26441 );
26442 (0, import_element77.useLayoutEffect)(() => {
26443 const container = containerRef.current;
26444 const anchor = anchorElementRef.current;
26445 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
26446 return;
26447 }
26448 const anchorElement = container.querySelector(
26449 `[aria-posinset="${anchor.posinset}"]`
26450 );
26451 if (anchorElement) {
26452 const containerRect = container.getBoundingClientRect();
26453 const anchorRect = anchorElement.getBoundingClientRect();
26454 const currentOffset = anchorRect.top - containerRect.top;
26455 const scrollAdjustment = currentOffset - anchor.viewportOffset + (container.scrollTop - anchor.scrollTop);
26456 if (Math.abs(scrollAdjustment) > 1) {
26457 container.scrollTop += scrollAdjustment;
26458 }
26459 }
26460 anchorElementRef.current = null;
26461 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
26462 const intersectionObserverRef = (0, import_element77.useRef)(
26463 null
26464 );
26465 (0, import_element77.useEffect)(() => {
26466 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
26467 if (intersectionObserverRef.current) {
26468 intersectionObserverRef.current.disconnect();
26469 intersectionObserverRef.current = null;
26470 }
26471 return;
26472 }
26473 intersectionObserverRef.current = new IntersectionObserver(
26474 intersectionObserverCallback,
26475 { root: null, rootMargin: "0px", threshold: 0.1 }
26476 );
26477 return () => {
26478 if (intersectionObserverRef.current) {
26479 intersectionObserverRef.current.disconnect();
26480 intersectionObserverRef.current = null;
26481 }
26482 };
26483 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
26484 (0, import_element77.useEffect)(() => {
26485 if (!view.infiniteScrollEnabled || !containerRef.current) {
26486 return;
26487 }
26488 let lastScrollTop = 0;
26489 const BOTTOM_THRESHOLD = 600;
26490 const TOP_THRESHOLD = 800;
26491 const handleScroll = (0, import_compose13.throttle)((event) => {
26492 const currentView = viewRef.current;
26493 const totalItems = totalItemsRef.current;
26494 const target = event.target;
26495 const scrollTop = target.scrollTop;
26496 const scrollHeight = target.scrollHeight;
26497 const clientHeight = target.clientHeight;
26498 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
26499 lastScrollTop = scrollTop;
26500 if (isLoadingRef.current) {
26501 return;
26502 }
26503 const currentStartPosition = currentView.startPosition || 1;
26504 const batchSize = currentView.perPage || 10;
26505 const currentEndPosition = Math.min(
26506 currentStartPosition + batchSize,
26507 totalItems
26508 );
26509 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
26510 if (currentEndPosition < totalItems) {
26511 const newStartPosition = currentEndPosition;
26512 captureAnchorElement(target, anchorElementRef, "down");
26513 onChangeViewRef.current({
26514 ...currentView,
26515 startPosition: newStartPosition
26516 });
26517 }
26518 }
26519 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
26520 if (currentStartPosition > 1) {
26521 const calculatedStartPosition = currentStartPosition - batchSize;
26522 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
26523 captureAnchorElement(target, anchorElementRef, "up");
26524 onChangeViewRef.current({
26525 ...currentView,
26526 startPosition: newStartPosition
26527 });
26528 }
26529 }
26530 }, 50);
26531 const container = containerRef.current;
26532 container.addEventListener("scroll", handleScroll);
26533 return () => {
26534 container.removeEventListener("scroll", handleScroll);
26535 handleScroll.cancel();
26536 };
26537 }, [containerRef, view.infiniteScrollEnabled]);
26538 return {
26539 intersectionObserver: intersectionObserverRef.current
26540 };
26541 }
26542
26543 // packages/dataviews/build-module/dataviews/index.mjs
26544 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
26545 var defaultGetItemId = (item) => item.id;
26546 var defaultIsItemClickable = () => true;
26547 var EMPTY_ARRAY7 = [];
26548 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
26549 var dataViewsLayouts = VIEW_LAYOUTS.filter(
26550 (viewLayout) => !viewLayout.isPicker
26551 );
26552 function DefaultUI({
26553 header,
26554 search = true,
26555 searchLabel = void 0
26556 }) {
26557 const { view } = (0, import_element78.useContext)(dataviews_context_default);
26558 const isInfiniteScroll = view.infiniteScrollEnabled;
26559 return /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)(import_jsx_runtime113.Fragment, { children: [
26560 /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)(
26561 Stack,
26562 {
26563 direction: "row",
26564 align: "top",
26565 justify: "space-between",
26566 className: clsx_default("dataviews__view-actions", {
26567 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
26568 }),
26569 gap: "xs",
26570 children: [
26571 /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)(
26572 Stack,
26573 {
26574 direction: "row",
26575 justify: "start",
26576 gap: "sm",
26577 className: "dataviews__search",
26578 children: [
26579 search && /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(dataviews_search_default, { label: searchLabel }),
26580 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(toggle_default, {})
26581 ]
26582 }
26583 ),
26584 /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
26585 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(dataviews_view_config_default, {}),
26586 header
26587 ] })
26588 ]
26589 }
26590 ),
26591 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
26592 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(DataViewsLayout, {}),
26593 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(DataViewsFooter, {})
26594 ] });
26595 }
26596 function DataViews({
26597 view,
26598 onChangeView,
26599 fields,
26600 search = true,
26601 searchLabel = void 0,
26602 actions = EMPTY_ARRAY7,
26603 data,
26604 getItemId = defaultGetItemId,
26605 getItemLevel,
26606 isLoading = false,
26607 paginationInfo,
26608 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
26609 selection: selectionProperty,
26610 onChangeSelection,
26611 onClickItem,
26612 renderItemLink,
26613 isItemClickable = defaultIsItemClickable,
26614 header,
26615 children,
26616 config = { perPageSizes: [10, 20, 50, 100] },
26617 empty,
26618 onReset
26619 }) {
26620 const [selectionState, setSelectionState] = (0, import_element78.useState)([]);
26621 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
26622 const selection = isUncontrolled ? selectionState : selectionProperty;
26623 const {
26624 data: displayData,
26625 paginationInfo: displayPaginationInfo,
26626 hasInitiallyLoaded,
26627 setVisibleEntries
26628 } = useData({
26629 view,
26630 data,
26631 getItemId,
26632 isLoading,
26633 selection,
26634 paginationInfo
26635 });
26636 const containerRef = (0, import_element78.useRef)(null);
26637 const [containerWidth, setContainerWidth] = (0, import_element78.useState)(0);
26638 const resizeObserverRef = (0, import_compose14.useResizeObserver)(
26639 (resizeObserverEntries) => {
26640 setContainerWidth(
26641 resizeObserverEntries[0].borderBoxSize[0].inlineSize
26642 );
26643 },
26644 { box: "border-box" }
26645 );
26646 const [openedFilter, setOpenedFilter] = (0, import_element78.useState)(null);
26647 function setSelectionWithChange(value) {
26648 const newValue = typeof value === "function" ? value(selection) : value;
26649 if (isUncontrolled) {
26650 setSelectionState(newValue);
26651 }
26652 if (onChangeSelection) {
26653 onChangeSelection(newValue);
26654 }
26655 }
26656 const _fields = (0, import_element78.useMemo)(() => normalizeFields(fields), [fields]);
26657 const _selection = (0, import_element78.useMemo)(() => {
26658 if (view.infiniteScrollEnabled) {
26659 return selection;
26660 }
26661 return selection.filter(
26662 (id) => data.some((item) => getItemId(item) === id)
26663 );
26664 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
26665 const filters = use_filters_default(_fields, view);
26666 const hasPrimaryOrLockedFilters = (0, import_element78.useMemo)(
26667 () => (filters || []).some(
26668 (filter) => filter.isPrimary || filter.isLocked
26669 ),
26670 [filters]
26671 );
26672 const [isShowingFilter, setIsShowingFilter] = (0, import_element78.useState)(
26673 hasPrimaryOrLockedFilters
26674 );
26675 const { intersectionObserver } = useInfiniteScroll({
26676 view,
26677 onChangeView,
26678 isLoading,
26679 paginationInfo,
26680 containerRef,
26681 setVisibleEntries
26682 });
26683 (0, import_element78.useEffect)(() => {
26684 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
26685 setIsShowingFilter(true);
26686 }
26687 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
26688 const defaultLayouts = (0, import_element78.useMemo)(
26689 () => Object.fromEntries(
26690 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
26691 return dataViewsLayouts.some(
26692 (viewLayout) => viewLayout.type === layoutType
26693 );
26694 }).map(([key, value]) => [
26695 key,
26696 value === true ? {} : value
26697 ])
26698 ),
26699 [defaultLayoutsProperty]
26700 );
26701 if (!defaultLayouts[view.type]) {
26702 return null;
26703 }
26704 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
26705 dataviews_context_default.Provider,
26706 {
26707 value: {
26708 view,
26709 onChangeView,
26710 fields: _fields,
26711 actions,
26712 data: displayData,
26713 isLoading,
26714 paginationInfo: displayPaginationInfo,
26715 selection: _selection,
26716 onChangeSelection: setSelectionWithChange,
26717 openedFilter,
26718 setOpenedFilter,
26719 getItemId,
26720 getItemLevel,
26721 isItemClickable,
26722 onClickItem,
26723 renderItemLink,
26724 containerWidth,
26725 containerRef,
26726 resizeObserverRef,
26727 defaultLayouts,
26728 filters,
26729 isShowingFilter,
26730 setIsShowingFilter,
26731 config,
26732 empty,
26733 hasInitiallyLoaded,
26734 onReset,
26735 intersectionObserver
26736 },
26737 children: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
26738 DefaultUI,
26739 {
26740 header,
26741 search,
26742 searchLabel
26743 }
26744 ) })
26745 }
26746 );
26747 }
26748 var DataViewsSubComponents = DataViews;
26749 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
26750 DataViewsSubComponents.Filters = filters_default;
26751 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
26752 DataViewsSubComponents.FiltersToggle = toggle_default;
26753 DataViewsSubComponents.Layout = DataViewsLayout;
26754 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
26755 DataViewsSubComponents.Pagination = DataViewsPagination;
26756 DataViewsSubComponents.Search = dataviews_search_default;
26757 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
26758 DataViewsSubComponents.Footer = DataViewsFooter;
26759 var dataviews_default = DataViewsSubComponents;
26760
26761 // packages/dataviews/build-module/utils/filter-sort-and-paginate.mjs
26762 var import_remove_accents2 = __toESM(require_remove_accents(), 1);
26763 var import_deprecated = __toESM(require_deprecated(), 1);
26764 function normalizeSearchInput2(input = "") {
26765 return (0, import_remove_accents2.default)(input.trim().toLowerCase());
26766 }
26767 var EMPTY_ARRAY8 = [];
26768 function filterSortAndPaginate(data, view, fields) {
26769 if (!data) {
26770 return {
26771 data: EMPTY_ARRAY8,
26772 paginationInfo: { totalItems: 0, totalPages: 0 }
26773 };
26774 }
26775 const _fields = normalizeFields(fields);
26776 let filteredData = [...data];
26777 if (view.search) {
26778 const normalizedSearch = normalizeSearchInput2(view.search);
26779 filteredData = filteredData.filter((item) => {
26780 return _fields.filter((field) => field.enableGlobalSearch).some((field) => {
26781 const fieldValue = field.getValue({ item });
26782 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
26783 return values.some(
26784 (value) => normalizeSearchInput2(String(value)).includes(
26785 normalizedSearch
26786 )
26787 );
26788 });
26789 });
26790 }
26791 if (view.filters && view.filters?.length > 0) {
26792 view.filters.forEach((filter) => {
26793 const field = _fields.find(
26794 (_field) => _field.id === filter.field
26795 );
26796 if (field) {
26797 if (filter.operator === OPERATOR_IS_NOT_ALL) {
26798 (0, import_deprecated.default)("The 'isNotAll' filter operator", {
26799 since: "7.0",
26800 alternative: "'isNone'"
26801 });
26802 }
26803 const handler = field.filter[filter.operator];
26804 if (handler) {
26805 filteredData = filteredData.filter(
26806 (item) => handler(item, field, filter.value)
26807 );
26808 }
26809 }
26810 });
26811 }
26812 const sortByField = view.sort?.field ? _fields.find((field) => {
26813 return field.enableSorting !== false && field.id === view.sort?.field;
26814 }) : null;
26815 const groupByField = view.groupBy?.field ? _fields.find((field) => {
26816 return field.enableSorting !== false && field.id === view.groupBy?.field;
26817 }) : null;
26818 if (sortByField || groupByField) {
26819 filteredData.sort((a2, b2) => {
26820 if (groupByField) {
26821 const groupCompare = groupByField.sort(
26822 a2,
26823 b2,
26824 view.groupBy?.direction ?? "asc"
26825 );
26826 if (groupCompare !== 0) {
26827 return groupCompare;
26828 }
26829 }
26830 if (sortByField) {
26831 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc");
26832 }
26833 return 0;
26834 });
26835 }
26836 let totalItems = filteredData.length;
26837 let totalPages = 1;
26838 if (view.infiniteScrollEnabled && view.startPosition !== void 0 && view.perPage !== void 0) {
26839 const start = view.startPosition - 1;
26840 const end = Math.min(start + view.perPage, totalItems);
26841 filteredData = filteredData?.slice(start, end);
26842 } else if (view.page !== void 0 && view.perPage !== void 0) {
26843 const start = (view.page - 1) * view.perPage;
26844 totalItems = filteredData?.length || 0;
26845 totalPages = Math.ceil(totalItems / view.perPage);
26846 filteredData = filteredData?.slice(start, start + view.perPage);
26847 }
26848 return {
26849 data: filteredData,
26850 paginationInfo: {
26851 totalItems,
26852 totalPages
26853 }
26854 };
26855 }
26856
26857 // packages/admin-ui/build-module/navigable-region/index.mjs
26858 var import_element79 = __toESM(require_element(), 1);
26859 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
26860 var NavigableRegion = (0, import_element79.forwardRef)(
26861 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
26862 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26863 Tag,
26864 {
26865 ref,
26866 className: clsx_default("admin-ui-navigable-region", className),
26867 "aria-label": ariaLabel,
26868 role: "region",
26869 tabIndex: "-1",
26870 ...props,
26871 children
26872 }
26873 );
26874 }
26875 );
26876 NavigableRegion.displayName = "NavigableRegion";
26877 var navigable_region_default = NavigableRegion;
26878
26879 // packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs
26880 var import_components47 = __toESM(require_components(), 1);
26881 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components47.createSlotFill)("SidebarToggle");
26882
26883 // packages/admin-ui/build-module/page/header.mjs
26884 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
26885 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
26886 function getRuntime7() {
26887 const globalScope = globalThis;
26888 if (globalScope.__wpStyleRuntime) {
26889 return globalScope.__wpStyleRuntime;
26890 }
26891 globalScope.__wpStyleRuntime = {
26892 documents: /* @__PURE__ */ new Map(),
26893 styles: /* @__PURE__ */ new Map(),
26894 injectedStyles: /* @__PURE__ */ new WeakMap()
26895 };
26896 if (typeof document !== "undefined") {
26897 registerDocument7(document);
26898 }
26899 return globalScope.__wpStyleRuntime;
26900 }
26901 function documentContainsStyleHash7(targetDocument, hash) {
26902 if (!targetDocument.head) {
26903 return false;
26904 }
26905 for (const style of targetDocument.head.querySelectorAll(
26906 `style[${STYLE_HASH_ATTRIBUTE7}]`
26907 )) {
26908 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
26909 return true;
26910 }
26911 }
26912 return false;
26913 }
26914 function injectStyle7(targetDocument, hash, css) {
26915 if (!targetDocument.head) {
26916 return;
26917 }
26918 const runtime = getRuntime7();
26919 let injectedStyles = runtime.injectedStyles.get(targetDocument);
26920 if (!injectedStyles) {
26921 injectedStyles = /* @__PURE__ */ new Set();
26922 runtime.injectedStyles.set(targetDocument, injectedStyles);
26923 }
26924 if (injectedStyles.has(hash)) {
26925 return;
26926 }
26927 if (documentContainsStyleHash7(targetDocument, hash)) {
26928 injectedStyles.add(hash);
26929 return;
26930 }
26931 const style = targetDocument.createElement("style");
26932 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
26933 style.appendChild(targetDocument.createTextNode(css));
26934 targetDocument.head.appendChild(style);
26935 injectedStyles.add(hash);
26936 }
26937 function registerDocument7(targetDocument) {
26938 const runtime = getRuntime7();
26939 runtime.documents.set(
26940 targetDocument,
26941 (runtime.documents.get(targetDocument) ?? 0) + 1
26942 );
26943 for (const [hash, css] of runtime.styles) {
26944 injectStyle7(targetDocument, hash, css);
26945 }
26946 return () => {
26947 const count = runtime.documents.get(targetDocument);
26948 if (count === void 0) {
26949 return;
26950 }
26951 if (count <= 1) {
26952 runtime.documents.delete(targetDocument);
26953 return;
26954 }
26955 runtime.documents.set(targetDocument, count - 1);
26956 };
26957 }
26958 function registerStyle7(hash, css) {
26959 const runtime = getRuntime7();
26960 runtime.styles.set(hash, css);
26961 for (const targetDocument of runtime.documents.keys()) {
26962 injectStyle7(targetDocument, hash, css);
26963 }
26964 }
26965 if (typeof process === "undefined" || true) {
26966 registerStyle7("ddd9aab364", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-background-surface-neutral,#fcfcfc);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-background-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);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:var(--wpds-dimension-size-md,32px)}.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:var(--wpds-dimension-size-sm,24px);width:var(--wpds-dimension-size-sm,24px);>*{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-foreground-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)}}");
26967 }
26968 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" };
26969 function Header({
26970 headingLevel = 1,
26971 breadcrumbs,
26972 badges,
26973 visual,
26974 title,
26975 subTitle,
26976 actions,
26977 showSidebarToggle = true
26978 }) {
26979 const HeadingTag = `h${headingLevel}`;
26980 return /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)(Stack, { direction: "column", className: style_default6.header, children: [
26981 /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)(
26982 Stack,
26983 {
26984 className: style_default6["header-content"],
26985 direction: "row",
26986 gap: "sm",
26987 justify: "space-between",
26988 children: [
26989 /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", justify: "start", children: [
26990 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
26991 SidebarToggleSlot,
26992 {
26993 bubblesVirtually: true,
26994 className: style_default6["sidebar-toggle-slot"]
26995 }
26996 ),
26997 visual && /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
26998 "div",
26999 {
27000 className: style_default6["header-visual"],
27001 "aria-hidden": "true",
27002 children: visual
27003 }
27004 ),
27005 title && /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
27006 Text,
27007 {
27008 className: style_default6["header-title"],
27009 render: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(HeadingTag, {}),
27010 variant: "heading-lg",
27011 children: title
27012 }
27013 ),
27014 breadcrumbs,
27015 badges
27016 ] }),
27017 actions && /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
27018 Stack,
27019 {
27020 align: "center",
27021 className: style_default6["header-actions"],
27022 direction: "row",
27023 gap: "sm",
27024 children: actions
27025 }
27026 )
27027 ]
27028 }
27029 ),
27030 subTitle && /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
27031 Text,
27032 {
27033 render: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)("p", {}),
27034 variant: "body-md",
27035 className: style_default6["header-subtitle"],
27036 children: subTitle
27037 }
27038 )
27039 ] });
27040 }
27041
27042 // packages/admin-ui/build-module/page/index.mjs
27043 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
27044 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
27045 function getRuntime8() {
27046 const globalScope = globalThis;
27047 if (globalScope.__wpStyleRuntime) {
27048 return globalScope.__wpStyleRuntime;
27049 }
27050 globalScope.__wpStyleRuntime = {
27051 documents: /* @__PURE__ */ new Map(),
27052 styles: /* @__PURE__ */ new Map(),
27053 injectedStyles: /* @__PURE__ */ new WeakMap()
27054 };
27055 if (typeof document !== "undefined") {
27056 registerDocument8(document);
27057 }
27058 return globalScope.__wpStyleRuntime;
27059 }
27060 function documentContainsStyleHash8(targetDocument, hash) {
27061 if (!targetDocument.head) {
27062 return false;
27063 }
27064 for (const style of targetDocument.head.querySelectorAll(
27065 `style[${STYLE_HASH_ATTRIBUTE8}]`
27066 )) {
27067 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
27068 return true;
27069 }
27070 }
27071 return false;
27072 }
27073 function injectStyle8(targetDocument, hash, css) {
27074 if (!targetDocument.head) {
27075 return;
27076 }
27077 const runtime = getRuntime8();
27078 let injectedStyles = runtime.injectedStyles.get(targetDocument);
27079 if (!injectedStyles) {
27080 injectedStyles = /* @__PURE__ */ new Set();
27081 runtime.injectedStyles.set(targetDocument, injectedStyles);
27082 }
27083 if (injectedStyles.has(hash)) {
27084 return;
27085 }
27086 if (documentContainsStyleHash8(targetDocument, hash)) {
27087 injectedStyles.add(hash);
27088 return;
27089 }
27090 const style = targetDocument.createElement("style");
27091 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
27092 style.appendChild(targetDocument.createTextNode(css));
27093 targetDocument.head.appendChild(style);
27094 injectedStyles.add(hash);
27095 }
27096 function registerDocument8(targetDocument) {
27097 const runtime = getRuntime8();
27098 runtime.documents.set(
27099 targetDocument,
27100 (runtime.documents.get(targetDocument) ?? 0) + 1
27101 );
27102 for (const [hash, css] of runtime.styles) {
27103 injectStyle8(targetDocument, hash, css);
27104 }
27105 return () => {
27106 const count = runtime.documents.get(targetDocument);
27107 if (count === void 0) {
27108 return;
27109 }
27110 if (count <= 1) {
27111 runtime.documents.delete(targetDocument);
27112 return;
27113 }
27114 runtime.documents.set(targetDocument, count - 1);
27115 };
27116 }
27117 function registerStyle8(hash, css) {
27118 const runtime = getRuntime8();
27119 runtime.styles.set(hash, css);
27120 for (const targetDocument of runtime.documents.keys()) {
27121 injectStyle8(targetDocument, hash, css);
27122 }
27123 }
27124 if (typeof process === "undefined" || true) {
27125 registerStyle8("ddd9aab364", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-background-surface-neutral,#fcfcfc);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-background-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);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:var(--wpds-dimension-size-md,32px)}.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:var(--wpds-dimension-size-sm,24px);width:var(--wpds-dimension-size-sm,24px);>*{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-foreground-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)}}");
27126 }
27127 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" };
27128 function Page({
27129 headingLevel,
27130 breadcrumbs,
27131 badges,
27132 visual,
27133 title,
27134 subTitle,
27135 children,
27136 className,
27137 actions,
27138 ariaLabel,
27139 hasPadding = false,
27140 showSidebarToggle = true
27141 }) {
27142 const classes = clsx_default(style_default7.page, className);
27143 const effectiveAriaLabel = ariaLabel ?? (typeof title === "string" ? title : "");
27144 return /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(navigable_region_default, { className: classes, ariaLabel: effectiveAriaLabel, children: [
27145 (title || breadcrumbs || badges || actions || visual) && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
27146 Header,
27147 {
27148 headingLevel,
27149 breadcrumbs,
27150 badges,
27151 visual,
27152 title,
27153 subTitle,
27154 actions,
27155 showSidebarToggle
27156 }
27157 ),
27158 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
27159 "div",
27160 {
27161 className: clsx_default(
27162 style_default7.content,
27163 style_default7["has-padding"]
27164 ),
27165 children
27166 }
27167 ) : children
27168 ] });
27169 }
27170 Page.SidebarToggleFill = SidebarToggleFill;
27171 var page_default = Page;
27172
27173 // routes/pattern-list/stage.tsx
27174 var import_core_data4 = __toESM(require_core_data());
27175 var import_components48 = __toESM(require_components());
27176 var import_data11 = __toESM(require_data());
27177 var import_element82 = __toESM(require_element());
27178 var import_editor = __toESM(require_editor());
27179 var import_patterns3 = __toESM(require_patterns());
27180 var import_i18n48 = __toESM(require_i18n());
27181
27182 // routes/lock-unlock/index.ts
27183 var import_private_apis4 = __toESM(require_private_apis());
27184 var { lock: lock4, unlock: unlock4 } = (0, import_private_apis4.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
27185 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
27186 "@wordpress/routes"
27187 );
27188
27189 // routes/pattern-list/view-utils.ts
27190 var import_i18n44 = __toESM(require_i18n());
27191 var LAYOUT_GRID2 = "grid";
27192 var LAYOUT_TABLE2 = "table";
27193 var DEFAULT_VIEW = {
27194 type: LAYOUT_GRID2,
27195 perPage: 20,
27196 sort: {
27197 field: "title",
27198 direction: "asc"
27199 },
27200 filters: [],
27201 fields: ["sync-status"],
27202 layout: {
27203 badgeFields: ["sync-status"]
27204 },
27205 titleField: "title",
27206 mediaField: "preview"
27207 };
27208 var DEFAULT_VIEWS = [
27209 {
27210 slug: "all",
27211 label: (0, import_i18n44.__)("All patterns")
27212 },
27213 {
27214 slug: "my-patterns",
27215 label: (0, import_i18n44.__)("My patterns")
27216 },
27217 {
27218 slug: "registered",
27219 label: (0, import_i18n44.__)("Registered")
27220 }
27221 ];
27222 var DEFAULT_LAYOUTS2 = {
27223 [LAYOUT_TABLE2]: true,
27224 [LAYOUT_GRID2]: {
27225 layout: {
27226 badgeFields: ["sync-status"]
27227 }
27228 }
27229 };
27230
27231 // routes/pattern-list/fields/preview.tsx
27232 var import_i18n45 = __toESM(require_i18n());
27233 import { Preview } from "@wordpress/lazy-editor";
27234 function PreviewField({ item }) {
27235 return /* @__PURE__ */ React.createElement(
27236 Preview,
27237 {
27238 blocks: item.blocks,
27239 content: item.content,
27240 description: item.description
27241 }
27242 );
27243 }
27244 var previewField = {
27245 label: (0, import_i18n45.__)("Preview"),
27246 id: "preview",
27247 render: PreviewField,
27248 enableSorting: false
27249 };
27250
27251 // routes/pattern-list/fields/sync-status.tsx
27252 var import_i18n46 = __toESM(require_i18n());
27253 var import_patterns = __toESM(require_patterns());
27254 var { PATTERN_SYNC_TYPES } = unlock4(import_patterns.privateApis);
27255 var OPERATOR_IS2 = "is";
27256 var SYNC_FILTERS = [
27257 {
27258 value: PATTERN_SYNC_TYPES.full,
27259 label: (0, import_i18n46._x)("Synced", "pattern (singular)"),
27260 description: (0, import_i18n46.__)("Patterns that are kept in sync across the site.")
27261 },
27262 {
27263 value: PATTERN_SYNC_TYPES.unsynced,
27264 label: (0, import_i18n46._x)("Not synced", "pattern (singular)"),
27265 description: (0, import_i18n46.__)(
27266 "Patterns that can be changed freely without affecting the site."
27267 )
27268 }
27269 ];
27270 var patternStatusField = {
27271 label: (0, import_i18n46.__)("Sync status"),
27272 id: "sync-status",
27273 render: ({ item }) => {
27274 const syncStatus = item.syncStatus;
27275 return /* @__PURE__ */ React.createElement(
27276 "span",
27277 {
27278 className: `routes-pattern-list__field-sync-status-${syncStatus}`
27279 },
27280 SYNC_FILTERS.find(({ value }) => value === syncStatus)?.label
27281 );
27282 },
27283 elements: SYNC_FILTERS,
27284 filterBy: {
27285 operators: [OPERATOR_IS2],
27286 isPrimary: true
27287 },
27288 enableSorting: false
27289 };
27290
27291 // routes/pattern-list/fields/category.tsx
27292 var import_i18n47 = __toESM(require_i18n());
27293 var import_data9 = __toESM(require_data());
27294 var import_core_data2 = __toESM(require_core_data());
27295 var import_element80 = __toESM(require_element());
27296 var OPERATOR_IS3 = "is";
27297 function CategoryField({ item }) {
27298 const blockPatternCategories = (0, import_data9.useSelect)(
27299 (select2) => select2(import_core_data2.store).getBlockPatternCategories(),
27300 []
27301 );
27302 const categoryLabels = (0, import_element80.useMemo)(() => {
27303 if (!item.categories || !Array.isArray(item.categories)) {
27304 return [];
27305 }
27306 return item.categories.map((catSlug) => {
27307 const category = blockPatternCategories?.find(
27308 (cat) => cat.name === catSlug
27309 );
27310 return category ? category.label || category.name : null;
27311 }).filter(Boolean);
27312 }, [item.categories, blockPatternCategories]);
27313 if (categoryLabels.length === 0) {
27314 return /* @__PURE__ */ React.createElement("span", { className: "pattern-category-field__empty" }, "\u2014");
27315 }
27316 return /* @__PURE__ */ React.createElement("span", { className: "pattern-category-field" }, categoryLabels.join(", "));
27317 }
27318 function usePatternCategories() {
27319 const userPatternCategories = (0, import_data9.useSelect)(
27320 (select2) => select2(import_core_data2.store).getUserPatternCategories(),
27321 []
27322 );
27323 const blockPatternCategories = (0, import_data9.useSelect)(
27324 (select2) => select2(import_core_data2.store).getBlockPatternCategories(),
27325 []
27326 );
27327 return (0, import_element80.useMemo)(() => {
27328 const categoryMap = /* @__PURE__ */ new Map();
27329 userPatternCategories?.forEach((cat) => {
27330 if (!categoryMap.has(cat.name)) {
27331 categoryMap.set(cat.name, {
27332 value: cat.name,
27333 label: cat.label || cat.name
27334 });
27335 }
27336 });
27337 blockPatternCategories?.forEach((cat) => {
27338 if (!categoryMap.has(cat.name)) {
27339 categoryMap.set(cat.name, {
27340 value: cat.name,
27341 label: cat.label || cat.name
27342 });
27343 }
27344 });
27345 return Array.from(categoryMap.values()).sort(
27346 (a2, b2) => a2.label.localeCompare(b2.label)
27347 );
27348 }, [userPatternCategories, blockPatternCategories]);
27349 }
27350 function usePatternCategoryField() {
27351 const categories = usePatternCategories();
27352 return {
27353 label: (0, import_i18n47.__)("Category"),
27354 id: "category",
27355 render: CategoryField,
27356 elements: categories,
27357 getValue: ({ item }) => {
27358 return item.categories;
27359 },
27360 filterBy: {
27361 operators: [OPERATOR_IS3],
27362 isPrimary: true
27363 },
27364 enableSorting: false
27365 };
27366 }
27367
27368 // routes/pattern-list/use-patterns.ts
27369 var import_data10 = __toESM(require_data());
27370 var import_core_data3 = __toESM(require_core_data());
27371 var import_element81 = __toESM(require_element());
27372 var import_patterns2 = __toESM(require_patterns());
27373 var import_block_editor = __toESM(require_block_editor());
27374
27375 // routes/pattern-list/utils.ts
27376 var filterOutDuplicatesByName = (currentItem, index2, items) => index2 === items.findIndex((item) => currentItem.name === item.name);
27377
27378 // routes/pattern-list/use-patterns.ts
27379 var {
27380 PATTERN_TYPES,
27381 PATTERN_SYNC_TYPES: PATTERN_SYNC_TYPES2,
27382 EXCLUDED_PATTERN_SOURCES,
27383 PATTERN_DEFAULT_CATEGORY
27384 } = unlock4(import_patterns2.privateApis);
27385 var { extractWords, getNormalizedSearchTerms, normalizeString: normalizeString2 } = unlock4(
27386 import_block_editor.privateApis
27387 );
27388 function normalizeThemePattern(pattern) {
27389 return {
27390 id: pattern.name,
27391 title: pattern.title,
27392 content: pattern.content,
27393 keywords: pattern.keywords || [],
27394 type: PATTERN_TYPES.theme,
27395 // Normalize categories to always be an array of slugs
27396 categories: pattern.categories || [],
27397 // Theme patterns are always unsynced
27398 syncStatus: PATTERN_SYNC_TYPES2.unsynced,
27399 description: pattern.description || ""
27400 };
27401 }
27402 function normalizeUserPattern(pattern, userPatternCategories) {
27403 const categories = [];
27404 if (pattern.wp_pattern_category && Array.isArray(pattern.wp_pattern_category)) {
27405 pattern.wp_pattern_category.forEach((catId) => {
27406 const category = userPatternCategories?.find(
27407 (cat) => cat.id === catId
27408 );
27409 if (category) {
27410 categories.push(category.name);
27411 }
27412 });
27413 }
27414 const numericId = pattern.id;
27415 return {
27416 id: pattern.name || pattern.id.toString(),
27417 _recordId: numericId,
27418 // Keep numeric ID for permissions lookup
27419 keywords: [],
27420 type: PATTERN_TYPES.user,
27421 // Normalize categories to always be an array of slugs
27422 categories,
27423 // Normalize sync status
27424 syncStatus: pattern.wp_pattern_sync_status || PATTERN_SYNC_TYPES2.full,
27425 title: typeof pattern.title === "string" ? pattern.title : pattern.title.raw,
27426 content: typeof pattern.content === "string" ? pattern.content : pattern.content.raw,
27427 description: pattern.excerpt?.raw || "",
27428 blocks: pattern.blocks
27429 };
27430 }
27431 var removeMatchingTerms = (unmatchedTerms, unprocessedTerms) => {
27432 return unmatchedTerms.filter(
27433 (term) => !getNormalizedSearchTerms(unprocessedTerms).some(
27434 (unprocessedTerm) => unprocessedTerm.includes(term)
27435 )
27436 );
27437 };
27438 function getItemSearchRank(item, searchTerm, config) {
27439 const { categoryId, hasCategory, onlyFilterByCategory } = config;
27440 let rank = categoryId === PATTERN_DEFAULT_CATEGORY || categoryId === "my-patterns" && item.type === PATTERN_TYPES.user || hasCategory && hasCategory(item, categoryId || "") ? 1 : 0;
27441 if (!rank || onlyFilterByCategory) {
27442 return rank;
27443 }
27444 const normalizedSearchInput = normalizeString2(searchTerm);
27445 const normalizedTitle = normalizeString2(item.title);
27446 if (normalizedSearchInput === normalizedTitle) {
27447 rank += 30;
27448 } else if (normalizedTitle.startsWith(normalizedSearchInput)) {
27449 rank += 20;
27450 } else {
27451 const terms = [
27452 item.id,
27453 item.title,
27454 item.description,
27455 ...item.keywords
27456 ].join(" ");
27457 const normalizedSearchTerms = extractWords(normalizedSearchInput);
27458 const unmatchedTerms = removeMatchingTerms(
27459 normalizedSearchTerms,
27460 terms
27461 );
27462 if (unmatchedTerms.length === 0) {
27463 rank += 10;
27464 }
27465 }
27466 return rank;
27467 }
27468 function searchItems(items = [], searchInput = "", config = {}) {
27469 const normalizedSearchTerms = getNormalizedSearchTerms(searchInput);
27470 const onlyFilterByCategory = config.categoryId !== PATTERN_DEFAULT_CATEGORY && !normalizedSearchTerms.length;
27471 const searchRankConfig = { ...config, onlyFilterByCategory };
27472 const threshold = onlyFilterByCategory ? 0 : 1;
27473 const rankedItems = items.map((item) => {
27474 return [
27475 item,
27476 getItemSearchRank(item, searchInput, searchRankConfig)
27477 ];
27478 }).filter(([, rank]) => rank > threshold);
27479 if (normalizedSearchTerms.length === 0) {
27480 return rankedItems.map(([item]) => item);
27481 }
27482 rankedItems.sort(([, rank1], [, rank2]) => rank2 - rank1);
27483 return rankedItems.map(([item]) => item);
27484 }
27485 var selectThemePatterns = (0, import_data10.createSelector)(
27486 (select2) => {
27487 const { getBlockPatterns } = select2(import_core_data3.store);
27488 const { isResolving: isResolvingSelector } = select2(import_core_data3.store);
27489 const restBlockPatterns = getBlockPatterns();
27490 const patterns = (restBlockPatterns || []).filter(
27491 (pattern) => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source)
27492 ).filter(filterOutDuplicatesByName).filter((pattern) => pattern.inserter !== false).map(normalizeThemePattern);
27493 return {
27494 patterns,
27495 isResolving: isResolvingSelector("getBlockPatterns")
27496 };
27497 },
27498 (select2) => [
27499 select2(import_core_data3.store).getBlockPatterns(),
27500 select2(import_core_data3.store).isResolving("getBlockPatterns")
27501 ]
27502 );
27503 var selectUserPatterns = (0, import_data10.createSelector)(
27504 (select2, syncStatus = void 0, search = "") => {
27505 const {
27506 getEntityRecords,
27507 isResolving: isResolvingSelector,
27508 getUserPatternCategories
27509 } = select2(import_core_data3.store);
27510 const query = { per_page: -1 };
27511 const patternPosts = getEntityRecords(
27512 "postType",
27513 PATTERN_TYPES.user,
27514 query
27515 );
27516 const userPatternCategories = getUserPatternCategories();
27517 let patterns = (patternPosts ?? []).map(
27518 (pattern) => normalizeUserPattern(pattern, userPatternCategories)
27519 );
27520 const isResolving = isResolvingSelector("getEntityRecords", [
27521 "postType",
27522 PATTERN_TYPES.user,
27523 query
27524 ]);
27525 if (syncStatus) {
27526 patterns = patterns.filter(
27527 (pattern) => pattern.syncStatus === syncStatus
27528 );
27529 }
27530 patterns = searchItems(patterns, search, {
27531 // We exit user pattern retrieval early if we aren't in the
27532 // catch-all category for user created patterns, so it has
27533 // to be in the category.
27534 categoryId: PATTERN_DEFAULT_CATEGORY,
27535 hasCategory: () => true
27536 });
27537 return {
27538 patterns,
27539 isResolving,
27540 categories: userPatternCategories
27541 };
27542 },
27543 (select2) => [
27544 select2(import_core_data3.store).getEntityRecords("postType", PATTERN_TYPES.user, {
27545 per_page: -1
27546 }),
27547 select2(import_core_data3.store).isResolving("getEntityRecords", [
27548 "postType",
27549 PATTERN_TYPES.user,
27550 { per_page: -1 }
27551 ]),
27552 select2(import_core_data3.store).getUserPatternCategories()
27553 ]
27554 );
27555 var selectPatterns = (0, import_data10.createSelector)(
27556 (select2, categoryId, syncStatus, search = "") => {
27557 const {
27558 patterns: themePatterns,
27559 isResolving: isResolvingThemePatterns
27560 } = selectThemePatterns(select2);
27561 const { patterns: userPatterns, isResolving: isResolvingUserPatterns } = selectUserPatterns(select2);
27562 let patterns = [
27563 ...themePatterns || [],
27564 ...userPatterns || []
27565 ];
27566 if (syncStatus) {
27567 patterns = patterns.filter(
27568 (pattern) => pattern.syncStatus === syncStatus
27569 );
27570 }
27571 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
27572 patterns = searchItems(patterns, search, {
27573 categoryId,
27574 hasCategory: (item, currentCategory) => {
27575 return item.categories?.includes(currentCategory);
27576 }
27577 });
27578 } else {
27579 patterns = searchItems(patterns, search, {
27580 categoryId: PATTERN_DEFAULT_CATEGORY,
27581 hasCategory: () => true
27582 });
27583 }
27584 return {
27585 patterns,
27586 isResolving: isResolvingThemePatterns || isResolvingUserPatterns
27587 };
27588 },
27589 (select2) => [
27590 selectThemePatterns(select2),
27591 selectUserPatterns(select2)
27592 ]
27593 );
27594 function useAugmentPatternsWithPermissions(patterns) {
27595 const idsAndTypes = (0, import_element81.useMemo)(
27596 () => patterns?.filter((record) => record.type !== PATTERN_TYPES.theme).map((record) => [
27597 record.type,
27598 record._recordId,
27599 record.id
27600 ]) ?? [],
27601 [patterns]
27602 );
27603 const permissions = (0, import_data10.useSelect)(
27604 (select2) => {
27605 const { getEntityRecordPermissions } = unlock4(
27606 select2(import_core_data3.store)
27607 );
27608 return idsAndTypes.reduce(
27609 (acc, [type, numericId, stringId]) => {
27610 acc[stringId] = getEntityRecordPermissions(
27611 "postType",
27612 type,
27613 numericId
27614 );
27615 return acc;
27616 },
27617 {}
27618 );
27619 },
27620 [idsAndTypes]
27621 );
27622 return (0, import_element81.useMemo)(
27623 () => patterns?.map((record) => ({
27624 ...record,
27625 permissions: permissions?.[record.id] ?? {}
27626 })) ?? [],
27627 [patterns, permissions]
27628 );
27629 }
27630 var usePatterns = (postType, categoryId, { search = "", syncStatus } = {}) => {
27631 return (0, import_data10.useSelect)(
27632 (select2) => {
27633 if (postType === PATTERN_TYPES.user) {
27634 const result = selectUserPatterns(select2, syncStatus, search);
27635 let { patterns } = result;
27636 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
27637 patterns = patterns.filter(
27638 (pattern) => pattern.categories.includes(categoryId)
27639 );
27640 }
27641 return {
27642 patterns,
27643 isResolving: result.isResolving
27644 };
27645 } else if (postType === PATTERN_TYPES.theme) {
27646 const result = selectThemePatterns(select2);
27647 let { patterns } = result;
27648 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
27649 patterns = patterns.filter(
27650 (pattern) => pattern.categories.includes(categoryId)
27651 );
27652 }
27653 patterns = searchItems(patterns, search, {
27654 categoryId: categoryId || PATTERN_DEFAULT_CATEGORY,
27655 hasCategory: () => true
27656 });
27657 return {
27658 patterns,
27659 isResolving: result.isResolving
27660 };
27661 }
27662 return selectPatterns(select2, categoryId, syncStatus, search);
27663 },
27664 [categoryId, postType, search, syncStatus]
27665 );
27666 };
27667 var use_patterns_default = usePatterns;
27668
27669 // routes/pattern-list/style.scss
27670 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='a3942f3f8d']")) {
27671 const style = document.createElement("style");
27672 style.setAttribute("data-wp-hash", "a3942f3f8d");
27673 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}.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)}"));
27674 document.head.appendChild(style);
27675 }
27676
27677 // routes/pattern-list/stage.tsx
27678 var { usePostActions, patternTitleField } = unlock4(import_editor.privateApis);
27679 var { Tabs } = unlock4(import_components48.privateApis);
27680 var { PATTERN_TYPES: PATTERN_TYPES2, CreatePatternModal } = unlock4(import_patterns3.privateApis);
27681 function PatternList() {
27682 const invalidate = useInvalidate();
27683 const { type = "all" } = useParams({
27684 from: "/patterns/list/$type"
27685 });
27686 const navigate = useNavigate();
27687 const searchParams = useSearch({ from: "/patterns/list/$type" });
27688 const postTypeObject = (0, import_data11.useSelect)(
27689 (select2) => select2(import_core_data4.store).getPostType("wp_block"),
27690 []
27691 );
27692 const labels = postTypeObject?.labels;
27693 const canCreateRecord = (0, import_data11.useSelect)(
27694 (select2) => select2(import_core_data4.store).canUser("create", {
27695 kind: "postType",
27696 name: "wp_block"
27697 }),
27698 []
27699 );
27700 const [showPatternModal, setShowPatternModal] = (0, import_element82.useState)(false);
27701 const handleQueryParamsChange = (0, import_element82.useCallback)(
27702 (params) => {
27703 navigate({
27704 search: {
27705 ...searchParams,
27706 ...params
27707 }
27708 });
27709 },
27710 [searchParams, navigate]
27711 );
27712 const { view, isModified, updateView, resetToDefault } = useView({
27713 kind: "postType",
27714 name: "wp_block",
27715 slug: "default-new",
27716 defaultView: DEFAULT_VIEW,
27717 queryParams: searchParams,
27718 onChangeQueryParams: handleQueryParamsChange
27719 });
27720 const onReset = () => {
27721 resetToDefault();
27722 invalidate();
27723 };
27724 const onChangeView = (newView) => {
27725 updateView(newView);
27726 if (newView.type !== view.type) {
27727 invalidate();
27728 }
27729 };
27730 const categoryFilter = (0, import_element82.useMemo)(() => {
27731 const filter = view.filters?.find((f2) => f2.field === "category");
27732 return filter?.value || "all-patterns";
27733 }, [view.filters]);
27734 const syncStatusFilter = (0, import_element82.useMemo)(() => {
27735 const filter = view.filters?.find((f2) => f2.field === "sync-status");
27736 return filter?.value;
27737 }, [view.filters]);
27738 const patternType = (0, import_element82.useMemo)(() => {
27739 if (type === "my-patterns") {
27740 return PATTERN_TYPES2.user;
27741 } else if (type === "registered") {
27742 return PATTERN_TYPES2.theme;
27743 }
27744 return null;
27745 }, [type]);
27746 const { patterns, isResolving } = use_patterns_default(
27747 patternType,
27748 categoryFilter,
27749 {
27750 search: view.search,
27751 syncStatus: syncStatusFilter
27752 }
27753 );
27754 const patternsWithPermissions = useAugmentPatternsWithPermissions(patterns);
27755 const patternCategoryField = usePatternCategoryField();
27756 const fields = (0, import_element82.useMemo)(() => {
27757 const patternFields = [
27758 previewField,
27759 patternTitleField,
27760 patternCategoryField
27761 ];
27762 if (type === "my-patterns" || type === "all") {
27763 patternFields.push(patternStatusField);
27764 }
27765 return patternFields;
27766 }, [type, patternCategoryField]);
27767 const { data: posts, paginationInfo } = (0, import_element82.useMemo)(() => {
27768 const viewWithoutFilters = { ...view };
27769 delete viewWithoutFilters.search;
27770 viewWithoutFilters.filters = [];
27771 return filterSortAndPaginate(
27772 patternsWithPermissions,
27773 viewWithoutFilters,
27774 fields
27775 );
27776 }, [patternsWithPermissions, view, fields]);
27777 const { totalItems, totalPages } = paginationInfo;
27778 const cleanupDeletedPostIdsFromUrl = (0, import_element82.useCallback)(
27779 (deletedItems) => {
27780 const deletedIds = deletedItems.map((item) => item.id);
27781 const currentPostIds = searchParams.postIds || [];
27782 const remainingPostIds = currentPostIds.filter(
27783 (id) => !deletedIds.includes(id)
27784 );
27785 if (remainingPostIds.length !== currentPostIds.length) {
27786 navigate({
27787 search: {
27788 ...searchParams,
27789 postIds: remainingPostIds.length > 0 ? remainingPostIds : void 0
27790 }
27791 });
27792 } else {
27793 invalidate();
27794 }
27795 },
27796 [invalidate, searchParams, navigate]
27797 );
27798 const postTypeActions = usePostActions({
27799 postType: "wp_block",
27800 context: "list",
27801 onActionPerformed: (actionId, items) => {
27802 if (actionId === "move-to-trash" || actionId === "permanently-delete") {
27803 cleanupDeletedPostIdsFromUrl(items);
27804 }
27805 }
27806 });
27807 const actions = (0, import_element82.useMemo)(() => {
27808 return [
27809 ...postTypeActions?.flatMap((action) => {
27810 if (action.id === "view-post-revisions") {
27811 return [];
27812 }
27813 return [action];
27814 })
27815 ];
27816 }, [postTypeActions]);
27817 const handleTabChange = (0, import_element82.useCallback)(
27818 (typeSlug) => {
27819 navigate({
27820 to: `/patterns/list/${typeSlug}`
27821 });
27822 },
27823 [navigate]
27824 );
27825 if (!postTypeObject) {
27826 return null;
27827 }
27828 const selection = searchParams.postIds ?? [];
27829 if (view.type === "list" && selection.length === 0 && posts?.length > 0) {
27830 selection.push(posts[0].id);
27831 }
27832 if (view.type === "list") {
27833 selection.splice(1);
27834 }
27835 return /* @__PURE__ */ React.createElement(
27836 page_default,
27837 {
27838 title: (0, import_i18n48.__)("Patterns"),
27839 headingLevel: 2,
27840 subTitle: (0, import_i18n48.__)(
27841 "Reusable design elements for your site. Create once, use everywhere."
27842 ),
27843 className: "pattern-page",
27844 actions: labels?.add_new_item && canCreateRecord && /* @__PURE__ */ React.createElement(
27845 import_components48.Button,
27846 {
27847 variant: "primary",
27848 onClick: () => setShowPatternModal(true),
27849 size: "compact"
27850 },
27851 labels.add_new_item
27852 ),
27853 hasPadding: false
27854 },
27855 DEFAULT_VIEWS.length > 1 && /* @__PURE__ */ React.createElement("div", { className: "routes-pattern-list__tabs-wrapper" }, /* @__PURE__ */ React.createElement(
27856 Tabs,
27857 {
27858 onSelect: handleTabChange,
27859 selectedTabId: type ?? "all"
27860 },
27861 /* @__PURE__ */ React.createElement(Tabs.TabList, null, DEFAULT_VIEWS.map(
27862 (filter) => /* @__PURE__ */ React.createElement(
27863 Tabs.Tab,
27864 {
27865 tabId: filter.slug,
27866 key: filter.slug
27867 },
27868 filter.label
27869 )
27870 ))
27871 )),
27872 /* @__PURE__ */ React.createElement(
27873 dataviews_default,
27874 {
27875 data: posts,
27876 fields,
27877 view,
27878 onChangeView,
27879 actions,
27880 isLoading: isResolving,
27881 paginationInfo: {
27882 totalItems,
27883 totalPages
27884 },
27885 defaultLayouts: DEFAULT_LAYOUTS2,
27886 selection,
27887 onReset: isModified ? onReset : false,
27888 onChangeSelection: (items) => {
27889 navigate({
27890 search: {
27891 ...searchParams,
27892 postIds: items.length > 0 ? items : void 0,
27893 edit: items.length === 0 ? void 0 : searchParams.edit
27894 }
27895 });
27896 },
27897 isItemClickable: (item) => item.type !== PATTERN_TYPES2.theme,
27898 renderItemLink: ({
27899 item,
27900 ...props
27901 }) => /* @__PURE__ */ React.createElement(
27902 Link,
27903 {
27904 to: `/types/wp_block/edit/${encodeURIComponent(
27905 item.id
27906 )}`,
27907 ...props,
27908 onClick: (event) => {
27909 event.stopPropagation();
27910 }
27911 }
27912 )
27913 }
27914 ),
27915 showPatternModal && /* @__PURE__ */ React.createElement(
27916 CreatePatternModal,
27917 {
27918 onClose: () => setShowPatternModal(false),
27919 onSuccess: ({
27920 pattern
27921 }) => {
27922 setShowPatternModal(false);
27923 navigate({
27924 to: `/types/wp_block/edit/${encodeURIComponent(
27925 pattern.id
27926 )}`
27927 });
27928 },
27929 content: []
27930 }
27931 )
27932 );
27933 }
27934 var stage = PatternList;
27935 export {
27936 stage
27937 };
27938 /*! Bundled license information:
27939
27940 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
27941 (**
27942 * @license React
27943 * use-sync-external-store-shim.development.js
27944 *
27945 * Copyright (c) Meta Platforms, Inc. and affiliates.
27946 *
27947 * This source code is licensed under the MIT license found in the
27948 * LICENSE file in the root directory of this source tree.
27949 *)
27950
27951 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
27952 (**
27953 * @license React
27954 * use-sync-external-store-shim/with-selector.development.js
27955 *
27956 * Copyright (c) Meta Platforms, Inc. and affiliates.
27957 *
27958 * This source code is licensed under the MIT license found in the
27959 * LICENSE file in the root directory of this source tree.
27960 *)
27961 */
27962