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 / scripts / media-utils / index.js

index.js in Gutenberg 23.7.2, at build/scripts/media-utils/index.js

28,939 lines 1.0 MB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 "use strict";
2 var wp;
3 (wp ||= {}).mediaUtils = (() => {
4 var __create = Object.create;
5 var __defProp = Object.defineProperty;
6 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7 var __getOwnPropNames = Object.getOwnPropertyNames;
8 var __getProtoOf = Object.getPrototypeOf;
9 var __hasOwnProp = Object.prototype.hasOwnProperty;
10 var __commonJS = (cb, mod) => function __require() {
11 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12 };
13 var __export = (target, all) => {
14 for (var name in all)
15 __defProp(target, name, { get: all[name], enumerable: true });
16 };
17 var __copyProps = (to, from, except, desc) => {
18 if (from && typeof from === "object" || typeof from === "function") {
19 for (let key of __getOwnPropNames(from))
20 if (!__hasOwnProp.call(to, key) && key !== except)
21 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22 }
23 return to;
24 };
25 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26 // If the importer is in node compatibility mode or this is not an ESM
27 // file that has been converted to a CommonJS file using a Babel-
28 // compatible transform (i.e. "__esModule" has not been set), then set
29 // "default" to the CommonJS "module.exports" for node compatibility.
30 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31 mod
32 ));
33 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
35 // package-external:@wordpress/element
36 var require_element = __commonJS({
37 "package-external:@wordpress/element"(exports, module) {
38 module.exports = window.wp.element;
39 }
40 });
41
42 // package-external:@wordpress/i18n
43 var require_i18n = __commonJS({
44 "package-external:@wordpress/i18n"(exports, module) {
45 module.exports = window.wp.i18n;
46 }
47 });
48
49 // package-external:@wordpress/data
50 var require_data = __commonJS({
51 "package-external:@wordpress/data"(exports, module) {
52 module.exports = window.wp.data;
53 }
54 });
55
56 // package-external:@wordpress/core-data
57 var require_core_data = __commonJS({
58 "package-external:@wordpress/core-data"(exports, module) {
59 module.exports = window.wp.coreData;
60 }
61 });
62
63 // package-external:@wordpress/blob
64 var require_blob = __commonJS({
65 "package-external:@wordpress/blob"(exports, module) {
66 module.exports = window.wp.blob;
67 }
68 });
69
70 // package-external:@wordpress/api-fetch
71 var require_api_fetch = __commonJS({
72 "package-external:@wordpress/api-fetch"(exports, module) {
73 module.exports = window.wp.apiFetch;
74 }
75 });
76
77 // package-external:@wordpress/components
78 var require_components = __commonJS({
79 "package-external:@wordpress/components"(exports, module) {
80 module.exports = window.wp.components;
81 }
82 });
83
84 // package-external:@wordpress/primitives
85 var require_primitives = __commonJS({
86 "package-external:@wordpress/primitives"(exports, module) {
87 module.exports = window.wp.primitives;
88 }
89 });
90
91 // vendor-external:react/jsx-runtime
92 var require_jsx_runtime = __commonJS({
93 "vendor-external:react/jsx-runtime"(exports, module) {
94 module.exports = window.ReactJSXRuntime;
95 }
96 });
97
98 // package-external:@wordpress/compose
99 var require_compose = __commonJS({
100 "package-external:@wordpress/compose"(exports, module) {
101 module.exports = window.wp.compose;
102 }
103 });
104
105 // vendor-external:react
106 var require_react = __commonJS({
107 "vendor-external:react"(exports, module) {
108 module.exports = window.React;
109 }
110 });
111
112 // vendor-external:react-dom
113 var require_react_dom = __commonJS({
114 "vendor-external:react-dom"(exports, module) {
115 module.exports = window.ReactDOM;
116 }
117 });
118
119 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
120 var require_use_sync_external_store_shim_development = __commonJS({
121 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
122 "use strict";
123 (function() {
124 function is(x2, y2) {
125 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
126 }
127 function useSyncExternalStore$2(subscribe2, getSnapshot) {
128 didWarnOld18Alpha || void 0 === React49.startTransition || (didWarnOld18Alpha = true, console.error(
129 "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."
130 ));
131 var value = getSnapshot();
132 if (!didWarnUncachedGetSnapshot) {
133 var cachedValue = getSnapshot();
134 objectIs(value, cachedValue) || (console.error(
135 "The result of getSnapshot should be cached to avoid an infinite loop"
136 ), didWarnUncachedGetSnapshot = true);
137 }
138 cachedValue = useState43({
139 inst: { value, getSnapshot }
140 });
141 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
142 useLayoutEffect6(
143 function() {
144 inst.value = value;
145 inst.getSnapshot = getSnapshot;
146 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
147 },
148 [subscribe2, value, getSnapshot]
149 );
150 useEffect36(
151 function() {
152 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
153 return subscribe2(function() {
154 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
155 });
156 },
157 [subscribe2]
158 );
159 useDebugValue2(value);
160 return value;
161 }
162 function checkIfSnapshotChanged(inst) {
163 var latestGetSnapshot = inst.getSnapshot;
164 inst = inst.value;
165 try {
166 var nextValue = latestGetSnapshot();
167 return !objectIs(inst, nextValue);
168 } catch (error) {
169 return true;
170 }
171 }
172 function useSyncExternalStore$1(subscribe2, getSnapshot) {
173 return getSnapshot();
174 }
175 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
176 var React49 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState43 = React49.useState, useEffect36 = React49.useEffect, useLayoutEffect6 = React49.useLayoutEffect, useDebugValue2 = React49.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
177 exports.useSyncExternalStore = void 0 !== React49.useSyncExternalStore ? React49.useSyncExternalStore : shim;
178 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
179 })();
180 }
181 });
182
183 // node_modules/use-sync-external-store/shim/index.js
184 var require_shim = __commonJS({
185 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
186 "use strict";
187 if (false) {
188 module.exports = null;
189 } else {
190 module.exports = require_use_sync_external_store_shim_development();
191 }
192 }
193 });
194
195 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
196 var require_with_selector_development = __commonJS({
197 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
198 "use strict";
199 (function() {
200 function is(x2, y2) {
201 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
202 }
203 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
204 var React49 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef51 = React49.useRef, useEffect36 = React49.useEffect, useMemo43 = React49.useMemo, useDebugValue2 = React49.useDebugValue;
205 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
206 var instRef = useRef51(null);
207 if (null === instRef.current) {
208 var inst = { hasValue: false, value: null };
209 instRef.current = inst;
210 } else inst = instRef.current;
211 instRef = useMemo43(
212 function() {
213 function memoizedSelector(nextSnapshot) {
214 if (!hasMemo) {
215 hasMemo = true;
216 memoizedSnapshot = nextSnapshot;
217 nextSnapshot = selector2(nextSnapshot);
218 if (void 0 !== isEqual && inst.hasValue) {
219 var currentSelection = inst.value;
220 if (isEqual(currentSelection, nextSnapshot))
221 return memoizedSelection = currentSelection;
222 }
223 return memoizedSelection = nextSnapshot;
224 }
225 currentSelection = memoizedSelection;
226 if (objectIs(memoizedSnapshot, nextSnapshot))
227 return currentSelection;
228 var nextSelection = selector2(nextSnapshot);
229 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
230 return memoizedSnapshot = nextSnapshot, currentSelection;
231 memoizedSnapshot = nextSnapshot;
232 return memoizedSelection = nextSelection;
233 }
234 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
235 return [
236 function() {
237 return memoizedSelector(getSnapshot());
238 },
239 null === maybeGetServerSnapshot ? void 0 : function() {
240 return memoizedSelector(maybeGetServerSnapshot());
241 }
242 ];
243 },
244 [getSnapshot, getServerSnapshot, selector2, isEqual]
245 );
246 var value = useSyncExternalStore3(subscribe2, instRef[0], instRef[1]);
247 useEffect36(
248 function() {
249 inst.hasValue = true;
250 inst.value = value;
251 },
252 [value]
253 );
254 useDebugValue2(value);
255 return value;
256 };
257 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
258 })();
259 }
260 });
261
262 // node_modules/use-sync-external-store/shim/with-selector.js
263 var require_with_selector = __commonJS({
264 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
265 "use strict";
266 if (false) {
267 module.exports = null;
268 } else {
269 module.exports = require_with_selector_development();
270 }
271 }
272 });
273
274 // package-external:@wordpress/a11y
275 var require_a11y = __commonJS({
276 "package-external:@wordpress/a11y"(exports, module) {
277 module.exports = window.wp.a11y;
278 }
279 });
280
281 // package-external:@wordpress/theme
282 var require_theme = __commonJS({
283 "package-external:@wordpress/theme"(exports, module) {
284 module.exports = window.wp.theme;
285 }
286 });
287
288 // package-external:@wordpress/private-apis
289 var require_private_apis = __commonJS({
290 "package-external:@wordpress/private-apis"(exports, module) {
291 module.exports = window.wp.privateApis;
292 }
293 });
294
295 // package-external:@wordpress/keycodes
296 var require_keycodes = __commonJS({
297 "package-external:@wordpress/keycodes"(exports, module) {
298 module.exports = window.wp.keycodes;
299 }
300 });
301
302 // node_modules/remove-accents/index.js
303 var require_remove_accents = __commonJS({
304 "node_modules/remove-accents/index.js"(exports, module) {
305 var characterMap = {
306 "\xC0": "A",
307 "\xC1": "A",
308 "\xC2": "A",
309 "\xC3": "A",
310 "\xC4": "A",
311 "\xC5": "A",
312 "\u1EA4": "A",
313 "\u1EAE": "A",
314 "\u1EB2": "A",
315 "\u1EB4": "A",
316 "\u1EB6": "A",
317 "\xC6": "AE",
318 "\u1EA6": "A",
319 "\u1EB0": "A",
320 "\u0202": "A",
321 "\u1EA2": "A",
322 "\u1EA0": "A",
323 "\u1EA8": "A",
324 "\u1EAA": "A",
325 "\u1EAC": "A",
326 "\xC7": "C",
327 "\u1E08": "C",
328 "\xC8": "E",
329 "\xC9": "E",
330 "\xCA": "E",
331 "\xCB": "E",
332 "\u1EBE": "E",
333 "\u1E16": "E",
334 "\u1EC0": "E",
335 "\u1E14": "E",
336 "\u1E1C": "E",
337 "\u0206": "E",
338 "\u1EBA": "E",
339 "\u1EBC": "E",
340 "\u1EB8": "E",
341 "\u1EC2": "E",
342 "\u1EC4": "E",
343 "\u1EC6": "E",
344 "\xCC": "I",
345 "\xCD": "I",
346 "\xCE": "I",
347 "\xCF": "I",
348 "\u1E2E": "I",
349 "\u020A": "I",
350 "\u1EC8": "I",
351 "\u1ECA": "I",
352 "\xD0": "D",
353 "\xD1": "N",
354 "\xD2": "O",
355 "\xD3": "O",
356 "\xD4": "O",
357 "\xD5": "O",
358 "\xD6": "O",
359 "\xD8": "O",
360 "\u1ED0": "O",
361 "\u1E4C": "O",
362 "\u1E52": "O",
363 "\u020E": "O",
364 "\u1ECE": "O",
365 "\u1ECC": "O",
366 "\u1ED4": "O",
367 "\u1ED6": "O",
368 "\u1ED8": "O",
369 "\u1EDC": "O",
370 "\u1EDE": "O",
371 "\u1EE0": "O",
372 "\u1EDA": "O",
373 "\u1EE2": "O",
374 "\xD9": "U",
375 "\xDA": "U",
376 "\xDB": "U",
377 "\xDC": "U",
378 "\u1EE6": "U",
379 "\u1EE4": "U",
380 "\u1EEC": "U",
381 "\u1EEE": "U",
382 "\u1EF0": "U",
383 "\xDD": "Y",
384 "\xE0": "a",
385 "\xE1": "a",
386 "\xE2": "a",
387 "\xE3": "a",
388 "\xE4": "a",
389 "\xE5": "a",
390 "\u1EA5": "a",
391 "\u1EAF": "a",
392 "\u1EB3": "a",
393 "\u1EB5": "a",
394 "\u1EB7": "a",
395 "\xE6": "ae",
396 "\u1EA7": "a",
397 "\u1EB1": "a",
398 "\u0203": "a",
399 "\u1EA3": "a",
400 "\u1EA1": "a",
401 "\u1EA9": "a",
402 "\u1EAB": "a",
403 "\u1EAD": "a",
404 "\xE7": "c",
405 "\u1E09": "c",
406 "\xE8": "e",
407 "\xE9": "e",
408 "\xEA": "e",
409 "\xEB": "e",
410 "\u1EBF": "e",
411 "\u1E17": "e",
412 "\u1EC1": "e",
413 "\u1E15": "e",
414 "\u1E1D": "e",
415 "\u0207": "e",
416 "\u1EBB": "e",
417 "\u1EBD": "e",
418 "\u1EB9": "e",
419 "\u1EC3": "e",
420 "\u1EC5": "e",
421 "\u1EC7": "e",
422 "\xEC": "i",
423 "\xED": "i",
424 "\xEE": "i",
425 "\xEF": "i",
426 "\u1E2F": "i",
427 "\u020B": "i",
428 "\u1EC9": "i",
429 "\u1ECB": "i",
430 "\xF0": "d",
431 "\xF1": "n",
432 "\xF2": "o",
433 "\xF3": "o",
434 "\xF4": "o",
435 "\xF5": "o",
436 "\xF6": "o",
437 "\xF8": "o",
438 "\u1ED1": "o",
439 "\u1E4D": "o",
440 "\u1E53": "o",
441 "\u020F": "o",
442 "\u1ECF": "o",
443 "\u1ECD": "o",
444 "\u1ED5": "o",
445 "\u1ED7": "o",
446 "\u1ED9": "o",
447 "\u1EDD": "o",
448 "\u1EDF": "o",
449 "\u1EE1": "o",
450 "\u1EDB": "o",
451 "\u1EE3": "o",
452 "\xF9": "u",
453 "\xFA": "u",
454 "\xFB": "u",
455 "\xFC": "u",
456 "\u1EE7": "u",
457 "\u1EE5": "u",
458 "\u1EED": "u",
459 "\u1EEF": "u",
460 "\u1EF1": "u",
461 "\xFD": "y",
462 "\xFF": "y",
463 "\u0100": "A",
464 "\u0101": "a",
465 "\u0102": "A",
466 "\u0103": "a",
467 "\u0104": "A",
468 "\u0105": "a",
469 "\u0106": "C",
470 "\u0107": "c",
471 "\u0108": "C",
472 "\u0109": "c",
473 "\u010A": "C",
474 "\u010B": "c",
475 "\u010C": "C",
476 "\u010D": "c",
477 "C\u0306": "C",
478 "c\u0306": "c",
479 "\u010E": "D",
480 "\u010F": "d",
481 "\u0110": "D",
482 "\u0111": "d",
483 "\u0112": "E",
484 "\u0113": "e",
485 "\u0114": "E",
486 "\u0115": "e",
487 "\u0116": "E",
488 "\u0117": "e",
489 "\u0118": "E",
490 "\u0119": "e",
491 "\u011A": "E",
492 "\u011B": "e",
493 "\u011C": "G",
494 "\u01F4": "G",
495 "\u011D": "g",
496 "\u01F5": "g",
497 "\u011E": "G",
498 "\u011F": "g",
499 "\u0120": "G",
500 "\u0121": "g",
501 "\u0122": "G",
502 "\u0123": "g",
503 "\u0124": "H",
504 "\u0125": "h",
505 "\u0126": "H",
506 "\u0127": "h",
507 "\u1E2A": "H",
508 "\u1E2B": "h",
509 "\u0128": "I",
510 "\u0129": "i",
511 "\u012A": "I",
512 "\u012B": "i",
513 "\u012C": "I",
514 "\u012D": "i",
515 "\u012E": "I",
516 "\u012F": "i",
517 "\u0130": "I",
518 "\u0131": "i",
519 "\u0132": "IJ",
520 "\u0133": "ij",
521 "\u0134": "J",
522 "\u0135": "j",
523 "\u0136": "K",
524 "\u0137": "k",
525 "\u1E30": "K",
526 "\u1E31": "k",
527 "K\u0306": "K",
528 "k\u0306": "k",
529 "\u0139": "L",
530 "\u013A": "l",
531 "\u013B": "L",
532 "\u013C": "l",
533 "\u013D": "L",
534 "\u013E": "l",
535 "\u013F": "L",
536 "\u0140": "l",
537 "\u0141": "l",
538 "\u0142": "l",
539 "\u1E3E": "M",
540 "\u1E3F": "m",
541 "M\u0306": "M",
542 "m\u0306": "m",
543 "\u0143": "N",
544 "\u0144": "n",
545 "\u0145": "N",
546 "\u0146": "n",
547 "\u0147": "N",
548 "\u0148": "n",
549 "\u0149": "n",
550 "N\u0306": "N",
551 "n\u0306": "n",
552 "\u014C": "O",
553 "\u014D": "o",
554 "\u014E": "O",
555 "\u014F": "o",
556 "\u0150": "O",
557 "\u0151": "o",
558 "\u0152": "OE",
559 "\u0153": "oe",
560 "P\u0306": "P",
561 "p\u0306": "p",
562 "\u0154": "R",
563 "\u0155": "r",
564 "\u0156": "R",
565 "\u0157": "r",
566 "\u0158": "R",
567 "\u0159": "r",
568 "R\u0306": "R",
569 "r\u0306": "r",
570 "\u0212": "R",
571 "\u0213": "r",
572 "\u015A": "S",
573 "\u015B": "s",
574 "\u015C": "S",
575 "\u015D": "s",
576 "\u015E": "S",
577 "\u0218": "S",
578 "\u0219": "s",
579 "\u015F": "s",
580 "\u0160": "S",
581 "\u0161": "s",
582 "\u0162": "T",
583 "\u0163": "t",
584 "\u021B": "t",
585 "\u021A": "T",
586 "\u0164": "T",
587 "\u0165": "t",
588 "\u0166": "T",
589 "\u0167": "t",
590 "T\u0306": "T",
591 "t\u0306": "t",
592 "\u0168": "U",
593 "\u0169": "u",
594 "\u016A": "U",
595 "\u016B": "u",
596 "\u016C": "U",
597 "\u016D": "u",
598 "\u016E": "U",
599 "\u016F": "u",
600 "\u0170": "U",
601 "\u0171": "u",
602 "\u0172": "U",
603 "\u0173": "u",
604 "\u0216": "U",
605 "\u0217": "u",
606 "V\u0306": "V",
607 "v\u0306": "v",
608 "\u0174": "W",
609 "\u0175": "w",
610 "\u1E82": "W",
611 "\u1E83": "w",
612 "X\u0306": "X",
613 "x\u0306": "x",
614 "\u0176": "Y",
615 "\u0177": "y",
616 "\u0178": "Y",
617 "Y\u0306": "Y",
618 "y\u0306": "y",
619 "\u0179": "Z",
620 "\u017A": "z",
621 "\u017B": "Z",
622 "\u017C": "z",
623 "\u017D": "Z",
624 "\u017E": "z",
625 "\u017F": "s",
626 "\u0192": "f",
627 "\u01A0": "O",
628 "\u01A1": "o",
629 "\u01AF": "U",
630 "\u01B0": "u",
631 "\u01CD": "A",
632 "\u01CE": "a",
633 "\u01CF": "I",
634 "\u01D0": "i",
635 "\u01D1": "O",
636 "\u01D2": "o",
637 "\u01D3": "U",
638 "\u01D4": "u",
639 "\u01D5": "U",
640 "\u01D6": "u",
641 "\u01D7": "U",
642 "\u01D8": "u",
643 "\u01D9": "U",
644 "\u01DA": "u",
645 "\u01DB": "U",
646 "\u01DC": "u",
647 "\u1EE8": "U",
648 "\u1EE9": "u",
649 "\u1E78": "U",
650 "\u1E79": "u",
651 "\u01FA": "A",
652 "\u01FB": "a",
653 "\u01FC": "AE",
654 "\u01FD": "ae",
655 "\u01FE": "O",
656 "\u01FF": "o",
657 "\xDE": "TH",
658 "\xFE": "th",
659 "\u1E54": "P",
660 "\u1E55": "p",
661 "\u1E64": "S",
662 "\u1E65": "s",
663 "X\u0301": "X",
664 "x\u0301": "x",
665 "\u0403": "\u0413",
666 "\u0453": "\u0433",
667 "\u040C": "\u041A",
668 "\u045C": "\u043A",
669 "A\u030B": "A",
670 "a\u030B": "a",
671 "E\u030B": "E",
672 "e\u030B": "e",
673 "I\u030B": "I",
674 "i\u030B": "i",
675 "\u01F8": "N",
676 "\u01F9": "n",
677 "\u1ED2": "O",
678 "\u1ED3": "o",
679 "\u1E50": "O",
680 "\u1E51": "o",
681 "\u1EEA": "U",
682 "\u1EEB": "u",
683 "\u1E80": "W",
684 "\u1E81": "w",
685 "\u1EF2": "Y",
686 "\u1EF3": "y",
687 "\u0200": "A",
688 "\u0201": "a",
689 "\u0204": "E",
690 "\u0205": "e",
691 "\u0208": "I",
692 "\u0209": "i",
693 "\u020C": "O",
694 "\u020D": "o",
695 "\u0210": "R",
696 "\u0211": "r",
697 "\u0214": "U",
698 "\u0215": "u",
699 "B\u030C": "B",
700 "b\u030C": "b",
701 "\u010C\u0323": "C",
702 "\u010D\u0323": "c",
703 "\xCA\u030C": "E",
704 "\xEA\u030C": "e",
705 "F\u030C": "F",
706 "f\u030C": "f",
707 "\u01E6": "G",
708 "\u01E7": "g",
709 "\u021E": "H",
710 "\u021F": "h",
711 "J\u030C": "J",
712 "\u01F0": "j",
713 "\u01E8": "K",
714 "\u01E9": "k",
715 "M\u030C": "M",
716 "m\u030C": "m",
717 "P\u030C": "P",
718 "p\u030C": "p",
719 "Q\u030C": "Q",
720 "q\u030C": "q",
721 "\u0158\u0329": "R",
722 "\u0159\u0329": "r",
723 "\u1E66": "S",
724 "\u1E67": "s",
725 "V\u030C": "V",
726 "v\u030C": "v",
727 "W\u030C": "W",
728 "w\u030C": "w",
729 "X\u030C": "X",
730 "x\u030C": "x",
731 "Y\u030C": "Y",
732 "y\u030C": "y",
733 "A\u0327": "A",
734 "a\u0327": "a",
735 "B\u0327": "B",
736 "b\u0327": "b",
737 "\u1E10": "D",
738 "\u1E11": "d",
739 "\u0228": "E",
740 "\u0229": "e",
741 "\u0190\u0327": "E",
742 "\u025B\u0327": "e",
743 "\u1E28": "H",
744 "\u1E29": "h",
745 "I\u0327": "I",
746 "i\u0327": "i",
747 "\u0197\u0327": "I",
748 "\u0268\u0327": "i",
749 "M\u0327": "M",
750 "m\u0327": "m",
751 "O\u0327": "O",
752 "o\u0327": "o",
753 "Q\u0327": "Q",
754 "q\u0327": "q",
755 "U\u0327": "U",
756 "u\u0327": "u",
757 "X\u0327": "X",
758 "x\u0327": "x",
759 "Z\u0327": "Z",
760 "z\u0327": "z",
761 "\u0439": "\u0438",
762 "\u0419": "\u0418",
763 "\u0451": "\u0435",
764 "\u0401": "\u0415"
765 };
766 var chars = Object.keys(characterMap).join("|");
767 var allAccents = new RegExp(chars, "g");
768 var firstAccent = new RegExp(chars, "");
769 function matcher(match2) {
770 return characterMap[match2];
771 }
772 var removeAccents2 = function(string) {
773 return string.replace(allAccents, matcher);
774 };
775 var hasAccents = function(string) {
776 return !!string.match(firstAccent);
777 };
778 module.exports = removeAccents2;
779 module.exports.has = hasAccents;
780 module.exports.remove = removeAccents2;
781 }
782 });
783
784 // node_modules/fast-deep-equal/es6/index.js
785 var require_es6 = __commonJS({
786 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
787 "use strict";
788 module.exports = function equal(a2, b2) {
789 if (a2 === b2) return true;
790 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
791 if (a2.constructor !== b2.constructor) return false;
792 var length, i2, keys;
793 if (Array.isArray(a2)) {
794 length = a2.length;
795 if (length != b2.length) return false;
796 for (i2 = length; i2-- !== 0; )
797 if (!equal(a2[i2], b2[i2])) return false;
798 return true;
799 }
800 if (a2 instanceof Map && b2 instanceof Map) {
801 if (a2.size !== b2.size) return false;
802 for (i2 of a2.entries())
803 if (!b2.has(i2[0])) return false;
804 for (i2 of a2.entries())
805 if (!equal(i2[1], b2.get(i2[0]))) return false;
806 return true;
807 }
808 if (a2 instanceof Set && b2 instanceof Set) {
809 if (a2.size !== b2.size) return false;
810 for (i2 of a2.entries())
811 if (!b2.has(i2[0])) return false;
812 return true;
813 }
814 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
815 length = a2.length;
816 if (length != b2.length) return false;
817 for (i2 = length; i2-- !== 0; )
818 if (a2[i2] !== b2[i2]) return false;
819 return true;
820 }
821 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
822 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
823 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
824 keys = Object.keys(a2);
825 length = keys.length;
826 if (length !== Object.keys(b2).length) return false;
827 for (i2 = length; i2-- !== 0; )
828 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
829 for (i2 = length; i2-- !== 0; ) {
830 var key = keys[i2];
831 if (!equal(a2[key], b2[key])) return false;
832 }
833 return true;
834 }
835 return a2 !== a2 && b2 !== b2;
836 };
837 }
838 });
839
840 // package-external:@wordpress/date
841 var require_date = __commonJS({
842 "package-external:@wordpress/date"(exports, module) {
843 module.exports = window.wp.date;
844 }
845 });
846
847 // package-external:@wordpress/warning
848 var require_warning = __commonJS({
849 "package-external:@wordpress/warning"(exports, module) {
850 module.exports = window.wp.warning;
851 }
852 });
853
854 // package-external:@wordpress/rich-text
855 var require_rich_text = __commonJS({
856 "package-external:@wordpress/rich-text"(exports, module) {
857 module.exports = window.wp.richText;
858 }
859 });
860
861 // package-external:@wordpress/preferences
862 var require_preferences = __commonJS({
863 "package-external:@wordpress/preferences"(exports, module) {
864 module.exports = window.wp.preferences;
865 }
866 });
867
868 // package-external:@wordpress/url
869 var require_url = __commonJS({
870 "package-external:@wordpress/url"(exports, module) {
871 module.exports = window.wp.url;
872 }
873 });
874
875 // package-external:@wordpress/notices
876 var require_notices = __commonJS({
877 "package-external:@wordpress/notices"(exports, module) {
878 module.exports = window.wp.notices;
879 }
880 });
881
882 // packages/media-utils/build-module/index.mjs
883 var index_exports = {};
884 __export(index_exports, {
885 MediaUpload: () => media_upload_default,
886 privateApis: () => privateApis12,
887 transformAttachment: () => transformAttachment,
888 uploadMedia: () => uploadMedia,
889 validateFileSize: () => validateFileSize,
890 validateMimeType: () => validateMimeType,
891 validateMimeTypeForUser: () => validateMimeTypeForUser
892 });
893
894 // packages/media-utils/build-module/components/media-upload/index.mjs
895 var import_element = __toESM(require_element(), 1);
896 var import_i18n = __toESM(require_i18n(), 1);
897 var import_data = __toESM(require_data(), 1);
898
899 // packages/media-utils/build-module/utils/invalidate-attachment-resolutions.mjs
900 var import_core_data = __toESM(require_core_data(), 1);
901 function invalidateAttachmentResolutions(registry) {
902 const resolvers = registry.select(import_core_data.store).getCachedResolvers();
903 const entityRecordResolutions = resolvers.getEntityRecords;
904 entityRecordResolutions?.forEach((_value, args) => {
905 if (args[0] === "postType" && args[1] === "attachment") {
906 registry.dispatch(import_core_data.store).invalidateResolution("getEntityRecords", args);
907 }
908 });
909 }
910
911 // packages/media-utils/build-module/components/media-upload/index.mjs
912 var DEFAULT_EMPTY_GALLERY = [];
913 var getFeaturedImageMediaFrame = () => {
914 const { wp } = window;
915 return wp.media.view.MediaFrame.Select.extend({
916 /**
917 * Enables the Set Featured Image Button.
918 *
919 * @param {Object} toolbar toolbar for featured image state
920 * @return {void}
921 */
922 featuredImageToolbar(toolbar) {
923 this.createSelectToolbar(toolbar, {
924 text: wp.media.view.l10n.setFeaturedImage,
925 state: this.options.state
926 });
927 },
928 /**
929 * Handle the edit state requirements of selected media item.
930 *
931 * @return {void}
932 */
933 editState() {
934 const selection = this.state("featured-image").get("selection");
935 const view = new wp.media.view.EditImage({
936 model: selection.single(),
937 controller: this
938 }).render();
939 this.content.set(view);
940 view.loadEditor();
941 },
942 /**
943 * Create the default states.
944 *
945 * @return {void}
946 */
947 createStates: function createStates() {
948 this.on(
949 "toolbar:create:featured-image",
950 this.featuredImageToolbar,
951 this
952 );
953 this.on("content:render:edit-image", this.editState, this);
954 this.states.add([
955 new wp.media.controller.FeaturedImage(),
956 new wp.media.controller.EditImage({
957 model: this.options.editImage
958 })
959 ]);
960 }
961 });
962 };
963 var getSingleMediaFrame = () => {
964 const { wp } = window;
965 return wp.media.view.MediaFrame.Select.extend({
966 /**
967 * Create the default states on the frame.
968 */
969 createStates() {
970 const options = this.options;
971 if (this.options.states) {
972 return;
973 }
974 this.states.add([
975 // Main states.
976 new wp.media.controller.Library({
977 library: wp.media.query(options.library),
978 multiple: options.multiple,
979 title: options.title,
980 priority: 20,
981 filterable: "uploaded"
982 // Allow filtering by uploaded images.
983 }),
984 new wp.media.controller.EditImage({
985 model: options.editImage
986 })
987 ]);
988 }
989 });
990 };
991 var getGalleryDetailsMediaFrame = () => {
992 const { wp } = window;
993 return wp.media.view.MediaFrame.Post.extend({
994 /**
995 * Set up gallery toolbar.
996 *
997 * @return {void}
998 */
999 galleryToolbar() {
1000 const editing = this.state().get("editing");
1001 this.toolbar.set(
1002 new wp.media.view.Toolbar({
1003 controller: this,
1004 items: {
1005 insert: {
1006 style: "primary",
1007 text: editing ? wp.media.view.l10n.updateGallery : wp.media.view.l10n.insertGallery,
1008 priority: 80,
1009 requires: { library: true },
1010 /**
1011 * @fires wp.media.controller.State#update
1012 */
1013 click() {
1014 const controller = this.controller, state = controller.state();
1015 controller.close();
1016 state.trigger(
1017 "update",
1018 state.get("library")
1019 );
1020 controller.setState(controller.options.state);
1021 controller.reset();
1022 }
1023 }
1024 }
1025 })
1026 );
1027 },
1028 /**
1029 * Handle the edit state requirements of selected media item.
1030 *
1031 * @return {void}
1032 */
1033 editState() {
1034 const selection = this.state("gallery").get("selection");
1035 const view = new wp.media.view.EditImage({
1036 model: selection.single(),
1037 controller: this
1038 }).render();
1039 this.content.set(view);
1040 view.loadEditor();
1041 },
1042 /**
1043 * Create the default states.
1044 *
1045 * @return {void}
1046 */
1047 createStates: function createStates() {
1048 this.on("toolbar:create:main-gallery", this.galleryToolbar, this);
1049 this.on("content:render:edit-image", this.editState, this);
1050 this.states.add([
1051 new wp.media.controller.Library({
1052 id: "gallery",
1053 title: wp.media.view.l10n.createGalleryTitle,
1054 priority: 40,
1055 toolbar: "main-gallery",
1056 filterable: "uploaded",
1057 multiple: "add",
1058 editable: false,
1059 library: wp.media.query({
1060 type: "image",
1061 ...this.options.library
1062 })
1063 }),
1064 new wp.media.controller.EditImage({
1065 model: this.options.editImage
1066 }),
1067 new wp.media.controller.GalleryEdit({
1068 library: this.options.selection,
1069 editing: this.options.editing,
1070 menu: "gallery",
1071 displaySettings: false,
1072 multiple: true
1073 }),
1074 new wp.media.controller.GalleryAdd()
1075 ]);
1076 }
1077 });
1078 };
1079 var slimImageObject = (img) => {
1080 const attrSet = [
1081 "sizes",
1082 "mime",
1083 "type",
1084 "subtype",
1085 "id",
1086 "url",
1087 "alt",
1088 "link",
1089 "caption"
1090 ];
1091 return attrSet.reduce((result, key) => {
1092 if (img?.hasOwnProperty(key)) {
1093 result[key] = img[key];
1094 }
1095 return result;
1096 }, {});
1097 };
1098 var getAttachmentsCollection = (ids) => {
1099 const { wp } = window;
1100 return wp.media.query({
1101 order: "ASC",
1102 orderby: "post__in",
1103 post__in: ids,
1104 posts_per_page: -1,
1105 query: true,
1106 type: "image"
1107 });
1108 };
1109 var MediaUpload = class extends import_element.Component {
1110 constructor() {
1111 super(...arguments);
1112 this.openModal = this.openModal.bind(this);
1113 this.onOpen = this.onOpen.bind(this);
1114 this.onSelect = this.onSelect.bind(this);
1115 this.onUpdate = this.onUpdate.bind(this);
1116 this.onClose = this.onClose.bind(this);
1117 }
1118 initializeListeners() {
1119 this.frame.on("select", this.onSelect);
1120 this.frame.on("update", this.onUpdate);
1121 this.frame.on("open", this.onOpen);
1122 this.frame.on("close", this.onClose);
1123 }
1124 /**
1125 * Sets the Gallery frame and initializes listeners.
1126 *
1127 * @return {void}
1128 */
1129 buildAndSetGalleryFrame() {
1130 const {
1131 addToGallery = false,
1132 allowedTypes,
1133 multiple = false,
1134 value = DEFAULT_EMPTY_GALLERY
1135 } = this.props;
1136 if (value === this.lastGalleryValue) {
1137 return;
1138 }
1139 const { wp } = window;
1140 this.lastGalleryValue = value;
1141 if (this.frame) {
1142 this.frame.remove();
1143 }
1144 let currentState;
1145 if (addToGallery) {
1146 currentState = "gallery-library";
1147 } else {
1148 currentState = value && value.length ? "gallery-edit" : "gallery";
1149 }
1150 if (!this.GalleryDetailsMediaFrame) {
1151 this.GalleryDetailsMediaFrame = getGalleryDetailsMediaFrame();
1152 }
1153 const attachments = getAttachmentsCollection(value);
1154 const selection = new wp.media.model.Selection(attachments.models, {
1155 props: attachments.props.toJSON(),
1156 multiple
1157 });
1158 this.frame = new this.GalleryDetailsMediaFrame({
1159 mimeType: allowedTypes,
1160 state: currentState,
1161 multiple,
1162 selection,
1163 editing: !!value?.length
1164 });
1165 wp.media.frame = this.frame;
1166 this.initializeListeners();
1167 }
1168 /**
1169 * Initializes the Media Library requirements for the featured image flow.
1170 *
1171 * @return {void}
1172 */
1173 buildAndSetFeatureImageFrame() {
1174 const { wp } = window;
1175 const { value: featuredImageId, multiple, allowedTypes } = this.props;
1176 const featuredImageFrame = getFeaturedImageMediaFrame();
1177 const attachments = getAttachmentsCollection(featuredImageId);
1178 const selection = new wp.media.model.Selection(attachments.models, {
1179 props: attachments.props.toJSON()
1180 });
1181 this.frame = new featuredImageFrame({
1182 mimeType: allowedTypes,
1183 state: "featured-image",
1184 multiple,
1185 selection,
1186 editing: featuredImageId
1187 });
1188 wp.media.frame = this.frame;
1189 wp.media.view.settings.post = {
1190 ...wp.media.view.settings.post,
1191 featuredImageId: featuredImageId || -1
1192 };
1193 }
1194 /**
1195 * Initializes the Media Library requirements for the single image flow.
1196 *
1197 * @return {void}
1198 */
1199 buildAndSetSingleMediaFrame() {
1200 const { wp } = window;
1201 const {
1202 allowedTypes,
1203 multiple = false,
1204 title = (0, import_i18n.__)("Select or Upload Media"),
1205 value
1206 } = this.props;
1207 const frameConfig = {
1208 title,
1209 multiple
1210 };
1211 if (!!allowedTypes) {
1212 frameConfig.library = { type: allowedTypes };
1213 }
1214 if (this.frame) {
1215 this.frame.remove();
1216 }
1217 const singleImageFrame = getSingleMediaFrame();
1218 const attachments = getAttachmentsCollection(value);
1219 const selection = new wp.media.model.Selection(attachments.models, {
1220 props: attachments.props.toJSON()
1221 });
1222 this.frame = new singleImageFrame({
1223 mimeType: allowedTypes,
1224 multiple,
1225 selection,
1226 ...frameConfig
1227 });
1228 wp.media.frame = this.frame;
1229 }
1230 componentWillUnmount() {
1231 this.frame?.remove();
1232 }
1233 onUpdate(selections) {
1234 const { onSelect, multiple = false } = this.props;
1235 const state = this.frame.state();
1236 const selectedImages = selections || state.get("selection");
1237 if (!selectedImages || !selectedImages.models.length) {
1238 return;
1239 }
1240 if (multiple) {
1241 onSelect(
1242 selectedImages.models.map(
1243 (model) => slimImageObject(model.toJSON())
1244 )
1245 );
1246 } else {
1247 onSelect(slimImageObject(selectedImages.models[0].toJSON()));
1248 }
1249 }
1250 onSelect() {
1251 const { onSelect, multiple = false } = this.props;
1252 const attachment = this.frame.state().get("selection").toJSON();
1253 onSelect(multiple ? attachment : attachment[0]);
1254 }
1255 onOpen() {
1256 const { wp } = window;
1257 const { value } = this.props;
1258 this.updateCollection();
1259 if (this.props.mode) {
1260 this.frame.content.mode(this.props.mode);
1261 }
1262 const hasMedia = Array.isArray(value) ? !!value?.length : !!value;
1263 if (!hasMedia) {
1264 return;
1265 }
1266 const isGallery = this.props.gallery;
1267 const selection = this.frame.state().get("selection");
1268 const valueArray = Array.isArray(value) ? value : [value];
1269 if (!isGallery) {
1270 valueArray.forEach((id) => {
1271 selection.add(wp.media.attachment(id));
1272 });
1273 }
1274 const attachments = getAttachmentsCollection(valueArray);
1275 attachments.more().done(function() {
1276 if (isGallery && attachments?.models?.length) {
1277 selection.add(attachments.models);
1278 }
1279 });
1280 }
1281 onClose() {
1282 const { onClose } = this.props;
1283 if (onClose) {
1284 onClose();
1285 }
1286 invalidateAttachmentResolutions({ select: import_data.select, dispatch: import_data.dispatch });
1287 this.frame.detach();
1288 }
1289 updateCollection() {
1290 const frameContent = this.frame.content.get();
1291 if (frameContent && frameContent.collection) {
1292 const collection = frameContent.collection;
1293 collection.toArray().forEach((model) => model.trigger("destroy", model));
1294 collection.mirroring._hasMore = true;
1295 collection.more();
1296 }
1297 }
1298 openModal() {
1299 const {
1300 gallery = false,
1301 unstableFeaturedImageFlow = false,
1302 modalClass
1303 } = this.props;
1304 if (gallery) {
1305 this.buildAndSetGalleryFrame();
1306 } else {
1307 this.buildAndSetSingleMediaFrame();
1308 }
1309 if (modalClass) {
1310 this.frame.$el.addClass(modalClass);
1311 }
1312 if (unstableFeaturedImageFlow) {
1313 this.buildAndSetFeatureImageFrame();
1314 }
1315 this.initializeListeners();
1316 this.frame.open();
1317 }
1318 render() {
1319 return this.props.render({ open: this.openModal });
1320 }
1321 };
1322 var media_upload_default = MediaUpload;
1323
1324 // packages/media-utils/build-module/utils/upload-media.mjs
1325 var import_i18n5 = __toESM(require_i18n(), 1);
1326 var import_blob = __toESM(require_blob(), 1);
1327
1328 // packages/media-utils/build-module/utils/upload-to-server.mjs
1329 var import_api_fetch = __toESM(require_api_fetch(), 1);
1330
1331 // packages/media-utils/build-module/utils/flatten-form-data.mjs
1332 function isPlainObject(data) {
1333 return data !== null && typeof data === "object" && Object.getPrototypeOf(data) === Object.prototype;
1334 }
1335 function flattenFormData(formData, key, data) {
1336 if (isPlainObject(data)) {
1337 for (const [name, value] of Object.entries(data)) {
1338 flattenFormData(formData, `${key}[${name}]`, value);
1339 }
1340 } else if (data !== void 0) {
1341 formData.append(key, String(data));
1342 }
1343 }
1344
1345 // packages/media-utils/build-module/utils/transform-attachment.mjs
1346 function transformAttachment(attachment) {
1347 const { alt_text, source_url, ...savedMediaProps } = attachment;
1348 return {
1349 ...savedMediaProps,
1350 alt: attachment.alt_text,
1351 caption: attachment.caption?.raw ?? "",
1352 title: attachment.title.raw,
1353 url: attachment.source_url,
1354 poster: attachment._embedded?.["wp:featuredmedia"]?.[0]?.source_url || void 0
1355 };
1356 }
1357
1358 // packages/media-utils/build-module/utils/upload-to-server.mjs
1359 async function uploadToServer(file, additionalData = {}, signal) {
1360 const data = new FormData();
1361 data.append("file", file, file.name || file.type.replace("/", "."));
1362 for (const [key, value] of Object.entries(additionalData)) {
1363 flattenFormData(
1364 data,
1365 key,
1366 value
1367 );
1368 }
1369 return transformAttachment(
1370 await (0, import_api_fetch.default)({
1371 // This allows the video block to directly get a video's poster image.
1372 path: "/wp/v2/media?_embed=wp:featuredmedia",
1373 body: data,
1374 method: "POST",
1375 signal
1376 })
1377 );
1378 }
1379
1380 // packages/media-utils/build-module/utils/validate-mime-type.mjs
1381 var import_i18n2 = __toESM(require_i18n(), 1);
1382
1383 // packages/media-utils/build-module/utils/upload-error.mjs
1384 var UploadError = class extends Error {
1385 code;
1386 file;
1387 constructor({ code, message: message2, file, cause }) {
1388 super(message2, { cause });
1389 Object.setPrototypeOf(this, new.target.prototype);
1390 this.code = code;
1391 this.file = file;
1392 }
1393 };
1394
1395 // packages/media-utils/build-module/utils/validate-mime-type.mjs
1396 function validateMimeType(file, allowedTypes) {
1397 if (!allowedTypes || allowedTypes.includes("*")) {
1398 return;
1399 }
1400 const isAllowedType = allowedTypes.some((allowedType) => {
1401 if (allowedType.includes("/")) {
1402 return allowedType === file.type;
1403 }
1404 return file.type.startsWith(`${allowedType}/`);
1405 });
1406 if (file.type && !isAllowedType) {
1407 throw new UploadError({
1408 code: "MIME_TYPE_NOT_SUPPORTED",
1409 message: (0, import_i18n2.sprintf)(
1410 // translators: %s: file name.
1411 (0, import_i18n2.__)("%s: Sorry, this file type is not supported here."),
1412 file.name
1413 ),
1414 file
1415 });
1416 }
1417 }
1418
1419 // packages/media-utils/build-module/utils/validate-mime-type-for-user.mjs
1420 var import_i18n3 = __toESM(require_i18n(), 1);
1421
1422 // packages/media-utils/build-module/utils/get-mime-types-array.mjs
1423 function getMimeTypesArray(wpMimeTypesObject) {
1424 if (!wpMimeTypesObject) {
1425 return null;
1426 }
1427 return Object.entries(wpMimeTypesObject).flatMap(
1428 ([extensionsString, mime]) => {
1429 const [type] = mime.split("/");
1430 const extensions = extensionsString.split("|");
1431 return [
1432 mime,
1433 ...extensions.map(
1434 (extension) => `${type}/${extension}`
1435 )
1436 ];
1437 }
1438 );
1439 }
1440
1441 // packages/media-utils/build-module/utils/validate-mime-type-for-user.mjs
1442 function validateMimeTypeForUser(file, wpAllowedMimeTypes) {
1443 const allowedMimeTypesForUser = getMimeTypesArray(wpAllowedMimeTypes);
1444 if (!allowedMimeTypesForUser) {
1445 return;
1446 }
1447 const isAllowedMimeTypeForUser = allowedMimeTypesForUser.includes(
1448 file.type
1449 );
1450 if (file.type && !isAllowedMimeTypeForUser) {
1451 throw new UploadError({
1452 code: "MIME_TYPE_NOT_ALLOWED_FOR_USER",
1453 message: (0, import_i18n3.sprintf)(
1454 // translators: %s: file name.
1455 (0, import_i18n3.__)(
1456 "%s: Sorry, you are not allowed to upload this file type."
1457 ),
1458 file.name
1459 ),
1460 file
1461 });
1462 }
1463 }
1464
1465 // packages/media-utils/build-module/utils/validate-file-size.mjs
1466 var import_i18n4 = __toESM(require_i18n(), 1);
1467 function validateFileSize(file, maxUploadFileSize) {
1468 if (file.size <= 0) {
1469 throw new UploadError({
1470 code: "EMPTY_FILE",
1471 message: (0, import_i18n4.sprintf)(
1472 // translators: %s: file name.
1473 (0, import_i18n4.__)("%s: This file is empty."),
1474 file.name
1475 ),
1476 file
1477 });
1478 }
1479 if (maxUploadFileSize && file.size > maxUploadFileSize) {
1480 throw new UploadError({
1481 code: "SIZE_ABOVE_LIMIT",
1482 message: (0, import_i18n4.sprintf)(
1483 // translators: %s: file name.
1484 (0, import_i18n4.__)(
1485 "%s: This file exceeds the maximum upload size for this site."
1486 ),
1487 file.name
1488 ),
1489 file
1490 });
1491 }
1492 }
1493
1494 // packages/media-utils/build-module/utils/upload-media.mjs
1495 function uploadMedia({
1496 wpAllowedMimeTypes,
1497 allowedTypes,
1498 additionalData = {},
1499 filesList,
1500 maxUploadFileSize,
1501 onError,
1502 onFileChange,
1503 signal,
1504 multiple = true
1505 }) {
1506 if (!multiple && filesList.length > 1) {
1507 onError?.(new Error((0, import_i18n5.__)("Only one file can be used here.")));
1508 return;
1509 }
1510 const validFiles = [];
1511 const filesSet = [];
1512 const setAndUpdateFiles = (index2, value) => {
1513 if (!window.__clientSideMediaProcessing) {
1514 if (filesSet[index2]?.url) {
1515 (0, import_blob.revokeBlobURL)(filesSet[index2].url);
1516 }
1517 }
1518 filesSet[index2] = value;
1519 onFileChange?.(
1520 filesSet.filter((attachment) => attachment !== null)
1521 );
1522 };
1523 for (const mediaFile of filesList) {
1524 try {
1525 validateMimeTypeForUser(mediaFile, wpAllowedMimeTypes);
1526 } catch (error) {
1527 onError?.(error);
1528 continue;
1529 }
1530 try {
1531 validateMimeType(mediaFile, allowedTypes);
1532 } catch (error) {
1533 onError?.(error);
1534 continue;
1535 }
1536 try {
1537 validateFileSize(mediaFile, maxUploadFileSize);
1538 } catch (error) {
1539 onError?.(error);
1540 continue;
1541 }
1542 validFiles.push(mediaFile);
1543 if (!window.__clientSideMediaProcessing) {
1544 filesSet.push({ url: (0, import_blob.createBlobURL)(mediaFile) });
1545 onFileChange?.(filesSet);
1546 }
1547 }
1548 validFiles.map(async (file, index2) => {
1549 try {
1550 const attachment = await uploadToServer(
1551 file,
1552 additionalData,
1553 signal
1554 );
1555 setAndUpdateFiles(index2, attachment);
1556 } catch (error) {
1557 setAndUpdateFiles(index2, null);
1558 let message2;
1559 if (typeof error === "object" && error !== null && "message" in error) {
1560 message2 = typeof error.message === "string" ? error.message : String(error.message);
1561 } else {
1562 message2 = (0, import_i18n5.sprintf)(
1563 // translators: %s: file name
1564 (0, import_i18n5.__)("Error while uploading file %s to the media library."),
1565 file.name
1566 );
1567 }
1568 onError?.(
1569 new UploadError({
1570 code: "GENERAL",
1571 message: message2,
1572 file,
1573 cause: error instanceof Error ? error : void 0
1574 })
1575 );
1576 }
1577 });
1578 }
1579
1580 // packages/media-utils/build-module/utils/sideload-media.mjs
1581 var import_i18n6 = __toESM(require_i18n(), 1);
1582
1583 // packages/media-utils/build-module/utils/sideload-to-server.mjs
1584 var import_api_fetch2 = __toESM(require_api_fetch(), 1);
1585 async function sideloadToServer(file, attachmentId, additionalData = {}, signal) {
1586 const data = new FormData();
1587 data.append("file", file, file.name || file.type.replace("/", "."));
1588 for (const [key, value] of Object.entries(additionalData)) {
1589 flattenFormData(
1590 data,
1591 key,
1592 value
1593 );
1594 }
1595 return (0, import_api_fetch2.default)({
1596 path: `/wp/v2/media/${attachmentId}/sideload`,
1597 body: data,
1598 method: "POST",
1599 signal
1600 });
1601 }
1602
1603 // packages/media-utils/build-module/utils/sideload-media.mjs
1604 var noop = () => {
1605 };
1606 async function sideloadMedia({
1607 file,
1608 attachmentId,
1609 additionalData = {},
1610 signal,
1611 onSuccess,
1612 onError = noop
1613 }) {
1614 try {
1615 const subSizeData = await sideloadToServer(
1616 file,
1617 attachmentId,
1618 additionalData,
1619 signal
1620 );
1621 onSuccess?.(subSizeData);
1622 } catch (error) {
1623 let message2;
1624 if (error instanceof Error) {
1625 message2 = error.message;
1626 } else {
1627 message2 = (0, import_i18n6.sprintf)(
1628 // translators: %s: file name
1629 (0, import_i18n6.__)("Error while sideloading file %s to the server."),
1630 file.name
1631 );
1632 }
1633 onError(
1634 new UploadError({
1635 code: "GENERAL",
1636 message: message2,
1637 file,
1638 cause: error instanceof Error ? error : void 0
1639 })
1640 );
1641 }
1642 }
1643
1644 // node_modules/clsx/dist/clsx.mjs
1645 function r(e2) {
1646 var t2, f2, n2 = "";
1647 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
1648 else if ("object" == typeof e2) if (Array.isArray(e2)) {
1649 var o2 = e2.length;
1650 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
1651 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
1652 return n2;
1653 }
1654 function clsx() {
1655 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
1656 return n2;
1657 }
1658 var clsx_default = clsx;
1659
1660 // packages/media-utils/build-module/components/media-upload-modal/index.mjs
1661 var import_element87 = __toESM(require_element(), 1);
1662 var import_i18n68 = __toESM(require_i18n(), 1);
1663 var import_core_data6 = __toESM(require_core_data(), 1);
1664 var import_data14 = __toESM(require_data(), 1);
1665 var import_components54 = __toESM(require_components(), 1);
1666
1667 // packages/icons/build-module/library/arrow-down.mjs
1668 var import_primitives = __toESM(require_primitives(), 1);
1669 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
1670 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.Path, { d: "m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z" }) });
1671
1672 // packages/icons/build-module/library/arrow-left.mjs
1673 var import_primitives2 = __toESM(require_primitives(), 1);
1674 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
1675 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) });
1676
1677 // packages/icons/build-module/library/arrow-right.mjs
1678 var import_primitives3 = __toESM(require_primitives(), 1);
1679 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
1680 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) });
1681
1682 // packages/icons/build-module/library/arrow-up.mjs
1683 var import_primitives4 = __toESM(require_primitives(), 1);
1684 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
1685 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
1686
1687 // packages/icons/build-module/library/audio.mjs
1688 var import_primitives5 = __toESM(require_primitives(), 1);
1689 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
1690 var audio_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.Path, { d: "M17.7 4.3c-1.2 0-2.8 0-3.8 1-.6.6-.9 1.5-.9 2.6V14c-.6-.6-1.5-1-2.5-1C8.6 13 7 14.6 7 16.5S8.6 20 10.5 20c1.5 0 2.8-1 3.3-2.3.5-.8.7-1.8.7-2.5V7.9c0-.7.2-1.2.5-1.6.6-.6 1.8-.6 2.8-.6h.3V4.3h-.4z" }) });
1691
1692 // packages/icons/build-module/library/block-table.mjs
1693 var import_primitives6 = __toESM(require_primitives(), 1);
1694 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
1695 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.Path, { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v3.5h-15V5c0-.3.2-.5.5-.5zm8 5.5h6.5v3.5H13V10zm-1.5 3.5h-7V10h7v3.5zm-7 5.5v-4h7v4.5H5c-.3 0-.5-.2-.5-.5zm14.5.5h-6V15h6.5v4c0 .3-.2.5-.5.5z" }) });
1696
1697 // packages/icons/build-module/library/category.mjs
1698 var import_primitives7 = __toESM(require_primitives(), 1);
1699 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
1700 var category_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M6 5.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm11-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-3a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM13 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2h-3a2 2 0 01-2-2V6zm5 8.5h-3a.5.5 0 00-.5.5v3a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5zM15 13a2 2 0 00-2 2v3a2 2 0 002 2h3a2 2 0 002-2v-3a2 2 0 00-2-2h-3zm-9 1.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5zM4 15a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2v-3z" }) });
1701
1702 // packages/icons/build-module/library/check.mjs
1703 var import_primitives8 = __toESM(require_primitives(), 1);
1704 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
1705 var check_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
1706
1707 // packages/icons/build-module/library/chevron-down.mjs
1708 var import_primitives9 = __toESM(require_primitives(), 1);
1709 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
1710 var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) });
1711
1712 // packages/icons/build-module/library/close-small.mjs
1713 var import_primitives10 = __toESM(require_primitives(), 1);
1714 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
1715 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.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" }) });
1716
1717 // packages/icons/build-module/library/cog.mjs
1718 var import_primitives11 = __toESM(require_primitives(), 1);
1719 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
1720 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.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" }) });
1721
1722 // packages/icons/build-module/library/comment-author-avatar.mjs
1723 var import_primitives12 = __toESM(require_primitives(), 1);
1724 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
1725 var comment_author_avatar_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M7.25 16.437a6.5 6.5 0 1 1 9.5 0V16A2.75 2.75 0 0 0 14 13.25h-4A2.75 2.75 0 0 0 7.25 16v.437Zm1.5 1.193a6.47 6.47 0 0 0 3.25.87 6.47 6.47 0 0 0 3.25-.87V16c0-.69-.56-1.25-1.25-1.25h-4c-.69 0-1.25.56-1.25 1.25v1.63ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm10-2a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z" }) });
1726
1727 // packages/icons/build-module/library/envelope.mjs
1728 var import_primitives13 = __toESM(require_primitives(), 1);
1729 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
1730 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.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" }) });
1731
1732 // packages/icons/build-module/library/error.mjs
1733 var import_primitives14 = __toESM(require_primitives(), 1);
1734 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
1735 var error_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.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" }) });
1736
1737 // packages/icons/build-module/library/file.mjs
1738 var import_primitives15 = __toESM(require_primitives(), 1);
1739 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
1740 var file_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12.848 8a1 1 0 0 1-.914-.594l-.723-1.63a.5.5 0 0 0-.447-.276H5a.5.5 0 0 0-.5.5v11.5a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5v-9A.5.5 0 0 0 19 8h-6.152Zm.612-1.5a.5.5 0 0 1-.462-.31l-.445-1.084A2 2 0 0 0 10.763 4H5a2 2 0 0 0-2 2v11.5a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2h-5.54Z" }) });
1741
1742 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
1743 var import_primitives16 = __toESM(require_primitives(), 1);
1744 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
1745 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.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" }) });
1746
1747 // packages/icons/build-module/library/format-list-bullets.mjs
1748 var import_primitives17 = __toESM(require_primitives(), 1);
1749 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
1750 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.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" }) });
1751
1752 // packages/icons/build-module/library/funnel.mjs
1753 var import_primitives18 = __toESM(require_primitives(), 1);
1754 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
1755 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
1756
1757 // packages/icons/build-module/library/image.mjs
1758 var import_primitives19 = __toESM(require_primitives(), 1);
1759 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
1760 var image_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.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.5v8.4l-3-2.9c-.3-.3-.8-.3-1 0L11.9 14 9 12c-.3-.2-.6-.2-.8 0l-3.6 2.6V5c-.1-.3.1-.5.4-.5zm14 15H5c-.3 0-.5-.2-.5-.5v-2.4l4.1-3 3 1.9c.3.2.7.2.9-.1L16 12l3.5 3.4V19c0 .3-.2.5-.5.5z" }) });
1761
1762 // packages/icons/build-module/library/link.mjs
1763 var import_primitives20 = __toESM(require_primitives(), 1);
1764 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
1765 var link_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.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" }) });
1766
1767 // packages/icons/build-module/library/mobile.mjs
1768 var import_primitives21 = __toESM(require_primitives(), 1);
1769 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
1770 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.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" }) });
1771
1772 // packages/icons/build-module/library/more-vertical.mjs
1773 var import_primitives22 = __toESM(require_primitives(), 1);
1774 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
1775 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
1776
1777 // packages/icons/build-module/library/next.mjs
1778 var import_primitives23 = __toESM(require_primitives(), 1);
1779 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
1780 var next_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.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" }) });
1781
1782 // packages/icons/build-module/library/previous.mjs
1783 var import_primitives24 = __toESM(require_primitives(), 1);
1784 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
1785 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.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" }) });
1786
1787 // packages/icons/build-module/library/scheduled.mjs
1788 var import_primitives25 = __toESM(require_primitives(), 1);
1789 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
1790 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.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" }) });
1791
1792 // packages/icons/build-module/library/search.mjs
1793 var import_primitives26 = __toESM(require_primitives(), 1);
1794 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
1795 var search_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives26.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" }) });
1796
1797 // packages/icons/build-module/library/seen.mjs
1798 var import_primitives27 = __toESM(require_primitives(), 1);
1799 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
1800 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives27.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" }) });
1801
1802 // packages/icons/build-module/library/unseen.mjs
1803 var import_primitives28 = __toESM(require_primitives(), 1);
1804 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
1805 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives28.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" }) });
1806
1807 // packages/icons/build-module/library/upload.mjs
1808 var import_primitives29 = __toESM(require_primitives(), 1);
1809 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
1810 var upload_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives29.Path, { d: "M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z" }) });
1811
1812 // packages/icons/build-module/library/video.mjs
1813 var import_primitives30 = __toESM(require_primitives(), 1);
1814 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
1815 var video_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives30.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives30.Path, { d: "M18.7 3H5.3C4 3 3 4 3 5.3v13.4C3 20 4 21 5.3 21h13.4c1.3 0 2.3-1 2.3-2.3V5.3C21 4 20 3 18.7 3zm.8 15.7c0 .4-.4.8-.8.8H5.3c-.4 0-.8-.4-.8-.8V5.3c0-.4.4-.8.8-.8h13.4c.4 0 .8.4.8.8v13.4zM10 15l5-3-5-3v6z" }) });
1816
1817 // node_modules/@base-ui/utils/safeReact.mjs
1818 var React = __toESM(require_react(), 1);
1819 var SafeReact = {
1820 ...React
1821 };
1822
1823 // node_modules/@base-ui/utils/useRefWithInit.mjs
1824 var React2 = __toESM(require_react(), 1);
1825 var UNINITIALIZED = {};
1826 function useRefWithInit(init2, initArg) {
1827 const ref = React2.useRef(UNINITIALIZED);
1828 if (ref.current === UNINITIALIZED) {
1829 ref.current = init2(initArg);
1830 }
1831 return ref;
1832 }
1833
1834 // node_modules/@base-ui/utils/useStableCallback.mjs
1835 var useInsertionEffect = SafeReact.useInsertionEffect;
1836 var useSafeInsertionEffect = (
1837 // React 17 doesn't have useInsertionEffect.
1838 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
1839 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn()
1840 );
1841 function useStableCallback(callback) {
1842 const stable = useRefWithInit(createStableCallback).current;
1843 stable.next = callback;
1844 useSafeInsertionEffect(stable.effect);
1845 return stable.trampoline;
1846 }
1847 function createStableCallback() {
1848 const stable = {
1849 next: void 0,
1850 callback: assertNotCalled,
1851 trampoline: (...args) => stable.callback?.(...args),
1852 effect: () => {
1853 stable.callback = stable.next;
1854 }
1855 };
1856 return stable;
1857 }
1858 function assertNotCalled() {
1859 if (true) {
1860 throw (
1861 /* minify-error-disabled */
1862 new Error("Base UI: Cannot call an event handler while rendering.")
1863 );
1864 }
1865 }
1866
1867 // node_modules/@base-ui/utils/useIsoLayoutEffect.mjs
1868 var React3 = __toESM(require_react(), 1);
1869 var noop2 = () => {
1870 };
1871 var useIsoLayoutEffect = typeof document !== "undefined" ? React3.useLayoutEffect : noop2;
1872
1873 // node_modules/@base-ui/utils/warn.mjs
1874 var set;
1875 if (true) {
1876 set = /* @__PURE__ */ new Set();
1877 }
1878 function warn(...messages) {
1879 if (true) {
1880 const messageKey = messages.join(" ");
1881 if (!set.has(messageKey)) {
1882 set.add(messageKey);
1883 console.warn(`Base UI: ${messageKey}`);
1884 }
1885 }
1886 }
1887
1888 // node_modules/@base-ui/react/internals/direction-context/DirectionContext.mjs
1889 var React4 = __toESM(require_react(), 1);
1890 var DirectionContext = /* @__PURE__ */ React4.createContext(void 0);
1891 if (true) DirectionContext.displayName = "DirectionContext";
1892 function useDirection() {
1893 const context = React4.useContext(DirectionContext);
1894 return context?.direction ?? "ltr";
1895 }
1896
1897 // node_modules/@base-ui/react/internals/useRenderElement.mjs
1898 var React7 = __toESM(require_react(), 1);
1899
1900 // node_modules/@base-ui/utils/useMergedRefs.mjs
1901 function useMergedRefs(a2, b2, c2, d2) {
1902 const forkRef = useRefWithInit(createForkRef).current;
1903 if (didChange(forkRef, a2, b2, c2, d2)) {
1904 update(forkRef, [a2, b2, c2, d2]);
1905 }
1906 return forkRef.callback;
1907 }
1908 function useMergedRefsN(refs) {
1909 const forkRef = useRefWithInit(createForkRef).current;
1910 if (didChangeN(forkRef, refs)) {
1911 update(forkRef, refs);
1912 }
1913 return forkRef.callback;
1914 }
1915 function createForkRef() {
1916 return {
1917 callback: null,
1918 cleanup: null,
1919 refs: []
1920 };
1921 }
1922 function didChange(forkRef, a2, b2, c2, d2) {
1923 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1924 }
1925 function didChangeN(forkRef, newRefs) {
1926 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
1927 }
1928 function update(forkRef, refs) {
1929 forkRef.refs = refs;
1930 if (refs.every((ref) => ref == null)) {
1931 forkRef.callback = null;
1932 return;
1933 }
1934 forkRef.callback = (instance) => {
1935 if (forkRef.cleanup) {
1936 forkRef.cleanup();
1937 forkRef.cleanup = null;
1938 }
1939 if (instance != null) {
1940 const cleanupCallbacks = Array(refs.length).fill(null);
1941 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1942 const ref = refs[i2];
1943 if (ref == null) {
1944 continue;
1945 }
1946 switch (typeof ref) {
1947 case "function": {
1948 const refCleanup = ref(instance);
1949 if (typeof refCleanup === "function") {
1950 cleanupCallbacks[i2] = refCleanup;
1951 }
1952 break;
1953 }
1954 case "object": {
1955 ref.current = instance;
1956 break;
1957 }
1958 default:
1959 }
1960 }
1961 forkRef.cleanup = () => {
1962 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1963 const ref = refs[i2];
1964 if (ref == null) {
1965 continue;
1966 }
1967 switch (typeof ref) {
1968 case "function": {
1969 const cleanupCallback = cleanupCallbacks[i2];
1970 if (typeof cleanupCallback === "function") {
1971 cleanupCallback();
1972 } else {
1973 ref(null);
1974 }
1975 break;
1976 }
1977 case "object": {
1978 ref.current = null;
1979 break;
1980 }
1981 default:
1982 }
1983 }
1984 };
1985 }
1986 };
1987 }
1988
1989 // node_modules/@base-ui/utils/getReactElementRef.mjs
1990 var React6 = __toESM(require_react(), 1);
1991
1992 // node_modules/@base-ui/utils/reactVersion.mjs
1993 var React5 = __toESM(require_react(), 1);
1994 var majorVersion = parseInt(React5.version, 10);
1995 function isReactVersionAtLeast(reactVersionToCheck) {
1996 return majorVersion >= reactVersionToCheck;
1997 }
1998
1999 // node_modules/@base-ui/utils/getReactElementRef.mjs
2000 function getReactElementRef(element) {
2001 if (!/* @__PURE__ */ React6.isValidElement(element)) {
2002 return null;
2003 }
2004 const reactElement = element;
2005 const propsWithRef = reactElement.props;
2006 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
2007 }
2008
2009 // node_modules/@base-ui/utils/mergeObjects.mjs
2010 function mergeObjects(a2, b2) {
2011 if (a2 && !b2) {
2012 return a2;
2013 }
2014 if (!a2 && b2) {
2015 return b2;
2016 }
2017 if (a2 || b2) {
2018 return {
2019 ...a2,
2020 ...b2
2021 };
2022 }
2023 return void 0;
2024 }
2025
2026 // node_modules/@base-ui/utils/empty.mjs
2027 function NOOP() {
2028 }
2029 var EMPTY_ARRAY = Object.freeze([]);
2030 var EMPTY_OBJECT = Object.freeze({});
2031
2032 // node_modules/@base-ui/react/internals/getStateAttributesProps.mjs
2033 function getStateAttributesProps(state, customMapping) {
2034 const props = {};
2035 for (const key in state) {
2036 const value = state[key];
2037 if (customMapping?.hasOwnProperty(key)) {
2038 const customProps = customMapping[key](value);
2039 if (customProps != null) {
2040 Object.assign(props, customProps);
2041 }
2042 continue;
2043 }
2044 if (value === true) {
2045 props[`data-${key.toLowerCase()}`] = "";
2046 } else if (value) {
2047 props[`data-${key.toLowerCase()}`] = value.toString();
2048 }
2049 }
2050 return props;
2051 }
2052
2053 // node_modules/@base-ui/react/utils/resolveClassName.mjs
2054 function resolveClassName(className, state) {
2055 return typeof className === "function" ? className(state) : className;
2056 }
2057
2058 // node_modules/@base-ui/react/utils/resolveStyle.mjs
2059 function resolveStyle(style, state) {
2060 return typeof style === "function" ? style(state) : style;
2061 }
2062
2063 // node_modules/@base-ui/react/merge-props/mergeProps.mjs
2064 var EMPTY_PROPS = {};
2065 function mergeProps(a2, b2, c2, d2, e2) {
2066 if (!c2 && !d2 && !e2 && !a2) {
2067 return createInitialMergedProps(b2);
2068 }
2069 let merged = createInitialMergedProps(a2);
2070 if (b2) {
2071 merged = mergeInto(merged, b2);
2072 }
2073 if (c2) {
2074 merged = mergeInto(merged, c2);
2075 }
2076 if (d2) {
2077 merged = mergeInto(merged, d2);
2078 }
2079 if (e2) {
2080 merged = mergeInto(merged, e2);
2081 }
2082 return merged;
2083 }
2084 function mergePropsN(props) {
2085 if (props.length === 0) {
2086 return EMPTY_PROPS;
2087 }
2088 if (props.length === 1) {
2089 return createInitialMergedProps(props[0]);
2090 }
2091 let merged = createInitialMergedProps(props[0]);
2092 for (let i2 = 1; i2 < props.length; i2 += 1) {
2093 merged = mergeInto(merged, props[i2]);
2094 }
2095 return merged;
2096 }
2097 function createInitialMergedProps(inputProps) {
2098 if (isPropsGetter(inputProps)) {
2099 return {
2100 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
2101 };
2102 }
2103 return copyInitialProps(inputProps);
2104 }
2105 function mergeInto(merged, inputProps) {
2106 if (isPropsGetter(inputProps)) {
2107 return resolvePropsGetter(inputProps, merged);
2108 }
2109 return mutablyMergeInto(merged, inputProps);
2110 }
2111 function copyInitialProps(inputProps) {
2112 const copiedProps = {
2113 ...inputProps
2114 };
2115 for (const propName in copiedProps) {
2116 const propValue = copiedProps[propName];
2117 if (isEventHandler(propName, propValue)) {
2118 copiedProps[propName] = wrapEventHandler(propValue);
2119 }
2120 }
2121 return copiedProps;
2122 }
2123 function mutablyMergeInto(mergedProps, externalProps) {
2124 if (!externalProps) {
2125 return mergedProps;
2126 }
2127 for (const propName in externalProps) {
2128 const externalPropValue = externalProps[propName];
2129 switch (propName) {
2130 case "style": {
2131 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
2132 break;
2133 }
2134 case "className": {
2135 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
2136 break;
2137 }
2138 default: {
2139 if (isEventHandler(propName, externalPropValue)) {
2140 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
2141 } else {
2142 mergedProps[propName] = externalPropValue;
2143 }
2144 }
2145 }
2146 }
2147 return mergedProps;
2148 }
2149 function isEventHandler(key, value) {
2150 const code0 = key.charCodeAt(0);
2151 const code1 = key.charCodeAt(1);
2152 const code2 = key.charCodeAt(2);
2153 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
2154 }
2155 function isPropsGetter(inputProps) {
2156 return typeof inputProps === "function";
2157 }
2158 function resolvePropsGetter(inputProps, previousProps) {
2159 if (isPropsGetter(inputProps)) {
2160 return inputProps(previousProps);
2161 }
2162 return inputProps ?? EMPTY_PROPS;
2163 }
2164 function mergeEventHandlers(ourHandler, theirHandler) {
2165 if (!theirHandler) {
2166 return ourHandler;
2167 }
2168 if (!ourHandler) {
2169 return wrapEventHandler(theirHandler);
2170 }
2171 return (...args) => {
2172 const event = args[0];
2173 if (isSyntheticEvent(event)) {
2174 const baseUIEvent = event;
2175 makeEventPreventable(baseUIEvent);
2176 const result2 = theirHandler(...args);
2177 if (!baseUIEvent.baseUIHandlerPrevented) {
2178 ourHandler?.(...args);
2179 }
2180 return result2;
2181 }
2182 const result = theirHandler(...args);
2183 ourHandler?.(...args);
2184 return result;
2185 };
2186 }
2187 function wrapEventHandler(handler) {
2188 if (!handler) {
2189 return handler;
2190 }
2191 return (...args) => {
2192 const event = args[0];
2193 if (isSyntheticEvent(event)) {
2194 makeEventPreventable(event);
2195 }
2196 return handler(...args);
2197 };
2198 }
2199 function makeEventPreventable(event) {
2200 event.preventBaseUIHandler = () => {
2201 event.baseUIHandlerPrevented = true;
2202 };
2203 return event;
2204 }
2205 function mergeClassNames(ourClassName, theirClassName) {
2206 if (theirClassName) {
2207 if (ourClassName) {
2208 return theirClassName + " " + ourClassName;
2209 }
2210 return theirClassName;
2211 }
2212 return ourClassName;
2213 }
2214 function isSyntheticEvent(event) {
2215 return event != null && typeof event === "object" && "nativeEvent" in event;
2216 }
2217
2218 // node_modules/@base-ui/react/internals/useRenderElement.mjs
2219 var import_react = __toESM(require_react(), 1);
2220 function useRenderElement(element, componentProps, params = {}) {
2221 const renderProp = componentProps.render;
2222 const outProps = useRenderElementProps(componentProps, params);
2223 if (params.enabled === false) {
2224 return null;
2225 }
2226 const state = params.state ?? EMPTY_OBJECT;
2227 return evaluateRenderProp(element, renderProp, outProps, state);
2228 }
2229 function useRenderElementProps(componentProps, params = {}) {
2230 const {
2231 className: classNameProp,
2232 style: styleProp,
2233 render: renderProp
2234 } = componentProps;
2235 const {
2236 state = EMPTY_OBJECT,
2237 ref,
2238 props,
2239 stateAttributesMapping: stateAttributesMapping3,
2240 enabled = true
2241 } = params;
2242 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
2243 const style = enabled ? resolveStyle(styleProp, state) : void 0;
2244 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
2245 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
2246 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
2247 if (typeof document !== "undefined") {
2248 if (!enabled) {
2249 useMergedRefs(null, null);
2250 } else if (Array.isArray(ref)) {
2251 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
2252 } else {
2253 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
2254 }
2255 }
2256 if (!enabled) {
2257 return EMPTY_OBJECT;
2258 }
2259 if (className !== void 0) {
2260 outProps.className = mergeClassNames(outProps.className, className);
2261 }
2262 if (style !== void 0) {
2263 outProps.style = mergeObjects(outProps.style, style);
2264 }
2265 return outProps;
2266 }
2267 function resolveRenderFunctionProps(props) {
2268 if (Array.isArray(props)) {
2269 return mergePropsN(props);
2270 }
2271 return mergeProps(void 0, props);
2272 }
2273 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
2274 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
2275 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
2276 function evaluateRenderProp(element, render4, props, state) {
2277 if (render4) {
2278 if (typeof render4 === "function") {
2279 if (true) {
2280 warnIfRenderPropLooksLikeComponent(render4);
2281 }
2282 return render4(props, state);
2283 }
2284 const mergedProps = mergeProps(props, render4.props);
2285 mergedProps.ref = props.ref;
2286 let newElement = render4;
2287 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
2288 const children = React7.Children.toArray(render4);
2289 newElement = children[0];
2290 }
2291 if (true) {
2292 if (!/* @__PURE__ */ React7.isValidElement(newElement)) {
2293 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"));
2294 }
2295 }
2296 return /* @__PURE__ */ React7.cloneElement(newElement, mergedProps);
2297 }
2298 if (element) {
2299 if (typeof element === "string") {
2300 return renderTag(element, props);
2301 }
2302 }
2303 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
2304 }
2305 function warnIfRenderPropLooksLikeComponent(renderFn) {
2306 const functionName = renderFn.name;
2307 if (functionName.length === 0) {
2308 return;
2309 }
2310 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
2311 return;
2312 }
2313 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
2314 return;
2315 }
2316 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");
2317 }
2318 function renderTag(Tag, props) {
2319 if (Tag === "button") {
2320 return /* @__PURE__ */ (0, import_react.createElement)("button", {
2321 type: "button",
2322 ...props,
2323 key: props.key
2324 });
2325 }
2326 if (Tag === "img") {
2327 return /* @__PURE__ */ (0, import_react.createElement)("img", {
2328 alt: "",
2329 ...props,
2330 key: props.key
2331 });
2332 }
2333 return /* @__PURE__ */ React7.createElement(Tag, props);
2334 }
2335
2336 // node_modules/@base-ui/utils/useId.mjs
2337 var React8 = __toESM(require_react(), 1);
2338 var globalId = 0;
2339 function useGlobalId(idOverride, prefix = "mui") {
2340 const [defaultId, setDefaultId] = React8.useState(idOverride);
2341 const id = idOverride || defaultId;
2342 React8.useEffect(() => {
2343 if (defaultId == null) {
2344 globalId += 1;
2345 setDefaultId(`${prefix}-${globalId}`);
2346 }
2347 }, [defaultId, prefix]);
2348 return id;
2349 }
2350 var maybeReactUseId = SafeReact.useId;
2351 function useId(idOverride, prefix) {
2352 if (maybeReactUseId !== void 0) {
2353 const reactId = maybeReactUseId();
2354 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
2355 }
2356 return useGlobalId(idOverride, prefix);
2357 }
2358
2359 // node_modules/@base-ui/react/internals/useBaseUiId.mjs
2360 function useBaseUiId(idOverride) {
2361 return useId(idOverride, "base-ui");
2362 }
2363
2364 // node_modules/@base-ui/react/internals/reason-parts.mjs
2365 var reason_parts_exports = {};
2366 __export(reason_parts_exports, {
2367 cancelOpen: () => cancelOpen,
2368 chipRemovePress: () => chipRemovePress,
2369 clearPress: () => clearPress,
2370 closePress: () => closePress,
2371 closeWatcher: () => closeWatcher,
2372 decrementPress: () => decrementPress,
2373 disabled: () => disabled,
2374 drag: () => drag,
2375 escapeKey: () => escapeKey,
2376 focusOut: () => focusOut,
2377 imperativeAction: () => imperativeAction,
2378 incrementPress: () => incrementPress,
2379 initial: () => initial,
2380 inputBlur: () => inputBlur,
2381 inputChange: () => inputChange,
2382 inputClear: () => inputClear,
2383 inputPaste: () => inputPaste,
2384 inputPress: () => inputPress,
2385 itemPress: () => itemPress,
2386 keyboard: () => keyboard,
2387 linkPress: () => linkPress,
2388 listNavigation: () => listNavigation,
2389 missing: () => missing,
2390 none: () => none,
2391 outsidePress: () => outsidePress,
2392 pointer: () => pointer,
2393 scrub: () => scrub,
2394 siblingOpen: () => siblingOpen,
2395 swipe: () => swipe,
2396 trackPress: () => trackPress,
2397 triggerFocus: () => triggerFocus,
2398 triggerHover: () => triggerHover,
2399 triggerPress: () => triggerPress,
2400 wheel: () => wheel,
2401 windowResize: () => windowResize
2402 });
2403 var none = "none";
2404 var triggerPress = "trigger-press";
2405 var triggerHover = "trigger-hover";
2406 var triggerFocus = "trigger-focus";
2407 var outsidePress = "outside-press";
2408 var itemPress = "item-press";
2409 var closePress = "close-press";
2410 var linkPress = "link-press";
2411 var clearPress = "clear-press";
2412 var chipRemovePress = "chip-remove-press";
2413 var trackPress = "track-press";
2414 var incrementPress = "increment-press";
2415 var decrementPress = "decrement-press";
2416 var inputChange = "input-change";
2417 var inputClear = "input-clear";
2418 var inputBlur = "input-blur";
2419 var inputPaste = "input-paste";
2420 var inputPress = "input-press";
2421 var focusOut = "focus-out";
2422 var escapeKey = "escape-key";
2423 var closeWatcher = "close-watcher";
2424 var listNavigation = "list-navigation";
2425 var keyboard = "keyboard";
2426 var pointer = "pointer";
2427 var drag = "drag";
2428 var wheel = "wheel";
2429 var scrub = "scrub";
2430 var cancelOpen = "cancel-open";
2431 var siblingOpen = "sibling-open";
2432 var disabled = "disabled";
2433 var missing = "missing";
2434 var initial = "initial";
2435 var imperativeAction = "imperative-action";
2436 var swipe = "swipe";
2437 var windowResize = "window-resize";
2438
2439 // node_modules/@base-ui/react/internals/createBaseUIEventDetails.mjs
2440 function createChangeEventDetails(reason, event, trigger, customProperties) {
2441 let canceled = false;
2442 let allowPropagation = false;
2443 const custom = customProperties ?? EMPTY_OBJECT;
2444 const details = {
2445 reason,
2446 event: event ?? new Event("base-ui"),
2447 cancel() {
2448 canceled = true;
2449 },
2450 allowPropagation() {
2451 allowPropagation = true;
2452 },
2453 get isCanceled() {
2454 return canceled;
2455 },
2456 get isPropagationAllowed() {
2457 return allowPropagation;
2458 },
2459 trigger,
2460 ...custom
2461 };
2462 return details;
2463 }
2464
2465 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs
2466 var React10 = __toESM(require_react(), 1);
2467
2468 // node_modules/@base-ui/utils/useOnMount.mjs
2469 var React9 = __toESM(require_react(), 1);
2470 var EMPTY = [];
2471 function useOnMount(fn) {
2472 React9.useEffect(fn, EMPTY);
2473 }
2474
2475 // node_modules/@base-ui/utils/useAnimationFrame.mjs
2476 var EMPTY2 = null;
2477 var LAST_RAF = globalThis.requestAnimationFrame;
2478 var Scheduler = class {
2479 /* This implementation uses an array as a backing data-structure for frame callbacks.
2480 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
2481 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
2482 * be much more efficient if there is a call pattern that alterns as
2483 * "request-cancel-request-cancel-…".
2484 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
2485 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
2486 callbacks = [];
2487 callbacksCount = 0;
2488 nextId = 1;
2489 startId = 1;
2490 isScheduled = false;
2491 tick = (timestamp) => {
2492 this.isScheduled = false;
2493 const currentCallbacks = this.callbacks;
2494 const currentCallbacksCount = this.callbacksCount;
2495 this.callbacks = [];
2496 this.callbacksCount = 0;
2497 this.startId = this.nextId;
2498 if (currentCallbacksCount > 0) {
2499 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
2500 currentCallbacks[i2]?.(timestamp);
2501 }
2502 }
2503 };
2504 request(fn) {
2505 const id = this.nextId;
2506 this.nextId += 1;
2507 this.callbacks.push(fn);
2508 this.callbacksCount += 1;
2509 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
2510 if (!this.isScheduled || didRAFChange) {
2511 requestAnimationFrame(this.tick);
2512 this.isScheduled = true;
2513 }
2514 return id;
2515 }
2516 cancel(id) {
2517 const index2 = id - this.startId;
2518 if (index2 < 0 || index2 >= this.callbacks.length) {
2519 return;
2520 }
2521 this.callbacks[index2] = null;
2522 this.callbacksCount -= 1;
2523 }
2524 };
2525 var scheduler = new Scheduler();
2526 var AnimationFrame = class _AnimationFrame {
2527 static create() {
2528 return new _AnimationFrame();
2529 }
2530 static request(fn) {
2531 return scheduler.request(fn);
2532 }
2533 static cancel(id) {
2534 return scheduler.cancel(id);
2535 }
2536 currentId = EMPTY2;
2537 /**
2538 * Executes `fn` after `delay`, clearing any previously scheduled call.
2539 */
2540 request(fn) {
2541 this.cancel();
2542 this.currentId = scheduler.request(() => {
2543 this.currentId = EMPTY2;
2544 fn();
2545 });
2546 }
2547 cancel = () => {
2548 if (this.currentId !== EMPTY2) {
2549 scheduler.cancel(this.currentId);
2550 this.currentId = EMPTY2;
2551 }
2552 };
2553 disposeEffect = () => {
2554 return this.cancel;
2555 };
2556 };
2557 function useAnimationFrame() {
2558 const timeout = useRefWithInit(AnimationFrame.create).current;
2559 useOnMount(timeout.disposeEffect);
2560 return timeout;
2561 }
2562
2563 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs
2564 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
2565 const [transitionStatus, setTransitionStatus] = React10.useState(open && enableIdleState ? "idle" : void 0);
2566 const [mounted, setMounted] = React10.useState(open);
2567 if (open && !mounted) {
2568 setMounted(true);
2569 setTransitionStatus("starting");
2570 }
2571 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
2572 setTransitionStatus("ending");
2573 }
2574 if (!open && !mounted && transitionStatus === "ending") {
2575 setTransitionStatus(void 0);
2576 }
2577 useIsoLayoutEffect(() => {
2578 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
2579 const frame = AnimationFrame.request(() => {
2580 setTransitionStatus("ending");
2581 });
2582 return () => {
2583 AnimationFrame.cancel(frame);
2584 };
2585 }
2586 return void 0;
2587 }, [open, mounted, transitionStatus, deferEndingState]);
2588 useIsoLayoutEffect(() => {
2589 if (!open || enableIdleState) {
2590 return void 0;
2591 }
2592 const frame = AnimationFrame.request(() => {
2593 setTransitionStatus(void 0);
2594 });
2595 return () => {
2596 AnimationFrame.cancel(frame);
2597 };
2598 }, [enableIdleState, open]);
2599 useIsoLayoutEffect(() => {
2600 if (!open || !enableIdleState) {
2601 return void 0;
2602 }
2603 if (open && mounted && transitionStatus !== "idle") {
2604 setTransitionStatus("starting");
2605 }
2606 const frame = AnimationFrame.request(() => {
2607 setTransitionStatus("idle");
2608 });
2609 return () => {
2610 AnimationFrame.cancel(frame);
2611 };
2612 }, [enableIdleState, open, mounted, transitionStatus]);
2613 return {
2614 mounted,
2615 setMounted,
2616 transitionStatus
2617 };
2618 }
2619
2620 // node_modules/@base-ui/react/internals/stateAttributesMapping.mjs
2621 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
2622 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
2623 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
2624 return TransitionStatusDataAttributes2;
2625 })({});
2626 var STARTING_HOOK = {
2627 [TransitionStatusDataAttributes.startingStyle]: ""
2628 };
2629 var ENDING_HOOK = {
2630 [TransitionStatusDataAttributes.endingStyle]: ""
2631 };
2632 var transitionStatusMapping = {
2633 transitionStatus(value) {
2634 if (value === "starting") {
2635 return STARTING_HOOK;
2636 }
2637 if (value === "ending") {
2638 return ENDING_HOOK;
2639 }
2640 return null;
2641 }
2642 };
2643
2644 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
2645 function hasWindow() {
2646 return typeof window !== "undefined";
2647 }
2648 function getNodeName(node) {
2649 if (isNode(node)) {
2650 return (node.nodeName || "").toLowerCase();
2651 }
2652 return "#document";
2653 }
2654 function getWindow(node) {
2655 var _node$ownerDocument;
2656 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2657 }
2658 function getDocumentElement(node) {
2659 var _ref;
2660 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2661 }
2662 function isNode(value) {
2663 if (!hasWindow()) {
2664 return false;
2665 }
2666 return value instanceof Node || value instanceof getWindow(value).Node;
2667 }
2668 function isElement(value) {
2669 if (!hasWindow()) {
2670 return false;
2671 }
2672 return value instanceof Element || value instanceof getWindow(value).Element;
2673 }
2674 function isHTMLElement(value) {
2675 if (!hasWindow()) {
2676 return false;
2677 }
2678 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2679 }
2680 function isShadowRoot(value) {
2681 if (!hasWindow() || typeof ShadowRoot === "undefined") {
2682 return false;
2683 }
2684 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2685 }
2686 function isOverflowElement(element) {
2687 const {
2688 overflow,
2689 overflowX,
2690 overflowY,
2691 display
2692 } = getComputedStyle2(element);
2693 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
2694 }
2695 function isTableElement(element) {
2696 return /^(table|td|th)$/.test(getNodeName(element));
2697 }
2698 function isTopLayer(element) {
2699 try {
2700 if (element.matches(":popover-open")) {
2701 return true;
2702 }
2703 } catch (_e) {
2704 }
2705 try {
2706 return element.matches(":modal");
2707 } catch (_e) {
2708 return false;
2709 }
2710 }
2711 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
2712 var containRe = /paint|layout|strict|content/;
2713 var isNotNone = (value) => !!value && value !== "none";
2714 var isWebKitValue;
2715 function isContainingBlock(elementOrCss) {
2716 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
2717 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 || "");
2718 }
2719 function getContainingBlock(element) {
2720 let currentNode = getParentNode(element);
2721 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2722 if (isContainingBlock(currentNode)) {
2723 return currentNode;
2724 } else if (isTopLayer(currentNode)) {
2725 return null;
2726 }
2727 currentNode = getParentNode(currentNode);
2728 }
2729 return null;
2730 }
2731 function isWebKit() {
2732 if (isWebKitValue == null) {
2733 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
2734 }
2735 return isWebKitValue;
2736 }
2737 function isLastTraversableNode(node) {
2738 return /^(html|body|#document)$/.test(getNodeName(node));
2739 }
2740 function getComputedStyle2(element) {
2741 return getWindow(element).getComputedStyle(element);
2742 }
2743 function getNodeScroll(element) {
2744 if (isElement(element)) {
2745 return {
2746 scrollLeft: element.scrollLeft,
2747 scrollTop: element.scrollTop
2748 };
2749 }
2750 return {
2751 scrollLeft: element.scrollX,
2752 scrollTop: element.scrollY
2753 };
2754 }
2755 function getParentNode(node) {
2756 if (getNodeName(node) === "html") {
2757 return node;
2758 }
2759 const result = (
2760 // Step into the shadow DOM of the parent of a slotted node.
2761 node.assignedSlot || // DOM Element detected.
2762 node.parentNode || // ShadowRoot detected.
2763 isShadowRoot(node) && node.host || // Fallback.
2764 getDocumentElement(node)
2765 );
2766 return isShadowRoot(result) ? result.host : result;
2767 }
2768 function getNearestOverflowAncestor(node) {
2769 const parentNode = getParentNode(node);
2770 if (isLastTraversableNode(parentNode)) {
2771 return node.ownerDocument ? node.ownerDocument.body : node.body;
2772 }
2773 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2774 return parentNode;
2775 }
2776 return getNearestOverflowAncestor(parentNode);
2777 }
2778 function getOverflowAncestors(node, list, traverseIframes) {
2779 var _node$ownerDocument2;
2780 if (list === void 0) {
2781 list = [];
2782 }
2783 if (traverseIframes === void 0) {
2784 traverseIframes = true;
2785 }
2786 const scrollableAncestor = getNearestOverflowAncestor(node);
2787 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2788 const win = getWindow(scrollableAncestor);
2789 if (isBody) {
2790 const frameElement = getFrameElement(win);
2791 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2792 } else {
2793 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2794 }
2795 }
2796 function getFrameElement(win) {
2797 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2798 }
2799
2800 // node_modules/@base-ui/utils/addEventListener.mjs
2801 function addEventListener(target, type, listener, options) {
2802 target.addEventListener(type, listener, options);
2803 return () => {
2804 target.removeEventListener(type, listener, options);
2805 };
2806 }
2807
2808 // node_modules/@base-ui/utils/useValueAsRef.mjs
2809 function useValueAsRef(value) {
2810 const latest = useRefWithInit(createLatestRef, value).current;
2811 latest.next = value;
2812 useIsoLayoutEffect(latest.effect);
2813 return latest;
2814 }
2815 function createLatestRef(value) {
2816 const latest = {
2817 current: value,
2818 next: value,
2819 effect: () => {
2820 latest.current = latest.next;
2821 }
2822 };
2823 return latest;
2824 }
2825
2826 // node_modules/@base-ui/utils/owner.mjs
2827 function ownerDocument(node) {
2828 return node?.ownerDocument || document;
2829 }
2830
2831 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs
2832 var React11 = __toESM(require_react(), 1);
2833
2834 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs
2835 var ReactDOM = __toESM(require_react_dom(), 1);
2836
2837 // node_modules/@base-ui/react/utils/resolveRef.mjs
2838 function resolveRef(maybeRef) {
2839 if (maybeRef == null) {
2840 return maybeRef;
2841 }
2842 return "current" in maybeRef ? maybeRef.current : maybeRef;
2843 }
2844
2845 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs
2846 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
2847 const frame = useAnimationFrame();
2848 return useStableCallback((fnToExecute, signal = null) => {
2849 frame.cancel();
2850 const element = resolveRef(elementOrRef);
2851 if (element == null) {
2852 return;
2853 }
2854 const resolvedElement = element;
2855 const done = () => {
2856 ReactDOM.flushSync(fnToExecute);
2857 };
2858 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
2859 fnToExecute();
2860 return;
2861 }
2862 function exec() {
2863 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
2864 if (!signal?.aborted) {
2865 done();
2866 }
2867 }).catch(() => {
2868 if (treatAbortedAsFinished) {
2869 if (!signal?.aborted) {
2870 done();
2871 }
2872 return;
2873 }
2874 const currentAnimations = resolvedElement.getAnimations();
2875 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
2876 exec();
2877 }
2878 });
2879 }
2880 if (waitForStartingStyleRemoved) {
2881 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
2882 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2883 frame.request(exec);
2884 return;
2885 }
2886 const attributeObserver = new MutationObserver(() => {
2887 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2888 attributeObserver.disconnect();
2889 exec();
2890 }
2891 });
2892 attributeObserver.observe(resolvedElement, {
2893 attributes: true,
2894 attributeFilter: [startingStyleAttribute]
2895 });
2896 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
2897 once: true
2898 });
2899 return;
2900 }
2901 frame.request(exec);
2902 });
2903 }
2904
2905 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs
2906 function useOpenChangeComplete(parameters) {
2907 const {
2908 enabled = true,
2909 open,
2910 ref,
2911 onComplete: onCompleteParam
2912 } = parameters;
2913 const onComplete = useStableCallback(onCompleteParam);
2914 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2915 React11.useEffect(() => {
2916 if (!enabled) {
2917 return void 0;
2918 }
2919 const abortController = new AbortController();
2920 runOnceAnimationsFinish(onComplete, abortController.signal);
2921 return () => {
2922 abortController.abort();
2923 };
2924 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2925 }
2926
2927 // node_modules/@base-ui/utils/useOnFirstRender.mjs
2928 var React12 = __toESM(require_react(), 1);
2929 function useOnFirstRender(fn) {
2930 const ref = React12.useRef(true);
2931 if (ref.current) {
2932 ref.current = false;
2933 fn();
2934 }
2935 }
2936
2937 // node_modules/@base-ui/utils/platform/parts.mjs
2938 var parts_exports = {};
2939 __export(parts_exports, {
2940 engine: () => engine_exports,
2941 env: () => env_exports,
2942 os: () => os_exports,
2943 screenReader: () => screen_reader_exports
2944 });
2945
2946 // node_modules/@base-ui/utils/platform/os.mjs
2947 var os_exports = {};
2948 __export(os_exports, {
2949 android: () => android,
2950 apple: () => apple,
2951 ios: () => ios,
2952 linux: () => linux,
2953 mac: () => mac,
2954 windows: () => windows
2955 });
2956
2957 // node_modules/@base-ui/utils/platform/shared.mjs
2958 function readRawData() {
2959 if (typeof navigator === "undefined") {
2960 return {
2961 userAgent: "",
2962 platform: "",
2963 maxTouchPoints: 0
2964 };
2965 }
2966 if (true) {
2967 const uaData = navigator.userAgentData;
2968 if (uaData && Array.isArray(uaData.brands)) {
2969 return {
2970 userAgent: uaData.brands.map(({
2971 brand,
2972 version: version2
2973 }) => `${brand}/${version2}`).join(" "),
2974 platform: uaData.platform ?? navigator.platform ?? "",
2975 maxTouchPoints: navigator.maxTouchPoints ?? 0
2976 };
2977 }
2978 }
2979 return {
2980 userAgent: navigator.userAgent,
2981 platform: navigator.platform ?? "",
2982 maxTouchPoints: navigator.maxTouchPoints ?? 0
2983 };
2984 }
2985 var {
2986 userAgent,
2987 platform,
2988 maxTouchPoints
2989 } = readRawData();
2990 var lowerUserAgent = userAgent.toLowerCase();
2991 var lowerPlatform = platform.toLowerCase();
2992
2993 // node_modules/@base-ui/utils/platform/os.mjs
2994 var ios = /^i(os$|p)/.test(lowerPlatform) || lowerPlatform === "macintel" && maxTouchPoints > 1;
2995 var ANDROID_STRING = "android";
2996 var android = lowerPlatform === ANDROID_STRING || lowerUserAgent.includes(ANDROID_STRING);
2997 var mac = !ios && lowerPlatform.startsWith("mac");
2998 var windows = lowerPlatform.startsWith("win");
2999 var linux = !android && /^(linux|chrome os)/.test(lowerPlatform);
3000 var apple = mac || ios;
3001
3002 // node_modules/@base-ui/utils/platform/engine.mjs
3003 var engine_exports = {};
3004 __export(engine_exports, {
3005 blink: () => blink,
3006 gecko: () => gecko,
3007 webkit: () => webkit
3008 });
3009 var webkit = typeof CSS !== "undefined" && !!CSS.supports?.("-webkit-backdrop-filter:none");
3010 var gecko = !webkit && lowerUserAgent.includes("firefox");
3011 var blink = !webkit && lowerUserAgent.includes("chrom");
3012
3013 // node_modules/@base-ui/utils/platform/screen-reader.mjs
3014 var screen_reader_exports = {};
3015 __export(screen_reader_exports, {
3016 voiceOver: () => voiceOver
3017 });
3018 var voiceOver = apple;
3019
3020 // node_modules/@base-ui/utils/platform/env.mjs
3021 var env_exports = {};
3022 __export(env_exports, {
3023 jsdom: () => jsdom
3024 });
3025 var jsdom = /jsdom|happydom/.test(lowerUserAgent);
3026
3027 // node_modules/@base-ui/utils/useTimeout.mjs
3028 var EMPTY3 = 0;
3029 var Timeout = class _Timeout {
3030 static create() {
3031 return new _Timeout();
3032 }
3033 currentId = EMPTY3;
3034 /**
3035 * Executes `fn` after `delay`, clearing any previously scheduled call.
3036 */
3037 start(delay, fn) {
3038 this.clear();
3039 this.currentId = setTimeout(() => {
3040 this.currentId = EMPTY3;
3041 fn();
3042 }, delay);
3043 }
3044 isStarted() {
3045 return this.currentId !== EMPTY3;
3046 }
3047 clear = () => {
3048 if (this.currentId !== EMPTY3) {
3049 clearTimeout(this.currentId);
3050 this.currentId = EMPTY3;
3051 }
3052 };
3053 disposeEffect = () => {
3054 return this.clear;
3055 };
3056 };
3057 function useTimeout() {
3058 const timeout = useRefWithInit(Timeout.create).current;
3059 useOnMount(timeout.disposeEffect);
3060 return timeout;
3061 }
3062
3063 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs
3064 var React13 = __toESM(require_react(), 1);
3065
3066 // node_modules/@base-ui/react/floating-ui-react/utils/event.mjs
3067 function isReactEvent(event) {
3068 return "nativeEvent" in event;
3069 }
3070 function isMouseLikePointerType(pointerType, strict) {
3071 const values = ["mouse", "pen"];
3072 if (!strict) {
3073 values.push("", void 0);
3074 }
3075 return values.includes(pointerType);
3076 }
3077 function isClickLikeEvent(event) {
3078 const type = event.type;
3079 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
3080 }
3081
3082 // node_modules/@base-ui/react/floating-ui-react/utils/constants.mjs
3083 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
3084 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
3085
3086 // node_modules/@base-ui/react/internals/shadowDom.mjs
3087 function activeElement(doc) {
3088 let element = doc.activeElement;
3089 while (element?.shadowRoot?.activeElement != null) {
3090 element = element.shadowRoot.activeElement;
3091 }
3092 return element;
3093 }
3094 function contains(parent, child) {
3095 if (!parent || !child) {
3096 return false;
3097 }
3098 const rootNode = child.getRootNode?.();
3099 if (parent.contains(child)) {
3100 return true;
3101 }
3102 if (rootNode && isShadowRoot(rootNode)) {
3103 let next = child;
3104 while (next) {
3105 if (parent === next) {
3106 return true;
3107 }
3108 next = next.parentNode || next.host;
3109 }
3110 }
3111 return false;
3112 }
3113 function getTarget(event) {
3114 if ("composedPath" in event) {
3115 return event.composedPath()[0];
3116 }
3117 return event.target;
3118 }
3119
3120 // node_modules/@base-ui/react/floating-ui-react/utils/element.mjs
3121 function isTargetInsideEnabledTrigger(target, triggerElements) {
3122 if (!isElement(target)) {
3123 return false;
3124 }
3125 const targetElement = target;
3126 if (triggerElements.hasElement(targetElement)) {
3127 return !targetElement.hasAttribute("data-trigger-disabled");
3128 }
3129 for (const [, trigger] of triggerElements.entries()) {
3130 if (contains(trigger, targetElement)) {
3131 return !trigger.hasAttribute("data-trigger-disabled");
3132 }
3133 }
3134 return false;
3135 }
3136 function isEventTargetWithin(event, node) {
3137 if (node == null) {
3138 return false;
3139 }
3140 if ("composedPath" in event) {
3141 return event.composedPath().includes(node);
3142 }
3143 const eventAgain = event;
3144 return eventAgain.target != null && node.contains(eventAgain.target);
3145 }
3146 function isRootElement(element) {
3147 return element.matches("html,body");
3148 }
3149 function isTypeableElement(element) {
3150 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
3151 }
3152 function isInteractiveElement(element) {
3153 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
3154 }
3155 function matchesFocusVisible(element) {
3156 if (!element || parts_exports.env.jsdom) {
3157 return true;
3158 }
3159 try {
3160 return element.matches(":focus-visible");
3161 } catch (_e) {
3162 return true;
3163 }
3164 }
3165
3166 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverShared.mjs
3167 function resolveValue(value, pointerType) {
3168 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
3169 return 0;
3170 }
3171 if (typeof value === "function") {
3172 return value();
3173 }
3174 return value;
3175 }
3176 function getDelay(value, prop, pointerType) {
3177 const result = resolveValue(value, pointerType);
3178 if (typeof result === "number") {
3179 return result;
3180 }
3181 return result?.[prop];
3182 }
3183 function getRestMs(value) {
3184 if (typeof value === "function") {
3185 return value();
3186 }
3187 return value;
3188 }
3189 function isClickLikeOpenEvent(openEventType, interactedInside) {
3190 return interactedInside || openEventType === "click" || openEventType === "mousedown";
3191 }
3192 function isHoverOpenEvent(openEventType) {
3193 return openEventType?.includes("mouse") && openEventType !== "mousedown";
3194 }
3195
3196 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs
3197 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
3198 var FloatingDelayGroupContext = /* @__PURE__ */ React13.createContext({
3199 hasProvider: false,
3200 timeoutMs: 0,
3201 delayRef: {
3202 current: 0
3203 },
3204 initialDelayRef: {
3205 current: 0
3206 },
3207 timeout: new Timeout(),
3208 currentIdRef: {
3209 current: null
3210 },
3211 currentContextRef: {
3212 current: null
3213 }
3214 });
3215 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
3216 function resetDelayRef(delayRef, initialDelayRef) {
3217 delayRef.current = initialDelayRef.current;
3218 }
3219 function FloatingDelayGroup(props) {
3220 const {
3221 children,
3222 delay,
3223 timeoutMs = 0
3224 } = props;
3225 const delayRef = React13.useRef(delay);
3226 const initialDelayRef = React13.useRef(delay);
3227 const currentIdRef = React13.useRef(null);
3228 const currentContextRef = React13.useRef(null);
3229 const timeout = useTimeout();
3230 useIsoLayoutEffect(() => {
3231 initialDelayRef.current = delay;
3232 if (!currentIdRef.current) {
3233 delayRef.current = delay;
3234 return;
3235 }
3236 delayRef.current = {
3237 open: getDelay(delayRef.current, "open"),
3238 close: getDelay(delay, "close")
3239 };
3240 }, [delay, currentIdRef, delayRef, initialDelayRef]);
3241 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(FloatingDelayGroupContext.Provider, {
3242 value: React13.useMemo(() => ({
3243 hasProvider: true,
3244 delayRef,
3245 initialDelayRef,
3246 currentIdRef,
3247 timeoutMs,
3248 currentContextRef,
3249 timeout
3250 }), [timeoutMs, timeout]),
3251 children
3252 });
3253 }
3254 function useDelayGroup(context, options = {
3255 open: false
3256 }) {
3257 const {
3258 open
3259 } = options;
3260 const store = "rootStore" in context ? context.rootStore : context;
3261 const floatingId = store.useState("floatingId");
3262 const groupContext = React13.useContext(FloatingDelayGroupContext);
3263 const {
3264 currentIdRef,
3265 delayRef,
3266 timeoutMs,
3267 initialDelayRef,
3268 currentContextRef,
3269 hasProvider,
3270 timeout
3271 } = groupContext;
3272 const [isInstantPhase, setIsInstantPhase] = React13.useState(false);
3273 const openRef = React13.useRef(open);
3274 const isUnmountedRef = React13.useRef(false);
3275 useIsoLayoutEffect(() => {
3276 openRef.current = open;
3277 }, [open]);
3278 useIsoLayoutEffect(() => {
3279 return () => {
3280 isUnmountedRef.current = true;
3281 };
3282 }, []);
3283 useIsoLayoutEffect(() => {
3284 function unset() {
3285 if (!isUnmountedRef.current) {
3286 setIsInstantPhase(false);
3287 }
3288 currentContextRef.current?.setIsInstantPhase(false);
3289 currentIdRef.current = null;
3290 currentContextRef.current = null;
3291 delayRef.current = initialDelayRef.current;
3292 timeout.clear();
3293 }
3294 if (!currentIdRef.current) {
3295 return void 0;
3296 }
3297 if (!open && currentIdRef.current === floatingId) {
3298 setIsInstantPhase(false);
3299 if (timeoutMs) {
3300 const closingId = floatingId;
3301 timeout.start(timeoutMs, () => {
3302 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
3303 return;
3304 }
3305 unset();
3306 });
3307 return () => {
3308 if (openRef.current || currentIdRef.current !== closingId) {
3309 timeout.clear();
3310 }
3311 };
3312 }
3313 unset();
3314 }
3315 return void 0;
3316 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
3317 useIsoLayoutEffect(() => {
3318 if (!open) {
3319 return;
3320 }
3321 const prevContext = currentContextRef.current;
3322 const prevId = currentIdRef.current;
3323 timeout.clear();
3324 currentContextRef.current = {
3325 onOpenChange: store.setOpen,
3326 setIsInstantPhase
3327 };
3328 currentIdRef.current = floatingId;
3329 delayRef.current = {
3330 open: 0,
3331 close: getDelay(initialDelayRef.current, "close")
3332 };
3333 if (prevId !== null && prevId !== floatingId) {
3334 setIsInstantPhase(true);
3335 prevContext?.setIsInstantPhase(true);
3336 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
3337 } else {
3338 setIsInstantPhase(false);
3339 prevContext?.setIsInstantPhase(false);
3340 }
3341 }, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
3342 useIsoLayoutEffect(() => {
3343 return () => {
3344 if (currentIdRef.current === floatingId) {
3345 currentContextRef.current = null;
3346 if (!openRef.current) {
3347 return;
3348 }
3349 currentIdRef.current = null;
3350 resetDelayRef(delayRef, initialDelayRef);
3351 timeout.clear();
3352 }
3353 };
3354 }, [currentContextRef, currentIdRef, delayRef, floatingId, initialDelayRef, timeout]);
3355 return React13.useMemo(() => ({
3356 hasProvider,
3357 delayRef,
3358 isInstantPhase
3359 }), [hasProvider, delayRef, isInstantPhase]);
3360 }
3361
3362 // node_modules/@base-ui/utils/mergeCleanups.mjs
3363 function mergeCleanups(...cleanups) {
3364 return () => {
3365 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
3366 const cleanup = cleanups[i2];
3367 if (cleanup) {
3368 cleanup();
3369 }
3370 }
3371 };
3372 }
3373
3374 // node_modules/@base-ui/react/utils/FocusGuard.mjs
3375 var React14 = __toESM(require_react(), 1);
3376
3377 // node_modules/@base-ui/utils/visuallyHidden.mjs
3378 var visuallyHiddenBase = {
3379 clipPath: "inset(50%)",
3380 overflow: "hidden",
3381 whiteSpace: "nowrap",
3382 border: 0,
3383 padding: 0,
3384 width: 1,
3385 height: 1,
3386 margin: -1
3387 };
3388 var visuallyHidden = {
3389 ...visuallyHiddenBase,
3390 position: "fixed",
3391 top: 0,
3392 left: 0
3393 };
3394 var visuallyHiddenInput = {
3395 ...visuallyHiddenBase,
3396 position: "absolute"
3397 };
3398
3399 // node_modules/@base-ui/react/utils/FocusGuard.mjs
3400 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
3401 var FocusGuard = /* @__PURE__ */ React14.forwardRef(function FocusGuard2(props, ref) {
3402 const [role, setRole] = React14.useState();
3403 useIsoLayoutEffect(() => {
3404 if (parts_exports.screenReader.voiceOver && parts_exports.engine.webkit) {
3405 setRole("button");
3406 }
3407 }, []);
3408 const restProps = {
3409 tabIndex: 0,
3410 // Role is only for VoiceOver
3411 role
3412 };
3413 return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", {
3414 ...props,
3415 ref,
3416 style: visuallyHidden,
3417 "aria-hidden": role ? void 0 : true,
3418 ...restProps,
3419 "data-base-ui-focus-guard": ""
3420 });
3421 });
3422 if (true) FocusGuard.displayName = "FocusGuard";
3423
3424 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
3425 var sides = ["top", "right", "bottom", "left"];
3426 var min = Math.min;
3427 var max = Math.max;
3428 var round = Math.round;
3429 var floor = Math.floor;
3430 var createCoords = (v2) => ({
3431 x: v2,
3432 y: v2
3433 });
3434 var oppositeSideMap = {
3435 left: "right",
3436 right: "left",
3437 bottom: "top",
3438 top: "bottom"
3439 };
3440 function clamp(start, value, end) {
3441 return max(start, min(value, end));
3442 }
3443 function evaluate(value, param) {
3444 return typeof value === "function" ? value(param) : value;
3445 }
3446 function getSide(placement) {
3447 return placement.split("-")[0];
3448 }
3449 function getAlignment(placement) {
3450 return placement.split("-")[1];
3451 }
3452 function getOppositeAxis(axis) {
3453 return axis === "x" ? "y" : "x";
3454 }
3455 function getAxisLength(axis) {
3456 return axis === "y" ? "height" : "width";
3457 }
3458 function getSideAxis(placement) {
3459 const firstChar = placement[0];
3460 return firstChar === "t" || firstChar === "b" ? "y" : "x";
3461 }
3462 function getAlignmentAxis(placement) {
3463 return getOppositeAxis(getSideAxis(placement));
3464 }
3465 function getAlignmentSides(placement, rects, rtl) {
3466 if (rtl === void 0) {
3467 rtl = false;
3468 }
3469 const alignment = getAlignment(placement);
3470 const alignmentAxis = getAlignmentAxis(placement);
3471 const length = getAxisLength(alignmentAxis);
3472 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
3473 if (rects.reference[length] > rects.floating[length]) {
3474 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
3475 }
3476 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
3477 }
3478 function getExpandedPlacements(placement) {
3479 const oppositePlacement = getOppositePlacement(placement);
3480 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
3481 }
3482 function getOppositeAlignmentPlacement(placement) {
3483 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
3484 }
3485 var lrPlacement = ["left", "right"];
3486 var rlPlacement = ["right", "left"];
3487 var tbPlacement = ["top", "bottom"];
3488 var btPlacement = ["bottom", "top"];
3489 function getSideList(side, isStart, rtl) {
3490 switch (side) {
3491 case "top":
3492 case "bottom":
3493 if (rtl) return isStart ? rlPlacement : lrPlacement;
3494 return isStart ? lrPlacement : rlPlacement;
3495 case "left":
3496 case "right":
3497 return isStart ? tbPlacement : btPlacement;
3498 default:
3499 return [];
3500 }
3501 }
3502 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
3503 const alignment = getAlignment(placement);
3504 let list = getSideList(getSide(placement), direction === "start", rtl);
3505 if (alignment) {
3506 list = list.map((side) => side + "-" + alignment);
3507 if (flipAlignment) {
3508 list = list.concat(list.map(getOppositeAlignmentPlacement));
3509 }
3510 }
3511 return list;
3512 }
3513 function getOppositePlacement(placement) {
3514 const side = getSide(placement);
3515 return oppositeSideMap[side] + placement.slice(side.length);
3516 }
3517 function expandPaddingObject(padding) {
3518 return {
3519 top: 0,
3520 right: 0,
3521 bottom: 0,
3522 left: 0,
3523 ...padding
3524 };
3525 }
3526 function getPaddingObject(padding) {
3527 return typeof padding !== "number" ? expandPaddingObject(padding) : {
3528 top: padding,
3529 right: padding,
3530 bottom: padding,
3531 left: padding
3532 };
3533 }
3534 function rectToClientRect(rect) {
3535 const {
3536 x: x2,
3537 y: y2,
3538 width,
3539 height
3540 } = rect;
3541 return {
3542 width,
3543 height,
3544 top: y2,
3545 left: x2,
3546 right: x2 + width,
3547 bottom: y2 + height,
3548 x: x2,
3549 y: y2
3550 };
3551 }
3552
3553 // node_modules/@base-ui/react/floating-ui-react/utils/composite.mjs
3554 function isHiddenByStyles(styles) {
3555 return styles.visibility === "hidden" || styles.visibility === "collapse";
3556 }
3557 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
3558 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
3559 return false;
3560 }
3561 if (typeof element.checkVisibility === "function") {
3562 return element.checkVisibility();
3563 }
3564 return styles.display !== "none" && styles.display !== "contents";
3565 }
3566
3567 // node_modules/@base-ui/react/floating-ui-react/utils/tabbable.mjs
3568 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
3569 function getParentElement(element) {
3570 const assignedSlot = element.assignedSlot;
3571 if (assignedSlot) {
3572 return assignedSlot;
3573 }
3574 if (element.parentElement) {
3575 return element.parentElement;
3576 }
3577 const rootNode = element.getRootNode();
3578 return isShadowRoot(rootNode) ? rootNode.host : null;
3579 }
3580 function getDetailsSummary(details) {
3581 for (const child of Array.from(details.children)) {
3582 if (getNodeName(child) === "summary") {
3583 return child;
3584 }
3585 }
3586 return null;
3587 }
3588 function isWithinOpenDetailsSummary(element, details) {
3589 const summary = getDetailsSummary(details);
3590 return !!summary && (element === summary || contains(summary, element));
3591 }
3592 function isFocusableCandidate(element) {
3593 const nodeName = element ? getNodeName(element) : "";
3594 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");
3595 }
3596 function isFocusableElement(element) {
3597 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
3598 return false;
3599 }
3600 for (let current = element; current; current = getParentElement(current)) {
3601 const isAncestor = current !== element;
3602 const isSlot = getNodeName(current) === "slot";
3603 if (current.hasAttribute("inert")) {
3604 return false;
3605 }
3606 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
3607 return false;
3608 }
3609 }
3610 return true;
3611 }
3612 function isVisibleInTabbableTree(element, isAncestor) {
3613 const styles = getComputedStyle2(element);
3614 if (!isAncestor) {
3615 return isElementVisible(element, styles);
3616 }
3617 return styles.display !== "none";
3618 }
3619 function getTabIndex(element) {
3620 const tabIndex = element.tabIndex;
3621 if (tabIndex < 0) {
3622 const nodeName = getNodeName(element);
3623 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
3624 return 0;
3625 }
3626 }
3627 return tabIndex;
3628 }
3629 function getNamedRadioInput(element) {
3630 if (getNodeName(element) !== "input") {
3631 return null;
3632 }
3633 const input = element;
3634 return input.type === "radio" && input.name !== "" ? input : null;
3635 }
3636 function isTabbableRadio(element, candidates) {
3637 const input = getNamedRadioInput(element);
3638 if (!input) {
3639 return true;
3640 }
3641 const checkedRadio = candidates.find((candidate) => {
3642 const radio = getNamedRadioInput(candidate);
3643 return radio?.name === input.name && radio.form === input.form && radio.checked;
3644 });
3645 if (checkedRadio) {
3646 return checkedRadio === input;
3647 }
3648 return candidates.find((candidate) => {
3649 const radio = getNamedRadioInput(candidate);
3650 return radio?.name === input.name && radio.form === input.form;
3651 }) === input;
3652 }
3653 function getComposedChildren(container) {
3654 if (isHTMLElement(container) && getNodeName(container) === "slot") {
3655 const assignedElements = container.assignedElements({
3656 flatten: true
3657 });
3658 if (assignedElements.length > 0) {
3659 return assignedElements;
3660 }
3661 }
3662 if (isHTMLElement(container) && container.shadowRoot) {
3663 return Array.from(container.shadowRoot.children);
3664 }
3665 return Array.from(container.children);
3666 }
3667 function appendCandidates(container, list) {
3668 getComposedChildren(container).forEach((child) => {
3669 if (isFocusableCandidate(child)) {
3670 list.push(child);
3671 }
3672 appendCandidates(child, list);
3673 });
3674 }
3675 function appendMatchingElements(container, selector2, list) {
3676 getComposedChildren(container).forEach((child) => {
3677 if (isHTMLElement(child) && child.matches(selector2)) {
3678 list.push(child);
3679 }
3680 appendMatchingElements(child, selector2, list);
3681 });
3682 }
3683 function focusable(container) {
3684 const candidates = [];
3685 appendCandidates(container, candidates);
3686 return candidates.filter(isFocusableElement);
3687 }
3688 function tabbable(container) {
3689 const candidates = focusable(container);
3690 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
3691 }
3692 function getTabbableIn(container, dir) {
3693 const list = tabbable(container);
3694 const len = list.length;
3695 if (len === 0) {
3696 return void 0;
3697 }
3698 const active = activeElement(ownerDocument(container));
3699 const index2 = list.indexOf(active);
3700 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
3701 return list[nextIndex];
3702 }
3703 function getNextTabbable(referenceElement) {
3704 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
3705 }
3706 function getPreviousTabbable(referenceElement) {
3707 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
3708 }
3709 function isOutsideEvent(event, container) {
3710 const containerElement = container || event.currentTarget;
3711 const relatedTarget = event.relatedTarget;
3712 return !relatedTarget || !contains(containerElement, relatedTarget);
3713 }
3714 function disableFocusInside(container) {
3715 const tabbableElements = tabbable(container);
3716 tabbableElements.forEach((element) => {
3717 element.dataset.tabindex = element.getAttribute("tabindex") || "";
3718 element.setAttribute("tabindex", "-1");
3719 });
3720 }
3721 function enableFocusInside(container) {
3722 const elements = [];
3723 appendMatchingElements(container, "[data-tabindex]", elements);
3724 elements.forEach((element) => {
3725 const tabindex = element.dataset.tabindex;
3726 delete element.dataset.tabindex;
3727 if (tabindex) {
3728 element.setAttribute("tabindex", tabindex);
3729 } else {
3730 element.removeAttribute("tabindex");
3731 }
3732 });
3733 }
3734
3735 // node_modules/@base-ui/react/floating-ui-react/utils/nodes.mjs
3736 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
3737 const directChildren = nodes.filter((node) => node.parentId === id);
3738 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
3739 }
3740
3741 // node_modules/@base-ui/react/floating-ui-react/utils/createAttribute.mjs
3742 function createAttribute(name) {
3743 return `data-base-ui-${name}`;
3744 }
3745
3746 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs
3747 var React15 = __toESM(require_react(), 1);
3748 var ReactDOM2 = __toESM(require_react_dom(), 1);
3749
3750 // node_modules/@base-ui/react/internals/constants.mjs
3751 var DISABLED_TRANSITIONS_STYLE = {
3752 style: {
3753 transition: "none"
3754 }
3755 };
3756 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
3757 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
3758 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
3759 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
3760 var POPUP_COLLISION_AVOIDANCE = {
3761 fallbackAxisSide: "end"
3762 };
3763 var ownerVisuallyHidden = {
3764 clipPath: "inset(50%)",
3765 position: "fixed",
3766 top: 0,
3767 left: 0
3768 };
3769
3770 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs
3771 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
3772 var PortalContext = /* @__PURE__ */ React15.createContext(null);
3773 if (true) PortalContext.displayName = "PortalContext";
3774 var usePortalContext = () => React15.useContext(PortalContext);
3775 var attr = createAttribute("portal");
3776 function useFloatingPortalNode(props = {}) {
3777 const {
3778 ref,
3779 container: containerProp,
3780 componentProps = EMPTY_OBJECT,
3781 elementProps
3782 } = props;
3783 const uniqueId = useId();
3784 const portalContext = usePortalContext();
3785 const parentPortalNode = portalContext?.portalNode;
3786 const [containerElement, setContainerElement] = React15.useState(null);
3787 const [portalNode, setPortalNode] = React15.useState(null);
3788 const setPortalNodeRef = useStableCallback((node) => {
3789 if (node !== null) {
3790 setPortalNode(node);
3791 }
3792 });
3793 const containerRef = React15.useRef(null);
3794 useIsoLayoutEffect(() => {
3795 if (containerProp === null) {
3796 if (containerRef.current) {
3797 containerRef.current = null;
3798 setPortalNode(null);
3799 setContainerElement(null);
3800 }
3801 return;
3802 }
3803 if (uniqueId == null) {
3804 return;
3805 }
3806 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
3807 if (resolvedContainer == null) {
3808 if (containerRef.current) {
3809 containerRef.current = null;
3810 setPortalNode(null);
3811 setContainerElement(null);
3812 }
3813 return;
3814 }
3815 if (containerRef.current !== resolvedContainer) {
3816 containerRef.current = resolvedContainer;
3817 setPortalNode(null);
3818 setContainerElement(resolvedContainer);
3819 }
3820 }, [containerProp, parentPortalNode, uniqueId]);
3821 const portalElement = useRenderElement("div", componentProps, {
3822 ref: [ref, setPortalNodeRef],
3823 props: [{
3824 id: uniqueId,
3825 [attr]: ""
3826 }, elementProps]
3827 });
3828 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
3829 return {
3830 portalNode,
3831 portalSubtree
3832 };
3833 }
3834 var FloatingPortal = /* @__PURE__ */ React15.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
3835 const {
3836 render: render4,
3837 className,
3838 style,
3839 children,
3840 container,
3841 renderGuards,
3842 ...elementProps
3843 } = componentProps;
3844 const {
3845 portalNode,
3846 portalSubtree
3847 } = useFloatingPortalNode({
3848 container,
3849 ref: forwardedRef,
3850 componentProps,
3851 elementProps
3852 });
3853 const beforeOutsideRef = React15.useRef(null);
3854 const afterOutsideRef = React15.useRef(null);
3855 const beforeInsideRef = React15.useRef(null);
3856 const afterInsideRef = React15.useRef(null);
3857 const [focusManagerState, setFocusManagerState] = React15.useState(null);
3858 const focusInsideDisabledRef = React15.useRef(false);
3859 const modal = focusManagerState?.modal;
3860 const open = focusManagerState?.open;
3861 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
3862 React15.useEffect(() => {
3863 if (!portalNode || modal) {
3864 return void 0;
3865 }
3866 function onFocus(event) {
3867 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
3868 if (event.type === "focusin") {
3869 if (focusInsideDisabledRef.current) {
3870 enableFocusInside(portalNode);
3871 focusInsideDisabledRef.current = false;
3872 }
3873 } else {
3874 disableFocusInside(portalNode);
3875 focusInsideDisabledRef.current = true;
3876 }
3877 }
3878 }
3879 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
3880 }, [portalNode, modal]);
3881 useIsoLayoutEffect(() => {
3882 if (!portalNode || open !== true || !focusInsideDisabledRef.current) {
3883 return;
3884 }
3885 enableFocusInside(portalNode);
3886 focusInsideDisabledRef.current = false;
3887 }, [open, portalNode]);
3888 const portalContextValue = React15.useMemo(() => ({
3889 beforeOutsideRef,
3890 afterOutsideRef,
3891 beforeInsideRef,
3892 afterInsideRef,
3893 portalNode,
3894 setFocusManagerState
3895 }), [portalNode]);
3896 return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(React15.Fragment, {
3897 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(PortalContext.Provider, {
3898 value: portalContextValue,
3899 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FocusGuard, {
3900 "data-type": "outside",
3901 ref: beforeOutsideRef,
3902 onFocus: (event) => {
3903 if (isOutsideEvent(event, portalNode)) {
3904 beforeInsideRef.current?.focus();
3905 } else {
3906 const domReference = focusManagerState ? focusManagerState.domReference : null;
3907 const prevTabbable = getPreviousTabbable(domReference);
3908 prevTabbable?.focus();
3909 }
3910 }
3911 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", {
3912 "aria-owns": portalNode.id,
3913 style: ownerVisuallyHidden
3914 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FocusGuard, {
3915 "data-type": "outside",
3916 ref: afterOutsideRef,
3917 onFocus: (event) => {
3918 if (isOutsideEvent(event, portalNode)) {
3919 afterInsideRef.current?.focus();
3920 } else {
3921 const domReference = focusManagerState ? focusManagerState.domReference : null;
3922 const nextTabbable = getNextTabbable(domReference);
3923 nextTabbable?.focus();
3924 if (focusManagerState?.closeOnFocusOut) {
3925 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
3926 }
3927 }
3928 }
3929 })]
3930 })]
3931 });
3932 });
3933 if (true) FloatingPortal.displayName = "FloatingPortal";
3934
3935 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs
3936 var React16 = __toESM(require_react(), 1);
3937
3938 // node_modules/@base-ui/react/floating-ui-react/utils/createEventEmitter.mjs
3939 function createEventEmitter() {
3940 const map = /* @__PURE__ */ new Map();
3941 return {
3942 emit(event, data) {
3943 map.get(event)?.forEach((listener) => listener(data));
3944 },
3945 on(event, listener) {
3946 if (!map.has(event)) {
3947 map.set(event, /* @__PURE__ */ new Set());
3948 }
3949 map.get(event).add(listener);
3950 },
3951 off(event, listener) {
3952 map.get(event)?.delete(listener);
3953 }
3954 };
3955 }
3956
3957 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs
3958 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
3959 var FloatingNodeContext = /* @__PURE__ */ React16.createContext(null);
3960 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
3961 var FloatingTreeContext = /* @__PURE__ */ React16.createContext(null);
3962 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3963 var useFloatingParentNodeId = () => React16.useContext(FloatingNodeContext)?.id || null;
3964 var useFloatingTree = (externalTree) => {
3965 const contextTree = React16.useContext(FloatingTreeContext);
3966 return externalTree ?? contextTree;
3967 };
3968
3969 // node_modules/@base-ui/react/floating-ui-react/hooks/useClientPoint.mjs
3970 var React17 = __toESM(require_react(), 1);
3971 function createVirtualElement(domElement, data) {
3972 let offsetX = null;
3973 let offsetY = null;
3974 let isAutoUpdateEvent = false;
3975 return {
3976 contextElement: domElement || void 0,
3977 getBoundingClientRect() {
3978 const domRect = domElement?.getBoundingClientRect() || {
3979 width: 0,
3980 height: 0,
3981 x: 0,
3982 y: 0
3983 };
3984 const isXAxis = data.axis === "x" || data.axis === "both";
3985 const isYAxis = data.axis === "y" || data.axis === "both";
3986 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
3987 let width = domRect.width;
3988 let height = domRect.height;
3989 let x2 = domRect.x;
3990 let y2 = domRect.y;
3991 if (offsetX == null && data.x && isXAxis) {
3992 offsetX = domRect.x - data.x;
3993 }
3994 if (offsetY == null && data.y && isYAxis) {
3995 offsetY = domRect.y - data.y;
3996 }
3997 x2 -= offsetX || 0;
3998 y2 -= offsetY || 0;
3999 width = 0;
4000 height = 0;
4001 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
4002 width = data.axis === "y" ? domRect.width : 0;
4003 height = data.axis === "x" ? domRect.height : 0;
4004 x2 = isXAxis && data.x != null ? data.x : x2;
4005 y2 = isYAxis && data.y != null ? data.y : y2;
4006 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
4007 height = data.axis === "x" ? domRect.height : height;
4008 width = data.axis === "y" ? domRect.width : width;
4009 }
4010 isAutoUpdateEvent = true;
4011 return {
4012 width,
4013 height,
4014 x: x2,
4015 y: y2,
4016 top: y2,
4017 right: x2 + width,
4018 bottom: y2 + height,
4019 left: x2
4020 };
4021 }
4022 };
4023 }
4024 function isMouseBasedEvent(event) {
4025 return event != null && event.clientX != null;
4026 }
4027 function useClientPoint(context, props = {}) {
4028 const {
4029 enabled = true,
4030 axis = "both"
4031 } = props;
4032 const store = "rootStore" in context ? context.rootStore : context;
4033 const open = store.useState("open");
4034 const floating = store.useState("floatingElement");
4035 const domReference = store.useState("domReferenceElement");
4036 const dataRef = store.context.dataRef;
4037 const initialRef = React17.useRef(false);
4038 const cleanupListenerRef = React17.useRef(null);
4039 const [pointerType, setPointerType] = React17.useState();
4040 const [reactive, setReactive] = React17.useState([]);
4041 const resetReference = useStableCallback((reference2) => {
4042 store.set("positionReference", reference2);
4043 });
4044 const setReference = useStableCallback((newX, newY, referenceElement) => {
4045 if (initialRef.current) {
4046 return;
4047 }
4048 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
4049 return;
4050 }
4051 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
4052 x: newX,
4053 y: newY,
4054 axis,
4055 dataRef,
4056 pointerType
4057 }));
4058 });
4059 const handleReferenceEnterOrMove = useStableCallback((event) => {
4060 if (!open) {
4061 setReference(event.clientX, event.clientY, event.currentTarget);
4062 } else if (!cleanupListenerRef.current) {
4063 setReference(event.clientX, event.clientY, event.currentTarget);
4064 setReactive([]);
4065 }
4066 });
4067 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
4068 React17.useEffect(() => {
4069 if (!enabled) {
4070 resetReference(domReference);
4071 return void 0;
4072 }
4073 if (!openCheck) {
4074 return void 0;
4075 }
4076 function cleanupListener() {
4077 cleanupListenerRef.current?.();
4078 cleanupListenerRef.current = null;
4079 }
4080 const win = getWindow(floating);
4081 function handleMouseMove(event) {
4082 const target = getTarget(event);
4083 if (!contains(floating, target)) {
4084 setReference(event.clientX, event.clientY);
4085 } else {
4086 cleanupListener();
4087 }
4088 }
4089 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
4090 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
4091 } else {
4092 resetReference(domReference);
4093 }
4094 return cleanupListener;
4095 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference, resetReference, reactive]);
4096 React17.useEffect(() => () => {
4097 store.set("positionReference", null);
4098 }, [store]);
4099 React17.useEffect(() => {
4100 if (enabled && !floating) {
4101 initialRef.current = false;
4102 }
4103 }, [enabled, floating]);
4104 React17.useEffect(() => {
4105 if (!enabled && open) {
4106 initialRef.current = true;
4107 }
4108 }, [enabled, open]);
4109 const reference = React17.useMemo(() => {
4110 function setPointerTypeRef(event) {
4111 setPointerType(event.pointerType);
4112 }
4113 return {
4114 onPointerDown: setPointerTypeRef,
4115 onPointerEnter: setPointerTypeRef,
4116 onMouseMove: handleReferenceEnterOrMove,
4117 onMouseEnter: handleReferenceEnterOrMove
4118 };
4119 }, [handleReferenceEnterOrMove]);
4120 return React17.useMemo(() => enabled ? {
4121 reference,
4122 trigger: reference
4123 } : {}, [enabled, reference]);
4124 }
4125
4126 // node_modules/@base-ui/react/floating-ui-react/hooks/useDismiss.mjs
4127 var React18 = __toESM(require_react(), 1);
4128 function alwaysFalse() {
4129 return false;
4130 }
4131 function normalizeProp(normalizable) {
4132 return {
4133 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
4134 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
4135 };
4136 }
4137 function useDismiss(context, props = {}) {
4138 const {
4139 enabled = true,
4140 escapeKey: escapeKey2 = true,
4141 outsidePress: outsidePressProp = true,
4142 outsidePressEvent = "sloppy",
4143 referencePress = alwaysFalse,
4144 bubbles,
4145 externalTree
4146 } = props;
4147 const store = "rootStore" in context ? context.rootStore : context;
4148 const open = store.useState("open");
4149 const floatingElement = store.useState("floatingElement");
4150 const {
4151 dataRef
4152 } = store.context;
4153 const tree = useFloatingTree(externalTree);
4154 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
4155 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
4156 const outsidePressEnabled = outsidePress2 !== false;
4157 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
4158 const {
4159 escapeKey: escapeKeyBubbles,
4160 outsidePress: outsidePressBubbles
4161 } = normalizeProp(bubbles);
4162 const pressStartedInsideRef = React18.useRef(false);
4163 const pressStartPreventedRef = React18.useRef(false);
4164 const suppressNextOutsideClickRef = React18.useRef(false);
4165 const isComposingRef = React18.useRef(false);
4166 const currentPointerTypeRef = React18.useRef("");
4167 const touchStateRef = React18.useRef(null);
4168 const cancelDismissOnEndTimeout = useTimeout();
4169 const clearInsideReactTreeTimeout = useTimeout();
4170 const clearInsideReactTree = useStableCallback(() => {
4171 clearInsideReactTreeTimeout.clear();
4172 dataRef.current.insideReactTree = false;
4173 });
4174 const hasBlockingChild = useStableCallback((bubbleKey) => {
4175 const nodeId = dataRef.current.floatingContext?.nodeId;
4176 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
4177 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
4178 });
4179 const isEventWithinOwnElements = useStableCallback((event) => {
4180 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"));
4181 });
4182 const closeOnReferencePress = useStableCallback((event) => {
4183 if (!referencePress()) {
4184 return;
4185 }
4186 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
4187 });
4188 const closeOnEscapeKeyDown = useStableCallback((event) => {
4189 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
4190 return;
4191 }
4192 if (isComposingRef.current) {
4193 return;
4194 }
4195 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
4196 return;
4197 }
4198 const native = isReactEvent(event) ? event.nativeEvent : event;
4199 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
4200 store.setOpen(false, eventDetails);
4201 if (!eventDetails.isCanceled) {
4202 event.preventDefault();
4203 }
4204 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
4205 event.stopPropagation();
4206 }
4207 });
4208 const markInsideReactTree = useStableCallback(() => {
4209 dataRef.current.insideReactTree = true;
4210 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
4211 });
4212 const markPressStartedInsideReactTree = useStableCallback((event) => {
4213 if (!open || !enabled || event.button !== 0) {
4214 return;
4215 }
4216 const target = getTarget(event.nativeEvent);
4217 if (!contains(store.select("floatingElement"), target)) {
4218 return;
4219 }
4220 if (!pressStartedInsideRef.current) {
4221 pressStartedInsideRef.current = true;
4222 pressStartPreventedRef.current = false;
4223 }
4224 });
4225 const markInsidePressStartPrevented = useStableCallback((event) => {
4226 if (!open || !enabled) {
4227 return;
4228 }
4229 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
4230 return;
4231 }
4232 if (pressStartedInsideRef.current) {
4233 pressStartPreventedRef.current = true;
4234 }
4235 });
4236 React18.useEffect(() => {
4237 if (!open || !enabled) {
4238 return void 0;
4239 }
4240 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
4241 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
4242 const compositionTimeout = new Timeout();
4243 const preventedPressSuppressionTimeout = new Timeout();
4244 function handleCompositionStart() {
4245 compositionTimeout.clear();
4246 isComposingRef.current = true;
4247 }
4248 function handleCompositionEnd() {
4249 compositionTimeout.start(
4250 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
4251 // Only apply to WebKit for the test to remain 0ms.
4252 parts_exports.engine.webkit ? 5 : 0,
4253 () => {
4254 isComposingRef.current = false;
4255 }
4256 );
4257 }
4258 function suppressImmediateOutsideClickAfterPreventedStart() {
4259 suppressNextOutsideClickRef.current = true;
4260 preventedPressSuppressionTimeout.start(0, () => {
4261 suppressNextOutsideClickRef.current = false;
4262 });
4263 }
4264 function resetPressStartState() {
4265 pressStartedInsideRef.current = false;
4266 pressStartPreventedRef.current = false;
4267 }
4268 function getOutsidePressEvent() {
4269 const type = currentPointerTypeRef.current;
4270 const computedType = type === "pen" || !type ? "mouse" : type;
4271 const outsidePressEventValue = getOutsidePressEventProp();
4272 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
4273 if (typeof resolved === "string") {
4274 return resolved;
4275 }
4276 return resolved[computedType];
4277 }
4278 function shouldIgnoreEvent(event) {
4279 const computedOutsidePressEvent = getOutsidePressEvent();
4280 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
4281 }
4282 function isEventWithinFloatingTree(event) {
4283 const nodeId = dataRef.current.floatingContext?.nodeId;
4284 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
4285 return isEventWithinOwnElements(event) || targetIsInsideChildren;
4286 }
4287 function closeOnPressOutside(event) {
4288 if (shouldIgnoreEvent(event)) {
4289 if (event.type !== "click" && !isEventWithinOwnElements(event)) {
4290 preventedPressSuppressionTimeout.clear();
4291 suppressNextOutsideClickRef.current = false;
4292 }
4293 clearInsideReactTree();
4294 return;
4295 }
4296 if (dataRef.current.insideReactTree) {
4297 clearInsideReactTree();
4298 return;
4299 }
4300 const target = getTarget(event);
4301 const inertSelector = `[${createAttribute("inert")}]`;
4302 const targetRoot = isElement(target) ? target.getRootNode() : null;
4303 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
4304 const triggers = store.context.triggerElements;
4305 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
4306 return;
4307 }
4308 let targetRootAncestor = isElement(target) ? target : null;
4309 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
4310 const nextParent = getParentNode(targetRootAncestor);
4311 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
4312 break;
4313 }
4314 targetRootAncestor = nextParent;
4315 }
4316 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
4317 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
4318 // element was injected after the floating element rendered.
4319 markers.every((marker) => !contains(targetRootAncestor, marker))) {
4320 return;
4321 }
4322 if (isHTMLElement(target) && !("touches" in event)) {
4323 const lastTraversableNode = isLastTraversableNode(target);
4324 const style = getComputedStyle2(target);
4325 const scrollRe = /auto|scroll/;
4326 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
4327 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
4328 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
4329 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
4330 const isRTL7 = style.direction === "rtl";
4331 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
4332 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
4333 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
4334 return;
4335 }
4336 }
4337 if (isEventWithinFloatingTree(event)) {
4338 return;
4339 }
4340 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
4341 preventedPressSuppressionTimeout.clear();
4342 suppressNextOutsideClickRef.current = false;
4343 return;
4344 }
4345 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
4346 return;
4347 }
4348 if (hasBlockingChild("__outsidePressBubbles")) {
4349 return;
4350 }
4351 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
4352 clearInsideReactTree();
4353 }
4354 function handlePointerDown(event) {
4355 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
4356 return;
4357 }
4358 closeOnPressOutside(event);
4359 }
4360 function handleTouchStart(event) {
4361 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
4362 return;
4363 }
4364 const touch = event.touches[0];
4365 if (touch) {
4366 touchStateRef.current = {
4367 startTime: Date.now(),
4368 startX: touch.clientX,
4369 startY: touch.clientY,
4370 dismissOnTouchEnd: false,
4371 dismissOnMouseDown: true
4372 };
4373 cancelDismissOnEndTimeout.start(1e3, () => {
4374 if (touchStateRef.current) {
4375 touchStateRef.current.dismissOnTouchEnd = false;
4376 touchStateRef.current.dismissOnMouseDown = false;
4377 }
4378 });
4379 }
4380 }
4381 function addTargetEventListenerOnce(event, listener) {
4382 const target = getTarget(event);
4383 if (!target) {
4384 return;
4385 }
4386 const unsubscribe2 = addEventListener(target, event.type, () => {
4387 listener(event);
4388 unsubscribe2();
4389 });
4390 }
4391 function handleTouchStartCapture(event) {
4392 currentPointerTypeRef.current = "touch";
4393 addTargetEventListenerOnce(event, handleTouchStart);
4394 }
4395 function closeOnPressOutsideCapture(event) {
4396 cancelDismissOnEndTimeout.clear();
4397 if (event.type === "pointerdown") {
4398 currentPointerTypeRef.current = event.pointerType;
4399 }
4400 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
4401 return;
4402 }
4403 addTargetEventListenerOnce(event, (targetEvent) => {
4404 if (targetEvent.type === "pointerdown") {
4405 handlePointerDown(targetEvent);
4406 } else {
4407 closeOnPressOutside(targetEvent);
4408 }
4409 });
4410 }
4411 function handlePressEndCapture(event) {
4412 if (!pressStartedInsideRef.current) {
4413 return;
4414 }
4415 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
4416 resetPressStartState();
4417 if (getOutsidePressEvent() !== "intentional") {
4418 return;
4419 }
4420 if (event.type === "pointercancel") {
4421 if (pressStartedInsideDefaultPrevented) {
4422 suppressImmediateOutsideClickAfterPreventedStart();
4423 }
4424 return;
4425 }
4426 if (isEventWithinFloatingTree(event)) {
4427 return;
4428 }
4429 if (pressStartedInsideDefaultPrevented) {
4430 suppressImmediateOutsideClickAfterPreventedStart();
4431 return;
4432 }
4433 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
4434 return;
4435 }
4436 preventedPressSuppressionTimeout.clear();
4437 suppressNextOutsideClickRef.current = true;
4438 clearInsideReactTree();
4439 }
4440 function handleTouchMove(event) {
4441 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
4442 return;
4443 }
4444 const touch = event.touches[0];
4445 if (!touch) {
4446 return;
4447 }
4448 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
4449 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
4450 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
4451 if (distance > 5) {
4452 touchStateRef.current.dismissOnTouchEnd = true;
4453 }
4454 if (distance > 10) {
4455 closeOnPressOutside(event);
4456 cancelDismissOnEndTimeout.clear();
4457 touchStateRef.current = null;
4458 }
4459 }
4460 function handleTouchMoveCapture(event) {
4461 addTargetEventListenerOnce(event, handleTouchMove);
4462 }
4463 function handleTouchEnd(event) {
4464 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
4465 return;
4466 }
4467 if (touchStateRef.current.dismissOnTouchEnd) {
4468 closeOnPressOutside(event);
4469 }
4470 cancelDismissOnEndTimeout.clear();
4471 touchStateRef.current = null;
4472 }
4473 function handleTouchEndCapture(event) {
4474 addTargetEventListenerOnce(event, handleTouchEnd);
4475 }
4476 const doc = ownerDocument(floatingElement);
4477 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)));
4478 return () => {
4479 unsubscribe();
4480 compositionTimeout.clear();
4481 preventedPressSuppressionTimeout.clear();
4482 resetPressStartState();
4483 suppressNextOutsideClickRef.current = false;
4484 };
4485 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store, cancelDismissOnEndTimeout]);
4486 React18.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
4487 const reference = React18.useMemo(() => ({
4488 onKeyDown: closeOnEscapeKeyDown,
4489 onPointerDown: closeOnReferencePress,
4490 onClick: closeOnReferencePress
4491 }), [closeOnEscapeKeyDown, closeOnReferencePress]);
4492 const floating = React18.useMemo(() => ({
4493 onKeyDown: closeOnEscapeKeyDown,
4494 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
4495 // `onPointerDown`, such as with <NumberField.ScrubArea>.
4496 // See https://github.com/mui/base-ui/pull/3379
4497 onPointerDown: markInsidePressStartPrevented,
4498 onMouseDown: markInsidePressStartPrevented,
4499 onClickCapture: markInsideReactTree,
4500 onMouseDownCapture(event) {
4501 markInsideReactTree();
4502 markPressStartedInsideReactTree(event);
4503 },
4504 onPointerDownCapture(event) {
4505 markInsideReactTree();
4506 markPressStartedInsideReactTree(event);
4507 },
4508 onMouseUpCapture: markInsideReactTree,
4509 onTouchEndCapture: markInsideReactTree,
4510 onTouchMoveCapture: markInsideReactTree
4511 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
4512 return React18.useMemo(() => enabled ? {
4513 reference,
4514 floating,
4515 trigger: reference
4516 } : {}, [enabled, reference, floating]);
4517 }
4518
4519 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs
4520 var React25 = __toESM(require_react(), 1);
4521
4522 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
4523 function computeCoordsFromPlacement(_ref, placement, rtl) {
4524 let {
4525 reference,
4526 floating
4527 } = _ref;
4528 const sideAxis = getSideAxis(placement);
4529 const alignmentAxis = getAlignmentAxis(placement);
4530 const alignLength = getAxisLength(alignmentAxis);
4531 const side = getSide(placement);
4532 const isVertical = sideAxis === "y";
4533 const commonX = reference.x + reference.width / 2 - floating.width / 2;
4534 const commonY = reference.y + reference.height / 2 - floating.height / 2;
4535 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
4536 let coords;
4537 switch (side) {
4538 case "top":
4539 coords = {
4540 x: commonX,
4541 y: reference.y - floating.height
4542 };
4543 break;
4544 case "bottom":
4545 coords = {
4546 x: commonX,
4547 y: reference.y + reference.height
4548 };
4549 break;
4550 case "right":
4551 coords = {
4552 x: reference.x + reference.width,
4553 y: commonY
4554 };
4555 break;
4556 case "left":
4557 coords = {
4558 x: reference.x - floating.width,
4559 y: commonY
4560 };
4561 break;
4562 default:
4563 coords = {
4564 x: reference.x,
4565 y: reference.y
4566 };
4567 }
4568 switch (getAlignment(placement)) {
4569 case "start":
4570 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
4571 break;
4572 case "end":
4573 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
4574 break;
4575 }
4576 return coords;
4577 }
4578 async function detectOverflow(state, options) {
4579 var _await$platform$isEle;
4580 if (options === void 0) {
4581 options = {};
4582 }
4583 const {
4584 x: x2,
4585 y: y2,
4586 platform: platform3,
4587 rects,
4588 elements,
4589 strategy
4590 } = state;
4591 const {
4592 boundary = "clippingAncestors",
4593 rootBoundary = "viewport",
4594 elementContext = "floating",
4595 altBoundary = false,
4596 padding = 0
4597 } = evaluate(options, state);
4598 const paddingObject = getPaddingObject(padding);
4599 const altContext = elementContext === "floating" ? "reference" : "floating";
4600 const element = elements[altBoundary ? altContext : elementContext];
4601 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
4602 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)),
4603 boundary,
4604 rootBoundary,
4605 strategy
4606 }));
4607 const rect = elementContext === "floating" ? {
4608 x: x2,
4609 y: y2,
4610 width: rects.floating.width,
4611 height: rects.floating.height
4612 } : rects.reference;
4613 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
4614 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
4615 x: 1,
4616 y: 1
4617 } : {
4618 x: 1,
4619 y: 1
4620 };
4621 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
4622 elements,
4623 rect,
4624 offsetParent,
4625 strategy
4626 }) : rect);
4627 return {
4628 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
4629 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
4630 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
4631 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
4632 };
4633 }
4634 var MAX_RESET_COUNT = 50;
4635 var computePosition = async (reference, floating, config) => {
4636 const {
4637 placement = "bottom",
4638 strategy = "absolute",
4639 middleware = [],
4640 platform: platform3
4641 } = config;
4642 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
4643 ...platform3,
4644 detectOverflow
4645 };
4646 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
4647 let rects = await platform3.getElementRects({
4648 reference,
4649 floating,
4650 strategy
4651 });
4652 let {
4653 x: x2,
4654 y: y2
4655 } = computeCoordsFromPlacement(rects, placement, rtl);
4656 let statefulPlacement = placement;
4657 let resetCount = 0;
4658 const middlewareData = {};
4659 for (let i2 = 0; i2 < middleware.length; i2++) {
4660 const currentMiddleware = middleware[i2];
4661 if (!currentMiddleware) {
4662 continue;
4663 }
4664 const {
4665 name,
4666 fn
4667 } = currentMiddleware;
4668 const {
4669 x: nextX,
4670 y: nextY,
4671 data,
4672 reset
4673 } = await fn({
4674 x: x2,
4675 y: y2,
4676 initialPlacement: placement,
4677 placement: statefulPlacement,
4678 strategy,
4679 middlewareData,
4680 rects,
4681 platform: platformWithDetectOverflow,
4682 elements: {
4683 reference,
4684 floating
4685 }
4686 });
4687 x2 = nextX != null ? nextX : x2;
4688 y2 = nextY != null ? nextY : y2;
4689 middlewareData[name] = {
4690 ...middlewareData[name],
4691 ...data
4692 };
4693 if (reset && resetCount < MAX_RESET_COUNT) {
4694 resetCount++;
4695 if (typeof reset === "object") {
4696 if (reset.placement) {
4697 statefulPlacement = reset.placement;
4698 }
4699 if (reset.rects) {
4700 rects = reset.rects === true ? await platform3.getElementRects({
4701 reference,
4702 floating,
4703 strategy
4704 }) : reset.rects;
4705 }
4706 ({
4707 x: x2,
4708 y: y2
4709 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
4710 }
4711 i2 = -1;
4712 }
4713 }
4714 return {
4715 x: x2,
4716 y: y2,
4717 placement: statefulPlacement,
4718 strategy,
4719 middlewareData
4720 };
4721 };
4722 var flip = function(options) {
4723 if (options === void 0) {
4724 options = {};
4725 }
4726 return {
4727 name: "flip",
4728 options,
4729 async fn(state) {
4730 var _middlewareData$arrow, _middlewareData$flip;
4731 const {
4732 placement,
4733 middlewareData,
4734 rects,
4735 initialPlacement,
4736 platform: platform3,
4737 elements
4738 } = state;
4739 const {
4740 mainAxis: checkMainAxis = true,
4741 crossAxis: checkCrossAxis = true,
4742 fallbackPlacements: specifiedFallbackPlacements,
4743 fallbackStrategy = "bestFit",
4744 fallbackAxisSideDirection = "none",
4745 flipAlignment = true,
4746 ...detectOverflowOptions
4747 } = evaluate(options, state);
4748 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4749 return {};
4750 }
4751 const side = getSide(placement);
4752 const initialSideAxis = getSideAxis(initialPlacement);
4753 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
4754 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4755 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
4756 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
4757 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
4758 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
4759 }
4760 const placements2 = [initialPlacement, ...fallbackPlacements];
4761 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4762 const overflows = [];
4763 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
4764 if (checkMainAxis) {
4765 overflows.push(overflow[side]);
4766 }
4767 if (checkCrossAxis) {
4768 const sides2 = getAlignmentSides(placement, rects, rtl);
4769 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
4770 }
4771 overflowsData = [...overflowsData, {
4772 placement,
4773 overflows
4774 }];
4775 if (!overflows.every((side2) => side2 <= 0)) {
4776 var _middlewareData$flip2, _overflowsData$filter;
4777 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
4778 const nextPlacement = placements2[nextIndex];
4779 if (nextPlacement) {
4780 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
4781 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
4782 // overflows the main axis.
4783 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
4784 return {
4785 data: {
4786 index: nextIndex,
4787 overflows: overflowsData
4788 },
4789 reset: {
4790 placement: nextPlacement
4791 }
4792 };
4793 }
4794 }
4795 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;
4796 if (!resetPlacement) {
4797 switch (fallbackStrategy) {
4798 case "bestFit": {
4799 var _overflowsData$filter2;
4800 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
4801 if (hasFallbackAxisSideDirection) {
4802 const currentSideAxis = getSideAxis(d2.placement);
4803 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
4804 // reading directions favoring greater width.
4805 currentSideAxis === "y";
4806 }
4807 return true;
4808 }).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];
4809 if (placement2) {
4810 resetPlacement = placement2;
4811 }
4812 break;
4813 }
4814 case "initialPlacement":
4815 resetPlacement = initialPlacement;
4816 break;
4817 }
4818 }
4819 if (placement !== resetPlacement) {
4820 return {
4821 reset: {
4822 placement: resetPlacement
4823 }
4824 };
4825 }
4826 }
4827 return {};
4828 }
4829 };
4830 };
4831 function getSideOffsets(overflow, rect) {
4832 return {
4833 top: overflow.top - rect.height,
4834 right: overflow.right - rect.width,
4835 bottom: overflow.bottom - rect.height,
4836 left: overflow.left - rect.width
4837 };
4838 }
4839 function isAnySideFullyClipped(overflow) {
4840 return sides.some((side) => overflow[side] >= 0);
4841 }
4842 var hide = function(options) {
4843 if (options === void 0) {
4844 options = {};
4845 }
4846 return {
4847 name: "hide",
4848 options,
4849 async fn(state) {
4850 const {
4851 rects,
4852 platform: platform3
4853 } = state;
4854 const {
4855 strategy = "referenceHidden",
4856 ...detectOverflowOptions
4857 } = evaluate(options, state);
4858 switch (strategy) {
4859 case "referenceHidden": {
4860 const overflow = await platform3.detectOverflow(state, {
4861 ...detectOverflowOptions,
4862 elementContext: "reference"
4863 });
4864 const offsets = getSideOffsets(overflow, rects.reference);
4865 return {
4866 data: {
4867 referenceHiddenOffsets: offsets,
4868 referenceHidden: isAnySideFullyClipped(offsets)
4869 }
4870 };
4871 }
4872 case "escaped": {
4873 const overflow = await platform3.detectOverflow(state, {
4874 ...detectOverflowOptions,
4875 altBoundary: true
4876 });
4877 const offsets = getSideOffsets(overflow, rects.floating);
4878 return {
4879 data: {
4880 escapedOffsets: offsets,
4881 escaped: isAnySideFullyClipped(offsets)
4882 }
4883 };
4884 }
4885 default: {
4886 return {};
4887 }
4888 }
4889 }
4890 };
4891 };
4892 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
4893 async function convertValueToCoords(state, options) {
4894 const {
4895 placement,
4896 platform: platform3,
4897 elements
4898 } = state;
4899 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4900 const side = getSide(placement);
4901 const alignment = getAlignment(placement);
4902 const isVertical = getSideAxis(placement) === "y";
4903 const mainAxisMulti = originSides.has(side) ? -1 : 1;
4904 const crossAxisMulti = rtl && isVertical ? -1 : 1;
4905 const rawValue = evaluate(options, state);
4906 let {
4907 mainAxis,
4908 crossAxis,
4909 alignmentAxis
4910 } = typeof rawValue === "number" ? {
4911 mainAxis: rawValue,
4912 crossAxis: 0,
4913 alignmentAxis: null
4914 } : {
4915 mainAxis: rawValue.mainAxis || 0,
4916 crossAxis: rawValue.crossAxis || 0,
4917 alignmentAxis: rawValue.alignmentAxis
4918 };
4919 if (alignment && typeof alignmentAxis === "number") {
4920 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
4921 }
4922 return isVertical ? {
4923 x: crossAxis * crossAxisMulti,
4924 y: mainAxis * mainAxisMulti
4925 } : {
4926 x: mainAxis * mainAxisMulti,
4927 y: crossAxis * crossAxisMulti
4928 };
4929 }
4930 var offset = function(options) {
4931 if (options === void 0) {
4932 options = 0;
4933 }
4934 return {
4935 name: "offset",
4936 options,
4937 async fn(state) {
4938 var _middlewareData$offse, _middlewareData$arrow;
4939 const {
4940 x: x2,
4941 y: y2,
4942 placement,
4943 middlewareData
4944 } = state;
4945 const diffCoords = await convertValueToCoords(state, options);
4946 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4947 return {};
4948 }
4949 return {
4950 x: x2 + diffCoords.x,
4951 y: y2 + diffCoords.y,
4952 data: {
4953 ...diffCoords,
4954 placement
4955 }
4956 };
4957 }
4958 };
4959 };
4960 var shift = function(options) {
4961 if (options === void 0) {
4962 options = {};
4963 }
4964 return {
4965 name: "shift",
4966 options,
4967 async fn(state) {
4968 const {
4969 x: x2,
4970 y: y2,
4971 placement,
4972 platform: platform3
4973 } = state;
4974 const {
4975 mainAxis: checkMainAxis = true,
4976 crossAxis: checkCrossAxis = false,
4977 limiter = {
4978 fn: (_ref) => {
4979 let {
4980 x: x3,
4981 y: y3
4982 } = _ref;
4983 return {
4984 x: x3,
4985 y: y3
4986 };
4987 }
4988 },
4989 ...detectOverflowOptions
4990 } = evaluate(options, state);
4991 const coords = {
4992 x: x2,
4993 y: y2
4994 };
4995 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4996 const crossAxis = getSideAxis(getSide(placement));
4997 const mainAxis = getOppositeAxis(crossAxis);
4998 let mainAxisCoord = coords[mainAxis];
4999 let crossAxisCoord = coords[crossAxis];
5000 if (checkMainAxis) {
5001 const minSide = mainAxis === "y" ? "top" : "left";
5002 const maxSide = mainAxis === "y" ? "bottom" : "right";
5003 const min2 = mainAxisCoord + overflow[minSide];
5004 const max2 = mainAxisCoord - overflow[maxSide];
5005 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
5006 }
5007 if (checkCrossAxis) {
5008 const minSide = crossAxis === "y" ? "top" : "left";
5009 const maxSide = crossAxis === "y" ? "bottom" : "right";
5010 const min2 = crossAxisCoord + overflow[minSide];
5011 const max2 = crossAxisCoord - overflow[maxSide];
5012 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
5013 }
5014 const limitedCoords = limiter.fn({
5015 ...state,
5016 [mainAxis]: mainAxisCoord,
5017 [crossAxis]: crossAxisCoord
5018 });
5019 return {
5020 ...limitedCoords,
5021 data: {
5022 x: limitedCoords.x - x2,
5023 y: limitedCoords.y - y2,
5024 enabled: {
5025 [mainAxis]: checkMainAxis,
5026 [crossAxis]: checkCrossAxis
5027 }
5028 }
5029 };
5030 }
5031 };
5032 };
5033 var limitShift = function(options) {
5034 if (options === void 0) {
5035 options = {};
5036 }
5037 return {
5038 options,
5039 fn(state) {
5040 const {
5041 x: x2,
5042 y: y2,
5043 placement,
5044 rects,
5045 middlewareData
5046 } = state;
5047 const {
5048 offset: offset4 = 0,
5049 mainAxis: checkMainAxis = true,
5050 crossAxis: checkCrossAxis = true
5051 } = evaluate(options, state);
5052 const coords = {
5053 x: x2,
5054 y: y2
5055 };
5056 const crossAxis = getSideAxis(placement);
5057 const mainAxis = getOppositeAxis(crossAxis);
5058 let mainAxisCoord = coords[mainAxis];
5059 let crossAxisCoord = coords[crossAxis];
5060 const rawOffset = evaluate(offset4, state);
5061 const computedOffset = typeof rawOffset === "number" ? {
5062 mainAxis: rawOffset,
5063 crossAxis: 0
5064 } : {
5065 mainAxis: 0,
5066 crossAxis: 0,
5067 ...rawOffset
5068 };
5069 if (checkMainAxis) {
5070 const len = mainAxis === "y" ? "height" : "width";
5071 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
5072 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
5073 if (mainAxisCoord < limitMin) {
5074 mainAxisCoord = limitMin;
5075 } else if (mainAxisCoord > limitMax) {
5076 mainAxisCoord = limitMax;
5077 }
5078 }
5079 if (checkCrossAxis) {
5080 var _middlewareData$offse, _middlewareData$offse2;
5081 const len = mainAxis === "y" ? "width" : "height";
5082 const isOriginSide = originSides.has(getSide(placement));
5083 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);
5084 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);
5085 if (crossAxisCoord < limitMin) {
5086 crossAxisCoord = limitMin;
5087 } else if (crossAxisCoord > limitMax) {
5088 crossAxisCoord = limitMax;
5089 }
5090 }
5091 return {
5092 [mainAxis]: mainAxisCoord,
5093 [crossAxis]: crossAxisCoord
5094 };
5095 }
5096 };
5097 };
5098 var size = function(options) {
5099 if (options === void 0) {
5100 options = {};
5101 }
5102 return {
5103 name: "size",
5104 options,
5105 async fn(state) {
5106 var _state$middlewareData, _state$middlewareData2;
5107 const {
5108 placement,
5109 rects,
5110 platform: platform3,
5111 elements
5112 } = state;
5113 const {
5114 apply = () => {
5115 },
5116 ...detectOverflowOptions
5117 } = evaluate(options, state);
5118 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
5119 const side = getSide(placement);
5120 const alignment = getAlignment(placement);
5121 const isYAxis = getSideAxis(placement) === "y";
5122 const {
5123 width,
5124 height
5125 } = rects.floating;
5126 let heightSide;
5127 let widthSide;
5128 if (side === "top" || side === "bottom") {
5129 heightSide = side;
5130 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
5131 } else {
5132 widthSide = side;
5133 heightSide = alignment === "end" ? "top" : "bottom";
5134 }
5135 const maximumClippingHeight = height - overflow.top - overflow.bottom;
5136 const maximumClippingWidth = width - overflow.left - overflow.right;
5137 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
5138 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
5139 const noShift = !state.middlewareData.shift;
5140 let availableHeight = overflowAvailableHeight;
5141 let availableWidth = overflowAvailableWidth;
5142 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
5143 availableWidth = maximumClippingWidth;
5144 }
5145 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
5146 availableHeight = maximumClippingHeight;
5147 }
5148 if (noShift && !alignment) {
5149 const xMin = max(overflow.left, 0);
5150 const xMax = max(overflow.right, 0);
5151 const yMin = max(overflow.top, 0);
5152 const yMax = max(overflow.bottom, 0);
5153 if (isYAxis) {
5154 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
5155 } else {
5156 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
5157 }
5158 }
5159 await apply({
5160 ...state,
5161 availableWidth,
5162 availableHeight
5163 });
5164 const nextDimensions = await platform3.getDimensions(elements.floating);
5165 if (width !== nextDimensions.width || height !== nextDimensions.height) {
5166 return {
5167 reset: {
5168 rects: true
5169 }
5170 };
5171 }
5172 return {};
5173 }
5174 };
5175 };
5176
5177 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
5178 function getCssDimensions(element) {
5179 const css = getComputedStyle2(element);
5180 let width = parseFloat(css.width) || 0;
5181 let height = parseFloat(css.height) || 0;
5182 const hasOffset = isHTMLElement(element);
5183 const offsetWidth = hasOffset ? element.offsetWidth : width;
5184 const offsetHeight = hasOffset ? element.offsetHeight : height;
5185 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
5186 if (shouldFallback) {
5187 width = offsetWidth;
5188 height = offsetHeight;
5189 }
5190 return {
5191 width,
5192 height,
5193 $: shouldFallback
5194 };
5195 }
5196 function unwrapElement(element) {
5197 return !isElement(element) ? element.contextElement : element;
5198 }
5199 function getScale(element) {
5200 const domElement = unwrapElement(element);
5201 if (!isHTMLElement(domElement)) {
5202 return createCoords(1);
5203 }
5204 const rect = domElement.getBoundingClientRect();
5205 const {
5206 width,
5207 height,
5208 $: $2
5209 } = getCssDimensions(domElement);
5210 let x2 = ($2 ? round(rect.width) : rect.width) / width;
5211 let y2 = ($2 ? round(rect.height) : rect.height) / height;
5212 if (!x2 || !Number.isFinite(x2)) {
5213 x2 = 1;
5214 }
5215 if (!y2 || !Number.isFinite(y2)) {
5216 y2 = 1;
5217 }
5218 return {
5219 x: x2,
5220 y: y2
5221 };
5222 }
5223 var noOffsets = /* @__PURE__ */ createCoords(0);
5224 function getVisualOffsets(element) {
5225 const win = getWindow(element);
5226 if (!isWebKit() || !win.visualViewport) {
5227 return noOffsets;
5228 }
5229 return {
5230 x: win.visualViewport.offsetLeft,
5231 y: win.visualViewport.offsetTop
5232 };
5233 }
5234 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
5235 if (isFixed === void 0) {
5236 isFixed = false;
5237 }
5238 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
5239 return false;
5240 }
5241 return isFixed;
5242 }
5243 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
5244 if (includeScale === void 0) {
5245 includeScale = false;
5246 }
5247 if (isFixedStrategy === void 0) {
5248 isFixedStrategy = false;
5249 }
5250 const clientRect = element.getBoundingClientRect();
5251 const domElement = unwrapElement(element);
5252 let scale = createCoords(1);
5253 if (includeScale) {
5254 if (offsetParent) {
5255 if (isElement(offsetParent)) {
5256 scale = getScale(offsetParent);
5257 }
5258 } else {
5259 scale = getScale(element);
5260 }
5261 }
5262 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
5263 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
5264 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
5265 let width = clientRect.width / scale.x;
5266 let height = clientRect.height / scale.y;
5267 if (domElement) {
5268 const win = getWindow(domElement);
5269 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
5270 let currentWin = win;
5271 let currentIFrame = getFrameElement(currentWin);
5272 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
5273 const iframeScale = getScale(currentIFrame);
5274 const iframeRect = currentIFrame.getBoundingClientRect();
5275 const css = getComputedStyle2(currentIFrame);
5276 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
5277 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
5278 x2 *= iframeScale.x;
5279 y2 *= iframeScale.y;
5280 width *= iframeScale.x;
5281 height *= iframeScale.y;
5282 x2 += left;
5283 y2 += top;
5284 currentWin = getWindow(currentIFrame);
5285 currentIFrame = getFrameElement(currentWin);
5286 }
5287 }
5288 return rectToClientRect({
5289 width,
5290 height,
5291 x: x2,
5292 y: y2
5293 });
5294 }
5295 function getWindowScrollBarX(element, rect) {
5296 const leftScroll = getNodeScroll(element).scrollLeft;
5297 if (!rect) {
5298 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
5299 }
5300 return rect.left + leftScroll;
5301 }
5302 function getHTMLOffset(documentElement, scroll) {
5303 const htmlRect = documentElement.getBoundingClientRect();
5304 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
5305 const y2 = htmlRect.top + scroll.scrollTop;
5306 return {
5307 x: x2,
5308 y: y2
5309 };
5310 }
5311 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
5312 let {
5313 elements,
5314 rect,
5315 offsetParent,
5316 strategy
5317 } = _ref;
5318 const isFixed = strategy === "fixed";
5319 const documentElement = getDocumentElement(offsetParent);
5320 const topLayer = elements ? isTopLayer(elements.floating) : false;
5321 if (offsetParent === documentElement || topLayer && isFixed) {
5322 return rect;
5323 }
5324 let scroll = {
5325 scrollLeft: 0,
5326 scrollTop: 0
5327 };
5328 let scale = createCoords(1);
5329 const offsets = createCoords(0);
5330 const isOffsetParentAnElement = isHTMLElement(offsetParent);
5331 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5332 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5333 scroll = getNodeScroll(offsetParent);
5334 }
5335 if (isOffsetParentAnElement) {
5336 const offsetRect = getBoundingClientRect(offsetParent);
5337 scale = getScale(offsetParent);
5338 offsets.x = offsetRect.x + offsetParent.clientLeft;
5339 offsets.y = offsetRect.y + offsetParent.clientTop;
5340 }
5341 }
5342 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5343 return {
5344 width: rect.width * scale.x,
5345 height: rect.height * scale.y,
5346 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
5347 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
5348 };
5349 }
5350 function getClientRects(element) {
5351 return Array.from(element.getClientRects());
5352 }
5353 function getDocumentRect(element) {
5354 const html = getDocumentElement(element);
5355 const scroll = getNodeScroll(element);
5356 const body = element.ownerDocument.body;
5357 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
5358 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
5359 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
5360 const y2 = -scroll.scrollTop;
5361 if (getComputedStyle2(body).direction === "rtl") {
5362 x2 += max(html.clientWidth, body.clientWidth) - width;
5363 }
5364 return {
5365 width,
5366 height,
5367 x: x2,
5368 y: y2
5369 };
5370 }
5371 var SCROLLBAR_MAX = 25;
5372 function getViewportRect(element, strategy) {
5373 const win = getWindow(element);
5374 const html = getDocumentElement(element);
5375 const visualViewport = win.visualViewport;
5376 let width = html.clientWidth;
5377 let height = html.clientHeight;
5378 let x2 = 0;
5379 let y2 = 0;
5380 if (visualViewport) {
5381 width = visualViewport.width;
5382 height = visualViewport.height;
5383 const visualViewportBased = isWebKit();
5384 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
5385 x2 = visualViewport.offsetLeft;
5386 y2 = visualViewport.offsetTop;
5387 }
5388 }
5389 const windowScrollbarX = getWindowScrollBarX(html);
5390 if (windowScrollbarX <= 0) {
5391 const doc = html.ownerDocument;
5392 const body = doc.body;
5393 const bodyStyles = getComputedStyle(body);
5394 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
5395 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
5396 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
5397 width -= clippingStableScrollbarWidth;
5398 }
5399 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
5400 width += windowScrollbarX;
5401 }
5402 return {
5403 width,
5404 height,
5405 x: x2,
5406 y: y2
5407 };
5408 }
5409 function getInnerBoundingClientRect(element, strategy) {
5410 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
5411 const top = clientRect.top + element.clientTop;
5412 const left = clientRect.left + element.clientLeft;
5413 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
5414 const width = element.clientWidth * scale.x;
5415 const height = element.clientHeight * scale.y;
5416 const x2 = left * scale.x;
5417 const y2 = top * scale.y;
5418 return {
5419 width,
5420 height,
5421 x: x2,
5422 y: y2
5423 };
5424 }
5425 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
5426 let rect;
5427 if (clippingAncestor === "viewport") {
5428 rect = getViewportRect(element, strategy);
5429 } else if (clippingAncestor === "document") {
5430 rect = getDocumentRect(getDocumentElement(element));
5431 } else if (isElement(clippingAncestor)) {
5432 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
5433 } else {
5434 const visualOffsets = getVisualOffsets(element);
5435 rect = {
5436 x: clippingAncestor.x - visualOffsets.x,
5437 y: clippingAncestor.y - visualOffsets.y,
5438 width: clippingAncestor.width,
5439 height: clippingAncestor.height
5440 };
5441 }
5442 return rectToClientRect(rect);
5443 }
5444 function hasFixedPositionAncestor(element, stopNode) {
5445 const parentNode = getParentNode(element);
5446 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
5447 return false;
5448 }
5449 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
5450 }
5451 function getClippingElementAncestors(element, cache) {
5452 const cachedResult = cache.get(element);
5453 if (cachedResult) {
5454 return cachedResult;
5455 }
5456 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
5457 let currentContainingBlockComputedStyle = null;
5458 const elementIsFixed = getComputedStyle2(element).position === "fixed";
5459 let currentNode = elementIsFixed ? getParentNode(element) : element;
5460 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
5461 const computedStyle = getComputedStyle2(currentNode);
5462 const currentNodeIsContaining = isContainingBlock(currentNode);
5463 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
5464 currentContainingBlockComputedStyle = null;
5465 }
5466 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
5467 if (shouldDropCurrentNode) {
5468 result = result.filter((ancestor) => ancestor !== currentNode);
5469 } else {
5470 currentContainingBlockComputedStyle = computedStyle;
5471 }
5472 currentNode = getParentNode(currentNode);
5473 }
5474 cache.set(element, result);
5475 return result;
5476 }
5477 function getClippingRect(_ref) {
5478 let {
5479 element,
5480 boundary,
5481 rootBoundary,
5482 strategy
5483 } = _ref;
5484 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
5485 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
5486 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
5487 let top = firstRect.top;
5488 let right = firstRect.right;
5489 let bottom = firstRect.bottom;
5490 let left = firstRect.left;
5491 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
5492 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
5493 top = max(rect.top, top);
5494 right = min(rect.right, right);
5495 bottom = min(rect.bottom, bottom);
5496 left = max(rect.left, left);
5497 }
5498 return {
5499 width: right - left,
5500 height: bottom - top,
5501 x: left,
5502 y: top
5503 };
5504 }
5505 function getDimensions(element) {
5506 const {
5507 width,
5508 height
5509 } = getCssDimensions(element);
5510 return {
5511 width,
5512 height
5513 };
5514 }
5515 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
5516 const isOffsetParentAnElement = isHTMLElement(offsetParent);
5517 const documentElement = getDocumentElement(offsetParent);
5518 const isFixed = strategy === "fixed";
5519 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
5520 let scroll = {
5521 scrollLeft: 0,
5522 scrollTop: 0
5523 };
5524 const offsets = createCoords(0);
5525 function setLeftRTLScrollbarOffset() {
5526 offsets.x = getWindowScrollBarX(documentElement);
5527 }
5528 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5529 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5530 scroll = getNodeScroll(offsetParent);
5531 }
5532 if (isOffsetParentAnElement) {
5533 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
5534 offsets.x = offsetRect.x + offsetParent.clientLeft;
5535 offsets.y = offsetRect.y + offsetParent.clientTop;
5536 } else if (documentElement) {
5537 setLeftRTLScrollbarOffset();
5538 }
5539 }
5540 if (isFixed && !isOffsetParentAnElement && documentElement) {
5541 setLeftRTLScrollbarOffset();
5542 }
5543 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5544 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
5545 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
5546 return {
5547 x: x2,
5548 y: y2,
5549 width: rect.width,
5550 height: rect.height
5551 };
5552 }
5553 function isStaticPositioned(element) {
5554 return getComputedStyle2(element).position === "static";
5555 }
5556 function getTrueOffsetParent(element, polyfill) {
5557 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
5558 return null;
5559 }
5560 if (polyfill) {
5561 return polyfill(element);
5562 }
5563 let rawOffsetParent = element.offsetParent;
5564 if (getDocumentElement(element) === rawOffsetParent) {
5565 rawOffsetParent = rawOffsetParent.ownerDocument.body;
5566 }
5567 return rawOffsetParent;
5568 }
5569 function getOffsetParent(element, polyfill) {
5570 const win = getWindow(element);
5571 if (isTopLayer(element)) {
5572 return win;
5573 }
5574 if (!isHTMLElement(element)) {
5575 let svgOffsetParent = getParentNode(element);
5576 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
5577 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
5578 return svgOffsetParent;
5579 }
5580 svgOffsetParent = getParentNode(svgOffsetParent);
5581 }
5582 return win;
5583 }
5584 let offsetParent = getTrueOffsetParent(element, polyfill);
5585 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
5586 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
5587 }
5588 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
5589 return win;
5590 }
5591 return offsetParent || getContainingBlock(element) || win;
5592 }
5593 var getElementRects = async function(data) {
5594 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
5595 const getDimensionsFn = this.getDimensions;
5596 const floatingDimensions = await getDimensionsFn(data.floating);
5597 return {
5598 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
5599 floating: {
5600 x: 0,
5601 y: 0,
5602 width: floatingDimensions.width,
5603 height: floatingDimensions.height
5604 }
5605 };
5606 };
5607 function isRTL(element) {
5608 return getComputedStyle2(element).direction === "rtl";
5609 }
5610 var platform2 = {
5611 convertOffsetParentRelativeRectToViewportRelativeRect,
5612 getDocumentElement,
5613 getClippingRect,
5614 getOffsetParent,
5615 getElementRects,
5616 getClientRects,
5617 getDimensions,
5618 getScale,
5619 isElement,
5620 isRTL
5621 };
5622 function rectsAreEqual(a2, b2) {
5623 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
5624 }
5625 function observeMove(element, onMove) {
5626 let io = null;
5627 let timeoutId;
5628 const root = getDocumentElement(element);
5629 function cleanup() {
5630 var _io;
5631 clearTimeout(timeoutId);
5632 (_io = io) == null || _io.disconnect();
5633 io = null;
5634 }
5635 function refresh(skip, threshold) {
5636 if (skip === void 0) {
5637 skip = false;
5638 }
5639 if (threshold === void 0) {
5640 threshold = 1;
5641 }
5642 cleanup();
5643 const elementRectForRootMargin = element.getBoundingClientRect();
5644 const {
5645 left,
5646 top,
5647 width,
5648 height
5649 } = elementRectForRootMargin;
5650 if (!skip) {
5651 onMove();
5652 }
5653 if (!width || !height) {
5654 return;
5655 }
5656 const insetTop = floor(top);
5657 const insetRight = floor(root.clientWidth - (left + width));
5658 const insetBottom = floor(root.clientHeight - (top + height));
5659 const insetLeft = floor(left);
5660 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
5661 const options = {
5662 rootMargin,
5663 threshold: max(0, min(1, threshold)) || 1
5664 };
5665 let isFirstUpdate = true;
5666 function handleObserve(entries) {
5667 const ratio = entries[0].intersectionRatio;
5668 if (ratio !== threshold) {
5669 if (!isFirstUpdate) {
5670 return refresh();
5671 }
5672 if (!ratio) {
5673 timeoutId = setTimeout(() => {
5674 refresh(false, 1e-7);
5675 }, 1e3);
5676 } else {
5677 refresh(false, ratio);
5678 }
5679 }
5680 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
5681 refresh();
5682 }
5683 isFirstUpdate = false;
5684 }
5685 try {
5686 io = new IntersectionObserver(handleObserve, {
5687 ...options,
5688 // Handle <iframe>s
5689 root: root.ownerDocument
5690 });
5691 } catch (_e) {
5692 io = new IntersectionObserver(handleObserve, options);
5693 }
5694 io.observe(element);
5695 }
5696 refresh(true);
5697 return cleanup;
5698 }
5699 function autoUpdate(reference, floating, update2, options) {
5700 if (options === void 0) {
5701 options = {};
5702 }
5703 const {
5704 ancestorScroll = true,
5705 ancestorResize = true,
5706 elementResize = typeof ResizeObserver === "function",
5707 layoutShift = typeof IntersectionObserver === "function",
5708 animationFrame = false
5709 } = options;
5710 const referenceEl = unwrapElement(reference);
5711 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
5712 ancestors.forEach((ancestor) => {
5713 ancestorScroll && ancestor.addEventListener("scroll", update2, {
5714 passive: true
5715 });
5716 ancestorResize && ancestor.addEventListener("resize", update2);
5717 });
5718 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
5719 let reobserveFrame = -1;
5720 let resizeObserver = null;
5721 if (elementResize) {
5722 resizeObserver = new ResizeObserver((_ref) => {
5723 let [firstEntry] = _ref;
5724 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
5725 resizeObserver.unobserve(floating);
5726 cancelAnimationFrame(reobserveFrame);
5727 reobserveFrame = requestAnimationFrame(() => {
5728 var _resizeObserver;
5729 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
5730 });
5731 }
5732 update2();
5733 });
5734 if (referenceEl && !animationFrame) {
5735 resizeObserver.observe(referenceEl);
5736 }
5737 if (floating) {
5738 resizeObserver.observe(floating);
5739 }
5740 }
5741 let frameId;
5742 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
5743 if (animationFrame) {
5744 frameLoop();
5745 }
5746 function frameLoop() {
5747 const nextRefRect = getBoundingClientRect(reference);
5748 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
5749 update2();
5750 }
5751 prevRefRect = nextRefRect;
5752 frameId = requestAnimationFrame(frameLoop);
5753 }
5754 update2();
5755 return () => {
5756 var _resizeObserver2;
5757 ancestors.forEach((ancestor) => {
5758 ancestorScroll && ancestor.removeEventListener("scroll", update2);
5759 ancestorResize && ancestor.removeEventListener("resize", update2);
5760 });
5761 cleanupIo == null || cleanupIo();
5762 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
5763 resizeObserver = null;
5764 if (animationFrame) {
5765 cancelAnimationFrame(frameId);
5766 }
5767 };
5768 }
5769 var offset2 = offset;
5770 var shift2 = shift;
5771 var flip2 = flip;
5772 var size2 = size;
5773 var hide2 = hide;
5774 var limitShift2 = limitShift;
5775 var computePosition2 = (reference, floating, options) => {
5776 const cache = /* @__PURE__ */ new Map();
5777 const mergedOptions = {
5778 platform: platform2,
5779 ...options
5780 };
5781 const platformWithCache = {
5782 ...mergedOptions.platform,
5783 _c: cache
5784 };
5785 return computePosition(reference, floating, {
5786 ...mergedOptions,
5787 platform: platformWithCache
5788 });
5789 };
5790
5791 // node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
5792 var React19 = __toESM(require_react(), 1);
5793 var import_react2 = __toESM(require_react(), 1);
5794 var ReactDOM3 = __toESM(require_react_dom(), 1);
5795 var isClient = typeof document !== "undefined";
5796 var noop3 = function noop4() {
5797 };
5798 var index = isClient ? import_react2.useLayoutEffect : noop3;
5799 function deepEqual(a2, b2) {
5800 if (a2 === b2) {
5801 return true;
5802 }
5803 if (typeof a2 !== typeof b2) {
5804 return false;
5805 }
5806 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
5807 return true;
5808 }
5809 let length;
5810 let i2;
5811 let keys;
5812 if (a2 && b2 && typeof a2 === "object") {
5813 if (Array.isArray(a2)) {
5814 length = a2.length;
5815 if (length !== b2.length) return false;
5816 for (i2 = length; i2-- !== 0; ) {
5817 if (!deepEqual(a2[i2], b2[i2])) {
5818 return false;
5819 }
5820 }
5821 return true;
5822 }
5823 keys = Object.keys(a2);
5824 length = keys.length;
5825 if (length !== Object.keys(b2).length) {
5826 return false;
5827 }
5828 for (i2 = length; i2-- !== 0; ) {
5829 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
5830 return false;
5831 }
5832 }
5833 for (i2 = length; i2-- !== 0; ) {
5834 const key = keys[i2];
5835 if (key === "_owner" && a2.$$typeof) {
5836 continue;
5837 }
5838 if (!deepEqual(a2[key], b2[key])) {
5839 return false;
5840 }
5841 }
5842 return true;
5843 }
5844 return a2 !== a2 && b2 !== b2;
5845 }
5846 function getDPR(element) {
5847 if (typeof window === "undefined") {
5848 return 1;
5849 }
5850 const win = element.ownerDocument.defaultView || window;
5851 return win.devicePixelRatio || 1;
5852 }
5853 function roundByDPR(element, value) {
5854 const dpr = getDPR(element);
5855 return Math.round(value * dpr) / dpr;
5856 }
5857 function useLatestRef(value) {
5858 const ref = React19.useRef(value);
5859 index(() => {
5860 ref.current = value;
5861 });
5862 return ref;
5863 }
5864 function useFloating(options) {
5865 if (options === void 0) {
5866 options = {};
5867 }
5868 const {
5869 placement = "bottom",
5870 strategy = "absolute",
5871 middleware = [],
5872 platform: platform3,
5873 elements: {
5874 reference: externalReference,
5875 floating: externalFloating
5876 } = {},
5877 transform = true,
5878 whileElementsMounted,
5879 open
5880 } = options;
5881 const [data, setData] = React19.useState({
5882 x: 0,
5883 y: 0,
5884 strategy,
5885 placement,
5886 middlewareData: {},
5887 isPositioned: false
5888 });
5889 const [latestMiddleware, setLatestMiddleware] = React19.useState(middleware);
5890 if (!deepEqual(latestMiddleware, middleware)) {
5891 setLatestMiddleware(middleware);
5892 }
5893 const [_reference, _setReference] = React19.useState(null);
5894 const [_floating, _setFloating] = React19.useState(null);
5895 const setReference = React19.useCallback((node) => {
5896 if (node !== referenceRef.current) {
5897 referenceRef.current = node;
5898 _setReference(node);
5899 }
5900 }, []);
5901 const setFloating = React19.useCallback((node) => {
5902 if (node !== floatingRef.current) {
5903 floatingRef.current = node;
5904 _setFloating(node);
5905 }
5906 }, []);
5907 const referenceEl = externalReference || _reference;
5908 const floatingEl = externalFloating || _floating;
5909 const referenceRef = React19.useRef(null);
5910 const floatingRef = React19.useRef(null);
5911 const dataRef = React19.useRef(data);
5912 const hasWhileElementsMounted = whileElementsMounted != null;
5913 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5914 const platformRef = useLatestRef(platform3);
5915 const openRef = useLatestRef(open);
5916 const update2 = React19.useCallback(() => {
5917 if (!referenceRef.current || !floatingRef.current) {
5918 return;
5919 }
5920 const config = {
5921 placement,
5922 strategy,
5923 middleware: latestMiddleware
5924 };
5925 if (platformRef.current) {
5926 config.platform = platformRef.current;
5927 }
5928 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
5929 const fullData = {
5930 ...data2,
5931 // The floating element's position may be recomputed while it's closed
5932 // but still mounted (such as when transitioning out). To ensure
5933 // `isPositioned` will be `false` initially on the next open, avoid
5934 // setting it to `true` when `open === false` (must be specified).
5935 isPositioned: openRef.current !== false
5936 };
5937 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5938 dataRef.current = fullData;
5939 ReactDOM3.flushSync(() => {
5940 setData(fullData);
5941 });
5942 }
5943 });
5944 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
5945 index(() => {
5946 if (open === false && dataRef.current.isPositioned) {
5947 dataRef.current.isPositioned = false;
5948 setData((data2) => ({
5949 ...data2,
5950 isPositioned: false
5951 }));
5952 }
5953 }, [open]);
5954 const isMountedRef = React19.useRef(false);
5955 index(() => {
5956 isMountedRef.current = true;
5957 return () => {
5958 isMountedRef.current = false;
5959 };
5960 }, []);
5961 index(() => {
5962 if (referenceEl) referenceRef.current = referenceEl;
5963 if (floatingEl) floatingRef.current = floatingEl;
5964 if (referenceEl && floatingEl) {
5965 if (whileElementsMountedRef.current) {
5966 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
5967 }
5968 update2();
5969 }
5970 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
5971 const refs = React19.useMemo(() => ({
5972 reference: referenceRef,
5973 floating: floatingRef,
5974 setReference,
5975 setFloating
5976 }), [setReference, setFloating]);
5977 const elements = React19.useMemo(() => ({
5978 reference: referenceEl,
5979 floating: floatingEl
5980 }), [referenceEl, floatingEl]);
5981 const floatingStyles = React19.useMemo(() => {
5982 const initialStyles = {
5983 position: strategy,
5984 left: 0,
5985 top: 0
5986 };
5987 if (!elements.floating) {
5988 return initialStyles;
5989 }
5990 const x2 = roundByDPR(elements.floating, data.x);
5991 const y2 = roundByDPR(elements.floating, data.y);
5992 if (transform) {
5993 return {
5994 ...initialStyles,
5995 transform: "translate(" + x2 + "px, " + y2 + "px)",
5996 ...getDPR(elements.floating) >= 1.5 && {
5997 willChange: "transform"
5998 }
5999 };
6000 }
6001 return {
6002 position: strategy,
6003 left: x2,
6004 top: y2
6005 };
6006 }, [strategy, transform, elements.floating, data.x, data.y]);
6007 return React19.useMemo(() => ({
6008 ...data,
6009 update: update2,
6010 refs,
6011 elements,
6012 floatingStyles
6013 }), [data, update2, refs, elements, floatingStyles]);
6014 }
6015 var offset3 = (options, deps) => {
6016 const result = offset2(options);
6017 return {
6018 name: result.name,
6019 fn: result.fn,
6020 options: [options, deps]
6021 };
6022 };
6023 var shift3 = (options, deps) => {
6024 const result = shift2(options);
6025 return {
6026 name: result.name,
6027 fn: result.fn,
6028 options: [options, deps]
6029 };
6030 };
6031 var limitShift3 = (options, deps) => {
6032 const result = limitShift2(options);
6033 return {
6034 fn: result.fn,
6035 options: [options, deps]
6036 };
6037 };
6038 var flip3 = (options, deps) => {
6039 const result = flip2(options);
6040 return {
6041 name: result.name,
6042 fn: result.fn,
6043 options: [options, deps]
6044 };
6045 };
6046 var size3 = (options, deps) => {
6047 const result = size2(options);
6048 return {
6049 name: result.name,
6050 fn: result.fn,
6051 options: [options, deps]
6052 };
6053 };
6054 var hide3 = (options, deps) => {
6055 const result = hide2(options);
6056 return {
6057 name: result.name,
6058 fn: result.fn,
6059 options: [options, deps]
6060 };
6061 };
6062
6063 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs
6064 var React24 = __toESM(require_react(), 1);
6065 var ReactDOM4 = __toESM(require_react_dom(), 1);
6066
6067 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs
6068 var React23 = __toESM(require_react(), 1);
6069
6070 // node_modules/@base-ui/utils/store/createSelector.mjs
6071 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
6072 if (other.length > 0) {
6073 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
6074 }
6075 let selector2;
6076 if (a2 && b2 && c2 && d2 && e2 && f2) {
6077 selector2 = (state, a1, a22, a3) => {
6078 const va = a2(state, a1, a22, a3);
6079 const vb = b2(state, a1, a22, a3);
6080 const vc = c2(state, a1, a22, a3);
6081 const vd = d2(state, a1, a22, a3);
6082 const ve = e2(state, a1, a22, a3);
6083 return f2(va, vb, vc, vd, ve, a1, a22, a3);
6084 };
6085 } else if (a2 && b2 && c2 && d2 && e2) {
6086 selector2 = (state, a1, a22, a3) => {
6087 const va = a2(state, a1, a22, a3);
6088 const vb = b2(state, a1, a22, a3);
6089 const vc = c2(state, a1, a22, a3);
6090 const vd = d2(state, a1, a22, a3);
6091 return e2(va, vb, vc, vd, a1, a22, a3);
6092 };
6093 } else if (a2 && b2 && c2 && d2) {
6094 selector2 = (state, a1, a22, a3) => {
6095 const va = a2(state, a1, a22, a3);
6096 const vb = b2(state, a1, a22, a3);
6097 const vc = c2(state, a1, a22, a3);
6098 return d2(va, vb, vc, a1, a22, a3);
6099 };
6100 } else if (a2 && b2 && c2) {
6101 selector2 = (state, a1, a22, a3) => {
6102 const va = a2(state, a1, a22, a3);
6103 const vb = b2(state, a1, a22, a3);
6104 return c2(va, vb, a1, a22, a3);
6105 };
6106 } else if (a2 && b2) {
6107 selector2 = (state, a1, a22, a3) => {
6108 const va = a2(state, a1, a22, a3);
6109 return b2(va, a1, a22, a3);
6110 };
6111 } else if (a2) {
6112 selector2 = a2;
6113 } else {
6114 throw (
6115 /* minify-error-disabled */
6116 new Error("Missing arguments")
6117 );
6118 }
6119 return selector2;
6120 };
6121
6122 // node_modules/@base-ui/utils/store/useStore.mjs
6123 var React21 = __toESM(require_react(), 1);
6124 var import_shim = __toESM(require_shim(), 1);
6125 var import_with_selector = __toESM(require_with_selector(), 1);
6126
6127 // node_modules/@base-ui/utils/fastHooks.mjs
6128 var React20 = __toESM(require_react(), 1);
6129 var hooks = [];
6130 var currentInstance = void 0;
6131 function getInstance() {
6132 return currentInstance;
6133 }
6134 function register(hook) {
6135 hooks.push(hook);
6136 }
6137 function fastComponent(fn) {
6138 const FastComponent = (props, forwardedRef) => {
6139 const instance = useRefWithInit(createInstance).current;
6140 let result;
6141 try {
6142 currentInstance = instance;
6143 for (const hook of hooks) {
6144 hook.before(instance);
6145 }
6146 result = fn(props, forwardedRef);
6147 for (const hook of hooks) {
6148 hook.after(instance);
6149 }
6150 instance.didInitialize = true;
6151 } finally {
6152 currentInstance = void 0;
6153 }
6154 return result;
6155 };
6156 FastComponent.displayName = fn.displayName || fn.name;
6157 return FastComponent;
6158 }
6159 function fastComponentRef(fn) {
6160 return /* @__PURE__ */ React20.forwardRef(fastComponent(fn));
6161 }
6162 function createInstance() {
6163 return {
6164 didInitialize: false
6165 };
6166 }
6167
6168 // node_modules/@base-ui/utils/store/useStore.mjs
6169 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
6170 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
6171 function useStore(store, selector2, a1, a2, a3) {
6172 return useStoreImplementation(store, selector2, a1, a2, a3);
6173 }
6174 function useStoreR19(store, selector2, a1, a2, a3) {
6175 const getSelection = React21.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
6176 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
6177 }
6178 register({
6179 before(instance) {
6180 instance.syncIndex = 0;
6181 if (!instance.didInitialize) {
6182 instance.syncTick = 1;
6183 instance.syncHooks = [];
6184 instance.didChangeStore = true;
6185 instance.getSnapshot = () => {
6186 let didChange2 = false;
6187 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
6188 const hook = instance.syncHooks[i2];
6189 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
6190 if (!Object.is(hook.value, value)) {
6191 didChange2 = true;
6192 hook.value = value;
6193 }
6194 }
6195 if (didChange2) {
6196 instance.syncTick += 1;
6197 }
6198 return instance.syncTick;
6199 };
6200 }
6201 },
6202 after(instance) {
6203 if (instance.syncHooks.length > 0) {
6204 if (instance.didChangeStore) {
6205 instance.didChangeStore = false;
6206 instance.subscribe = (onStoreChange) => {
6207 const stores = /* @__PURE__ */ new Set();
6208 for (const hook of instance.syncHooks) {
6209 stores.add(hook.store);
6210 }
6211 const unsubscribes = [];
6212 for (const store of stores) {
6213 unsubscribes.push(store.subscribe(onStoreChange));
6214 }
6215 return () => {
6216 for (const unsubscribe of unsubscribes) {
6217 unsubscribe();
6218 }
6219 };
6220 };
6221 }
6222 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
6223 }
6224 }
6225 });
6226 function useStoreFast(store, selector2, a1, a2, a3) {
6227 const instance = getInstance();
6228 if (!instance) {
6229 return useStoreR19(store, selector2, a1, a2, a3);
6230 }
6231 const index2 = instance.syncIndex;
6232 instance.syncIndex += 1;
6233 let hook;
6234 if (!instance.didInitialize) {
6235 hook = {
6236 store,
6237 selector: selector2,
6238 a1,
6239 a2,
6240 a3,
6241 value: selector2(store.getSnapshot(), a1, a2, a3)
6242 };
6243 instance.syncHooks.push(hook);
6244 } else {
6245 hook = instance.syncHooks[index2];
6246 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
6247 if (hook.store !== store) {
6248 instance.didChangeStore = true;
6249 }
6250 hook.store = store;
6251 hook.selector = selector2;
6252 hook.a1 = a1;
6253 hook.a2 = a2;
6254 hook.a3 = a3;
6255 hook.value = selector2(store.getSnapshot(), a1, a2, a3);
6256 }
6257 }
6258 return hook.value;
6259 }
6260 function useStoreLegacy(store, selector2, a1, a2, a3) {
6261 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
6262 }
6263
6264 // node_modules/@base-ui/utils/store/Store.mjs
6265 var Store = class {
6266 /**
6267 * The current state of the store.
6268 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
6269 * 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).
6270 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
6271 *
6272 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
6273 */
6274 // Internal state to handle recursive `setState()` calls
6275 constructor(state) {
6276 this.state = state;
6277 this.listeners = /* @__PURE__ */ new Set();
6278 this.updateTick = 0;
6279 }
6280 /**
6281 * Registers a listener that will be called whenever the store's state changes.
6282 *
6283 * @param fn The listener function to be called on state changes.
6284 * @returns A function to unsubscribe the listener.
6285 */
6286 subscribe = (fn) => {
6287 this.listeners.add(fn);
6288 return () => {
6289 this.listeners.delete(fn);
6290 };
6291 };
6292 /**
6293 * Returns the current state of the store.
6294 */
6295 getSnapshot = () => {
6296 return this.state;
6297 };
6298 /**
6299 * Updates the entire store's state and notifies all registered listeners.
6300 *
6301 * @param newState The new state to set for the store.
6302 */
6303 setState(newState) {
6304 if (this.state === newState) {
6305 return;
6306 }
6307 this.state = newState;
6308 this.updateTick += 1;
6309 const currentTick = this.updateTick;
6310 for (const listener of this.listeners) {
6311 if (currentTick !== this.updateTick) {
6312 return;
6313 }
6314 listener(newState);
6315 }
6316 }
6317 /**
6318 * Merges the provided changes into the current state and notifies listeners if there are changes.
6319 *
6320 * @param changes An object containing the changes to apply to the current state.
6321 */
6322 update(changes) {
6323 for (const key in changes) {
6324 if (!Object.is(this.state[key], changes[key])) {
6325 this.setState({
6326 ...this.state,
6327 ...changes
6328 });
6329 return;
6330 }
6331 }
6332 }
6333 /**
6334 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
6335 *
6336 * @param key The key in the store's state to update.
6337 * @param value The new value to set for the specified key.
6338 */
6339 set(key, value) {
6340 if (!Object.is(this.state[key], value)) {
6341 this.setState({
6342 ...this.state,
6343 [key]: value
6344 });
6345 }
6346 }
6347 /**
6348 * Gives the state a new reference and updates all registered listeners.
6349 */
6350 notifyAll() {
6351 const newState = {
6352 ...this.state
6353 };
6354 this.setState(newState);
6355 }
6356 use(selector2, a1, a2, a3) {
6357 return useStore(this, selector2, a1, a2, a3);
6358 }
6359 };
6360
6361 // node_modules/@base-ui/utils/store/ReactStore.mjs
6362 var React22 = __toESM(require_react(), 1);
6363 var ReactStore = class extends Store {
6364 /**
6365 * Creates a new ReactStore instance.
6366 *
6367 * @param state Initial state of the store.
6368 * @param context Non-reactive context values.
6369 * @param selectors Optional selectors for use with `useState`.
6370 */
6371 constructor(state, context = {}, selectors3) {
6372 super(state);
6373 this.context = context;
6374 this.selectors = selectors3;
6375 }
6376 /**
6377 * Non-reactive values such as refs, callbacks, etc.
6378 */
6379 /**
6380 * Synchronizes a single external value into the store.
6381 *
6382 * Note that the while the value in `state` is updated immediately, the value returned
6383 * by `useState` is updated before the next render (similarly to React's `useState`).
6384 */
6385 useSyncedValue(key, value) {
6386 React22.useDebugValue(key);
6387 const store = this;
6388 useIsoLayoutEffect(() => {
6389 if (store.state[key] !== value) {
6390 store.set(key, value);
6391 }
6392 }, [store, key, value]);
6393 }
6394 /**
6395 * Synchronizes a single external value into the store and
6396 * cleans it up (sets to `undefined`) on unmount.
6397 *
6398 * Note that the while the value in `state` is updated immediately, the value returned
6399 * by `useState` is updated before the next render (similarly to React's `useState`).
6400 */
6401 useSyncedValueWithCleanup(key, value) {
6402 const store = this;
6403 useIsoLayoutEffect(() => {
6404 if (store.state[key] !== value) {
6405 store.set(key, value);
6406 }
6407 return () => {
6408 store.set(key, void 0);
6409 };
6410 }, [store, key, value]);
6411 }
6412 /**
6413 * Synchronizes multiple external values into the store.
6414 *
6415 * Note that the while the values in `state` are updated immediately, the values returned
6416 * by `useState` are updated before the next render (similarly to React's `useState`).
6417 */
6418 useSyncedValues(statePart) {
6419 const store = this;
6420 if (true) {
6421 React22.useDebugValue(statePart, (p2) => Object.keys(p2));
6422 const keys = React22.useRef(Object.keys(statePart)).current;
6423 const nextKeys = Object.keys(statePart);
6424 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
6425 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
6426 }
6427 }
6428 const dependencies = Object.values(statePart);
6429 useIsoLayoutEffect(() => {
6430 store.update(statePart);
6431 }, [store, ...dependencies]);
6432 }
6433 /**
6434 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
6435 * is non-undefined, the store's state at `key` is updated to match `controlled`.
6436 */
6437 useControlledProp(key, controlled) {
6438 React22.useDebugValue(key);
6439 const store = this;
6440 const isControlled = controlled !== void 0;
6441 useIsoLayoutEffect(() => {
6442 if (isControlled && !Object.is(store.state[key], controlled)) {
6443 store.setState({
6444 ...store.state,
6445 [key]: controlled
6446 });
6447 }
6448 }, [store, key, controlled, isControlled]);
6449 if (true) {
6450 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
6451 if (!cache.has(key)) {
6452 cache.set(key, isControlled);
6453 }
6454 const previouslyControlled = cache.get(key);
6455 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
6456 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).`);
6457 }
6458 }
6459 }
6460 /** Gets the current value from the store using a selector with the provided key.
6461 *
6462 * @param key Key of the selector to use.
6463 */
6464 select(key, a1, a2, a3) {
6465 const selector2 = this.selectors[key];
6466 return selector2(this.state, a1, a2, a3);
6467 }
6468 /**
6469 * Returns a value from the store's state using a selector function.
6470 * Used to subscribe to specific parts of the state.
6471 * This methods causes a rerender whenever the selected state changes.
6472 *
6473 * @param key Key of the selector to use.
6474 */
6475 useState(key, a1, a2, a3) {
6476 React22.useDebugValue(key);
6477 return useStore(this, this.selectors[key], a1, a2, a3);
6478 }
6479 /**
6480 * Wraps a function with `useStableCallback` to ensure it has a stable reference
6481 * and assigns it to the context.
6482 *
6483 * @param key Key of the event callback. Must be a function in the context.
6484 * @param fn Function to assign.
6485 */
6486 useContextCallback(key, fn) {
6487 React22.useDebugValue(key);
6488 const stableFunction = useStableCallback(fn ?? NOOP);
6489 this.context[key] = stableFunction;
6490 }
6491 /**
6492 * Returns a stable setter function for a specific key in the store's state.
6493 * It's commonly used to pass as a ref callback to React elements.
6494 *
6495 * @param key Key of the state to set.
6496 */
6497 useStateSetter(key) {
6498 const ref = React22.useRef(void 0);
6499 if (ref.current === void 0) {
6500 ref.current = (value) => {
6501 this.set(key, value);
6502 };
6503 }
6504 return ref.current;
6505 }
6506 /**
6507 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
6508 *
6509 * @param key Key of the selector to observe.
6510 * @param listener Listener function called when the selector result changes.
6511 */
6512 observe(selector2, listener) {
6513 let selectFn;
6514 if (typeof selector2 === "function") {
6515 selectFn = selector2;
6516 } else {
6517 selectFn = this.selectors[selector2];
6518 }
6519 let prevValue = selectFn(this.state);
6520 listener(prevValue, prevValue, this);
6521 return this.subscribe((nextState) => {
6522 const nextValue = selectFn(nextState);
6523 if (!Object.is(prevValue, nextValue)) {
6524 const oldValue = prevValue;
6525 prevValue = nextValue;
6526 listener(nextValue, oldValue, this);
6527 }
6528 });
6529 }
6530 };
6531
6532 // node_modules/@base-ui/react/floating-ui-react/components/FloatingRootStore.mjs
6533 var selectors = {
6534 open: createSelector((state) => state.open),
6535 transitionStatus: createSelector((state) => state.transitionStatus),
6536 domReferenceElement: createSelector((state) => state.domReferenceElement),
6537 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
6538 floatingElement: createSelector((state) => state.floatingElement),
6539 floatingId: createSelector((state) => state.floatingId)
6540 };
6541 var FloatingRootStore = class extends ReactStore {
6542 constructor(options) {
6543 const {
6544 syncOnly,
6545 nested,
6546 onOpenChange,
6547 triggerElements,
6548 ...initialState
6549 } = options;
6550 super({
6551 ...initialState,
6552 positionReference: initialState.referenceElement,
6553 domReferenceElement: initialState.referenceElement
6554 }, {
6555 onOpenChange,
6556 dataRef: {
6557 current: {}
6558 },
6559 events: createEventEmitter(),
6560 nested,
6561 triggerElements
6562 }, selectors);
6563 this.syncOnly = syncOnly;
6564 }
6565 /**
6566 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
6567 */
6568 syncOpenEvent = (newOpen, event) => {
6569 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
6570 // click events to upgrade a hover-open.
6571 event != null && isClickLikeEvent(event)) {
6572 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
6573 }
6574 };
6575 /**
6576 * Runs the root-owned side effects for an open state change.
6577 */
6578 dispatchOpenChange = (newOpen, eventDetails) => {
6579 this.syncOpenEvent(newOpen, eventDetails.event);
6580 const details = {
6581 open: newOpen,
6582 reason: eventDetails.reason,
6583 nativeEvent: eventDetails.event,
6584 nested: this.context.nested,
6585 triggerElement: eventDetails.trigger
6586 };
6587 this.context.events.emit("openchange", details);
6588 };
6589 /**
6590 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
6591 *
6592 * @param newOpen The new open state.
6593 * @param eventDetails Details about the event that triggered the open state change.
6594 */
6595 setOpen = (newOpen, eventDetails) => {
6596 if (this.syncOnly) {
6597 this.context.onOpenChange?.(newOpen, eventDetails);
6598 return;
6599 }
6600 this.dispatchOpenChange(newOpen, eventDetails);
6601 this.context.onOpenChange?.(newOpen, eventDetails);
6602 };
6603 };
6604
6605 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs
6606 function useSyncedFloatingRootContext(options) {
6607 const {
6608 popupStore,
6609 treatPopupAsFloatingElement = false,
6610 floatingRootContext: floatingRootContextProp,
6611 floatingId,
6612 nested,
6613 onOpenChange
6614 } = options;
6615 const open = popupStore.useState("open");
6616 const referenceElement = popupStore.useState("activeTriggerElement");
6617 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
6618 const triggerElements = popupStore.context.triggerElements;
6619 const handleOpenChange = onOpenChange;
6620 const internalStoreRef = React23.useRef(null);
6621 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
6622 internalStoreRef.current = new FloatingRootStore({
6623 open,
6624 transitionStatus: void 0,
6625 referenceElement,
6626 floatingElement,
6627 triggerElements,
6628 onOpenChange: handleOpenChange,
6629 floatingId,
6630 syncOnly: true,
6631 nested
6632 });
6633 }
6634 const store = floatingRootContextProp ?? internalStoreRef.current;
6635 popupStore.useSyncedValue("floatingId", floatingId);
6636 useIsoLayoutEffect(() => {
6637 const valuesToSync = {
6638 open,
6639 floatingId,
6640 referenceElement,
6641 floatingElement
6642 };
6643 if (isElement(referenceElement)) {
6644 valuesToSync.domReferenceElement = referenceElement;
6645 }
6646 if (store.state.positionReference === store.state.referenceElement) {
6647 valuesToSync.positionReference = referenceElement;
6648 }
6649 store.update(valuesToSync);
6650 }, [open, floatingId, referenceElement, floatingElement, store]);
6651 store.context.onOpenChange = handleOpenChange;
6652 store.context.nested = nested;
6653 return store;
6654 }
6655
6656 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs
6657 var FOCUSABLE_POPUP_PROPS = {
6658 tabIndex: -1,
6659 [FOCUSABLE_ATTRIBUTE]: ""
6660 };
6661 function usePopupStore(externalStore, createStore2, treatPopupAsFloatingElement = false) {
6662 const floatingId = useId();
6663 const nested = useFloatingParentNodeId() != null;
6664 const internalStoreRef = React24.useRef(null);
6665 if (externalStore === void 0 && internalStoreRef.current === null) {
6666 internalStoreRef.current = createStore2(floatingId, nested);
6667 }
6668 const store = externalStore ?? internalStoreRef.current;
6669 useSyncedFloatingRootContext({
6670 popupStore: store,
6671 treatPopupAsFloatingElement,
6672 floatingRootContext: store.state.floatingRootContext,
6673 floatingId,
6674 nested,
6675 onOpenChange: store.setOpen
6676 });
6677 return {
6678 store,
6679 internalStore: internalStoreRef.current
6680 };
6681 }
6682 function useTriggerRegistration(id, store) {
6683 const registeredElementIdRef = React24.useRef(null);
6684 const registeredElementRef = React24.useRef(null);
6685 return React24.useCallback((element) => {
6686 if (id === void 0) {
6687 return;
6688 }
6689 let shouldSyncTriggerCount = false;
6690 if (registeredElementIdRef.current !== null) {
6691 const registeredId = registeredElementIdRef.current;
6692 const registeredElement = registeredElementRef.current;
6693 const currentElement = store.context.triggerElements.getById(registeredId);
6694 if (registeredElement && currentElement === registeredElement) {
6695 store.context.triggerElements.delete(registeredId);
6696 shouldSyncTriggerCount = true;
6697 }
6698 registeredElementIdRef.current = null;
6699 registeredElementRef.current = null;
6700 }
6701 if (element !== null) {
6702 registeredElementIdRef.current = id;
6703 registeredElementRef.current = element;
6704 store.context.triggerElements.add(id, element);
6705 shouldSyncTriggerCount = true;
6706 }
6707 if (shouldSyncTriggerCount) {
6708 const triggerCount = store.context.triggerElements.size;
6709 if (store.select("open") && store.state.triggerCount !== triggerCount) {
6710 store.set("triggerCount", triggerCount);
6711 }
6712 }
6713 }, [store, id]);
6714 }
6715 function setPopupOpenState(state, open, trigger, preventUnmountOnClose = false) {
6716 if (open) {
6717 state.preventUnmountingOnClose = false;
6718 } else if (preventUnmountOnClose) {
6719 state.preventUnmountingOnClose = true;
6720 }
6721 const triggerId = trigger?.id ?? null;
6722 if (triggerId || open) {
6723 state.activeTriggerId = triggerId;
6724 state.activeTriggerElement = trigger ?? null;
6725 }
6726 }
6727 function attachPreventUnmountOnClose(eventDetails) {
6728 let preventUnmountOnClose = false;
6729 eventDetails.preventUnmountOnClose = () => {
6730 preventUnmountOnClose = true;
6731 };
6732 return () => preventUnmountOnClose;
6733 }
6734 function applyPopupOpenChange(store, nextOpen, eventDetails, options = {}) {
6735 const reason = eventDetails.reason;
6736 const isHover = reason === reason_parts_exports.triggerHover;
6737 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
6738 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
6739 const shouldPreventUnmountOnClose = attachPreventUnmountOnClose(eventDetails);
6740 store.context.onOpenChange?.(nextOpen, eventDetails);
6741 if (eventDetails.isCanceled) {
6742 return;
6743 }
6744 options.onBeforeDispatch?.();
6745 store.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
6746 const changeState = () => {
6747 const updatedState = {
6748 ...options.extraState,
6749 open: nextOpen
6750 };
6751 if (isFocusOpen) {
6752 updatedState.instantType = "focus";
6753 } else if (isDismissClose) {
6754 updatedState.instantType = "dismiss";
6755 } else if (isHover) {
6756 updatedState.instantType = void 0;
6757 }
6758 setPopupOpenState(updatedState, nextOpen, eventDetails.trigger, shouldPreventUnmountOnClose());
6759 store.update(updatedState);
6760 };
6761 if (isHover) {
6762 ReactDOM4.flushSync(changeState);
6763 } else {
6764 changeState();
6765 }
6766 }
6767 function useInitialOpenSync(store, openProp, defaultOpen, defaultTriggerId) {
6768 useOnFirstRender(() => {
6769 if (openProp === void 0 && store.state.open === false && defaultOpen) {
6770 store.state = {
6771 ...store.state,
6772 open: true,
6773 activeTriggerId: defaultTriggerId,
6774 preventUnmountingOnClose: false
6775 };
6776 }
6777 });
6778 }
6779 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
6780 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
6781 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
6782 const registerTrigger = useStableCallback((element) => {
6783 baseRegisterTrigger(element);
6784 if (!element) {
6785 return;
6786 }
6787 const open = store.select("open");
6788 const activeTriggerId = store.select("activeTriggerId");
6789 if (activeTriggerId === triggerId) {
6790 store.update({
6791 activeTriggerElement: element,
6792 ...open ? stateUpdates : null
6793 });
6794 return;
6795 }
6796 if (activeTriggerId == null && open) {
6797 store.update({
6798 activeTriggerId: triggerId,
6799 activeTriggerElement: element,
6800 ...stateUpdates
6801 });
6802 }
6803 });
6804 useIsoLayoutEffect(() => {
6805 if (isMountedByThisTrigger) {
6806 store.update({
6807 activeTriggerElement: triggerElementRef.current,
6808 ...stateUpdates
6809 });
6810 }
6811 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
6812 return {
6813 registerTrigger,
6814 isMountedByThisTrigger
6815 };
6816 }
6817 function useImplicitActiveTrigger(store, options = {}) {
6818 const {
6819 closeOnActiveTriggerUnmount = false
6820 } = options;
6821 const open = store.useState("open");
6822 const reactiveTriggerCount = store.useState("triggerCount");
6823 useIsoLayoutEffect(() => {
6824 if (!open) {
6825 if (store.state.triggerCount !== 0) {
6826 store.set("triggerCount", 0);
6827 }
6828 return;
6829 }
6830 const triggerCount = store.context.triggerElements.size;
6831 const stateUpdates = {};
6832 if (store.state.triggerCount !== triggerCount) {
6833 stateUpdates.triggerCount = triggerCount;
6834 }
6835 const activeTriggerId = store.select("activeTriggerId");
6836 let lostActiveTriggerId = null;
6837 if (activeTriggerId) {
6838 const activeTriggerElement = store.context.triggerElements.getById(activeTriggerId);
6839 if (!activeTriggerElement) {
6840 lostActiveTriggerId = activeTriggerId;
6841 } else if (activeTriggerElement !== store.state.activeTriggerElement) {
6842 stateUpdates.activeTriggerElement = activeTriggerElement;
6843 }
6844 }
6845 if (!lostActiveTriggerId && !activeTriggerId && triggerCount === 1) {
6846 const iteratorResult = store.context.triggerElements.entries().next();
6847 if (!iteratorResult.done) {
6848 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
6849 stateUpdates.activeTriggerId = implicitTriggerId;
6850 stateUpdates.activeTriggerElement = implicitTriggerElement;
6851 }
6852 }
6853 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0 || stateUpdates.activeTriggerElement !== void 0) {
6854 store.update(stateUpdates);
6855 }
6856 if (lostActiveTriggerId) {
6857 if (closeOnActiveTriggerUnmount) {
6858 queueMicrotask(() => {
6859 if (store.select("open") && store.select("activeTriggerId") === lostActiveTriggerId && !store.context.triggerElements.getById(lostActiveTriggerId)) {
6860 const eventDetails = createChangeEventDetails(reason_parts_exports.none);
6861 store.setOpen(false, eventDetails);
6862 if (!eventDetails.isCanceled) {
6863 store.update({
6864 activeTriggerId: null,
6865 activeTriggerElement: null
6866 });
6867 }
6868 }
6869 });
6870 }
6871 }
6872 }, [open, store, reactiveTriggerCount, closeOnActiveTriggerUnmount]);
6873 }
6874 function useOpenStateTransitions(open, store, onUnmount) {
6875 const {
6876 mounted,
6877 setMounted,
6878 transitionStatus
6879 } = useTransitionStatus(open);
6880 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
6881 const syncedPreventUnmountingOnClose = open ? false : preventUnmountingOnClose;
6882 store.useSyncedValues({
6883 mounted,
6884 transitionStatus,
6885 preventUnmountingOnClose: syncedPreventUnmountingOnClose
6886 });
6887 const forceUnmount = useStableCallback(() => {
6888 setMounted(false);
6889 store.update({
6890 activeTriggerId: null,
6891 activeTriggerElement: null,
6892 mounted: false,
6893 preventUnmountingOnClose: false
6894 });
6895 onUnmount?.();
6896 store.context.onOpenChangeComplete?.(false);
6897 });
6898 useOpenChangeComplete({
6899 enabled: mounted && !open && !syncedPreventUnmountingOnClose,
6900 open,
6901 ref: store.context.popupRef,
6902 onComplete() {
6903 if (!open) {
6904 forceUnmount();
6905 }
6906 }
6907 });
6908 return {
6909 forceUnmount,
6910 transitionStatus
6911 };
6912 }
6913 function usePopupInteractionProps(store, statePart) {
6914 store.useSyncedValues(statePart);
6915 useIsoLayoutEffect(() => () => {
6916 store.update({
6917 activeTriggerProps: EMPTY_OBJECT,
6918 inactiveTriggerProps: EMPTY_OBJECT,
6919 popupProps: EMPTY_OBJECT
6920 });
6921 }, [store]);
6922 }
6923
6924 // node_modules/@base-ui/react/utils/popups/popupTriggerMap.mjs
6925 var PopupTriggerMap = class {
6926 constructor() {
6927 this.elementsSet = /* @__PURE__ */ new Set();
6928 this.idMap = /* @__PURE__ */ new Map();
6929 }
6930 /**
6931 * Adds a trigger element with the given ID.
6932 *
6933 * Note: The provided element is assumed to not be registered under multiple IDs.
6934 */
6935 add(id, element) {
6936 const existingElement = this.idMap.get(id);
6937 if (existingElement === element) {
6938 return;
6939 }
6940 if (existingElement !== void 0) {
6941 this.elementsSet.delete(existingElement);
6942 }
6943 this.elementsSet.add(element);
6944 this.idMap.set(id, element);
6945 if (true) {
6946 if (this.elementsSet.size !== this.idMap.size) {
6947 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
6948 }
6949 }
6950 }
6951 /**
6952 * Removes the trigger element with the given ID.
6953 */
6954 delete(id) {
6955 const element = this.idMap.get(id);
6956 if (element) {
6957 this.elementsSet.delete(element);
6958 this.idMap.delete(id);
6959 }
6960 }
6961 /**
6962 * Whether the given element is registered as a trigger.
6963 */
6964 hasElement(element) {
6965 return this.elementsSet.has(element);
6966 }
6967 /**
6968 * Whether there is a registered trigger element matching the given predicate.
6969 */
6970 hasMatchingElement(predicate) {
6971 for (const element of this.elementsSet) {
6972 if (predicate(element)) {
6973 return true;
6974 }
6975 }
6976 return false;
6977 }
6978 /**
6979 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
6980 */
6981 getById(id) {
6982 return this.idMap.get(id);
6983 }
6984 /**
6985 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
6986 */
6987 entries() {
6988 return this.idMap.entries();
6989 }
6990 /**
6991 * Returns an iterable of all registered trigger elements.
6992 */
6993 elements() {
6994 return this.elementsSet.values();
6995 }
6996 /**
6997 * Returns the number of registered trigger elements.
6998 */
6999 get size() {
7000 return this.idMap.size;
7001 }
7002 };
7003
7004 // node_modules/@base-ui/react/floating-ui-react/utils/getEmptyRootContext.mjs
7005 function getEmptyRootContext() {
7006 return new FloatingRootStore({
7007 open: false,
7008 transitionStatus: void 0,
7009 floatingElement: null,
7010 referenceElement: null,
7011 triggerElements: new PopupTriggerMap(),
7012 floatingId: void 0,
7013 syncOnly: false,
7014 nested: false,
7015 onOpenChange: void 0
7016 });
7017 }
7018
7019 // node_modules/@base-ui/react/utils/popups/store.mjs
7020 function createInitialPopupStoreState() {
7021 return {
7022 open: false,
7023 openProp: void 0,
7024 mounted: false,
7025 transitionStatus: void 0,
7026 floatingRootContext: getEmptyRootContext(),
7027 floatingId: void 0,
7028 triggerCount: 0,
7029 preventUnmountingOnClose: false,
7030 payload: void 0,
7031 activeTriggerId: null,
7032 activeTriggerElement: null,
7033 triggerIdProp: void 0,
7034 popupElement: null,
7035 positionerElement: null,
7036 activeTriggerProps: EMPTY_OBJECT,
7037 inactiveTriggerProps: EMPTY_OBJECT,
7038 popupProps: EMPTY_OBJECT
7039 };
7040 }
7041 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) {
7042 return new FloatingRootStore({
7043 open: false,
7044 transitionStatus: void 0,
7045 floatingElement: null,
7046 referenceElement: null,
7047 triggerElements,
7048 floatingId,
7049 syncOnly: true,
7050 nested,
7051 onOpenChange: void 0
7052 });
7053 }
7054 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
7055 var openSelector = createSelector((state) => state.openProp ?? state.open);
7056 var popupIdSelector = createSelector((state) => {
7057 const popupId = state.popupElement?.id ?? state.floatingId;
7058 return popupId || void 0;
7059 });
7060 function triggerOwnsOpenPopup(state, triggerId) {
7061 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
7062 }
7063 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
7064 if (triggerOwnsOpenPopup(state, triggerId)) {
7065 return true;
7066 }
7067 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
7068 }
7069 var popupStoreSelectors = {
7070 open: openSelector,
7071 mounted: createSelector((state) => state.mounted),
7072 transitionStatus: createSelector((state) => state.transitionStatus),
7073 floatingRootContext: createSelector((state) => state.floatingRootContext),
7074 triggerCount: createSelector((state) => state.triggerCount),
7075 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
7076 payload: createSelector((state) => state.payload),
7077 activeTriggerId: activeTriggerIdSelector,
7078 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
7079 popupId: popupIdSelector,
7080 /**
7081 * Whether the trigger with the given ID was used to open the popup.
7082 */
7083 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
7084 /**
7085 * Whether the popup is open and was activated by a trigger with the given ID.
7086 */
7087 isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)),
7088 /**
7089 * Whether the popup is mounted and was activated by a trigger with the given ID.
7090 */
7091 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
7092 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
7093 /**
7094 * Popup id for the trigger that currently owns the open popup.
7095 */
7096 triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0),
7097 popupProps: createSelector((state) => state.popupProps),
7098 popupElement: createSelector((state) => state.popupElement),
7099 positionerElement: createSelector((state) => state.positionerElement)
7100 };
7101
7102 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloatingRootContext.mjs
7103 function useFloatingRootContext(options) {
7104 const {
7105 open = false,
7106 onOpenChange,
7107 elements = {}
7108 } = options;
7109 const floatingId = useId();
7110 const nested = useFloatingParentNodeId() != null;
7111 if (true) {
7112 const optionDomReference = elements.reference;
7113 if (optionDomReference && !isElement(optionDomReference)) {
7114 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
7115 }
7116 }
7117 const store = useRefWithInit(() => new FloatingRootStore({
7118 open,
7119 transitionStatus: void 0,
7120 onOpenChange,
7121 referenceElement: elements.reference ?? null,
7122 floatingElement: elements.floating ?? null,
7123 triggerElements: new PopupTriggerMap(),
7124 floatingId,
7125 syncOnly: false,
7126 nested
7127 })).current;
7128 useIsoLayoutEffect(() => {
7129 const valuesToSync = {
7130 open,
7131 floatingId
7132 };
7133 if (elements.reference !== void 0) {
7134 valuesToSync.referenceElement = elements.reference;
7135 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
7136 }
7137 if (elements.floating !== void 0) {
7138 valuesToSync.floatingElement = elements.floating;
7139 }
7140 store.update(valuesToSync);
7141 }, [open, floatingId, elements.reference, elements.floating, store]);
7142 store.context.onOpenChange = onOpenChange;
7143 store.context.nested = nested;
7144 return store;
7145 }
7146
7147 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs
7148 function useFloating2(options = {}) {
7149 const {
7150 nodeId,
7151 externalTree
7152 } = options;
7153 const internalStore = useFloatingRootContext(options);
7154 const store = options.rootContext || internalStore;
7155 const referenceElement = store.useState("referenceElement");
7156 const floatingElement = store.useState("floatingElement");
7157 const domReferenceElement = store.useState("domReferenceElement");
7158 const open = store.useState("open");
7159 const floatingId = store.useState("floatingId");
7160 const [positionReference, setPositionReferenceRaw] = React25.useState(null);
7161 const [localDomReference, setLocalDomReference] = React25.useState(void 0);
7162 const [localFloatingElement, setLocalFloatingElement] = React25.useState(void 0);
7163 const domReferenceRef = React25.useRef(null);
7164 const tree = useFloatingTree(externalTree);
7165 const storeElements = React25.useMemo(() => ({
7166 reference: referenceElement,
7167 floating: floatingElement,
7168 domReference: domReferenceElement
7169 }), [referenceElement, floatingElement, domReferenceElement]);
7170 const position = useFloating({
7171 ...options,
7172 elements: {
7173 ...storeElements,
7174 ...positionReference && {
7175 reference: positionReference
7176 }
7177 }
7178 });
7179 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
7180 const syncedFloatingElement = localFloatingElement === void 0 ? store.state.floatingElement : localFloatingElement;
7181 store.useSyncedValue("referenceElement", localDomReference ?? null);
7182 store.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement);
7183 store.useSyncedValue("floatingElement", syncedFloatingElement);
7184 const setPositionReference = React25.useCallback((node) => {
7185 const computedPositionReference = isElement(node) ? {
7186 getBoundingClientRect: () => node.getBoundingClientRect(),
7187 getClientRects: () => node.getClientRects(),
7188 contextElement: node
7189 } : node;
7190 setPositionReferenceRaw(computedPositionReference);
7191 position.refs.setReference(computedPositionReference);
7192 }, [position.refs]);
7193 const setReference = React25.useCallback((node) => {
7194 if (isElement(node) || node === null) {
7195 domReferenceRef.current = node;
7196 setLocalDomReference(node);
7197 }
7198 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
7199 // `null` to support `positionReference` + an unstable `reference`
7200 // callback ref.
7201 node !== null && !isElement(node)) {
7202 position.refs.setReference(node);
7203 }
7204 }, [position.refs, setLocalDomReference]);
7205 const setFloating = React25.useCallback((node) => {
7206 setLocalFloatingElement(node);
7207 position.refs.setFloating(node);
7208 }, [position.refs]);
7209 const refs = React25.useMemo(() => ({
7210 ...position.refs,
7211 setReference,
7212 setFloating,
7213 setPositionReference,
7214 domReference: domReferenceRef
7215 }), [position.refs, setReference, setFloating, setPositionReference]);
7216 const elements = React25.useMemo(() => ({
7217 ...position.elements,
7218 domReference: domReferenceElement
7219 }), [position.elements, domReferenceElement]);
7220 const context = React25.useMemo(() => ({
7221 ...position,
7222 dataRef: store.context.dataRef,
7223 open,
7224 onOpenChange: store.setOpen,
7225 events: store.context.events,
7226 floatingId,
7227 refs,
7228 elements,
7229 nodeId,
7230 rootStore: store
7231 }), [position, refs, elements, nodeId, store, open, floatingId]);
7232 useIsoLayoutEffect(() => {
7233 if (domReferenceElement) {
7234 domReferenceRef.current = domReferenceElement;
7235 }
7236 }, [domReferenceElement]);
7237 useIsoLayoutEffect(() => {
7238 store.context.dataRef.current.floatingContext = context;
7239 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
7240 if (node) {
7241 node.context = context;
7242 }
7243 });
7244 return React25.useMemo(() => ({
7245 ...position,
7246 context,
7247 refs,
7248 elements,
7249 rootStore: store
7250 }), [position, refs, elements, context, store]);
7251 }
7252
7253 // node_modules/@base-ui/react/floating-ui-react/hooks/useFocus.mjs
7254 var React26 = __toESM(require_react(), 1);
7255 var isMacSafari = parts_exports.os.mac && parts_exports.engine.webkit;
7256 function useFocus(context, props = {}) {
7257 const {
7258 enabled = true,
7259 delay
7260 } = props;
7261 const store = "rootStore" in context ? context.rootStore : context;
7262 const {
7263 events,
7264 dataRef
7265 } = store.context;
7266 const blockFocusRef = React26.useRef(false);
7267 const blockedReferenceRef = React26.useRef(null);
7268 const keyboardModalityRef = React26.useRef(true);
7269 const timeout = useTimeout();
7270 React26.useEffect(() => {
7271 const domReference = store.select("domReferenceElement");
7272 if (!enabled) {
7273 return void 0;
7274 }
7275 const win = getWindow(domReference);
7276 function onBlur() {
7277 const currentDomReference = store.select("domReferenceElement");
7278 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
7279 blockFocusRef.current = true;
7280 }
7281 }
7282 function onKeyDown() {
7283 keyboardModalityRef.current = true;
7284 }
7285 function onPointerDown() {
7286 keyboardModalityRef.current = false;
7287 }
7288 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
7289 }, [store, enabled]);
7290 React26.useEffect(() => {
7291 if (!enabled) {
7292 return void 0;
7293 }
7294 function onOpenChangeLocal(details) {
7295 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
7296 const referenceElement = store.select("domReferenceElement");
7297 if (isElement(referenceElement)) {
7298 blockedReferenceRef.current = referenceElement;
7299 blockFocusRef.current = true;
7300 }
7301 }
7302 }
7303 events.on("openchange", onOpenChangeLocal);
7304 return () => {
7305 events.off("openchange", onOpenChangeLocal);
7306 };
7307 }, [events, enabled, store]);
7308 const reference = React26.useMemo(() => {
7309 function resetBlockedFocus() {
7310 blockFocusRef.current = false;
7311 blockedReferenceRef.current = null;
7312 }
7313 return {
7314 onMouseLeave() {
7315 resetBlockedFocus();
7316 },
7317 onFocus(event) {
7318 const focusTarget = event.currentTarget;
7319 if (blockFocusRef.current) {
7320 if (blockedReferenceRef.current === focusTarget) {
7321 return;
7322 }
7323 resetBlockedFocus();
7324 }
7325 const target = getTarget(event.nativeEvent);
7326 if (isElement(target)) {
7327 if (isMacSafari && !event.relatedTarget) {
7328 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
7329 return;
7330 }
7331 } else if (!matchesFocusVisible(target)) {
7332 return;
7333 }
7334 }
7335 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
7336 const {
7337 nativeEvent,
7338 currentTarget
7339 } = event;
7340 const delayValue = typeof delay === "function" ? delay() : delay;
7341 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
7342 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
7343 return;
7344 }
7345 timeout.start(delayValue, () => {
7346 if (blockFocusRef.current) {
7347 return;
7348 }
7349 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
7350 });
7351 },
7352 onBlur(event) {
7353 resetBlockedFocus();
7354 const relatedTarget = event.relatedTarget;
7355 const nativeEvent = event.nativeEvent;
7356 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
7357 timeout.start(0, () => {
7358 const domReference = store.select("domReferenceElement");
7359 const activeEl = activeElement(ownerDocument(domReference));
7360 if (!relatedTarget && activeEl === domReference) {
7361 return;
7362 }
7363 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
7364 return;
7365 }
7366 const nextFocusedElement = relatedTarget ?? activeEl;
7367 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
7368 return;
7369 }
7370 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
7371 });
7372 }
7373 };
7374 }, [dataRef, delay, store, timeout]);
7375 return React26.useMemo(() => enabled ? {
7376 reference,
7377 trigger: reference
7378 } : {}, [enabled, reference]);
7379 }
7380
7381 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs
7382 var React27 = __toESM(require_react(), 1);
7383
7384 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverInteractionSharedState.mjs
7385 var HoverInteraction = class _HoverInteraction {
7386 constructor() {
7387 this.pointerType = void 0;
7388 this.interactedInside = false;
7389 this.handler = void 0;
7390 this.blockMouseMove = true;
7391 this.performedPointerEventsMutation = false;
7392 this.pointerEventsScopeElement = null;
7393 this.pointerEventsReferenceElement = null;
7394 this.pointerEventsFloatingElement = null;
7395 this.restTimeoutPending = false;
7396 this.openChangeTimeout = new Timeout();
7397 this.restTimeout = new Timeout();
7398 this.handleCloseOptions = void 0;
7399 }
7400 static create() {
7401 return new _HoverInteraction();
7402 }
7403 dispose = () => {
7404 this.openChangeTimeout.clear();
7405 this.restTimeout.clear();
7406 };
7407 disposeEffect = () => {
7408 return this.dispose;
7409 };
7410 };
7411 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
7412 function clearSafePolygonPointerEventsMutation(instance) {
7413 if (!instance.performedPointerEventsMutation) {
7414 return;
7415 }
7416 const scopeElement = instance.pointerEventsScopeElement;
7417 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
7418 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
7419 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
7420 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
7421 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
7422 }
7423 instance.performedPointerEventsMutation = false;
7424 instance.pointerEventsScopeElement = null;
7425 instance.pointerEventsReferenceElement = null;
7426 instance.pointerEventsFloatingElement = null;
7427 }
7428 function applySafePolygonPointerEventsMutation(instance, options) {
7429 const {
7430 scopeElement,
7431 referenceElement,
7432 floatingElement
7433 } = options;
7434 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
7435 if (existingOwner && existingOwner !== instance) {
7436 clearSafePolygonPointerEventsMutation(existingOwner);
7437 }
7438 clearSafePolygonPointerEventsMutation(instance);
7439 instance.performedPointerEventsMutation = true;
7440 instance.pointerEventsScopeElement = scopeElement;
7441 instance.pointerEventsReferenceElement = referenceElement;
7442 instance.pointerEventsFloatingElement = floatingElement;
7443 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
7444 scopeElement.style.pointerEvents = "none";
7445 referenceElement.style.pointerEvents = "auto";
7446 floatingElement.style.pointerEvents = "auto";
7447 }
7448 function useHoverInteractionSharedState(store) {
7449 const data = store.context.dataRef.current;
7450 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current;
7451 if (!data.hoverInteractionState) {
7452 data.hoverInteractionState = instance;
7453 }
7454 useOnMount(data.hoverInteractionState.disposeEffect);
7455 return data.hoverInteractionState;
7456 }
7457
7458 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs
7459 function useHoverFloatingInteraction(context, parameters = {}) {
7460 const {
7461 enabled = true,
7462 closeDelay: closeDelayProp = 0,
7463 nodeId: nodeIdProp
7464 } = parameters;
7465 const store = "rootStore" in context ? context.rootStore : context;
7466 const open = store.useState("open");
7467 const floatingElement = store.useState("floatingElement");
7468 const domReferenceElement = store.useState("domReferenceElement");
7469 const {
7470 dataRef
7471 } = store.context;
7472 const tree = useFloatingTree();
7473 const parentId = useFloatingParentNodeId();
7474 const instance = useHoverInteractionSharedState(store);
7475 const childClosedTimeout = useTimeout();
7476 const isClickLikeOpenEvent2 = useStableCallback(() => {
7477 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7478 });
7479 const isHoverOpen = useStableCallback(() => {
7480 return isHoverOpenEvent(dataRef.current.openEvent?.type);
7481 });
7482 const clearPointerEvents = useStableCallback(() => {
7483 clearSafePolygonPointerEventsMutation(instance);
7484 });
7485 useIsoLayoutEffect(() => {
7486 if (!open) {
7487 instance.pointerType = void 0;
7488 instance.restTimeoutPending = false;
7489 instance.interactedInside = false;
7490 clearPointerEvents();
7491 }
7492 }, [open, instance, clearPointerEvents]);
7493 React27.useEffect(() => {
7494 return clearPointerEvents;
7495 }, [clearPointerEvents]);
7496 useIsoLayoutEffect(() => {
7497 if (!enabled) {
7498 return void 0;
7499 }
7500 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
7501 const ref = domReferenceElement;
7502 const floatingEl = floatingElement;
7503 const doc = ownerDocument(floatingElement);
7504 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
7505 if (parentFloating) {
7506 parentFloating.style.pointerEvents = "";
7507 }
7508 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
7509 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
7510 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
7511 applySafePolygonPointerEventsMutation(instance, {
7512 scopeElement,
7513 referenceElement: ref,
7514 floatingElement: floatingEl
7515 });
7516 return () => {
7517 clearPointerEvents();
7518 };
7519 }
7520 return void 0;
7521 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
7522 React27.useEffect(() => {
7523 if (!enabled) {
7524 return void 0;
7525 }
7526 function hasParentChildren() {
7527 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0);
7528 }
7529 function closeWithDelay(event) {
7530 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
7531 const close = () => {
7532 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7533 tree?.events.emit("floating.closed", event);
7534 };
7535 if (closeDelay) {
7536 instance.openChangeTimeout.start(closeDelay, close);
7537 } else {
7538 instance.openChangeTimeout.clear();
7539 close();
7540 }
7541 }
7542 function handleInteractInside(event) {
7543 const target = getTarget(event);
7544 if (!isInteractiveElement(target)) {
7545 instance.interactedInside = false;
7546 return;
7547 }
7548 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
7549 }
7550 function onFloatingMouseEnter() {
7551 instance.openChangeTimeout.clear();
7552 childClosedTimeout.clear();
7553 tree?.events.off("floating.closed", onNodeClosed);
7554 clearPointerEvents();
7555 }
7556 function onFloatingMouseLeave(event) {
7557 if (hasParentChildren() && tree) {
7558 tree.events.on("floating.closed", onNodeClosed);
7559 return;
7560 }
7561 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
7562 return;
7563 }
7564 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
7565 const relatedTarget = event.relatedTarget;
7566 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
7567 if (isMovingIntoDescendantFloating) {
7568 return;
7569 }
7570 if (instance.handler) {
7571 instance.handler(event);
7572 return;
7573 }
7574 clearPointerEvents();
7575 if (isHoverOpen() && !isClickLikeOpenEvent2()) {
7576 closeWithDelay(event);
7577 }
7578 }
7579 function onNodeClosed(event) {
7580 if (!tree || !parentId || hasParentChildren()) {
7581 return;
7582 }
7583 childClosedTimeout.start(0, () => {
7584 tree.events.off("floating.closed", onNodeClosed);
7585 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7586 tree.events.emit("floating.closed", event);
7587 });
7588 }
7589 const floating = floatingElement;
7590 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
7591 tree?.events.off("floating.closed", onNodeClosed);
7592 });
7593 }, [enabled, floatingElement, store, dataRef, closeDelayProp, nodeIdProp, isHoverOpen, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]);
7594 }
7595
7596 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverReferenceInteraction.mjs
7597 var React28 = __toESM(require_react(), 1);
7598 var ReactDOM5 = __toESM(require_react_dom(), 1);
7599 var EMPTY_REF = {
7600 current: null
7601 };
7602 function useHoverReferenceInteraction(context, props = {}) {
7603 const {
7604 enabled = true,
7605 delay = 0,
7606 handleClose = null,
7607 mouseOnly = false,
7608 restMs = 0,
7609 move = true,
7610 triggerElementRef = EMPTY_REF,
7611 externalTree,
7612 isActiveTrigger = true,
7613 getHandleCloseContext,
7614 isClosing,
7615 shouldOpen: shouldOpenProp
7616 } = props;
7617 const store = "rootStore" in context ? context.rootStore : context;
7618 const {
7619 dataRef,
7620 events
7621 } = store.context;
7622 const tree = useFloatingTree(externalTree);
7623 const instance = useHoverInteractionSharedState(store);
7624 const isHoverCloseActiveRef = React28.useRef(false);
7625 const handleCloseRef = useValueAsRef(handleClose);
7626 const delayRef = useValueAsRef(delay);
7627 const restMsRef = useValueAsRef(restMs);
7628 const enabledRef = useValueAsRef(enabled);
7629 const shouldOpenRef = useValueAsRef(shouldOpenProp);
7630 const isClosingRef = useValueAsRef(isClosing);
7631 const isClickLikeOpenEvent2 = useStableCallback(() => {
7632 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7633 });
7634 const checkShouldOpen = useStableCallback(() => {
7635 return shouldOpenRef.current?.() !== false;
7636 });
7637 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
7638 const allTriggers = store.context.triggerElements;
7639 if (allTriggers.hasElement(currentTarget)) {
7640 return !currentDomReference || !contains(currentDomReference, currentTarget);
7641 }
7642 if (!isElement(target)) {
7643 return false;
7644 }
7645 const targetElement = target;
7646 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
7647 });
7648 const cleanupMouseMoveHandler = useStableCallback(() => {
7649 if (!instance.handler) {
7650 return;
7651 }
7652 const doc = ownerDocument(store.select("domReferenceElement"));
7653 doc.removeEventListener("mousemove", instance.handler);
7654 instance.handler = void 0;
7655 });
7656 const clearPointerEvents = useStableCallback(() => {
7657 clearSafePolygonPointerEventsMutation(instance);
7658 });
7659 if (isActiveTrigger) {
7660 instance.handleCloseOptions = handleCloseRef.current?.__options;
7661 }
7662 React28.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
7663 React28.useEffect(() => {
7664 if (!enabled) {
7665 return void 0;
7666 }
7667 function onOpenChangeLocal(details) {
7668 if (!details.open) {
7669 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
7670 cleanupMouseMoveHandler();
7671 instance.openChangeTimeout.clear();
7672 instance.restTimeout.clear();
7673 instance.blockMouseMove = true;
7674 instance.restTimeoutPending = false;
7675 } else {
7676 isHoverCloseActiveRef.current = false;
7677 }
7678 }
7679 events.on("openchange", onOpenChangeLocal);
7680 return () => {
7681 events.off("openchange", onOpenChangeLocal);
7682 };
7683 }, [enabled, events, instance, cleanupMouseMoveHandler]);
7684 React28.useEffect(() => {
7685 if (!enabled) {
7686 return void 0;
7687 }
7688 function closeWithDelay(event, runElseBranch = true) {
7689 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
7690 if (closeDelay) {
7691 instance.openChangeTimeout.start(closeDelay, () => {
7692 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7693 tree?.events.emit("floating.closed", event);
7694 });
7695 } else if (runElseBranch) {
7696 instance.openChangeTimeout.clear();
7697 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7698 tree?.events.emit("floating.closed", event);
7699 }
7700 }
7701 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
7702 if (!isElement(trigger)) {
7703 return void 0;
7704 }
7705 function onMouseEnter(event) {
7706 instance.openChangeTimeout.clear();
7707 instance.blockMouseMove = false;
7708 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7709 return;
7710 }
7711 const restMsValue = getRestMs(restMsRef.current);
7712 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
7713 const eventTarget = getTarget(event);
7714 const currentTarget = event.currentTarget ?? null;
7715 const currentDomReference = store.select("domReferenceElement");
7716 let triggerNode = currentTarget;
7717 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
7718 for (const triggerElement of store.context.triggerElements.elements()) {
7719 if (contains(triggerElement, eventTarget)) {
7720 triggerNode = triggerElement;
7721 break;
7722 }
7723 }
7724 }
7725 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
7726 triggerNode = currentDomReference;
7727 }
7728 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
7729 const isOpen = store.select("open");
7730 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
7731 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
7732 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
7733 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
7734 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
7735 const shouldOpen = !isOpen || isOverInactive;
7736 if (shouldOpenImmediately) {
7737 if (checkShouldOpen()) {
7738 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7739 }
7740 return;
7741 }
7742 if (isRestOnlyDelay) {
7743 return;
7744 }
7745 if (openDelay) {
7746 instance.openChangeTimeout.start(openDelay, () => {
7747 if (shouldOpen && checkShouldOpen()) {
7748 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7749 }
7750 });
7751 } else if (shouldOpen) {
7752 if (checkShouldOpen()) {
7753 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7754 }
7755 }
7756 }
7757 function onMouseLeave(event) {
7758 if (isClickLikeOpenEvent2()) {
7759 clearPointerEvents();
7760 return;
7761 }
7762 cleanupMouseMoveHandler();
7763 const domReferenceElement = store.select("domReferenceElement");
7764 const doc = ownerDocument(domReferenceElement);
7765 instance.restTimeout.clear();
7766 instance.restTimeoutPending = false;
7767 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
7768 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
7769 return;
7770 }
7771 if (handleCloseRef.current && handleCloseContextBase) {
7772 if (!store.select("open")) {
7773 instance.openChangeTimeout.clear();
7774 }
7775 const currentTrigger = triggerElementRef.current;
7776 instance.handler = handleCloseRef.current({
7777 ...handleCloseContextBase,
7778 tree,
7779 x: event.clientX,
7780 y: event.clientY,
7781 onClose() {
7782 clearPointerEvents();
7783 cleanupMouseMoveHandler();
7784 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
7785 closeWithDelay(event, true);
7786 }
7787 }
7788 });
7789 doc.addEventListener("mousemove", instance.handler);
7790 instance.handler(event);
7791 return;
7792 }
7793 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
7794 if (shouldClose) {
7795 closeWithDelay(event);
7796 }
7797 }
7798 if (move) {
7799 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
7800 once: true
7801 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7802 }
7803 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7804 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]);
7805 return React28.useMemo(() => {
7806 if (!enabled) {
7807 return void 0;
7808 }
7809 function setPointerRef(event) {
7810 instance.pointerType = event.pointerType;
7811 }
7812 return {
7813 onPointerDown: setPointerRef,
7814 onPointerEnter: setPointerRef,
7815 onMouseMove(event) {
7816 const {
7817 nativeEvent
7818 } = event;
7819 const trigger = event.currentTarget;
7820 const currentDomReference = store.select("domReferenceElement");
7821 const currentOpen = store.select("open");
7822 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
7823 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7824 return;
7825 }
7826 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
7827 const floatingElement = store.select("floatingElement");
7828 if (floatingElement) {
7829 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
7830 applySafePolygonPointerEventsMutation(instance, {
7831 scopeElement,
7832 referenceElement: trigger,
7833 floatingElement
7834 });
7835 }
7836 }
7837 const restMsValue = getRestMs(restMsRef.current);
7838 if (currentOpen && !isOverInactive || restMsValue === 0) {
7839 return;
7840 }
7841 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
7842 return;
7843 }
7844 instance.restTimeout.clear();
7845 function handleMouseMove() {
7846 instance.restTimeoutPending = false;
7847 if (isClickLikeOpenEvent2()) {
7848 return;
7849 }
7850 const latestOpen = store.select("open");
7851 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
7852 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
7853 }
7854 }
7855 if (instance.pointerType === "touch") {
7856 ReactDOM5.flushSync(() => {
7857 handleMouseMove();
7858 });
7859 } else if (isOverInactive && currentOpen) {
7860 handleMouseMove();
7861 } else {
7862 instance.restTimeoutPending = true;
7863 instance.restTimeout.start(restMsValue, handleMouseMove);
7864 }
7865 }
7866 };
7867 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef, checkShouldOpen]);
7868 }
7869
7870 // node_modules/@base-ui/react/floating-ui-react/safePolygon.mjs
7871 var CURSOR_SPEED_THRESHOLD = 0.1;
7872 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
7873 var POLYGON_BUFFER = 0.5;
7874 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
7875 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
7876 }
7877 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
7878 let isInsideValue = false;
7879 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
7880 isInsideValue = !isInsideValue;
7881 }
7882 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
7883 isInsideValue = !isInsideValue;
7884 }
7885 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
7886 isInsideValue = !isInsideValue;
7887 }
7888 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
7889 isInsideValue = !isInsideValue;
7890 }
7891 return isInsideValue;
7892 }
7893 function isInsideRect(pointX, pointY, rect) {
7894 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
7895 }
7896 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
7897 const minX = Math.min(x1, x2);
7898 const maxX = Math.max(x1, x2);
7899 const minY = Math.min(y1, y2);
7900 const maxY = Math.max(y1, y2);
7901 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
7902 }
7903 function safePolygon(options = {}) {
7904 const {
7905 blockPointerEvents = false
7906 } = options;
7907 const timeout = new Timeout();
7908 const fn = ({
7909 x: x2,
7910 y: y2,
7911 placement,
7912 elements,
7913 onClose,
7914 nodeId,
7915 tree
7916 }) => {
7917 const side = placement?.split("-")[0];
7918 let hasLanded = false;
7919 let lastX = null;
7920 let lastY = null;
7921 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
7922 function isCursorMovingSlowly(nextX, nextY) {
7923 const currentTime = performance.now();
7924 const elapsedTime = currentTime - lastCursorTime;
7925 if (lastX === null || lastY === null || elapsedTime === 0) {
7926 lastX = nextX;
7927 lastY = nextY;
7928 lastCursorTime = currentTime;
7929 return false;
7930 }
7931 const deltaX = nextX - lastX;
7932 const deltaY = nextY - lastY;
7933 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
7934 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
7935 lastX = nextX;
7936 lastY = nextY;
7937 lastCursorTime = currentTime;
7938 return distanceSquared < thresholdSquared;
7939 }
7940 function close() {
7941 timeout.clear();
7942 onClose();
7943 }
7944 return function onMouseMove(event) {
7945 timeout.clear();
7946 const domReference = elements.domReference;
7947 const floating = elements.floating;
7948 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
7949 return void 0;
7950 }
7951 const {
7952 clientX,
7953 clientY
7954 } = event;
7955 const target = getTarget(event);
7956 const isLeave = event.type === "mouseleave";
7957 const isOverFloatingEl = contains(floating, target);
7958 const isOverReferenceEl = contains(domReference, target);
7959 if (isOverFloatingEl) {
7960 hasLanded = true;
7961 if (!isLeave) {
7962 return void 0;
7963 }
7964 }
7965 if (isOverReferenceEl) {
7966 hasLanded = false;
7967 if (!isLeave) {
7968 hasLanded = true;
7969 return void 0;
7970 }
7971 }
7972 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
7973 return void 0;
7974 }
7975 function hasOpenChildNode() {
7976 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
7977 }
7978 function closeIfNoOpenChild() {
7979 if (!hasOpenChildNode()) {
7980 close();
7981 }
7982 }
7983 if (hasOpenChildNode()) {
7984 return void 0;
7985 }
7986 const refRect = domReference.getBoundingClientRect();
7987 const rect = floating.getBoundingClientRect();
7988 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
7989 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
7990 const isFloatingWider = rect.width > refRect.width;
7991 const isFloatingTaller = rect.height > refRect.height;
7992 const left = (isFloatingWider ? refRect : rect).left;
7993 const right = (isFloatingWider ? refRect : rect).right;
7994 const top = (isFloatingTaller ? refRect : rect).top;
7995 const bottom = (isFloatingTaller ? refRect : rect).bottom;
7996 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) {
7997 closeIfNoOpenChild();
7998 return void 0;
7999 }
8000 let isInsideTroughRect = false;
8001 switch (side) {
8002 case "top":
8003 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
8004 break;
8005 case "bottom":
8006 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
8007 break;
8008 case "left":
8009 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
8010 break;
8011 case "right":
8012 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
8013 break;
8014 default:
8015 }
8016 if (isInsideTroughRect) {
8017 return void 0;
8018 }
8019 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
8020 closeIfNoOpenChild();
8021 return void 0;
8022 }
8023 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
8024 closeIfNoOpenChild();
8025 return void 0;
8026 }
8027 let isInsidePolygon = false;
8028 switch (side) {
8029 case "top": {
8030 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8031 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8032 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8033 const cursorPointY = y2 + POLYGON_BUFFER + 1;
8034 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
8035 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
8036 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
8037 break;
8038 }
8039 case "bottom": {
8040 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8041 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8042 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8043 const cursorPointY = y2 - POLYGON_BUFFER;
8044 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
8045 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
8046 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
8047 break;
8048 }
8049 case "left": {
8050 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8051 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8052 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8053 const cursorPointX = x2 + POLYGON_BUFFER + 1;
8054 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
8055 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
8056 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
8057 break;
8058 }
8059 case "right": {
8060 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8061 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8062 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8063 const cursorPointX = x2 - POLYGON_BUFFER;
8064 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
8065 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
8066 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
8067 break;
8068 }
8069 default:
8070 }
8071 if (!isInsidePolygon) {
8072 closeIfNoOpenChild();
8073 } else if (!hasLanded) {
8074 timeout.start(40, closeIfNoOpenChild);
8075 }
8076 return void 0;
8077 };
8078 };
8079 fn.__options = {
8080 ...options,
8081 blockPointerEvents
8082 };
8083 return fn;
8084 }
8085
8086 // node_modules/@base-ui/react/utils/popupStateMapping.mjs
8087 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
8088 CommonPopupDataAttributes2["open"] = "data-open";
8089 CommonPopupDataAttributes2["closed"] = "data-closed";
8090 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
8091 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
8092 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
8093 CommonPopupDataAttributes2["side"] = "data-side";
8094 CommonPopupDataAttributes2["align"] = "data-align";
8095 return CommonPopupDataAttributes2;
8096 })({});
8097 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
8098 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
8099 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
8100 return CommonTriggerDataAttributes2;
8101 })({});
8102 var TRIGGER_HOOK = {
8103 [CommonTriggerDataAttributes.popupOpen]: ""
8104 };
8105 var PRESSABLE_TRIGGER_HOOK = {
8106 [CommonTriggerDataAttributes.popupOpen]: "",
8107 [CommonTriggerDataAttributes.pressed]: ""
8108 };
8109 var POPUP_OPEN_HOOK = {
8110 [CommonPopupDataAttributes.open]: ""
8111 };
8112 var POPUP_CLOSED_HOOK = {
8113 [CommonPopupDataAttributes.closed]: ""
8114 };
8115 var ANCHOR_HIDDEN_HOOK = {
8116 [CommonPopupDataAttributes.anchorHidden]: ""
8117 };
8118 var triggerOpenStateMapping = {
8119 open(value) {
8120 if (value) {
8121 return TRIGGER_HOOK;
8122 }
8123 return null;
8124 }
8125 };
8126 var popupStateMapping = {
8127 open(value) {
8128 if (value) {
8129 return POPUP_OPEN_HOOK;
8130 }
8131 return POPUP_CLOSED_HOOK;
8132 },
8133 anchorHidden(value) {
8134 if (value) {
8135 return ANCHOR_HIDDEN_HOOK;
8136 }
8137 return null;
8138 }
8139 };
8140
8141 // node_modules/@base-ui/utils/inertValue.mjs
8142 function inertValue(value) {
8143 if (isReactVersionAtLeast(19)) {
8144 return value;
8145 }
8146 return value ? "true" : void 0;
8147 }
8148
8149 // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs
8150 var React29 = __toESM(require_react(), 1);
8151
8152 // node_modules/@base-ui/react/floating-ui-react/middleware/arrow.mjs
8153 var baseArrow = (options) => ({
8154 name: "arrow",
8155 options,
8156 async fn(state) {
8157 const {
8158 x: x2,
8159 y: y2,
8160 placement,
8161 rects,
8162 platform: platform3,
8163 elements,
8164 middlewareData
8165 } = state;
8166 const {
8167 element,
8168 padding = 0,
8169 offsetParent = "real"
8170 } = evaluate(options, state) || {};
8171 if (element == null) {
8172 return {};
8173 }
8174 const paddingObject = getPaddingObject(padding);
8175 const coords = {
8176 x: x2,
8177 y: y2
8178 };
8179 const axis = getAlignmentAxis(placement);
8180 const length = getAxisLength(axis);
8181 const arrowDimensions = await platform3.getDimensions(element);
8182 const isYAxis = axis === "y";
8183 const minProp = isYAxis ? "top" : "left";
8184 const maxProp = isYAxis ? "bottom" : "right";
8185 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
8186 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
8187 const startDiff = coords[axis] - rects.reference[axis];
8188 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
8189 let clientSize = elements.floating[clientProp] || rects.floating[length];
8190 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
8191 clientSize = elements.floating[clientProp] || rects.floating[length];
8192 }
8193 const centerToReference = endDiff / 2 - startDiff / 2;
8194 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
8195 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
8196 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
8197 const min2 = minPadding;
8198 const max2 = clientSize - arrowDimensions[length] - maxPadding;
8199 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
8200 const offset4 = clamp(min2, center, max2);
8201 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
8202 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
8203 return {
8204 [axis]: coords[axis] + alignmentOffset,
8205 data: {
8206 [axis]: offset4,
8207 centerOffset: center - offset4 - alignmentOffset,
8208 ...shouldAddOffset && {
8209 alignmentOffset
8210 }
8211 },
8212 reset: shouldAddOffset
8213 };
8214 }
8215 });
8216 var arrow4 = (options, deps) => ({
8217 ...baseArrow(options),
8218 options: [options, deps]
8219 });
8220
8221 // node_modules/@base-ui/react/utils/hideMiddleware.mjs
8222 var nativeHideFn = hide3().fn;
8223 var hide4 = {
8224 name: "hide",
8225 async fn(state) {
8226 const {
8227 width,
8228 height,
8229 x: x2,
8230 y: y2
8231 } = state.rects.reference;
8232 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
8233 const nativeHideResult = await nativeHideFn(state);
8234 return {
8235 data: {
8236 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
8237 }
8238 };
8239 }
8240 };
8241
8242 // node_modules/@base-ui/react/utils/adaptiveOriginMiddleware.mjs
8243 var DEFAULT_SIDES = {
8244 sideX: "left",
8245 sideY: "top"
8246 };
8247 var adaptiveOrigin = {
8248 name: "adaptiveOrigin",
8249 async fn(state) {
8250 const {
8251 x: rawX,
8252 y: rawY,
8253 rects: {
8254 floating: floatRect
8255 },
8256 elements: {
8257 floating
8258 },
8259 platform: platform3,
8260 strategy,
8261 placement
8262 } = state;
8263 const win = getWindow(floating);
8264 const styles = win.getComputedStyle(floating);
8265 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
8266 if (!hasTransition) {
8267 return {
8268 x: rawX,
8269 y: rawY,
8270 data: DEFAULT_SIDES
8271 };
8272 }
8273 const offsetParent = await platform3.getOffsetParent?.(floating);
8274 let offsetDimensions = {
8275 width: 0,
8276 height: 0
8277 };
8278 if (strategy === "fixed" && win?.visualViewport) {
8279 offsetDimensions = {
8280 width: win.visualViewport.width,
8281 height: win.visualViewport.height
8282 };
8283 } else if (offsetParent === win) {
8284 const doc = ownerDocument(floating);
8285 offsetDimensions = {
8286 width: doc.documentElement.clientWidth,
8287 height: doc.documentElement.clientHeight
8288 };
8289 } else if (await platform3.isElement?.(offsetParent)) {
8290 offsetDimensions = await platform3.getDimensions(offsetParent);
8291 }
8292 const currentSide = getSide(placement);
8293 let x2 = rawX;
8294 let y2 = rawY;
8295 if (currentSide === "left") {
8296 x2 = offsetDimensions.width - (rawX + floatRect.width);
8297 }
8298 if (currentSide === "top") {
8299 y2 = offsetDimensions.height - (rawY + floatRect.height);
8300 }
8301 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
8302 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
8303 return {
8304 x: x2,
8305 y: y2,
8306 data: {
8307 sideX,
8308 sideY
8309 }
8310 };
8311 }
8312 };
8313
8314 // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs
8315 function getLogicalSide(sideParam, renderedSide, isRtl) {
8316 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
8317 const logicalRight = isRtl ? "inline-start" : "inline-end";
8318 const logicalLeft = isRtl ? "inline-end" : "inline-start";
8319 return {
8320 top: "top",
8321 right: isLogicalSideParam ? logicalRight : "right",
8322 bottom: "bottom",
8323 left: isLogicalSideParam ? logicalLeft : "left"
8324 }[renderedSide];
8325 }
8326 function getOffsetData(state, sideParam, isRtl) {
8327 const {
8328 rects,
8329 placement
8330 } = state;
8331 const data = {
8332 side: getLogicalSide(sideParam, getSide(placement), isRtl),
8333 align: getAlignment(placement) || "center",
8334 anchor: {
8335 width: rects.reference.width,
8336 height: rects.reference.height
8337 },
8338 positioner: {
8339 width: rects.floating.width,
8340 height: rects.floating.height
8341 }
8342 };
8343 return data;
8344 }
8345 function useAnchorPositioning(params) {
8346 const {
8347 // Public parameters
8348 anchor,
8349 positionMethod = "absolute",
8350 side: sideParam = "bottom",
8351 sideOffset = 0,
8352 align = "center",
8353 alignOffset = 0,
8354 collisionBoundary,
8355 collisionPadding: collisionPaddingParam = 5,
8356 sticky = false,
8357 arrowPadding = 5,
8358 disableAnchorTracking = false,
8359 inline: inlineMiddleware,
8360 // Private parameters
8361 keepMounted = false,
8362 floatingRootContext,
8363 mounted,
8364 collisionAvoidance,
8365 shiftCrossAxis = false,
8366 nodeId,
8367 adaptiveOrigin: adaptiveOrigin2,
8368 lazyFlip = false,
8369 externalTree
8370 } = params;
8371 const [mountSide, setMountSide] = React29.useState(null);
8372 if (!mounted && mountSide !== null) {
8373 setMountSide(null);
8374 }
8375 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
8376 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
8377 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
8378 const anchorFn = typeof anchor === "function" ? anchor : void 0;
8379 const anchorFnCallback = useStableCallback(anchorFn);
8380 const anchorDep = anchorFn ? anchorFnCallback : anchor;
8381 const anchorValueRef = useValueAsRef(anchor);
8382 const mountedRef = useValueAsRef(mounted);
8383 const direction = useDirection();
8384 const isRtl = direction === "rtl";
8385 const side = mountSide || {
8386 top: "top",
8387 right: "right",
8388 bottom: "bottom",
8389 left: "left",
8390 "inline-end": isRtl ? "left" : "right",
8391 "inline-start": isRtl ? "right" : "left"
8392 }[sideParam];
8393 const placement = align === "center" ? side : `${side}-${align}`;
8394 let collisionPadding = collisionPaddingParam;
8395 const bias = 1;
8396 const biasTop = sideParam === "bottom" ? bias : 0;
8397 const biasBottom = sideParam === "top" ? bias : 0;
8398 const biasLeft = sideParam === "right" ? bias : 0;
8399 const biasRight = sideParam === "left" ? bias : 0;
8400 if (typeof collisionPadding === "number") {
8401 collisionPadding = {
8402 top: collisionPadding + biasTop,
8403 right: collisionPadding + biasRight,
8404 bottom: collisionPadding + biasBottom,
8405 left: collisionPadding + biasLeft
8406 };
8407 } else if (collisionPadding) {
8408 collisionPadding = {
8409 top: (collisionPadding.top || 0) + biasTop,
8410 right: (collisionPadding.right || 0) + biasRight,
8411 bottom: (collisionPadding.bottom || 0) + biasBottom,
8412 left: (collisionPadding.left || 0) + biasLeft
8413 };
8414 }
8415 const commonCollisionProps = {
8416 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
8417 padding: collisionPadding
8418 };
8419 const arrowRef = React29.useRef(null);
8420 const sideOffsetRef = useValueAsRef(sideOffset);
8421 const alignOffsetRef = useValueAsRef(alignOffset);
8422 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
8423 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
8424 const middleware = [];
8425 if (inlineMiddleware) {
8426 middleware.push(inlineMiddleware);
8427 }
8428 middleware.push(offset3((state) => {
8429 const data = getOffsetData(state, sideParam, isRtl);
8430 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
8431 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
8432 return {
8433 mainAxis: sideAxis,
8434 crossAxis: alignAxis,
8435 alignmentAxis: alignAxis
8436 };
8437 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
8438 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
8439 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
8440 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
8441 ...commonCollisionProps,
8442 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
8443 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
8444 padding: {
8445 top: collisionPadding.top + bias,
8446 right: collisionPadding.right + bias,
8447 bottom: collisionPadding.bottom + bias,
8448 left: collisionPadding.left + bias
8449 },
8450 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
8451 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
8452 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
8453 });
8454 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
8455 const html = ownerDocument(data.elements.floating).documentElement;
8456 return {
8457 ...commonCollisionProps,
8458 // Use the Layout Viewport to avoid shifting around when pinch-zooming
8459 // for context menus.
8460 rootBoundary: shiftCrossAxis ? {
8461 x: 0,
8462 y: 0,
8463 width: html.clientWidth,
8464 height: html.clientHeight
8465 } : void 0,
8466 mainAxis: collisionAvoidanceAlign !== "none",
8467 crossAxis: crossAxisShiftEnabled,
8468 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
8469 if (!arrowRef.current) {
8470 return {};
8471 }
8472 const {
8473 width,
8474 height
8475 } = arrowRef.current.getBoundingClientRect();
8476 const sideAxis = getSideAxis(getSide(limitData.placement));
8477 const arrowSize = sideAxis === "y" ? width : height;
8478 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
8479 return {
8480 offset: arrowSize / 2 + offsetAmount / 2
8481 };
8482 })
8483 };
8484 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
8485 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
8486 middleware.push(shiftMiddleware, flipMiddleware);
8487 } else {
8488 middleware.push(flipMiddleware, shiftMiddleware);
8489 }
8490 middleware.push(size3({
8491 ...commonCollisionProps,
8492 apply({
8493 elements: {
8494 floating
8495 },
8496 availableWidth,
8497 availableHeight,
8498 rects
8499 }) {
8500 if (!mountedRef.current) {
8501 return;
8502 }
8503 const floatingStyle = floating.style;
8504 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
8505 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
8506 const dpr = getWindow(floating).devicePixelRatio || 1;
8507 const {
8508 x: x3,
8509 y: y3,
8510 width,
8511 height
8512 } = rects.reference;
8513 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
8514 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
8515 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
8516 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
8517 }
8518 }), arrow4((state) => ({
8519 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
8520 // we'll create a fake element.
8521 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"),
8522 padding: arrowPadding,
8523 offsetParent: "floating"
8524 }), [arrowPadding]), {
8525 name: "transformOrigin",
8526 fn(state) {
8527 const {
8528 elements: elements2,
8529 middlewareData: middlewareData2,
8530 placement: renderedPlacement2,
8531 rects,
8532 y: y3
8533 } = state;
8534 const currentRenderedSide = getSide(renderedPlacement2);
8535 const currentRenderedAxis = getSideAxis(currentRenderedSide);
8536 const arrowEl = arrowRef.current;
8537 const arrowX = middlewareData2.arrow?.x || 0;
8538 const arrowY = middlewareData2.arrow?.y || 0;
8539 const arrowWidth = arrowEl?.clientWidth || 0;
8540 const arrowHeight = arrowEl?.clientHeight || 0;
8541 const transformX = arrowX + arrowWidth / 2;
8542 const transformY = arrowY + arrowHeight / 2;
8543 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
8544 const halfAnchorHeight = rects.reference.height / 2;
8545 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
8546 const isOverlappingAnchor = shiftY > sideOffsetValue;
8547 const adjacentTransformOrigin = {
8548 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
8549 bottom: `${transformX}px ${-sideOffsetValue}px`,
8550 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
8551 right: `${-sideOffsetValue}px ${transformY}px`
8552 }[currentRenderedSide];
8553 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
8554 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
8555 return {};
8556 }
8557 }, hide4, adaptiveOrigin2);
8558 useIsoLayoutEffect(() => {
8559 if (!mounted && floatingRootContext) {
8560 floatingRootContext.update({
8561 referenceElement: null,
8562 floatingElement: null,
8563 domReferenceElement: null,
8564 positionReference: null
8565 });
8566 }
8567 }, [mounted, floatingRootContext]);
8568 const autoUpdateOptions = React29.useMemo(() => ({
8569 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
8570 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
8571 }), [disableAnchorTracking]);
8572 const {
8573 refs,
8574 elements,
8575 x: x2,
8576 y: y2,
8577 middlewareData,
8578 update: update2,
8579 placement: renderedPlacement,
8580 context,
8581 isPositioned,
8582 floatingStyles: originalFloatingStyles
8583 } = useFloating2({
8584 rootContext: floatingRootContext,
8585 open: keepMounted ? mounted : void 0,
8586 placement,
8587 middleware,
8588 strategy: positionMethod,
8589 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
8590 nodeId,
8591 externalTree
8592 });
8593 const {
8594 sideX,
8595 sideY
8596 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
8597 const resolvedPosition = isPositioned ? positionMethod : "fixed";
8598 const floatingStyles = React29.useMemo(() => {
8599 const base = adaptiveOrigin2 ? {
8600 position: resolvedPosition,
8601 [sideX]: x2,
8602 [sideY]: y2
8603 } : {
8604 position: resolvedPosition,
8605 ...originalFloatingStyles
8606 };
8607 if (!isPositioned) {
8608 base.opacity = 0;
8609 }
8610 return base;
8611 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
8612 const registeredPositionReferenceRef = React29.useRef(null);
8613 useIsoLayoutEffect(() => {
8614 if (!mounted) {
8615 return;
8616 }
8617 const anchorValue = anchorValueRef.current;
8618 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
8619 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
8620 const finalAnchor = unwrappedElement || null;
8621 if (finalAnchor !== registeredPositionReferenceRef.current) {
8622 refs.setPositionReference(finalAnchor);
8623 registeredPositionReferenceRef.current = finalAnchor;
8624 }
8625 }, [mounted, refs, anchorDep, anchorValueRef]);
8626 React29.useEffect(() => {
8627 if (!mounted) {
8628 return;
8629 }
8630 const anchorValue = anchorValueRef.current;
8631 if (typeof anchorValue === "function") {
8632 return;
8633 }
8634 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
8635 refs.setPositionReference(anchorValue.current);
8636 registeredPositionReferenceRef.current = anchorValue.current;
8637 }
8638 }, [mounted, refs, anchorDep, anchorValueRef]);
8639 React29.useEffect(() => {
8640 if (keepMounted && mounted && elements.reference && elements.floating) {
8641 return autoUpdate(elements.reference, elements.floating, update2, autoUpdateOptions);
8642 }
8643 return void 0;
8644 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
8645 const renderedSide = getSide(renderedPlacement);
8646 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
8647 const renderedAlign = getAlignment(renderedPlacement) || "center";
8648 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
8649 useIsoLayoutEffect(() => {
8650 if (lazyFlip && mounted && isPositioned) {
8651 setMountSide(renderedSide);
8652 }
8653 }, [lazyFlip, mounted, isPositioned, renderedSide]);
8654 const arrowStyles = React29.useMemo(() => ({
8655 position: "absolute",
8656 top: middlewareData.arrow?.y,
8657 left: middlewareData.arrow?.x
8658 }), [middlewareData.arrow]);
8659 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
8660 return React29.useMemo(() => ({
8661 positionerStyles: floatingStyles,
8662 arrowStyles,
8663 arrowRef,
8664 arrowUncentered,
8665 side: logicalRenderedSide,
8666 align: renderedAlign,
8667 physicalSide: renderedSide,
8668 anchorHidden,
8669 refs,
8670 context,
8671 isPositioned,
8672 update: update2
8673 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
8674 }
8675 function isRef(param) {
8676 return param != null && "current" in param;
8677 }
8678
8679 // node_modules/@base-ui/react/utils/getDisabledMountTransitionStyles.mjs
8680 function getDisabledMountTransitionStyles(transitionStatus) {
8681 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
8682 }
8683
8684 // node_modules/@base-ui/react/utils/usePositioner.mjs
8685 function usePositioner(componentProps, state, {
8686 styles,
8687 transitionStatus,
8688 props,
8689 refs,
8690 hidden,
8691 inert = false
8692 }) {
8693 const style = {
8694 ...styles
8695 };
8696 if (inert) {
8697 style.pointerEvents = "none";
8698 }
8699 return useRenderElement("div", componentProps, {
8700 state,
8701 ref: refs,
8702 props: [{
8703 role: "presentation",
8704 hidden,
8705 style
8706 }, getDisabledMountTransitionStyles(transitionStatus), props],
8707 stateAttributesMapping: popupStateMapping
8708 });
8709 }
8710
8711 // node_modules/@base-ui/react/utils/usePopupViewport.mjs
8712 var React32 = __toESM(require_react(), 1);
8713 var ReactDOM6 = __toESM(require_react_dom(), 1);
8714
8715 // node_modules/@base-ui/utils/usePreviousValue.mjs
8716 var React30 = __toESM(require_react(), 1);
8717 function usePreviousValue(value) {
8718 const [state, setState] = React30.useState({
8719 current: value,
8720 previous: null
8721 });
8722 if (value !== state.current) {
8723 setState({
8724 current: value,
8725 previous: state.current
8726 });
8727 }
8728 return state.previous;
8729 }
8730
8731 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs
8732 var React31 = __toESM(require_react(), 1);
8733
8734 // node_modules/@base-ui/react/utils/getCssDimensions.mjs
8735 function getCssDimensions2(element) {
8736 const css = getComputedStyle2(element);
8737 let width = parseFloat(css.width) || 0;
8738 let height = parseFloat(css.height) || 0;
8739 const hasOffset = isHTMLElement(element);
8740 const offsetWidth = hasOffset ? element.offsetWidth : width;
8741 const offsetHeight = hasOffset ? element.offsetHeight : height;
8742 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
8743 if (shouldFallback) {
8744 width = offsetWidth;
8745 height = offsetHeight;
8746 }
8747 return {
8748 width,
8749 height
8750 };
8751 }
8752
8753 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs
8754 function usePopupAutoResize(parameters) {
8755 const {
8756 popupElement,
8757 positionerElement,
8758 content,
8759 mounted,
8760 onMeasureLayout: onMeasureLayoutParam,
8761 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
8762 side,
8763 direction
8764 } = parameters;
8765 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
8766 const animationFrame = useAnimationFrame();
8767 const committedDimensionsRef = React31.useRef(null);
8768 const isInitialRenderRef = React31.useRef(true);
8769 const restoreAnchoringStylesRef = React31.useRef(NOOP);
8770 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
8771 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
8772 const anchoringStyles = React31.useMemo(() => {
8773 let isOriginSide = side === "top";
8774 let isPhysicalLeft = side === "left";
8775 if (direction === "rtl") {
8776 isOriginSide = isOriginSide || side === "inline-end";
8777 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
8778 } else {
8779 isOriginSide = isOriginSide || side === "inline-start";
8780 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
8781 }
8782 return isOriginSide ? {
8783 position: "absolute",
8784 [side === "top" ? "bottom" : "top"]: "0",
8785 [isPhysicalLeft ? "right" : "left"]: "0"
8786 } : EMPTY_OBJECT;
8787 }, [side, direction]);
8788 useIsoLayoutEffect(() => {
8789 if (!mounted) {
8790 restoreAnchoringStylesRef.current = NOOP;
8791 isInitialRenderRef.current = true;
8792 committedDimensionsRef.current = null;
8793 return void 0;
8794 }
8795 if (!popupElement || !positionerElement) {
8796 return void 0;
8797 }
8798 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
8799 setPopupCssSize(popupElement, "auto");
8800 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
8801 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
8802 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
8803 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
8804 "--available-width": "max-content",
8805 "--available-height": "max-content"
8806 });
8807 function restoreMeasurementOverrides() {
8808 restorePopupPosition();
8809 restorePopupTransform();
8810 restorePositionerAvailableSize();
8811 }
8812 function restoreMeasurementOverridesIncludingScale() {
8813 restoreMeasurementOverrides();
8814 restorePopupScale();
8815 }
8816 onMeasureLayout?.();
8817 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
8818 setPositionerCssSize(positionerElement, "max-content");
8819 const dimensions = getCssDimensions2(popupElement);
8820 committedDimensionsRef.current = dimensions;
8821 setPositionerCssSize(positionerElement, dimensions);
8822 restoreMeasurementOverridesIncludingScale();
8823 onMeasureLayoutComplete?.(null, dimensions);
8824 isInitialRenderRef.current = false;
8825 return () => {
8826 restoreAnchoringStylesRef.current();
8827 restoreAnchoringStylesRef.current = NOOP;
8828 };
8829 }
8830 setPositionerCssSize(positionerElement, "max-content");
8831 const previousDimensions = committedDimensionsRef.current;
8832 const newDimensions = getCssDimensions2(popupElement);
8833 committedDimensionsRef.current = newDimensions;
8834 setPopupCssSize(popupElement, previousDimensions);
8835 restoreMeasurementOverridesIncludingScale();
8836 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
8837 setPositionerCssSize(positionerElement, newDimensions);
8838 const abortController = new AbortController();
8839 animationFrame.request(() => {
8840 setPopupCssSize(popupElement, newDimensions);
8841 runOnceAnimationsFinish(() => {
8842 popupElement.style.setProperty("--popup-width", "auto");
8843 popupElement.style.setProperty("--popup-height", "auto");
8844 }, abortController.signal);
8845 });
8846 return () => {
8847 abortController.abort();
8848 animationFrame.cancel();
8849 restoreAnchoringStylesRef.current();
8850 restoreAnchoringStylesRef.current = NOOP;
8851 };
8852 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
8853 }
8854 function overrideElementStyle(element, property, value) {
8855 const originalValue = element.style.getPropertyValue(property);
8856 element.style.setProperty(property, value);
8857 return () => {
8858 element.style.setProperty(property, originalValue);
8859 };
8860 }
8861 function applyElementStyles(element, styles) {
8862 const restorers = [];
8863 for (const [key, value] of Object.entries(styles)) {
8864 restorers.push(overrideElementStyle(element, key, value));
8865 }
8866 return restorers.length ? () => {
8867 restorers.forEach((restore) => restore());
8868 } : NOOP;
8869 }
8870 function setPopupCssSize(popupElement, size4) {
8871 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
8872 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
8873 popupElement.style.setProperty("--popup-width", width);
8874 popupElement.style.setProperty("--popup-height", height);
8875 }
8876 function setPositionerCssSize(positionerElement, size4) {
8877 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
8878 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
8879 positionerElement.style.setProperty("--positioner-width", width);
8880 positionerElement.style.setProperty("--positioner-height", height);
8881 }
8882
8883 // node_modules/@base-ui/react/utils/usePopupViewport.mjs
8884 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
8885 function usePopupViewport(parameters) {
8886 const {
8887 store,
8888 side,
8889 cssVars,
8890 children
8891 } = parameters;
8892 const direction = useDirection();
8893 const activeTrigger = store.useState("activeTriggerElement");
8894 const activeTriggerId = store.useState("activeTriggerId");
8895 const open = store.useState("open");
8896 const payload = store.useState("payload");
8897 const mounted = store.useState("mounted");
8898 const popupElement = store.useState("popupElement");
8899 const positionerElement = store.useState("positionerElement");
8900 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
8901 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
8902 const capturedNodeRef = React32.useRef(null);
8903 const [previousContentNode, setPreviousContentNode] = React32.useState(null);
8904 const [newTriggerOffset, setNewTriggerOffset] = React32.useState(null);
8905 const currentContainerRef = React32.useRef(null);
8906 const previousContainerRef = React32.useRef(null);
8907 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
8908 const cleanupFrame = useAnimationFrame();
8909 const [previousContentDimensions, setPreviousContentDimensions] = React32.useState(null);
8910 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React32.useState(false);
8911 useIsoLayoutEffect(() => {
8912 store.set("hasViewport", true);
8913 return () => {
8914 store.set("hasViewport", false);
8915 };
8916 }, [store]);
8917 const handleMeasureLayout = useStableCallback(() => {
8918 currentContainerRef.current?.style.setProperty("animation", "none");
8919 currentContainerRef.current?.style.setProperty("transition", "none");
8920 previousContainerRef.current?.style.setProperty("display", "none");
8921 });
8922 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
8923 currentContainerRef.current?.style.removeProperty("animation");
8924 currentContainerRef.current?.style.removeProperty("transition");
8925 previousContainerRef.current?.style.removeProperty("display");
8926 if (previousDimensions) {
8927 setPreviousContentDimensions(previousDimensions);
8928 }
8929 });
8930 const lastHandledTriggerRef = React32.useRef(null);
8931 useIsoLayoutEffect(() => {
8932 if (!open || !mounted) {
8933 lastHandledTriggerRef.current = null;
8934 }
8935 }, [open, mounted]);
8936 useIsoLayoutEffect(() => {
8937 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
8938 setPreviousContentNode(capturedNodeRef.current);
8939 setShowStartingStyleAttribute(true);
8940 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
8941 setNewTriggerOffset(offset4);
8942 cleanupFrame.request(() => {
8943 ReactDOM6.flushSync(() => {
8944 setShowStartingStyleAttribute(false);
8945 });
8946 onAnimationsFinished(() => {
8947 setPreviousContentNode(null);
8948 setPreviousContentDimensions(null);
8949 capturedNodeRef.current = null;
8950 });
8951 });
8952 lastHandledTriggerRef.current = activeTrigger;
8953 }
8954 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
8955 useIsoLayoutEffect(() => {
8956 const source = currentContainerRef.current;
8957 if (!source) {
8958 return;
8959 }
8960 const wrapper = ownerDocument(source).createElement("div");
8961 for (const child of Array.from(source.childNodes)) {
8962 wrapper.appendChild(child.cloneNode(true));
8963 }
8964 capturedNodeRef.current = wrapper;
8965 });
8966 const isTransitioning = previousContentNode != null;
8967 let childrenToRender;
8968 if (!isTransitioning) {
8969 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", {
8970 "data-current": true,
8971 ref: currentContainerRef,
8972 children
8973 }, currentContentKey);
8974 } else {
8975 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(React32.Fragment, {
8976 children: [/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", {
8977 "data-previous": true,
8978 inert: inertValue(true),
8979 ref: previousContainerRef,
8980 style: {
8981 ...previousContentDimensions ? {
8982 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
8983 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
8984 } : null,
8985 position: "absolute"
8986 },
8987 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
8988 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", {
8989 "data-current": true,
8990 ref: currentContainerRef,
8991 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
8992 children
8993 }, currentContentKey)]
8994 });
8995 }
8996 useIsoLayoutEffect(() => {
8997 const container = previousContainerRef.current;
8998 if (!container || !previousContentNode) {
8999 return;
9000 }
9001 container.replaceChildren(...Array.from(previousContentNode.childNodes));
9002 }, [previousContentNode]);
9003 usePopupAutoResize({
9004 popupElement,
9005 positionerElement,
9006 mounted,
9007 content: payload,
9008 onMeasureLayout: handleMeasureLayout,
9009 onMeasureLayoutComplete: handleMeasureLayoutComplete,
9010 side,
9011 direction
9012 });
9013 const state = {
9014 activationDirection: getActivationDirection(newTriggerOffset),
9015 transitioning: isTransitioning
9016 };
9017 return {
9018 children: childrenToRender,
9019 state
9020 };
9021 }
9022 function getActivationDirection(offset4) {
9023 if (!offset4) {
9024 return void 0;
9025 }
9026 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
9027 }
9028 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
9029 if (value > tolerance) {
9030 return positiveLabel;
9031 }
9032 if (value < -tolerance) {
9033 return negativeLabel;
9034 }
9035 return "";
9036 }
9037 function calculateRelativePosition(from, to) {
9038 const fromRect = from.getBoundingClientRect();
9039 const toRect = to.getBoundingClientRect();
9040 const fromCenter = {
9041 x: fromRect.left + fromRect.width / 2,
9042 y: fromRect.top + fromRect.height / 2
9043 };
9044 const toCenter = {
9045 x: toRect.left + toRect.width / 2,
9046 y: toRect.top + toRect.height / 2
9047 };
9048 return {
9049 horizontal: toCenter.x - fromCenter.x,
9050 vertical: toCenter.y - fromCenter.y
9051 };
9052 }
9053 function usePopupContentKey(activeTriggerId, payload) {
9054 const [contentKey, setContentKey] = React32.useState(0);
9055 const previousActiveTriggerIdRef = React32.useRef(activeTriggerId);
9056 const previousPayloadRef = React32.useRef(payload);
9057 const pendingPayloadUpdateRef = React32.useRef(false);
9058 useIsoLayoutEffect(() => {
9059 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
9060 const previousPayload = previousPayloadRef.current;
9061 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
9062 const payloadChanged = payload !== previousPayload;
9063 if (triggerIdChanged) {
9064 setContentKey((value) => value + 1);
9065 pendingPayloadUpdateRef.current = !payloadChanged;
9066 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
9067 setContentKey((value) => value + 1);
9068 pendingPayloadUpdateRef.current = false;
9069 }
9070 previousActiveTriggerIdRef.current = activeTriggerId;
9071 previousPayloadRef.current = payload;
9072 }, [activeTriggerId, payload]);
9073 return `${activeTriggerId ?? "current"}-${contentKey}`;
9074 }
9075
9076 // node_modules/@base-ui/react/utils/FloatingPortalLite.mjs
9077 var React33 = __toESM(require_react(), 1);
9078 var ReactDOM7 = __toESM(require_react_dom(), 1);
9079 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
9080 var FloatingPortalLite = /* @__PURE__ */ React33.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
9081 const {
9082 children,
9083 container,
9084 className,
9085 render: render4,
9086 style,
9087 ...elementProps
9088 } = componentProps;
9089 const {
9090 portalNode,
9091 portalSubtree
9092 } = useFloatingPortalNode({
9093 container,
9094 ref: forwardedRef,
9095 componentProps,
9096 elementProps
9097 });
9098 if (!portalSubtree && !portalNode) {
9099 return null;
9100 }
9101 return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(React33.Fragment, {
9102 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM7.createPortal(children, portalNode)]
9103 });
9104 });
9105 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
9106
9107 // node_modules/@base-ui/react/tooltip/index.parts.mjs
9108 var index_parts_exports = {};
9109 __export(index_parts_exports, {
9110 Arrow: () => TooltipArrow,
9111 Handle: () => TooltipHandle,
9112 Popup: () => TooltipPopup,
9113 Portal: () => TooltipPortal,
9114 Positioner: () => TooltipPositioner,
9115 Provider: () => TooltipProvider,
9116 Root: () => TooltipRoot,
9117 Trigger: () => TooltipTrigger,
9118 Viewport: () => TooltipViewport,
9119 createHandle: () => createTooltipHandle
9120 });
9121
9122 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs
9123 var React36 = __toESM(require_react(), 1);
9124
9125 // node_modules/@base-ui/react/tooltip/root/TooltipRootContext.mjs
9126 var React34 = __toESM(require_react(), 1);
9127 var TooltipRootContext = /* @__PURE__ */ React34.createContext(void 0);
9128 if (true) TooltipRootContext.displayName = "TooltipRootContext";
9129 function useTooltipRootContext(optional) {
9130 const context = React34.useContext(TooltipRootContext);
9131 if (context === void 0 && !optional) {
9132 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
9133 }
9134 return context;
9135 }
9136
9137 // node_modules/@base-ui/react/tooltip/store/TooltipStore.mjs
9138 var React35 = __toESM(require_react(), 1);
9139 var selectors2 = {
9140 ...popupStoreSelectors,
9141 disabled: createSelector((state) => state.disabled),
9142 instantType: createSelector((state) => state.instantType),
9143 isInstantPhase: createSelector((state) => state.isInstantPhase),
9144 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
9145 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
9146 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
9147 closeOnClick: createSelector((state) => state.closeOnClick),
9148 closeDelay: createSelector((state) => state.closeDelay),
9149 hasViewport: createSelector((state) => state.hasViewport)
9150 };
9151 var TooltipStore = class _TooltipStore extends ReactStore {
9152 constructor(initialState, floatingId, nested = false) {
9153 const triggerElements = new PopupTriggerMap();
9154 const state = {
9155 ...createInitialState(),
9156 ...initialState
9157 };
9158 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
9159 super(state, {
9160 popupRef: /* @__PURE__ */ React35.createRef(),
9161 onOpenChange: void 0,
9162 onOpenChangeComplete: void 0,
9163 triggerElements
9164 }, selectors2);
9165 }
9166 setOpen = (nextOpen, eventDetails) => {
9167 applyPopupOpenChange(this, nextOpen, eventDetails, {
9168 extraState: {
9169 openChangeReason: eventDetails.reason
9170 }
9171 });
9172 };
9173 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change.
9174 cancelPendingOpen(event) {
9175 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event));
9176 }
9177 static useStore(externalStore, initialState) {
9178 const store = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store;
9179 return store;
9180 }
9181 };
9182 function createInitialState() {
9183 return {
9184 ...createInitialPopupStoreState(),
9185 disabled: false,
9186 instantType: void 0,
9187 isInstantPhase: false,
9188 trackCursorAxis: "none",
9189 disableHoverablePopup: false,
9190 openChangeReason: null,
9191 closeOnClick: true,
9192 closeDelay: 0,
9193 hasViewport: false
9194 };
9195 }
9196
9197 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs
9198 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
9199 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
9200 const {
9201 disabled: disabled2 = false,
9202 defaultOpen = false,
9203 open: openProp,
9204 disableHoverablePopup = false,
9205 trackCursorAxis = "none",
9206 actionsRef,
9207 onOpenChange,
9208 onOpenChangeComplete,
9209 handle,
9210 triggerId: triggerIdProp,
9211 defaultTriggerId: defaultTriggerIdProp = null,
9212 children
9213 } = props;
9214 const store = TooltipStore.useStore(handle?.store, {
9215 open: defaultOpen,
9216 openProp,
9217 activeTriggerId: defaultTriggerIdProp,
9218 triggerIdProp
9219 });
9220 useInitialOpenSync(store, openProp, defaultOpen, defaultTriggerIdProp);
9221 store.useControlledProp("openProp", openProp);
9222 store.useControlledProp("triggerIdProp", triggerIdProp);
9223 store.useContextCallback("onOpenChange", onOpenChange);
9224 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
9225 const openState = store.useState("open");
9226 const open = !disabled2 && openState;
9227 const activeTriggerId = store.useState("activeTriggerId");
9228 const mounted = store.useState("mounted");
9229 const payload = store.useState("payload");
9230 store.useSyncedValues({
9231 trackCursorAxis,
9232 disableHoverablePopup
9233 });
9234 store.useSyncedValue("disabled", disabled2);
9235 useImplicitActiveTrigger(store, {
9236 closeOnActiveTriggerUnmount: true
9237 });
9238 const {
9239 forceUnmount,
9240 transitionStatus
9241 } = useOpenStateTransitions(open, store);
9242 const isInstantPhase = store.useState("isInstantPhase");
9243 const instantType = store.useState("instantType");
9244 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
9245 const previousInstantTypeRef = React36.useRef(null);
9246 useIsoLayoutEffect(() => {
9247 if (openState && disabled2) {
9248 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
9249 }
9250 }, [openState, disabled2, store]);
9251 useIsoLayoutEffect(() => {
9252 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
9253 if (instantType !== "delay") {
9254 previousInstantTypeRef.current = instantType;
9255 }
9256 store.set("instantType", "delay");
9257 } else if (previousInstantTypeRef.current !== null) {
9258 store.set("instantType", previousInstantTypeRef.current);
9259 previousInstantTypeRef.current = null;
9260 }
9261 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
9262 useIsoLayoutEffect(() => {
9263 if (open) {
9264 if (activeTriggerId == null) {
9265 store.set("payload", void 0);
9266 }
9267 }
9268 }, [store, activeTriggerId, open]);
9269 const handleImperativeClose = React36.useCallback(() => {
9270 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
9271 }, [store]);
9272 React36.useImperativeHandle(actionsRef, () => ({
9273 unmount: forceUnmount,
9274 close: handleImperativeClose
9275 }), [forceUnmount, handleImperativeClose]);
9276 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none";
9277 return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(TooltipRootContext.Provider, {
9278 value: store,
9279 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(TooltipInteractions, {
9280 store,
9281 disabled: disabled2,
9282 trackCursorAxis
9283 }), typeof children === "function" ? children({
9284 payload
9285 }) : children]
9286 });
9287 });
9288 if (true) TooltipRoot.displayName = "TooltipRoot";
9289 function TooltipInteractions({
9290 store,
9291 disabled: disabled2,
9292 trackCursorAxis
9293 }) {
9294 const floatingRootContext = store.useState("floatingRootContext");
9295 const dismiss = useDismiss(floatingRootContext, {
9296 enabled: !disabled2,
9297 referencePress: () => store.select("closeOnClick")
9298 });
9299 const clientPoint = useClientPoint(floatingRootContext, {
9300 enabled: !disabled2 && trackCursorAxis !== "none",
9301 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
9302 });
9303 const activeTriggerProps = React36.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]);
9304 const inactiveTriggerProps = React36.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]);
9305 const popupProps = React36.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]);
9306 usePopupInteractionProps(store, {
9307 activeTriggerProps,
9308 inactiveTriggerProps,
9309 popupProps
9310 });
9311 return null;
9312 }
9313
9314 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs
9315 var React38 = __toESM(require_react(), 1);
9316
9317 // node_modules/@base-ui/react/tooltip/provider/TooltipProviderContext.mjs
9318 var React37 = __toESM(require_react(), 1);
9319 var TooltipProviderContext = /* @__PURE__ */ React37.createContext(void 0);
9320 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
9321 function useTooltipProviderContext() {
9322 return React37.useContext(TooltipProviderContext);
9323 }
9324
9325 // node_modules/@base-ui/react/tooltip/trigger/TooltipTriggerDataAttributes.mjs
9326 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
9327 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
9328 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
9329 return TooltipTriggerDataAttributes2;
9330 })({});
9331
9332 // node_modules/@base-ui/react/tooltip/utils/constants.mjs
9333 var OPEN_DELAY = 600;
9334
9335 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs
9336 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger";
9337 function getTargetElement(event) {
9338 if ("composedPath" in event) {
9339 const path = event.composedPath();
9340 for (let i2 = 0; i2 < path.length; i2 += 1) {
9341 const element = path[i2];
9342 if (isElement(element)) {
9343 return element;
9344 }
9345 }
9346 }
9347 const target = event.target;
9348 if (isElement(target)) {
9349 return target;
9350 }
9351 return null;
9352 }
9353 function closestEnabledTooltipTrigger(element) {
9354 let current = element;
9355 while (current) {
9356 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) {
9357 return current;
9358 }
9359 const parentElement = current.parentElement;
9360 if (parentElement) {
9361 current = parentElement;
9362 continue;
9363 }
9364 const root = current.getRootNode();
9365 current = "host" in root && isElement(root.host) ? root.host : null;
9366 }
9367 return null;
9368 }
9369 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
9370 const {
9371 render: render4,
9372 className,
9373 style,
9374 handle,
9375 payload,
9376 disabled: disabledProp,
9377 delay,
9378 closeOnClick = true,
9379 closeDelay,
9380 id: idProp,
9381 ...elementProps
9382 } = componentProps;
9383 const rootContext = useTooltipRootContext(true);
9384 const store = handle?.store ?? rootContext;
9385 if (!store) {
9386 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));
9387 }
9388 const thisTriggerId = useBaseUiId(idProp);
9389 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
9390 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
9391 const floatingRootContext = store.useState("floatingRootContext");
9392 const triggerElementRef = React38.useRef(null);
9393 const delayWithDefault = delay ?? OPEN_DELAY;
9394 const closeDelayWithDefault = closeDelay ?? 0;
9395 const {
9396 registerTrigger,
9397 isMountedByThisTrigger
9398 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
9399 payload,
9400 closeOnClick,
9401 closeDelay: closeDelayWithDefault
9402 });
9403 const providerContext = useTooltipProviderContext();
9404 const {
9405 delayRef,
9406 isInstantPhase,
9407 hasProvider
9408 } = useDelayGroup(floatingRootContext, {
9409 open: isOpenedByThisTrigger
9410 });
9411 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext);
9412 store.useSyncedValue("isInstantPhase", isInstantPhase);
9413 const rootDisabled = store.useState("disabled");
9414 const disabled2 = disabledProp ?? rootDisabled;
9415 const disabledRef = useValueAsRef(disabled2);
9416 const trackCursorAxis = store.useState("trackCursorAxis");
9417 const disableHoverablePopup = store.useState("disableHoverablePopup");
9418 const isNestedTriggerHoveredRef = React38.useRef(false);
9419 const nestedTriggerOpenTimeout = useTimeout();
9420 const pointerTypeRef = React38.useRef(void 0);
9421 function getOpenDelay() {
9422 const providerDelay = providerContext?.delay;
9423 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
9424 let computedOpenDelay = delayWithDefault;
9425 if (hasProvider) {
9426 if (groupOpenValue !== 0) {
9427 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault;
9428 } else {
9429 computedOpenDelay = 0;
9430 }
9431 }
9432 return computedOpenDelay;
9433 }
9434 function isEnabledNestedTriggerTarget(target) {
9435 const triggerEl = triggerElementRef.current;
9436 if (!triggerEl || !target) {
9437 return false;
9438 }
9439 const nearestTrigger = closestEnabledTooltipTrigger(target);
9440 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger);
9441 }
9442 function detectNestedTriggerHover(target) {
9443 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target);
9444 isNestedTriggerHoveredRef.current = nestedTriggerHovered;
9445 if (nestedTriggerHovered) {
9446 hoverInteraction.openChangeTimeout.clear();
9447 hoverInteraction.restTimeout.clear();
9448 hoverInteraction.restTimeoutPending = false;
9449 nestedTriggerOpenTimeout.clear();
9450 }
9451 return nestedTriggerHovered;
9452 }
9453 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
9454 enabled: !disabled2,
9455 mouseOnly: true,
9456 move: false,
9457 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
9458 restMs: getOpenDelay,
9459 delay() {
9460 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
9461 let computedCloseDelay = closeDelayWithDefault;
9462 if (closeDelay == null && hasProvider) {
9463 computedCloseDelay = closeValue;
9464 }
9465 return {
9466 close: computedCloseDelay
9467 };
9468 },
9469 triggerElementRef,
9470 isActiveTrigger: isTriggerActive,
9471 isClosing: () => store.select("transitionStatus") === "ending",
9472 shouldOpen() {
9473 return !isNestedTriggerHoveredRef.current;
9474 }
9475 });
9476 const focusProps = useFocus(floatingRootContext, {
9477 enabled: !disabled2
9478 }).reference;
9479 const handleNestedTriggerHover = (event) => {
9480 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current;
9481 const target = getTargetElement(event);
9482 const nestedTriggerHovered = detectNestedTriggerHover(target);
9483 const triggerEl = triggerElementRef.current;
9484 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target);
9485 if (nestedTriggerHovered && store.select("open") && store.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) {
9486 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
9487 return;
9488 }
9489 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences.
9490 isMouseLikePointerType(pointerTypeRef.current)) {
9491 const open = () => {
9492 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store.select("open")) {
9493 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl));
9494 }
9495 };
9496 const openDelay = getOpenDelay();
9497 if (openDelay === 0) {
9498 nestedTriggerOpenTimeout.clear();
9499 open();
9500 } else {
9501 nestedTriggerOpenTimeout.start(openDelay, open);
9502 }
9503 }
9504 };
9505 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
9506 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none";
9507 const state = {
9508 open: isOpenedByThisTrigger
9509 };
9510 const element = useRenderElement("button", componentProps, {
9511 state,
9512 ref: [forwardedRef, registerTrigger, triggerElementRef],
9513 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, {
9514 onMouseOver(event) {
9515 handleNestedTriggerHover(event.nativeEvent);
9516 },
9517 onFocus(event) {
9518 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) {
9519 event.preventBaseUIHandler();
9520 }
9521 },
9522 onMouseLeave() {
9523 isNestedTriggerHoveredRef.current = false;
9524 nestedTriggerOpenTimeout.clear();
9525 pointerTypeRef.current = void 0;
9526 },
9527 onPointerEnter(event) {
9528 pointerTypeRef.current = event.pointerType;
9529 },
9530 onPointerDown(event) {
9531 pointerTypeRef.current = event.pointerType;
9532 store.set("closeOnClick", closeOnClick);
9533 if (closeOnClick && !store.select("open")) {
9534 store.cancelPendingOpen(event.nativeEvent);
9535 }
9536 },
9537 onClick(event) {
9538 if (closeOnClick && !store.select("open")) {
9539 store.cancelPendingOpen(event.nativeEvent);
9540 }
9541 },
9542 id: thisTriggerId,
9543 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0,
9544 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : ""
9545 }, elementProps],
9546 stateAttributesMapping: triggerOpenStateMapping
9547 });
9548 return element;
9549 });
9550 if (true) TooltipTrigger.displayName = "TooltipTrigger";
9551
9552 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs
9553 var React40 = __toESM(require_react(), 1);
9554
9555 // node_modules/@base-ui/react/tooltip/portal/TooltipPortalContext.mjs
9556 var React39 = __toESM(require_react(), 1);
9557 var TooltipPortalContext = /* @__PURE__ */ React39.createContext(void 0);
9558 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
9559 function useTooltipPortalContext() {
9560 const value = React39.useContext(TooltipPortalContext);
9561 if (value === void 0) {
9562 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
9563 }
9564 return value;
9565 }
9566
9567 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs
9568 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
9569 var TooltipPortal = /* @__PURE__ */ React40.forwardRef(function TooltipPortal2(props, forwardedRef) {
9570 const {
9571 keepMounted = false,
9572 ...portalProps
9573 } = props;
9574 const store = useTooltipRootContext();
9575 const mounted = store.useState("mounted");
9576 const shouldRender = mounted || keepMounted;
9577 if (!shouldRender) {
9578 return null;
9579 }
9580 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(TooltipPortalContext.Provider, {
9581 value: keepMounted,
9582 children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(FloatingPortalLite, {
9583 ref: forwardedRef,
9584 ...portalProps
9585 })
9586 });
9587 });
9588 if (true) TooltipPortal.displayName = "TooltipPortal";
9589
9590 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs
9591 var React42 = __toESM(require_react(), 1);
9592
9593 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositionerContext.mjs
9594 var React41 = __toESM(require_react(), 1);
9595 var TooltipPositionerContext = /* @__PURE__ */ React41.createContext(void 0);
9596 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
9597 function useTooltipPositionerContext() {
9598 const context = React41.useContext(TooltipPositionerContext);
9599 if (context === void 0) {
9600 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
9601 }
9602 return context;
9603 }
9604
9605 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs
9606 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
9607 var TooltipPositioner = /* @__PURE__ */ React42.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
9608 const {
9609 render: render4,
9610 className,
9611 anchor,
9612 positionMethod = "absolute",
9613 side = "top",
9614 align = "center",
9615 sideOffset = 0,
9616 alignOffset = 0,
9617 collisionBoundary = "clipping-ancestors",
9618 collisionPadding = 5,
9619 arrowPadding = 5,
9620 sticky = false,
9621 disableAnchorTracking = false,
9622 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
9623 style,
9624 ...elementProps
9625 } = componentProps;
9626 const store = useTooltipRootContext();
9627 const keepMounted = useTooltipPortalContext();
9628 const open = store.useState("open");
9629 const mounted = store.useState("mounted");
9630 const trackCursorAxis = store.useState("trackCursorAxis");
9631 const disableHoverablePopup = store.useState("disableHoverablePopup");
9632 const floatingRootContext = store.useState("floatingRootContext");
9633 const instantType = store.useState("instantType");
9634 const transitionStatus = store.useState("transitionStatus");
9635 const hasViewport = store.useState("hasViewport");
9636 const positioning = useAnchorPositioning({
9637 anchor,
9638 positionMethod,
9639 floatingRootContext,
9640 mounted,
9641 side,
9642 sideOffset,
9643 align,
9644 alignOffset,
9645 collisionBoundary,
9646 collisionPadding,
9647 sticky,
9648 arrowPadding,
9649 disableAnchorTracking,
9650 keepMounted,
9651 collisionAvoidance,
9652 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
9653 });
9654 const state = React42.useMemo(() => ({
9655 open,
9656 side: positioning.side,
9657 align: positioning.align,
9658 anchorHidden: positioning.anchorHidden,
9659 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
9660 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
9661 const element = usePositioner(componentProps, state, {
9662 styles: positioning.positionerStyles,
9663 transitionStatus,
9664 props: elementProps,
9665 refs: [forwardedRef, store.useStateSetter("positionerElement")],
9666 hidden: !mounted,
9667 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
9668 });
9669 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(TooltipPositionerContext.Provider, {
9670 value: positioning,
9671 children: element
9672 });
9673 });
9674 if (true) TooltipPositioner.displayName = "TooltipPositioner";
9675
9676 // node_modules/@base-ui/react/tooltip/popup/TooltipPopup.mjs
9677 var React43 = __toESM(require_react(), 1);
9678 var stateAttributesMapping = {
9679 ...popupStateMapping,
9680 ...transitionStatusMapping
9681 };
9682 var TooltipPopup = /* @__PURE__ */ React43.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
9683 const {
9684 render: render4,
9685 className,
9686 style,
9687 ...elementProps
9688 } = componentProps;
9689 const store = useTooltipRootContext();
9690 const {
9691 side,
9692 align
9693 } = useTooltipPositionerContext();
9694 const open = store.useState("open");
9695 const instantType = store.useState("instantType");
9696 const transitionStatus = store.useState("transitionStatus");
9697 const popupProps = store.useState("popupProps");
9698 const floatingContext = store.useState("floatingRootContext");
9699 const disabled2 = store.useState("disabled");
9700 const closeDelay = store.useState("closeDelay");
9701 useOpenChangeComplete({
9702 open,
9703 ref: store.context.popupRef,
9704 onComplete() {
9705 if (open) {
9706 store.context.onOpenChangeComplete?.(true);
9707 }
9708 }
9709 });
9710 useHoverFloatingInteraction(floatingContext, {
9711 enabled: !disabled2,
9712 closeDelay
9713 });
9714 const setPopupElement = store.useStateSetter("popupElement");
9715 const state = {
9716 open,
9717 side,
9718 align,
9719 instant: instantType,
9720 transitionStatus
9721 };
9722 const element = useRenderElement("div", componentProps, {
9723 state,
9724 ref: [forwardedRef, store.context.popupRef, setPopupElement],
9725 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
9726 stateAttributesMapping
9727 });
9728 return element;
9729 });
9730 if (true) TooltipPopup.displayName = "TooltipPopup";
9731
9732 // node_modules/@base-ui/react/tooltip/arrow/TooltipArrow.mjs
9733 var React44 = __toESM(require_react(), 1);
9734 var TooltipArrow = /* @__PURE__ */ React44.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
9735 const {
9736 render: render4,
9737 className,
9738 style,
9739 ...elementProps
9740 } = componentProps;
9741 const store = useTooltipRootContext();
9742 const {
9743 arrowRef,
9744 side,
9745 align,
9746 arrowUncentered,
9747 arrowStyles
9748 } = useTooltipPositionerContext();
9749 const open = store.useState("open");
9750 const instantType = store.useState("instantType");
9751 const state = {
9752 open,
9753 side,
9754 align,
9755 uncentered: arrowUncentered,
9756 instant: instantType
9757 };
9758 const element = useRenderElement("div", componentProps, {
9759 state,
9760 ref: [forwardedRef, arrowRef],
9761 props: [{
9762 style: arrowStyles,
9763 "aria-hidden": true
9764 }, elementProps],
9765 stateAttributesMapping: popupStateMapping
9766 });
9767 return element;
9768 });
9769 if (true) TooltipArrow.displayName = "TooltipArrow";
9770
9771 // node_modules/@base-ui/react/tooltip/provider/TooltipProvider.mjs
9772 var React45 = __toESM(require_react(), 1);
9773 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
9774 var TooltipProvider = function TooltipProvider2(props) {
9775 const {
9776 delay,
9777 closeDelay,
9778 timeout = 400
9779 } = props;
9780 const contextValue = React45.useMemo(() => ({
9781 delay,
9782 closeDelay
9783 }), [delay, closeDelay]);
9784 const delayValue = React45.useMemo(() => ({
9785 open: delay,
9786 close: closeDelay
9787 }), [delay, closeDelay]);
9788 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(TooltipProviderContext.Provider, {
9789 value: contextValue,
9790 children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(FloatingDelayGroup, {
9791 delay: delayValue,
9792 timeoutMs: timeout,
9793 children: props.children
9794 })
9795 });
9796 };
9797 if (true) TooltipProvider.displayName = "TooltipProvider";
9798
9799 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs
9800 var React46 = __toESM(require_react(), 1);
9801
9802 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewportCssVars.mjs
9803 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
9804 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
9805 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
9806 return TooltipViewportCssVars2;
9807 })({});
9808
9809 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs
9810 var stateAttributesMapping2 = {
9811 activationDirection: (value) => value ? {
9812 "data-activation-direction": value
9813 } : null
9814 };
9815 var TooltipViewport = /* @__PURE__ */ React46.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
9816 const {
9817 render: render4,
9818 className,
9819 style,
9820 children,
9821 ...elementProps
9822 } = componentProps;
9823 const store = useTooltipRootContext();
9824 const positioner = useTooltipPositionerContext();
9825 const instantType = store.useState("instantType");
9826 const {
9827 children: childrenToRender,
9828 state: viewportState
9829 } = usePopupViewport({
9830 store,
9831 side: positioner.side,
9832 cssVars: TooltipViewportCssVars,
9833 children
9834 });
9835 const state = {
9836 activationDirection: viewportState.activationDirection,
9837 transitioning: viewportState.transitioning,
9838 instant: instantType
9839 };
9840 return useRenderElement("div", componentProps, {
9841 state,
9842 ref: forwardedRef,
9843 props: [elementProps, {
9844 children: childrenToRender
9845 }],
9846 stateAttributesMapping: stateAttributesMapping2
9847 });
9848 });
9849 if (true) TooltipViewport.displayName = "TooltipViewport";
9850
9851 // node_modules/@base-ui/react/tooltip/store/TooltipHandle.mjs
9852 var TooltipHandle = class {
9853 /**
9854 * Internal store holding the tooltip state.
9855 * @internal
9856 */
9857 constructor() {
9858 this.store = new TooltipStore();
9859 }
9860 /**
9861 * Opens the tooltip and associates it with the trigger with the given ID.
9862 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
9863 *
9864 * This method should only be called in an event handler or an effect (not during rendering).
9865 *
9866 * @param triggerId ID of the trigger to associate with the tooltip.
9867 */
9868 open(triggerId) {
9869 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
9870 if (triggerId && !triggerElement) {
9871 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
9872 }
9873 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
9874 }
9875 /**
9876 * Closes the tooltip.
9877 */
9878 close() {
9879 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
9880 }
9881 /**
9882 * Indicates whether the tooltip is currently open.
9883 */
9884 get isOpen() {
9885 return this.store.select("open");
9886 }
9887 };
9888 function createTooltipHandle() {
9889 return new TooltipHandle();
9890 }
9891
9892 // node_modules/@base-ui/react/use-render/useRender.mjs
9893 function useRender(params) {
9894 return useRenderElement(params.defaultTagName ?? "div", params, params);
9895 }
9896
9897 // packages/ui/build-module/utils/render-slot-with-children.mjs
9898 var import_element11 = __toESM(require_element(), 1);
9899 function renderSlotWithChildren(slot, defaultSlot, children) {
9900 return (0, import_element11.cloneElement)(slot ?? defaultSlot, { children });
9901 }
9902
9903 // packages/ui/build-module/utils/theme-provider.mjs
9904 var theme = __toESM(require_theme(), 1);
9905
9906 // packages/ui/build-module/lock-unlock.mjs
9907 var import_private_apis = __toESM(require_private_apis(), 1);
9908 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
9909 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
9910 "@wordpress/ui"
9911 );
9912
9913 // packages/ui/build-module/utils/theme-provider.mjs
9914 function getThemeProvider() {
9915 const themePackage = theme;
9916 if (themePackage.ThemeProvider) {
9917 return themePackage.ThemeProvider;
9918 }
9919 if (!themePackage.privateApis) {
9920 throw new Error(
9921 "@wordpress/ui: @wordpress/theme must expose `ThemeProvider` or `privateApis.ThemeProvider`."
9922 );
9923 }
9924 return unlock(
9925 themePackage.privateApis
9926 ).ThemeProvider;
9927 }
9928 var ThemeProvider = getThemeProvider();
9929
9930 // packages/ui/build-module/stack/stack.mjs
9931 var import_element12 = __toESM(require_element(), 1);
9932 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
9933 function getRuntime() {
9934 const globalScope = globalThis;
9935 if (globalScope.__wpStyleRuntime) {
9936 return globalScope.__wpStyleRuntime;
9937 }
9938 globalScope.__wpStyleRuntime = {
9939 documents: /* @__PURE__ */ new Map(),
9940 styles: /* @__PURE__ */ new Map(),
9941 injectedStyles: /* @__PURE__ */ new WeakMap()
9942 };
9943 if (typeof document !== "undefined") {
9944 registerDocument(document);
9945 }
9946 return globalScope.__wpStyleRuntime;
9947 }
9948 function documentContainsStyleHash(targetDocument, hash) {
9949 if (!targetDocument.head) {
9950 return false;
9951 }
9952 for (const style of targetDocument.head.querySelectorAll(
9953 `style[${STYLE_HASH_ATTRIBUTE}]`
9954 )) {
9955 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
9956 return true;
9957 }
9958 }
9959 return false;
9960 }
9961 function injectStyle(targetDocument, hash, css) {
9962 if (!targetDocument.head) {
9963 return;
9964 }
9965 const runtime = getRuntime();
9966 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9967 if (!injectedStyles) {
9968 injectedStyles = /* @__PURE__ */ new Set();
9969 runtime.injectedStyles.set(targetDocument, injectedStyles);
9970 }
9971 if (injectedStyles.has(hash)) {
9972 return;
9973 }
9974 if (documentContainsStyleHash(targetDocument, hash)) {
9975 injectedStyles.add(hash);
9976 return;
9977 }
9978 const style = targetDocument.createElement("style");
9979 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
9980 style.appendChild(targetDocument.createTextNode(css));
9981 targetDocument.head.appendChild(style);
9982 injectedStyles.add(hash);
9983 }
9984 function registerDocument(targetDocument) {
9985 const runtime = getRuntime();
9986 runtime.documents.set(
9987 targetDocument,
9988 (runtime.documents.get(targetDocument) ?? 0) + 1
9989 );
9990 for (const [hash, css] of runtime.styles) {
9991 injectStyle(targetDocument, hash, css);
9992 }
9993 return () => {
9994 const count = runtime.documents.get(targetDocument);
9995 if (count === void 0) {
9996 return;
9997 }
9998 if (count <= 1) {
9999 runtime.documents.delete(targetDocument);
10000 return;
10001 }
10002 runtime.documents.set(targetDocument, count - 1);
10003 };
10004 }
10005 function registerStyle(hash, css) {
10006 const runtime = getRuntime();
10007 runtime.styles.set(hash, css);
10008 for (const targetDocument of runtime.documents.keys()) {
10009 injectStyle(targetDocument, hash, css);
10010 }
10011 }
10012 if (typeof process === "undefined" || true) {
10013 registerStyle("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}");
10014 }
10015 var style_default = { "stack": "_19ce0419607e1896__stack" };
10016 var gapTokens = {
10017 xs: "var(--wpds-dimension-gap-xs, 4px)",
10018 sm: "var(--wpds-dimension-gap-sm, 8px)",
10019 md: "var(--wpds-dimension-gap-md, 12px)",
10020 lg: "var(--wpds-dimension-gap-lg, 16px)",
10021 xl: "var(--wpds-dimension-gap-xl, 24px)",
10022 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
10023 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
10024 };
10025 var Stack = (0, import_element12.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
10026 const style = {
10027 gap: gap && gapTokens[gap],
10028 alignItems: align,
10029 justifyContent: justify,
10030 flexDirection: direction,
10031 flexWrap: wrap
10032 };
10033 const element = useRender({
10034 render: render4,
10035 ref,
10036 props: mergeProps(props, { style, className: style_default.stack })
10037 });
10038 return element;
10039 });
10040
10041 // packages/ui/build-module/tooltip/index.mjs
10042 var tooltip_exports = {};
10043 __export(tooltip_exports, {
10044 Popup: () => Popup,
10045 Portal: () => Portal,
10046 Positioner: () => Positioner,
10047 Provider: () => Provider,
10048 Root: () => Root,
10049 Trigger: () => Trigger
10050 });
10051
10052 // packages/ui/build-module/tooltip/popup.mjs
10053 var import_element15 = __toESM(require_element(), 1);
10054
10055 // packages/ui/build-module/tooltip/portal.mjs
10056 var import_element13 = __toESM(require_element(), 1);
10057
10058 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
10059 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
10060 function getRuntime2() {
10061 const globalScope = globalThis;
10062 if (globalScope.__wpStyleRuntime) {
10063 return globalScope.__wpStyleRuntime;
10064 }
10065 globalScope.__wpStyleRuntime = {
10066 documents: /* @__PURE__ */ new Map(),
10067 styles: /* @__PURE__ */ new Map(),
10068 injectedStyles: /* @__PURE__ */ new WeakMap()
10069 };
10070 if (typeof document !== "undefined") {
10071 registerDocument2(document);
10072 }
10073 return globalScope.__wpStyleRuntime;
10074 }
10075 function documentContainsStyleHash2(targetDocument, hash) {
10076 if (!targetDocument.head) {
10077 return false;
10078 }
10079 for (const style of targetDocument.head.querySelectorAll(
10080 `style[${STYLE_HASH_ATTRIBUTE2}]`
10081 )) {
10082 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
10083 return true;
10084 }
10085 }
10086 return false;
10087 }
10088 function injectStyle2(targetDocument, hash, css) {
10089 if (!targetDocument.head) {
10090 return;
10091 }
10092 const runtime = getRuntime2();
10093 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10094 if (!injectedStyles) {
10095 injectedStyles = /* @__PURE__ */ new Set();
10096 runtime.injectedStyles.set(targetDocument, injectedStyles);
10097 }
10098 if (injectedStyles.has(hash)) {
10099 return;
10100 }
10101 if (documentContainsStyleHash2(targetDocument, hash)) {
10102 injectedStyles.add(hash);
10103 return;
10104 }
10105 const style = targetDocument.createElement("style");
10106 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
10107 style.appendChild(targetDocument.createTextNode(css));
10108 targetDocument.head.appendChild(style);
10109 injectedStyles.add(hash);
10110 }
10111 function registerDocument2(targetDocument) {
10112 const runtime = getRuntime2();
10113 runtime.documents.set(
10114 targetDocument,
10115 (runtime.documents.get(targetDocument) ?? 0) + 1
10116 );
10117 for (const [hash, css] of runtime.styles) {
10118 injectStyle2(targetDocument, hash, css);
10119 }
10120 return () => {
10121 const count = runtime.documents.get(targetDocument);
10122 if (count === void 0) {
10123 return;
10124 }
10125 if (count <= 1) {
10126 runtime.documents.delete(targetDocument);
10127 return;
10128 }
10129 runtime.documents.set(targetDocument, count - 1);
10130 };
10131 }
10132 function registerStyle2(hash, css) {
10133 const runtime = getRuntime2();
10134 runtime.styles.set(hash, css);
10135 for (const targetDocument of runtime.documents.keys()) {
10136 injectStyle2(targetDocument, hash, css);
10137 }
10138 }
10139 if (typeof process === "undefined" || true) {
10140 registerStyle2("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}}}");
10141 }
10142 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
10143 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
10144 function resolveOwnerDocument() {
10145 return typeof document === "undefined" ? null : document;
10146 }
10147 function isInWordPressEnvironment() {
10148 let topWp;
10149 try {
10150 topWp = window.top?.wp;
10151 } catch {
10152 }
10153 const wp = topWp ?? window.wp;
10154 return typeof wp?.components === "object" && wp.components !== null;
10155 }
10156 var cachedSlot = null;
10157 function ensureSlotIsAccessible(element) {
10158 element.setAttribute("aria-hidden", "false");
10159 return element;
10160 }
10161 function createSlot(ownerDocument2) {
10162 const element = ownerDocument2.createElement("div");
10163 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
10164 if (wp_compat_overlay_slot_default.slot) {
10165 element.classList.add(wp_compat_overlay_slot_default.slot);
10166 }
10167 ownerDocument2.body.appendChild(element);
10168 return element;
10169 }
10170 function getWpCompatOverlaySlot() {
10171 if (typeof window === "undefined") {
10172 return void 0;
10173 }
10174 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
10175 return void 0;
10176 }
10177 const ownerDocument2 = resolveOwnerDocument();
10178 if (!ownerDocument2 || !ownerDocument2.body) {
10179 return void 0;
10180 }
10181 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
10182 return ensureSlotIsAccessible(cachedSlot);
10183 }
10184 const existing = ownerDocument2.querySelector(
10185 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
10186 );
10187 if (existing instanceof HTMLDivElement) {
10188 cachedSlot = ensureSlotIsAccessible(existing);
10189 return cachedSlot;
10190 }
10191 if (cachedSlot?.isConnected) {
10192 cachedSlot.remove();
10193 }
10194 cachedSlot = ensureSlotIsAccessible(createSlot(ownerDocument2));
10195 return cachedSlot;
10196 }
10197
10198 // packages/ui/build-module/tooltip/portal.mjs
10199 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
10200 var Portal = (0, import_element13.forwardRef)(
10201 function TooltipPortal3({ container, ...restProps }, ref) {
10202 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10203 index_parts_exports.Portal,
10204 {
10205 container: container ?? getWpCompatOverlaySlot(),
10206 ...restProps,
10207 ref
10208 }
10209 );
10210 }
10211 );
10212
10213 // packages/ui/build-module/tooltip/positioner.mjs
10214 var import_element14 = __toESM(require_element(), 1);
10215 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
10216 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
10217 function getRuntime3() {
10218 const globalScope = globalThis;
10219 if (globalScope.__wpStyleRuntime) {
10220 return globalScope.__wpStyleRuntime;
10221 }
10222 globalScope.__wpStyleRuntime = {
10223 documents: /* @__PURE__ */ new Map(),
10224 styles: /* @__PURE__ */ new Map(),
10225 injectedStyles: /* @__PURE__ */ new WeakMap()
10226 };
10227 if (typeof document !== "undefined") {
10228 registerDocument3(document);
10229 }
10230 return globalScope.__wpStyleRuntime;
10231 }
10232 function documentContainsStyleHash3(targetDocument, hash) {
10233 if (!targetDocument.head) {
10234 return false;
10235 }
10236 for (const style of targetDocument.head.querySelectorAll(
10237 `style[${STYLE_HASH_ATTRIBUTE3}]`
10238 )) {
10239 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
10240 return true;
10241 }
10242 }
10243 return false;
10244 }
10245 function injectStyle3(targetDocument, hash, css) {
10246 if (!targetDocument.head) {
10247 return;
10248 }
10249 const runtime = getRuntime3();
10250 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10251 if (!injectedStyles) {
10252 injectedStyles = /* @__PURE__ */ new Set();
10253 runtime.injectedStyles.set(targetDocument, injectedStyles);
10254 }
10255 if (injectedStyles.has(hash)) {
10256 return;
10257 }
10258 if (documentContainsStyleHash3(targetDocument, hash)) {
10259 injectedStyles.add(hash);
10260 return;
10261 }
10262 const style = targetDocument.createElement("style");
10263 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
10264 style.appendChild(targetDocument.createTextNode(css));
10265 targetDocument.head.appendChild(style);
10266 injectedStyles.add(hash);
10267 }
10268 function registerDocument3(targetDocument) {
10269 const runtime = getRuntime3();
10270 runtime.documents.set(
10271 targetDocument,
10272 (runtime.documents.get(targetDocument) ?? 0) + 1
10273 );
10274 for (const [hash, css] of runtime.styles) {
10275 injectStyle3(targetDocument, hash, css);
10276 }
10277 return () => {
10278 const count = runtime.documents.get(targetDocument);
10279 if (count === void 0) {
10280 return;
10281 }
10282 if (count <= 1) {
10283 runtime.documents.delete(targetDocument);
10284 return;
10285 }
10286 runtime.documents.set(targetDocument, count - 1);
10287 };
10288 }
10289 function registerStyle3(hash, css) {
10290 const runtime = getRuntime3();
10291 runtime.styles.set(hash, css);
10292 for (const targetDocument of runtime.documents.keys()) {
10293 injectStyle3(targetDocument, hash, css);
10294 }
10295 }
10296 if (typeof process === "undefined" || true) {
10297 registerStyle3("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
10298 }
10299 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10300 if (typeof process === "undefined" || true) {
10301 registerStyle3("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}}}}');
10302 }
10303 var style_default2 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
10304 var Positioner = (0, import_element14.forwardRef)(
10305 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
10306 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10307 index_parts_exports.Positioner,
10308 {
10309 ref,
10310 align,
10311 side,
10312 sideOffset,
10313 ...props,
10314 className: clsx_default(
10315 resets_default["box-sizing"],
10316 style_default2.positioner,
10317 className
10318 )
10319 }
10320 );
10321 }
10322 );
10323
10324 // packages/ui/build-module/tooltip/popup.mjs
10325 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
10326 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
10327 function getRuntime4() {
10328 const globalScope = globalThis;
10329 if (globalScope.__wpStyleRuntime) {
10330 return globalScope.__wpStyleRuntime;
10331 }
10332 globalScope.__wpStyleRuntime = {
10333 documents: /* @__PURE__ */ new Map(),
10334 styles: /* @__PURE__ */ new Map(),
10335 injectedStyles: /* @__PURE__ */ new WeakMap()
10336 };
10337 if (typeof document !== "undefined") {
10338 registerDocument4(document);
10339 }
10340 return globalScope.__wpStyleRuntime;
10341 }
10342 function documentContainsStyleHash4(targetDocument, hash) {
10343 if (!targetDocument.head) {
10344 return false;
10345 }
10346 for (const style of targetDocument.head.querySelectorAll(
10347 `style[${STYLE_HASH_ATTRIBUTE4}]`
10348 )) {
10349 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
10350 return true;
10351 }
10352 }
10353 return false;
10354 }
10355 function injectStyle4(targetDocument, hash, css) {
10356 if (!targetDocument.head) {
10357 return;
10358 }
10359 const runtime = getRuntime4();
10360 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10361 if (!injectedStyles) {
10362 injectedStyles = /* @__PURE__ */ new Set();
10363 runtime.injectedStyles.set(targetDocument, injectedStyles);
10364 }
10365 if (injectedStyles.has(hash)) {
10366 return;
10367 }
10368 if (documentContainsStyleHash4(targetDocument, hash)) {
10369 injectedStyles.add(hash);
10370 return;
10371 }
10372 const style = targetDocument.createElement("style");
10373 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
10374 style.appendChild(targetDocument.createTextNode(css));
10375 targetDocument.head.appendChild(style);
10376 injectedStyles.add(hash);
10377 }
10378 function registerDocument4(targetDocument) {
10379 const runtime = getRuntime4();
10380 runtime.documents.set(
10381 targetDocument,
10382 (runtime.documents.get(targetDocument) ?? 0) + 1
10383 );
10384 for (const [hash, css] of runtime.styles) {
10385 injectStyle4(targetDocument, hash, css);
10386 }
10387 return () => {
10388 const count = runtime.documents.get(targetDocument);
10389 if (count === void 0) {
10390 return;
10391 }
10392 if (count <= 1) {
10393 runtime.documents.delete(targetDocument);
10394 return;
10395 }
10396 runtime.documents.set(targetDocument, count - 1);
10397 };
10398 }
10399 function registerStyle4(hash, css) {
10400 const runtime = getRuntime4();
10401 runtime.styles.set(hash, css);
10402 for (const targetDocument of runtime.documents.keys()) {
10403 injectStyle4(targetDocument, hash, css);
10404 }
10405 }
10406 if (typeof process === "undefined" || true) {
10407 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}}}}');
10408 }
10409 var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
10410 var POPUP_COLOR = { background: "#1e1e1e" };
10411 var Popup = (0, import_element15.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
10412 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10413 index_parts_exports.Popup,
10414 {
10415 ref,
10416 className: clsx_default(style_default3.popup, className),
10417 ...props,
10418 children
10419 }
10420 ) });
10421 const positionedPopup = renderSlotWithChildren(
10422 positioner,
10423 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Positioner, {}),
10424 popupContent
10425 );
10426 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Portal, {}), positionedPopup);
10427 });
10428
10429 // packages/ui/build-module/tooltip/trigger.mjs
10430 var import_element16 = __toESM(require_element(), 1);
10431 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
10432 var Trigger = (0, import_element16.forwardRef)(
10433 function TooltipTrigger3(props, ref) {
10434 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(index_parts_exports.Trigger, { ref, ...props });
10435 }
10436 );
10437
10438 // packages/ui/build-module/tooltip/root.mjs
10439 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
10440 function Root(props) {
10441 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(index_parts_exports.Root, { ...props });
10442 }
10443
10444 // packages/ui/build-module/tooltip/provider.mjs
10445 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
10446 function Provider({ ...props }) {
10447 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(index_parts_exports.Provider, { ...props });
10448 }
10449
10450 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
10451 var import_element17 = __toESM(require_element(), 1);
10452 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
10453 function getRuntime5() {
10454 const globalScope = globalThis;
10455 if (globalScope.__wpStyleRuntime) {
10456 return globalScope.__wpStyleRuntime;
10457 }
10458 globalScope.__wpStyleRuntime = {
10459 documents: /* @__PURE__ */ new Map(),
10460 styles: /* @__PURE__ */ new Map(),
10461 injectedStyles: /* @__PURE__ */ new WeakMap()
10462 };
10463 if (typeof document !== "undefined") {
10464 registerDocument5(document);
10465 }
10466 return globalScope.__wpStyleRuntime;
10467 }
10468 function documentContainsStyleHash5(targetDocument, hash) {
10469 if (!targetDocument.head) {
10470 return false;
10471 }
10472 for (const style of targetDocument.head.querySelectorAll(
10473 `style[${STYLE_HASH_ATTRIBUTE5}]`
10474 )) {
10475 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
10476 return true;
10477 }
10478 }
10479 return false;
10480 }
10481 function injectStyle5(targetDocument, hash, css) {
10482 if (!targetDocument.head) {
10483 return;
10484 }
10485 const runtime = getRuntime5();
10486 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10487 if (!injectedStyles) {
10488 injectedStyles = /* @__PURE__ */ new Set();
10489 runtime.injectedStyles.set(targetDocument, injectedStyles);
10490 }
10491 if (injectedStyles.has(hash)) {
10492 return;
10493 }
10494 if (documentContainsStyleHash5(targetDocument, hash)) {
10495 injectedStyles.add(hash);
10496 return;
10497 }
10498 const style = targetDocument.createElement("style");
10499 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
10500 style.appendChild(targetDocument.createTextNode(css));
10501 targetDocument.head.appendChild(style);
10502 injectedStyles.add(hash);
10503 }
10504 function registerDocument5(targetDocument) {
10505 const runtime = getRuntime5();
10506 runtime.documents.set(
10507 targetDocument,
10508 (runtime.documents.get(targetDocument) ?? 0) + 1
10509 );
10510 for (const [hash, css] of runtime.styles) {
10511 injectStyle5(targetDocument, hash, css);
10512 }
10513 return () => {
10514 const count = runtime.documents.get(targetDocument);
10515 if (count === void 0) {
10516 return;
10517 }
10518 if (count <= 1) {
10519 runtime.documents.delete(targetDocument);
10520 return;
10521 }
10522 runtime.documents.set(targetDocument, count - 1);
10523 };
10524 }
10525 function registerStyle5(hash, css) {
10526 const runtime = getRuntime5();
10527 runtime.styles.set(hash, css);
10528 for (const targetDocument of runtime.documents.keys()) {
10529 injectStyle5(targetDocument, hash, css);
10530 }
10531 }
10532 if (typeof process === "undefined" || true) {
10533 registerStyle5("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}}}");
10534 }
10535 var style_default4 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
10536 var VisuallyHidden = (0, import_element17.forwardRef)(
10537 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
10538 const element = useRender({
10539 render: render4,
10540 ref,
10541 props: mergeProps(
10542 { className: style_default4["visually-hidden"] },
10543 restProps,
10544 {
10545 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
10546 "data-visually-hidden": ""
10547 }
10548 )
10549 });
10550 return element;
10551 }
10552 );
10553
10554 // packages/ui/build-module/link/link.mjs
10555 var import_element18 = __toESM(require_element(), 1);
10556 var import_i18n7 = __toESM(require_i18n(), 1);
10557 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
10558 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
10559 function getRuntime6() {
10560 const globalScope = globalThis;
10561 if (globalScope.__wpStyleRuntime) {
10562 return globalScope.__wpStyleRuntime;
10563 }
10564 globalScope.__wpStyleRuntime = {
10565 documents: /* @__PURE__ */ new Map(),
10566 styles: /* @__PURE__ */ new Map(),
10567 injectedStyles: /* @__PURE__ */ new WeakMap()
10568 };
10569 if (typeof document !== "undefined") {
10570 registerDocument6(document);
10571 }
10572 return globalScope.__wpStyleRuntime;
10573 }
10574 function documentContainsStyleHash6(targetDocument, hash) {
10575 if (!targetDocument.head) {
10576 return false;
10577 }
10578 for (const style of targetDocument.head.querySelectorAll(
10579 `style[${STYLE_HASH_ATTRIBUTE6}]`
10580 )) {
10581 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
10582 return true;
10583 }
10584 }
10585 return false;
10586 }
10587 function injectStyle6(targetDocument, hash, css) {
10588 if (!targetDocument.head) {
10589 return;
10590 }
10591 const runtime = getRuntime6();
10592 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10593 if (!injectedStyles) {
10594 injectedStyles = /* @__PURE__ */ new Set();
10595 runtime.injectedStyles.set(targetDocument, injectedStyles);
10596 }
10597 if (injectedStyles.has(hash)) {
10598 return;
10599 }
10600 if (documentContainsStyleHash6(targetDocument, hash)) {
10601 injectedStyles.add(hash);
10602 return;
10603 }
10604 const style = targetDocument.createElement("style");
10605 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
10606 style.appendChild(targetDocument.createTextNode(css));
10607 targetDocument.head.appendChild(style);
10608 injectedStyles.add(hash);
10609 }
10610 function registerDocument6(targetDocument) {
10611 const runtime = getRuntime6();
10612 runtime.documents.set(
10613 targetDocument,
10614 (runtime.documents.get(targetDocument) ?? 0) + 1
10615 );
10616 for (const [hash, css] of runtime.styles) {
10617 injectStyle6(targetDocument, hash, css);
10618 }
10619 return () => {
10620 const count = runtime.documents.get(targetDocument);
10621 if (count === void 0) {
10622 return;
10623 }
10624 if (count <= 1) {
10625 runtime.documents.delete(targetDocument);
10626 return;
10627 }
10628 runtime.documents.set(targetDocument, count - 1);
10629 };
10630 }
10631 function registerStyle6(hash, css) {
10632 const runtime = getRuntime6();
10633 runtime.styles.set(hash, css);
10634 for (const targetDocument of runtime.documents.keys()) {
10635 injectStyle6(targetDocument, hash, css);
10636 }
10637 }
10638 if (typeof process === "undefined" || true) {
10639 registerStyle6("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
10640 }
10641 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10642 if (typeof process === "undefined" || true) {
10643 registerStyle6("5f8e7aa0bc", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._08e8a2e44959f892__outset-ring--focus:focus,._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible:focus-within:has(:focus-visible),.cd83dfc2126a0846__outset-ring--focus-within:focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible:focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active),:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}}}");
10644 }
10645 var focus_default = { "outset-ring--focus": "_08e8a2e44959f892__outset-ring--focus", "outset-ring--focus-except-active": "e25b2bdd7aa21721__outset-ring--focus-except-active", "outset-ring--focus-visible": "d0541bc9dd9dc7b6__outset-ring--focus-visible", "outset-ring--focus-within": "cd83dfc2126a0846__outset-ring--focus-within", "outset-ring--focus-within-except-active": "_970d04df7376df67__outset-ring--focus-within-except-active", "outset-ring--focus-within-visible": "c5cb3ee4bddaa8e4__outset-ring--focus-within-visible", "outset-ring--focus-parent-visible": "ecadb9e080e2dfa5__outset-ring--focus-parent-visible" };
10646 if (typeof process === "undefined" || true) {
10647 registerStyle6("e8e6a9be37", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.d4250949359b05ce__link{text-decoration-thickness:from-font;text-underline-offset:.2em}.c6055659b8e2cd2c__is-brand,.c6055659b8e2cd2c__is-brand:visited{--_gcd-a-color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9))}.c6055659b8e2cd2c__is-brand:active,.c6055659b8e2cd2c__is-brand:hover{--_gcd-a-color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000))}._92e0dfcaeee15b88__is-neutral,._92e0dfcaeee15b88__is-neutral:visited{--_gcd-a-color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);text-decoration-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d)}._92e0dfcaeee15b88__is-neutral:active,._92e0dfcaeee15b88__is-neutral:hover{--_gcd-a-color:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e);color:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e)}.cf122a9bf1035d42__is-unstyled{--_gcd-a-color:inherit;color:inherit;text-decoration:none}._0cb411afac4c86c7__link-icon{display:inline-block;font-weight:var(--wpds-typography-font-weight-default,400);line-height:1;margin-inline-start:var(--wpds-dimension-padding-xs,4px);text-decoration:none}._0cb411afac4c86c7__link-icon:after{content:"\\2197"}._0cb411afac4c86c7__link-icon:dir(rtl):after{content:"\\2196"}}}');
10648 }
10649 var style_default5 = { "link": "d4250949359b05ce__link", "is-brand": "c6055659b8e2cd2c__is-brand", "is-neutral": "_92e0dfcaeee15b88__is-neutral", "is-unstyled": "cf122a9bf1035d42__is-unstyled", "link-icon": "_0cb411afac4c86c7__link-icon" };
10650 if (typeof process === "undefined" || true) {
10651 registerStyle6("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)}");
10652 }
10653 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" };
10654 var Link = (0, import_element18.forwardRef)(function Link2({
10655 children,
10656 variant = "default",
10657 tone = "brand",
10658 openInNewTab = false,
10659 render: render4,
10660 className,
10661 ...props
10662 }, ref) {
10663 const element = useRender({
10664 render: render4,
10665 defaultTagName: "a",
10666 ref,
10667 props: mergeProps(props, {
10668 className: clsx_default(
10669 global_css_defense_default.a,
10670 resets_default2["box-sizing"],
10671 focus_default["outset-ring--focus-except-active"],
10672 variant !== "unstyled" && style_default5.link,
10673 variant !== "unstyled" && style_default5[`is-${tone}`],
10674 variant === "unstyled" && style_default5["is-unstyled"],
10675 className
10676 ),
10677 target: openInNewTab ? "_blank" : void 0,
10678 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
10679 children,
10680 openInNewTab && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
10681 "span",
10682 {
10683 className: style_default5["link-icon"],
10684 role: "img",
10685 "aria-label": (
10686 /* translators: accessibility text appended to link text */
10687 (0, import_i18n7.__)("(opens in a new tab)")
10688 )
10689 }
10690 )
10691 ] })
10692 })
10693 });
10694 return element;
10695 });
10696
10697 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10698 var import_element19 = __toESM(require_element(), 1);
10699
10700 // packages/dataviews/build-module/constants.mjs
10701 var import_i18n8 = __toESM(require_i18n(), 1);
10702 var OPERATOR_IS_ANY = "isAny";
10703 var OPERATOR_IS_NONE = "isNone";
10704 var OPERATOR_IS_ALL = "isAll";
10705 var OPERATOR_IS_NOT_ALL = "isNotAll";
10706 var OPERATOR_BETWEEN = "between";
10707 var OPERATOR_IN_THE_PAST = "inThePast";
10708 var OPERATOR_OVER = "over";
10709 var OPERATOR_IS = "is";
10710 var OPERATOR_IS_NOT = "isNot";
10711 var OPERATOR_LESS_THAN = "lessThan";
10712 var OPERATOR_GREATER_THAN = "greaterThan";
10713 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
10714 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
10715 var OPERATOR_BEFORE = "before";
10716 var OPERATOR_AFTER = "after";
10717 var OPERATOR_BEFORE_INC = "beforeInc";
10718 var OPERATOR_AFTER_INC = "afterInc";
10719 var OPERATOR_CONTAINS = "contains";
10720 var OPERATOR_NOT_CONTAINS = "notContains";
10721 var OPERATOR_STARTS_WITH = "startsWith";
10722 var OPERATOR_ON = "on";
10723 var OPERATOR_NOT_ON = "notOn";
10724 var SORTING_DIRECTIONS = ["asc", "desc"];
10725 var sortArrows = { asc: "\u2191", desc: "\u2193" };
10726 var sortValues = { asc: "ascending", desc: "descending" };
10727 var sortLabels = {
10728 asc: (0, import_i18n8.__)("Sort ascending"),
10729 desc: (0, import_i18n8.__)("Sort descending")
10730 };
10731 var sortIcons = {
10732 asc: arrow_up_default,
10733 desc: arrow_down_default
10734 };
10735 var LAYOUT_TABLE = "table";
10736 var LAYOUT_GRID = "grid";
10737 var LAYOUT_LIST = "list";
10738 var LAYOUT_ACTIVITY = "activity";
10739 var LAYOUT_PICKER_GRID = "pickerGrid";
10740 var LAYOUT_PICKER_TABLE = "pickerTable";
10741 var LAYOUT_PICKER_ACTIVITY = "pickerActivity";
10742
10743 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10744 var DataViewsContext = (0, import_element19.createContext)({
10745 view: { type: LAYOUT_TABLE },
10746 onChangeView: () => {
10747 },
10748 fields: [],
10749 data: [],
10750 paginationInfo: {
10751 totalItems: 0,
10752 totalPages: 0
10753 },
10754 selection: [],
10755 onChangeSelection: () => {
10756 },
10757 setOpenedFilter: () => {
10758 },
10759 openedFilter: null,
10760 getItemId: (item) => item.id,
10761 isItemClickable: () => true,
10762 renderItemLink: void 0,
10763 containerWidth: 0,
10764 containerRef: (0, import_element19.createRef)(),
10765 resizeObserverRef: () => {
10766 },
10767 defaultLayouts: { list: {}, grid: {}, table: {} },
10768 filters: [],
10769 isShowingFilter: false,
10770 setIsShowingFilter: () => {
10771 },
10772 hasInitiallyLoaded: false,
10773 config: {
10774 perPageSizes: []
10775 },
10776 intersectionObserver: null
10777 });
10778 DataViewsContext.displayName = "DataViewsContext";
10779 var dataviews_context_default = DataViewsContext;
10780
10781 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
10782 var import_i18n29 = __toESM(require_i18n(), 1);
10783
10784 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
10785 var import_i18n16 = __toESM(require_i18n(), 1);
10786 var import_components6 = __toESM(require_components(), 1);
10787 var import_element28 = __toESM(require_element(), 1);
10788 var import_keycodes2 = __toESM(require_keycodes(), 1);
10789
10790 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
10791 var import_components = __toESM(require_components(), 1);
10792 var import_i18n9 = __toESM(require_i18n(), 1);
10793 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
10794 var SELECTION_CHECKBOX_CLASS = "dataviews-selection-checkbox";
10795 function DataViewsSelectionCheckbox({
10796 selection,
10797 onChangeSelection,
10798 item,
10799 getItemId,
10800 titleField,
10801 disabled: disabled2,
10802 ...extraProps
10803 }) {
10804 const id = getItemId(item);
10805 const isInSelectionArray = selection.includes(id);
10806 const checked = !disabled2 && isInSelectionArray;
10807 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n9.__)("(no title)");
10808 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10809 import_components.CheckboxControl,
10810 {
10811 className: SELECTION_CHECKBOX_CLASS,
10812 "aria-label": selectionLabel,
10813 "aria-disabled": disabled2,
10814 checked,
10815 onChange: () => {
10816 if (disabled2) {
10817 return;
10818 }
10819 onChangeSelection(
10820 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
10821 );
10822 },
10823 ...extraProps
10824 }
10825 );
10826 }
10827
10828 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10829 var import_components2 = __toESM(require_components(), 1);
10830 var import_i18n10 = __toESM(require_i18n(), 1);
10831 var import_element20 = __toESM(require_element(), 1);
10832 var import_data2 = __toESM(require_data(), 1);
10833 var import_compose = __toESM(require_compose(), 1);
10834
10835 // packages/dataviews/build-module/lock-unlock.mjs
10836 var import_private_apis2 = __toESM(require_private_apis(), 1);
10837 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
10838 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
10839 "@wordpress/dataviews"
10840 );
10841
10842 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10843 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
10844 var { Menu, kebabCase } = unlock2(import_components2.privateApis);
10845 function ButtonTrigger({
10846 action,
10847 onClick,
10848 items,
10849 variant
10850 }) {
10851 const label = typeof action.label === "string" ? action.label : action.label(items);
10852 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10853 import_components2.Button,
10854 {
10855 disabled: !!action.disabled,
10856 accessibleWhenDisabled: true,
10857 size: "compact",
10858 variant,
10859 onClick,
10860 children: label
10861 }
10862 );
10863 }
10864 function MenuItemTrigger({
10865 action,
10866 onClick,
10867 items
10868 }) {
10869 const label = typeof action.label === "string" ? action.label : action.label(items);
10870 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.ItemLabel, { children: label }) });
10871 }
10872 function ActionModal({
10873 action,
10874 items,
10875 closeModal
10876 }) {
10877 const label = typeof action.label === "string" ? action.label : action.label(items);
10878 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
10879 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10880 import_components2.Modal,
10881 {
10882 title: modalHeader || label,
10883 __experimentalHideHeader: !!action.hideModalHeader,
10884 onRequestClose: closeModal,
10885 focusOnMount: action.modalFocusOnMount ?? true,
10886 size: action.modalSize || "medium",
10887 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
10888 action.id
10889 )}`,
10890 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(action.RenderModal, { items, closeModal })
10891 }
10892 );
10893 }
10894 function ActionsMenuGroup({
10895 actions,
10896 item,
10897 registry,
10898 setActiveModalAction
10899 }) {
10900 const { primaryActions, regularActions } = (0, import_element20.useMemo)(() => {
10901 return actions.reduce(
10902 (acc, action) => {
10903 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
10904 return acc;
10905 },
10906 {
10907 primaryActions: [],
10908 regularActions: []
10909 }
10910 );
10911 }, [actions]);
10912 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10913 MenuItemTrigger,
10914 {
10915 action,
10916 onClick: () => {
10917 if ("RenderModal" in action) {
10918 setActiveModalAction(action);
10919 return;
10920 }
10921 action.callback([item], { registry });
10922 },
10923 items: [item]
10924 },
10925 action.id
10926 ));
10927 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Menu.Group, { children: [
10928 renderActionGroup(primaryActions),
10929 renderActionGroup(regularActions)
10930 ] });
10931 }
10932 function ItemActions({
10933 item,
10934 actions,
10935 isCompact
10936 }) {
10937 const registry = (0, import_data2.useRegistry)();
10938 const { primaryActions, eligibleActions } = (0, import_element20.useMemo)(() => {
10939 const _eligibleActions = actions.filter(
10940 (action) => !action.isEligible || action.isEligible(item)
10941 );
10942 const _primaryActions = _eligibleActions.filter(
10943 (action) => action.isPrimary
10944 );
10945 return {
10946 primaryActions: _primaryActions,
10947 eligibleActions: _eligibleActions
10948 };
10949 }, [actions, item]);
10950 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10951 if (isCompact) {
10952 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10953 CompactItemActions,
10954 {
10955 item,
10956 actions: eligibleActions,
10957 isSmall: true,
10958 registry
10959 }
10960 );
10961 }
10962 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
10963 Stack,
10964 {
10965 direction: "row",
10966 justify: "flex-end",
10967 className: "dataviews-item-actions",
10968 style: {
10969 flexShrink: 0,
10970 width: "auto"
10971 },
10972 children: [
10973 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10974 PrimaryActions,
10975 {
10976 item,
10977 actions: primaryActions,
10978 registry
10979 }
10980 ),
10981 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
10982 // there if there are any actions at all.
10983 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10984 CompactItemActions,
10985 {
10986 item,
10987 actions: eligibleActions,
10988 registry
10989 }
10990 )
10991 ]
10992 }
10993 );
10994 }
10995 function CompactItemActions({
10996 item,
10997 actions,
10998 isSmall,
10999 registry
11000 }) {
11001 const [activeModalAction, setActiveModalAction] = (0, import_element20.useState)(
11002 null
11003 );
11004 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
11005 /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Menu, { placement: "bottom-end", children: [
11006 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11007 Menu.TriggerButton,
11008 {
11009 render: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11010 import_components2.Button,
11011 {
11012 size: isSmall ? "small" : "compact",
11013 icon: more_vertical_default,
11014 label: (0, import_i18n10.__)("Actions"),
11015 accessibleWhenDisabled: true,
11016 disabled: !actions.length,
11017 className: "dataviews-all-actions-button"
11018 }
11019 )
11020 }
11021 ),
11022 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11023 ActionsMenuGroup,
11024 {
11025 actions,
11026 item,
11027 registry,
11028 setActiveModalAction
11029 }
11030 ) })
11031 ] }),
11032 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11033 ActionModal,
11034 {
11035 action: activeModalAction,
11036 items: [item],
11037 closeModal: () => setActiveModalAction(null)
11038 }
11039 )
11040 ] });
11041 }
11042 function PrimaryActions({
11043 item,
11044 actions,
11045 registry,
11046 buttonVariant
11047 }) {
11048 const [activeModalAction, setActiveModalAction] = (0, import_element20.useState)(null);
11049 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
11050 if (isMobileViewport) {
11051 return null;
11052 }
11053 if (!Array.isArray(actions) || actions.length === 0) {
11054 return null;
11055 }
11056 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
11057 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11058 ButtonTrigger,
11059 {
11060 action,
11061 onClick: () => {
11062 if ("RenderModal" in action) {
11063 setActiveModalAction(action);
11064 return;
11065 }
11066 action.callback([item], { registry });
11067 },
11068 items: [item],
11069 variant: buttonVariant
11070 },
11071 action.id
11072 )),
11073 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11074 ActionModal,
11075 {
11076 action: activeModalAction,
11077 items: [item],
11078 closeModal: () => setActiveModalAction(null)
11079 }
11080 )
11081 ] });
11082 }
11083
11084 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
11085 var import_components3 = __toESM(require_components(), 1);
11086 var import_i18n12 = __toESM(require_i18n(), 1);
11087 var import_element21 = __toESM(require_element(), 1);
11088 var import_data3 = __toESM(require_data(), 1);
11089 var import_compose2 = __toESM(require_compose(), 1);
11090
11091 // packages/dataviews/build-module/utils/get-footer-message.mjs
11092 var import_i18n11 = __toESM(require_i18n(), 1);
11093 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
11094 if (selectionCount > 0) {
11095 return (0, import_i18n11.sprintf)(
11096 /* translators: %d: number of items. */
11097 (0, import_i18n11._n)("%d Item selected", "%d Items selected", selectionCount),
11098 selectionCount
11099 );
11100 }
11101 if (onlyTotalCount || totalItems <= itemsCount) {
11102 return (0, import_i18n11.sprintf)(
11103 /* translators: %d: number of items. */
11104 (0, import_i18n11._n)("%d Item", "%d Items", totalItems),
11105 totalItems
11106 );
11107 }
11108 return (0, import_i18n11.sprintf)(
11109 /* translators: %1$d: number of items. %2$d: total number of items. */
11110 (0, import_i18n11._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
11111 itemsCount,
11112 totalItems
11113 );
11114 }
11115
11116 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
11117 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
11118 function hasAPossibleBulkAction(actions, item) {
11119 return actions.some(
11120 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
11121 );
11122 }
11123 function useHasAPossibleBulkAction(actions, item) {
11124 return (0, import_element21.useMemo)(
11125 () => hasAPossibleBulkAction(actions, item),
11126 [actions, item]
11127 );
11128 }
11129 function useSomeItemHasAPossibleBulkAction(actions, data) {
11130 return (0, import_element21.useMemo)(
11131 () => data.some((item) => hasAPossibleBulkAction(actions, item)),
11132 [actions, data]
11133 );
11134 }
11135 function BulkSelectionCheckbox({
11136 selection,
11137 onChangeSelection,
11138 data,
11139 actions,
11140 getItemId,
11141 disableSelectAll = false
11142 }) {
11143 const selectableItems = (0, import_element21.useMemo)(() => {
11144 return data.filter((item) => {
11145 return actions.some(
11146 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
11147 );
11148 });
11149 }, [data, actions]);
11150 const selectedItems = data.filter(
11151 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
11152 );
11153 const hasSelection = selection.length > 0;
11154 const areAllSelected = selectedItems.length === selectableItems.length;
11155 if (disableSelectAll) {
11156 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11157 import_components3.CheckboxControl,
11158 {
11159 className: "dataviews-view-table-selection-checkbox",
11160 checked: hasSelection,
11161 disabled: !hasSelection,
11162 onChange: () => {
11163 onChangeSelection([]);
11164 },
11165 "aria-label": (0, import_i18n12.__)("Deselect all")
11166 }
11167 );
11168 }
11169 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11170 import_components3.CheckboxControl,
11171 {
11172 className: "dataviews-view-table-selection-checkbox",
11173 checked: areAllSelected,
11174 indeterminate: !areAllSelected && !!selectedItems.length,
11175 onChange: () => {
11176 if (areAllSelected) {
11177 onChangeSelection([]);
11178 } else {
11179 onChangeSelection(
11180 selectableItems.map((item) => getItemId(item))
11181 );
11182 }
11183 },
11184 "aria-label": areAllSelected ? (0, import_i18n12.__)("Deselect all") : (0, import_i18n12.__)("Select all")
11185 }
11186 );
11187 }
11188
11189 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11190 var import_i18n13 = __toESM(require_i18n(), 1);
11191 var import_components4 = __toESM(require_components(), 1);
11192 var import_element22 = __toESM(require_element(), 1);
11193
11194 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
11195 function getHideableFields(view, fields) {
11196 const togglableFields = [
11197 view?.titleField,
11198 view?.mediaField,
11199 view?.descriptionField
11200 ].filter(Boolean);
11201 return fields.filter(
11202 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
11203 );
11204 }
11205
11206 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11207 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
11208 var { Menu: Menu2 } = unlock2(import_components4.privateApis);
11209 function WithMenuSeparators({ children }) {
11210 return import_element22.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_element22.Fragment, { children: [
11211 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Separator, {}),
11212 child
11213 ] }, i2));
11214 }
11215 var _HeaderMenu = (0, import_element22.forwardRef)(function HeaderMenu({
11216 fieldId,
11217 view,
11218 fields,
11219 onChangeView,
11220 onHide,
11221 setOpenedFilter,
11222 canMove = true,
11223 canInsertLeft = true,
11224 canInsertRight = true
11225 }, ref) {
11226 const visibleFieldIds = view.fields ?? [];
11227 const index2 = visibleFieldIds?.indexOf(fieldId);
11228 const isSorted = view.sort?.field === fieldId;
11229 let isHidable = false;
11230 let isSortable = false;
11231 let canAddFilter = false;
11232 let operators = [];
11233 const field = fields.find((f2) => f2.id === fieldId);
11234 const { setIsShowingFilter } = (0, import_element22.useContext)(dataviews_context_default);
11235 if (!field) {
11236 return null;
11237 }
11238 isHidable = field.enableHiding !== false;
11239 isSortable = field.enableSorting !== false;
11240 const header = field.header;
11241 operators = !!field.filterBy && field.filterBy?.operators || [];
11242 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
11243 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
11244 return header;
11245 }
11246 const hiddenFields = getHideableFields(view, fields).filter(
11247 (f2) => !visibleFieldIds.includes(f2.id)
11248 );
11249 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
11250 const isRtl = (0, import_i18n13.isRTL)();
11251 return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11252 /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
11253 Menu2.TriggerButton,
11254 {
11255 render: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11256 import_components4.Button,
11257 {
11258 size: "compact",
11259 className: "dataviews-view-table-header-button",
11260 ref,
11261 variant: "tertiary"
11262 }
11263 ),
11264 children: [
11265 header,
11266 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
11267 ]
11268 }
11269 ),
11270 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(WithMenuSeparators, { children: [
11271 isSortable && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
11272 (direction) => {
11273 const isChecked = view.sort && isSorted && view.sort.direction === direction;
11274 const value = `${fieldId}-${direction}`;
11275 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11276 Menu2.RadioItem,
11277 {
11278 name: "view-table-sorting",
11279 value,
11280 checked: isChecked,
11281 onChange: () => {
11282 onChangeView({
11283 ...view,
11284 sort: {
11285 field: fieldId,
11286 direction
11287 },
11288 showLevels: false
11289 });
11290 },
11291 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
11292 },
11293 value
11294 );
11295 }
11296 ) }),
11297 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11298 Menu2.Item,
11299 {
11300 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: funnel_default }),
11301 onClick: () => {
11302 setOpenedFilter(fieldId);
11303 setIsShowingFilter(true);
11304 onChangeView({
11305 ...view,
11306 page: 1,
11307 filters: [
11308 ...view.filters || [],
11309 {
11310 field: fieldId,
11311 value: void 0,
11312 operator: operators[0]
11313 }
11314 ]
11315 });
11316 },
11317 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n13.__)("Add filter") })
11318 }
11319 ) }),
11320 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2.Group, { children: [
11321 canMove && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11322 Menu2.Item,
11323 {
11324 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: arrow_left_default }),
11325 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
11326 onClick: () => {
11327 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
11328 const newFields = [
11329 ...visibleFieldIds
11330 ];
11331 newFields.splice(index2, 1);
11332 newFields.splice(
11333 targetIndex,
11334 0,
11335 fieldId
11336 );
11337 onChangeView({
11338 ...view,
11339 fields: newFields
11340 });
11341 },
11342 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n13.__)("Move left") })
11343 }
11344 ),
11345 canMove && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11346 Menu2.Item,
11347 {
11348 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: arrow_right_default }),
11349 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
11350 onClick: () => {
11351 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
11352 const newFields = [
11353 ...visibleFieldIds
11354 ];
11355 newFields.splice(index2, 1);
11356 newFields.splice(
11357 targetIndex,
11358 0,
11359 fieldId
11360 );
11361 onChangeView({
11362 ...view,
11363 fields: newFields
11364 });
11365 },
11366 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n13.__)("Move right") })
11367 }
11368 ),
11369 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11370 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n13.__)("Insert left") }) }),
11371 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11372 const insertIndex = isRtl ? index2 + 1 : index2;
11373 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11374 Menu2.Item,
11375 {
11376 onClick: () => {
11377 onChangeView({
11378 ...view,
11379 fields: [
11380 ...visibleFieldIds.slice(
11381 0,
11382 insertIndex
11383 ),
11384 hiddenField.id,
11385 ...visibleFieldIds.slice(
11386 insertIndex
11387 )
11388 ]
11389 });
11390 },
11391 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11392 },
11393 hiddenField.id
11394 );
11395 }) })
11396 ] }),
11397 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11398 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n13.__)("Insert right") }) }),
11399 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11400 const insertIndex = isRtl ? index2 : index2 + 1;
11401 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11402 Menu2.Item,
11403 {
11404 onClick: () => {
11405 onChangeView({
11406 ...view,
11407 fields: [
11408 ...visibleFieldIds.slice(
11409 0,
11410 insertIndex
11411 ),
11412 hiddenField.id,
11413 ...visibleFieldIds.slice(
11414 insertIndex
11415 )
11416 ]
11417 });
11418 },
11419 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11420 },
11421 hiddenField.id
11422 );
11423 }) })
11424 ] }),
11425 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11426 Menu2.Item,
11427 {
11428 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: unseen_default }),
11429 onClick: () => {
11430 onHide(field);
11431 onChangeView({
11432 ...view,
11433 fields: visibleFieldIds.filter(
11434 (id) => id !== fieldId
11435 )
11436 });
11437 },
11438 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n13.__)("Hide column") })
11439 }
11440 )
11441 ] })
11442 ] }) })
11443 ] });
11444 });
11445 var ColumnHeaderMenu = _HeaderMenu;
11446 var column_header_menu_default = ColumnHeaderMenu;
11447
11448 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
11449 var import_element23 = __toESM(require_element(), 1);
11450 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
11451 function getClickableItemProps({
11452 item,
11453 isItemClickable: isItemClickable2,
11454 onClickItem,
11455 className
11456 }) {
11457 if (!isItemClickable2(item) || !onClickItem) {
11458 return { className };
11459 }
11460 return {
11461 className: className ? `${className} ${className}--clickable` : void 0,
11462 role: "button",
11463 tabIndex: 0,
11464 onClick: (event) => {
11465 event.stopPropagation();
11466 onClickItem(item);
11467 },
11468 onKeyDown: (event) => {
11469 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11470 event.stopPropagation();
11471 onClickItem(item);
11472 }
11473 }
11474 };
11475 }
11476 function ItemClickWrapper({
11477 item,
11478 isItemClickable: isItemClickable2,
11479 onClickItem,
11480 renderItemLink,
11481 className,
11482 children,
11483 ...extraProps
11484 }) {
11485 if (!isItemClickable2(item)) {
11486 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className, ...extraProps, children });
11487 }
11488 if (renderItemLink) {
11489 const renderedElement = renderItemLink({
11490 item,
11491 className: `${className} ${className}--clickable`,
11492 ...extraProps,
11493 children
11494 });
11495 return (0, import_element23.cloneElement)(renderedElement, {
11496 onClick: (event) => {
11497 event.stopPropagation();
11498 if (renderedElement.props.onClick) {
11499 renderedElement.props.onClick(event);
11500 }
11501 },
11502 onKeyDown: (event) => {
11503 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11504 event.stopPropagation();
11505 if (renderedElement.props.onKeyDown) {
11506 renderedElement.props.onKeyDown(event);
11507 }
11508 }
11509 }
11510 });
11511 }
11512 const clickProps = getClickableItemProps({
11513 item,
11514 isItemClickable: isItemClickable2,
11515 onClickItem,
11516 className
11517 });
11518 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { ...clickProps, ...extraProps, children });
11519 }
11520
11521 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
11522 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
11523 function ColumnPrimary({
11524 item,
11525 level,
11526 titleField,
11527 mediaField,
11528 descriptionField: descriptionField2,
11529 onClickItem,
11530 renderItemLink,
11531 isItemClickable: isItemClickable2
11532 }) {
11533 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
11534 mediaField && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11535 ItemClickWrapper,
11536 {
11537 item,
11538 isItemClickable: isItemClickable2,
11539 onClickItem,
11540 renderItemLink,
11541 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
11542 "aria-label": isItemClickable2(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
11543 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11544 mediaField.render,
11545 {
11546 item,
11547 field: mediaField,
11548 config: { sizes: "32px" }
11549 }
11550 )
11551 }
11552 ),
11553 /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
11554 Stack,
11555 {
11556 direction: "column",
11557 align: "flex-start",
11558 className: "dataviews-view-table__primary-column-content",
11559 children: [
11560 titleField && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
11561 ItemClickWrapper,
11562 {
11563 item,
11564 isItemClickable: isItemClickable2,
11565 onClickItem,
11566 renderItemLink,
11567 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
11568 children: [
11569 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("span", { className: "dataviews-view-table__level", children: [
11570 Array(level).fill("\u2014").join(" "),
11571 "\xA0"
11572 ] }),
11573 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(titleField.render, { item, field: titleField })
11574 ]
11575 }
11576 ),
11577 descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11578 descriptionField2.render,
11579 {
11580 item,
11581 field: descriptionField2
11582 }
11583 )
11584 ]
11585 }
11586 )
11587 ] });
11588 }
11589 var column_primary_default = ColumnPrimary;
11590
11591 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
11592 var import_element24 = __toESM(require_element(), 1);
11593 var import_i18n14 = __toESM(require_i18n(), 1);
11594 var isScrolledToEnd = (element) => {
11595 if ((0, import_i18n14.isRTL)()) {
11596 const scrollLeft = Math.abs(element.scrollLeft);
11597 return scrollLeft <= 1;
11598 }
11599 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
11600 };
11601 function useScrollState({
11602 scrollContainerRef,
11603 enabledHorizontal = false
11604 }) {
11605 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element24.useState)(false);
11606 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element24.useState)(false);
11607 const handleScroll = (0, import_element24.useCallback)(() => {
11608 const scrollContainer = scrollContainerRef.current;
11609 if (!scrollContainer) {
11610 return;
11611 }
11612 if (enabledHorizontal) {
11613 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
11614 }
11615 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
11616 }, [scrollContainerRef, enabledHorizontal]);
11617 (0, import_element24.useEffect)(() => {
11618 if (typeof window === "undefined" || !scrollContainerRef.current) {
11619 return () => {
11620 };
11621 }
11622 const scrollContainer = scrollContainerRef.current;
11623 handleScroll();
11624 scrollContainer.addEventListener("scroll", handleScroll);
11625 window.addEventListener("resize", handleScroll);
11626 return () => {
11627 scrollContainer.removeEventListener("scroll", handleScroll);
11628 window.removeEventListener("resize", handleScroll);
11629 };
11630 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
11631 return { isHorizontalScrollEnd, isVerticallyScrolled };
11632 }
11633
11634 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
11635 function getDataByGroup(data, groupByField) {
11636 return data.reduce((groups, item) => {
11637 const groupName = groupByField.getValue({ item });
11638 if (!groups.has(groupName)) {
11639 groups.set(groupName, []);
11640 }
11641 groups.get(groupName)?.push(item);
11642 return groups;
11643 }, /* @__PURE__ */ new Map());
11644 }
11645
11646 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-selection-props.mjs
11647 var import_element25 = __toESM(require_element(), 1);
11648 var import_keycodes = __toESM(require_keycodes(), 1);
11649 function getRange(orderedIds, fromIndex, toIndex) {
11650 return orderedIds.slice(
11651 Math.min(fromIndex, toIndex),
11652 Math.max(fromIndex, toIndex) + 1
11653 );
11654 }
11655 function getRangeSelection({
11656 anchorId,
11657 targetId,
11658 lastTargetId,
11659 orderedIds,
11660 selection
11661 }) {
11662 const targetIndex = orderedIds.indexOf(targetId);
11663 if (targetIndex === -1) {
11664 return selection;
11665 }
11666 const anchorIndex = anchorId === null ? -1 : orderedIds.indexOf(anchorId);
11667 const hasAnchor = anchorIndex !== -1;
11668 const rangeStart = hasAnchor ? anchorIndex : targetIndex;
11669 const lastTargetIndex = hasAnchor && lastTargetId !== null ? orderedIds.indexOf(lastTargetId) : -1;
11670 const lastRange = lastTargetIndex === -1 ? [] : getRange(orderedIds, rangeStart, lastTargetIndex);
11671 const base = selection.filter((id) => !lastRange.includes(id));
11672 return [
11673 .../* @__PURE__ */ new Set([
11674 ...base,
11675 ...getRange(orderedIds, rangeStart, targetIndex)
11676 ])
11677 ];
11678 }
11679 function getClosestSelectedId({
11680 targetId,
11681 orderedIds,
11682 selection
11683 }) {
11684 const targetIndex = orderedIds.indexOf(targetId);
11685 if (targetIndex === -1) {
11686 return null;
11687 }
11688 const selectedIds = new Set(selection);
11689 let closestId = null;
11690 let closestDistance = Infinity;
11691 orderedIds.forEach((id, index2) => {
11692 if (!selectedIds.has(id)) {
11693 return;
11694 }
11695 const distance = Math.abs(index2 - targetIndex);
11696 if (distance < closestDistance) {
11697 closestDistance = distance;
11698 closestId = id;
11699 }
11700 });
11701 return closestId;
11702 }
11703 function useSelectionProps({
11704 data,
11705 getItemId,
11706 isItemSelectable,
11707 selection,
11708 onChangeSelection,
11709 selectionMode,
11710 shouldSelectOnClick
11711 }) {
11712 const isMultiselect = selectionMode === "multi";
11713 const allowDeselect = selectionMode !== "single-required";
11714 const gestureRef = (0, import_element25.useRef)(null);
11715 const anchorTo = (id) => {
11716 gestureRef.current = { anchorId: id, lastTargetId: null };
11717 };
11718 const isTouchDeviceRef = (0, import_element25.useRef)(false);
11719 (0, import_element25.useEffect)(() => {
11720 const markTouchDevice = () => {
11721 isTouchDeviceRef.current = true;
11722 };
11723 document.addEventListener("touchstart", markTouchDevice, {
11724 once: true
11725 });
11726 return () => document.removeEventListener("touchstart", markTouchDevice);
11727 }, []);
11728 const selectableIds = data.filter(isItemSelectable).map(getItemId);
11729 const selectableIdSet = new Set(selectableIds);
11730 const hasSelectableItems = selectableIds.length > 0;
11731 const hasRangeGesture = hasSelectableItems && isMultiselect;
11732 const getSelectionProps = (id) => {
11733 const isSelectable = selectableIdSet.has(id);
11734 return {
11735 // When a plain click selects, that click is also what anchors the
11736 // range a following Shift+Click extends from. Modifier clicks never
11737 // reach here: `onClickCapture` stops them.
11738 ...shouldSelectOnClick && {
11739 onClick: () => {
11740 if (allowDeselect && selection.includes(id)) {
11741 onChangeSelection(
11742 selection.filter((itemId) => id !== itemId)
11743 );
11744 } else {
11745 onChangeSelection(
11746 isMultiselect ? [...selection, id] : [id]
11747 );
11748 }
11749 anchorTo(id);
11750 }
11751 },
11752 onMouseDown: (event) => {
11753 if (event.button === 0 && event.shiftKey && hasRangeGesture) {
11754 event.preventDefault();
11755 }
11756 },
11757 onClickCapture: (event) => {
11758 if (!hasRangeGesture) {
11759 return;
11760 }
11761 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11762 const isSelectionCheckboxClick = event.target instanceof Element && !!event.target.closest(`.${SELECTION_CHECKBOX_CLASS}`);
11763 if (!isModifierKeyPressed && !event.shiftKey) {
11764 if (isSelectable && isSelectionCheckboxClick) {
11765 anchorTo(id);
11766 }
11767 return;
11768 }
11769 if (isTouchDeviceRef.current || document.getSelection()?.type === "Range") {
11770 return;
11771 }
11772 event.stopPropagation();
11773 if (!isSelectionCheckboxClick) {
11774 event.preventDefault();
11775 }
11776 if (!isSelectable) {
11777 return;
11778 }
11779 if (event.shiftKey) {
11780 let gesture = gestureRef.current;
11781 if (!gesture || !selectableIdSet.has(gesture.anchorId)) {
11782 gesture = {
11783 anchorId: getClosestSelectedId({
11784 targetId: id,
11785 orderedIds: selectableIds,
11786 selection
11787 }) ?? id,
11788 lastTargetId: null
11789 };
11790 }
11791 onChangeSelection(
11792 getRangeSelection({
11793 anchorId: gesture.anchorId,
11794 targetId: id,
11795 lastTargetId: gesture.lastTargetId,
11796 orderedIds: selectableIds,
11797 selection
11798 })
11799 );
11800 gestureRef.current = {
11801 anchorId: gesture.anchorId,
11802 lastTargetId: id
11803 };
11804 } else {
11805 onChangeSelection(
11806 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
11807 );
11808 anchorTo(id);
11809 }
11810 }
11811 };
11812 };
11813 return { getSelectionProps };
11814 }
11815
11816 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
11817 var import_components5 = __toESM(require_components(), 1);
11818 var import_i18n15 = __toESM(require_i18n(), 1);
11819 var import_element26 = __toESM(require_element(), 1);
11820 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
11821 function FieldItem({
11822 field,
11823 isVisible: isVisible2,
11824 onToggleVisibility
11825 }) {
11826 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components5.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
11827 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components5.Icon, { icon: check_default }) }),
11828 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
11829 ] }) });
11830 }
11831 function isDefined(item) {
11832 return !!item;
11833 }
11834 function PropertiesSection({
11835 showLabel = true
11836 }) {
11837 const { view, fields, onChangeView } = (0, import_element26.useContext)(dataviews_context_default);
11838 const regularFields = getHideableFields(view, fields);
11839 if (!regularFields?.length) {
11840 return null;
11841 }
11842 const titleField = fields.find((f2) => f2.id === view.titleField);
11843 const previewField = fields.find((f2) => f2.id === view.mediaField);
11844 const descriptionField2 = fields.find(
11845 (f2) => f2.id === view.descriptionField
11846 );
11847 const lockedFields = [
11848 {
11849 field: titleField,
11850 isVisibleFlag: "showTitle"
11851 },
11852 {
11853 field: previewField,
11854 isVisibleFlag: "showMedia"
11855 },
11856 {
11857 field: descriptionField2,
11858 isVisibleFlag: "showDescription"
11859 }
11860 ].filter(({ field }) => isDefined(field));
11861 const visibleFieldIds = view.fields ?? [];
11862 const visibleRegularFieldsCount = regularFields.filter(
11863 (f2) => visibleFieldIds.includes(f2.id)
11864 ).length;
11865 const visibleLockedFields = lockedFields.filter(
11866 ({ isVisibleFlag }) => (
11867 // @ts-expect-error
11868 view[isVisibleFlag] ?? true
11869 )
11870 );
11871 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
11872 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
11873 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
11874 showLabel && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n15.__)("Properties") }),
11875 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11876 Stack,
11877 {
11878 direction: "column",
11879 className: "dataviews-view-config__properties",
11880 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
11881 lockedFields.map(({ field, isVisibleFlag }) => {
11882 const isVisible2 = view[isVisibleFlag] ?? true;
11883 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
11884 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11885 FieldItem,
11886 {
11887 field: fieldToRender,
11888 isVisible: isVisible2,
11889 onToggleVisibility: () => {
11890 onChangeView({
11891 ...view,
11892 [isVisibleFlag]: !isVisible2
11893 });
11894 }
11895 },
11896 field.id
11897 );
11898 }),
11899 regularFields.map((field) => {
11900 const isVisible2 = visibleFieldIds.includes(field.id);
11901 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
11902 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11903 FieldItem,
11904 {
11905 field: fieldToRender,
11906 isVisible: isVisible2,
11907 onToggleVisibility: () => {
11908 onChangeView({
11909 ...view,
11910 fields: isVisible2 ? visibleFieldIds.filter(
11911 (fieldId) => fieldId !== field.id
11912 ) : [...visibleFieldIds, field.id]
11913 });
11914 }
11915 },
11916 field.id
11917 );
11918 })
11919 ] })
11920 }
11921 )
11922 ] });
11923 }
11924
11925 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
11926 var import_element27 = __toESM(require_element(), 1);
11927 function useDelayedLoading(isLoading, options = { delay: 400 }) {
11928 const [showLoader, setShowLoader] = (0, import_element27.useState)(false);
11929 (0, import_element27.useEffect)(() => {
11930 if (!isLoading) {
11931 return;
11932 }
11933 const timeout = setTimeout(() => {
11934 setShowLoader(true);
11935 }, options.delay);
11936 return () => {
11937 clearTimeout(timeout);
11938 setShowLoader(false);
11939 };
11940 }, [isLoading, options.delay]);
11941 return showLoader;
11942 }
11943
11944 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
11945 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
11946 function getEffectiveAlign(explicitAlign, fieldType) {
11947 if (explicitAlign) {
11948 return explicitAlign;
11949 }
11950 if (fieldType === "integer" || fieldType === "number") {
11951 return "end";
11952 }
11953 return void 0;
11954 }
11955 function TableColumnField({
11956 item,
11957 fields,
11958 column,
11959 align
11960 }) {
11961 const field = fields.find((f2) => f2.id === column);
11962 if (!field) {
11963 return null;
11964 }
11965 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
11966 "dataviews-view-table__cell-align-end": align === "end",
11967 "dataviews-view-table__cell-align-center": align === "center"
11968 });
11969 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(field.render, { item, field }) });
11970 }
11971 function TableRow({
11972 hasBulkActions,
11973 item,
11974 level,
11975 actions,
11976 fields,
11977 id,
11978 view,
11979 titleField,
11980 mediaField,
11981 descriptionField: descriptionField2,
11982 selection,
11983 getItemId,
11984 isItemClickable: isItemClickable2,
11985 onClickItem,
11986 renderItemLink,
11987 onChangeSelection,
11988 onMouseDown,
11989 onClickCapture,
11990 isActionsColumnSticky,
11991 posinset
11992 }) {
11993 const { paginationInfo } = (0, import_element28.useContext)(dataviews_context_default);
11994 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
11995 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
11996 const {
11997 showTitle = true,
11998 showMedia = true,
11999 showDescription = true,
12000 infiniteScrollEnabled
12001 } = view;
12002 const columns = view.fields ?? [];
12003 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
12004 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
12005 "tr",
12006 {
12007 className: clsx_default("dataviews-view-table__row", {
12008 "is-selected": hasPossibleBulkAction && isSelected2,
12009 "has-bulk-actions": hasPossibleBulkAction
12010 }),
12011 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
12012 "aria-posinset": posinset,
12013 role: infiniteScrollEnabled ? "article" : void 0,
12014 onClickCapture,
12015 onMouseDown: (event) => {
12016 const isMetaClick = (0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey;
12017 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
12018 event.preventDefault();
12019 }
12020 onMouseDown(event);
12021 },
12022 children: [
12023 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12024 DataViewsSelectionCheckbox,
12025 {
12026 item,
12027 selection,
12028 onChangeSelection,
12029 getItemId,
12030 titleField,
12031 disabled: !hasPossibleBulkAction
12032 }
12033 ) }) }),
12034 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12035 column_primary_default,
12036 {
12037 item,
12038 level,
12039 titleField: showTitle ? titleField : void 0,
12040 mediaField: showMedia ? mediaField : void 0,
12041 descriptionField: showDescription ? descriptionField2 : void 0,
12042 isItemClickable: isItemClickable2,
12043 onClickItem,
12044 renderItemLink
12045 }
12046 ) }),
12047 columns.map((column) => {
12048 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
12049 const field = fields.find((f2) => f2.id === column);
12050 const effectiveAlign = getEffectiveAlign(align, field?.type);
12051 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12052 "td",
12053 {
12054 style: {
12055 width,
12056 maxWidth,
12057 minWidth
12058 },
12059 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12060 TableColumnField,
12061 {
12062 fields,
12063 item,
12064 column,
12065 align: effectiveAlign
12066 }
12067 )
12068 },
12069 column
12070 );
12071 }),
12072 !!actions?.length && // Disable reason: we are not making the element interactive,
12073 // but preventing any click events from bubbling up to the
12074 // table row. This allows us to add a click handler to the row
12075 // itself (to toggle row selection) without erroneously
12076 // intercepting click events from ItemActions.
12077 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12078 "td",
12079 {
12080 className: clsx_default("dataviews-view-table__actions-column", {
12081 "dataviews-view-table__actions-column--sticky": true,
12082 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
12083 }),
12084 onClick: (e2) => e2.stopPropagation(),
12085 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ItemActions, { item, actions })
12086 }
12087 )
12088 ]
12089 }
12090 );
12091 }
12092 function ViewTable({
12093 actions,
12094 data,
12095 fields,
12096 getItemId,
12097 getItemLevel,
12098 isLoading = false,
12099 onChangeView,
12100 onChangeSelection,
12101 selection,
12102 setOpenedFilter,
12103 onClickItem,
12104 isItemClickable: isItemClickable2,
12105 renderItemLink,
12106 view,
12107 className,
12108 empty
12109 }) {
12110 const { containerRef } = (0, import_element28.useContext)(dataviews_context_default);
12111 const isDelayedLoading = useDelayedLoading(isLoading);
12112 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12113 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12114 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
12115 const { getSelectionProps } = useSelectionProps({
12116 data: orderedData,
12117 getItemId,
12118 isItemSelectable: (item) => hasAPossibleBulkAction(actions, item),
12119 selection,
12120 onChangeSelection,
12121 selectionMode: "multi",
12122 shouldSelectOnClick: false
12123 });
12124 const headerMenuRefs = (0, import_element28.useRef)(/* @__PURE__ */ new Map());
12125 const headerMenuToFocusRef = (0, import_element28.useRef)(void 0);
12126 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element28.useState)();
12127 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element28.useState)(null);
12128 (0, import_element28.useEffect)(() => {
12129 if (headerMenuToFocusRef.current) {
12130 headerMenuToFocusRef.current.focus();
12131 headerMenuToFocusRef.current = void 0;
12132 }
12133 });
12134 const tableNoticeId = (0, import_element28.useId)();
12135 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
12136 scrollContainerRef: containerRef,
12137 enabledHorizontal: !!actions?.length
12138 });
12139 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12140 if (nextHeaderMenuToFocus) {
12141 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
12142 setNextHeaderMenuToFocus(void 0);
12143 return;
12144 }
12145 const onHide = (field) => {
12146 const hidden = headerMenuRefs.current.get(field.id);
12147 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
12148 setNextHeaderMenuToFocus(fallback?.node);
12149 };
12150 const handleHeaderContextMenu = (event) => {
12151 event.preventDefault();
12152 event.stopPropagation();
12153 const virtualAnchor = {
12154 getBoundingClientRect: () => ({
12155 x: event.clientX,
12156 y: event.clientY,
12157 top: event.clientY,
12158 left: event.clientX,
12159 right: event.clientX,
12160 bottom: event.clientY,
12161 width: 0,
12162 height: 0,
12163 toJSON: () => ({})
12164 })
12165 };
12166 window.requestAnimationFrame(() => {
12167 setContextMenuAnchor(virtualAnchor);
12168 });
12169 };
12170 const hasData = !!data?.length;
12171 const titleField = fields.find((field) => field.id === view.titleField);
12172 const mediaField = fields.find((field) => field.id === view.mediaField);
12173 const descriptionField2 = fields.find(
12174 (field) => field.id === view.descriptionField
12175 );
12176 const { showTitle = true, showMedia = true, showDescription = true } = view;
12177 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
12178 const columns = view.fields ?? [];
12179 const headerMenuRef = (column, index2) => (node) => {
12180 if (node) {
12181 headerMenuRefs.current.set(column, {
12182 node,
12183 fallback: columns[index2 > 0 ? index2 - 1 : 1]
12184 });
12185 } else {
12186 headerMenuRefs.current.delete(column);
12187 }
12188 };
12189 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12190 const isRtl = (0, import_i18n16.isRTL)();
12191 if (!hasData) {
12192 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12193 "div",
12194 {
12195 className: clsx_default("dataviews-no-results", {
12196 "is-refreshing": isDelayedLoading
12197 }),
12198 id: tableNoticeId,
12199 children: empty
12200 }
12201 );
12202 }
12203 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
12204 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
12205 "table",
12206 {
12207 className: clsx_default("dataviews-view-table", className, {
12208 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12209 view.layout.density
12210 ),
12211 "has-bulk-actions": hasBulkActions,
12212 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12213 }),
12214 "aria-busy": isLoading,
12215 "aria-describedby": tableNoticeId,
12216 role: isInfiniteScroll ? "feed" : void 0,
12217 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
12218 children: [
12219 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("colgroup", { children: [
12220 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
12221 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
12222 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12223 "col",
12224 {
12225 className: clsx_default(
12226 `dataviews-view-table__col-${column}`,
12227 {
12228 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
12229 }
12230 )
12231 },
12232 `col-${column}`
12233 )),
12234 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-actions" })
12235 ] }),
12236 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12237 import_components6.Popover,
12238 {
12239 anchor: contextMenuAnchor,
12240 onClose: () => setContextMenuAnchor(null),
12241 placement: "bottom-start",
12242 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(PropertiesSection, { showLabel: false })
12243 }
12244 ),
12245 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12246 "thead",
12247 {
12248 className: clsx_default({
12249 "dataviews-view-table__thead--stuck": isVerticallyScrolled
12250 }),
12251 onContextMenu: handleHeaderContextMenu,
12252 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("tr", { className: "dataviews-view-table__row", children: [
12253 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12254 "th",
12255 {
12256 className: "dataviews-view-table__checkbox-column",
12257 scope: "col",
12258 onContextMenu: handleHeaderContextMenu,
12259 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12260 BulkSelectionCheckbox,
12261 {
12262 selection,
12263 onChangeSelection,
12264 data,
12265 actions,
12266 getItemId
12267 }
12268 )
12269 }
12270 ),
12271 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12272 column_header_menu_default,
12273 {
12274 ref: headerMenuRef(
12275 titleField.id,
12276 0
12277 ),
12278 fieldId: titleField.id,
12279 view,
12280 fields,
12281 onChangeView,
12282 onHide,
12283 setOpenedFilter,
12284 canMove: false,
12285 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
12286 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
12287 }
12288 ) }),
12289 columns.map((column, index2) => {
12290 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
12291 const field = fields.find(
12292 (f2) => f2.id === column
12293 );
12294 const effectiveAlign = getEffectiveAlign(
12295 align,
12296 field?.type
12297 );
12298 const canInsertOrMove = view.layout?.enableMoving ?? true;
12299 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12300 "th",
12301 {
12302 style: {
12303 width,
12304 maxWidth,
12305 minWidth,
12306 textAlign: effectiveAlign
12307 },
12308 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
12309 scope: "col",
12310 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12311 column_header_menu_default,
12312 {
12313 ref: headerMenuRef(column, index2),
12314 fieldId: column,
12315 view,
12316 fields,
12317 onChangeView,
12318 onHide,
12319 setOpenedFilter,
12320 canMove: canInsertOrMove,
12321 canInsertLeft: canInsertOrMove,
12322 canInsertRight: canInsertOrMove
12323 }
12324 )
12325 },
12326 column
12327 );
12328 }),
12329 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12330 "th",
12331 {
12332 className: clsx_default(
12333 "dataviews-view-table__actions-column",
12334 {
12335 "dataviews-view-table__actions-column--sticky": true,
12336 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
12337 }
12338 ),
12339 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n16.__)("Actions") })
12340 }
12341 )
12342 ] })
12343 }
12344 ),
12345 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
12346 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("tbody", { children: [
12347 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12348 "td",
12349 {
12350 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
12351 className: "dataviews-view-table__group-header-cell",
12352 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n16.sprintf)(
12353 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12354 (0, import_i18n16.__)("%1$s: %2$s"),
12355 groupField.label,
12356 groupName
12357 )
12358 }
12359 ) }),
12360 groupItems.map((item, index2) => {
12361 const id = getItemId(item) || index2.toString();
12362 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12363 TableRow,
12364 {
12365 item,
12366 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12367 hasBulkActions,
12368 actions,
12369 fields,
12370 id,
12371 view,
12372 titleField,
12373 mediaField,
12374 descriptionField: descriptionField2,
12375 selection,
12376 getItemId,
12377 onChangeSelection,
12378 ...getSelectionProps(id),
12379 onClickItem,
12380 renderItemLink,
12381 isItemClickable: isItemClickable2,
12382 isActionsColumnSticky: !isHorizontalScrollEnd
12383 },
12384 getItemId(item)
12385 );
12386 })
12387 ] }, `group-${groupName}`)
12388 ) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("tbody", { children: hasData && data.map((item, index2) => {
12389 const id = getItemId(item) || index2.toString();
12390 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12391 TableRow,
12392 {
12393 item,
12394 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12395 hasBulkActions,
12396 actions,
12397 fields,
12398 id,
12399 view,
12400 titleField,
12401 mediaField,
12402 descriptionField: descriptionField2,
12403 selection,
12404 getItemId,
12405 onChangeSelection,
12406 ...getSelectionProps(id),
12407 onClickItem,
12408 renderItemLink,
12409 isItemClickable: isItemClickable2,
12410 isActionsColumnSticky: !isHorizontalScrollEnd,
12411 posinset: isInfiniteScroll ? index2 + 1 : void 0
12412 },
12413 getItemId(item)
12414 );
12415 }) })
12416 ]
12417 }
12418 ),
12419 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components6.Spinner, {}) }) })
12420 ] });
12421 }
12422 var table_default = ViewTable;
12423
12424 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12425 var import_components9 = __toESM(require_components(), 1);
12426 var import_i18n19 = __toESM(require_i18n(), 1);
12427
12428 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12429 var import_components8 = __toESM(require_components(), 1);
12430 var import_i18n18 = __toESM(require_i18n(), 1);
12431 var import_compose3 = __toESM(require_compose(), 1);
12432 var import_element32 = __toESM(require_element(), 1);
12433
12434 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
12435 var import_components7 = __toESM(require_components(), 1);
12436 var import_i18n17 = __toESM(require_i18n(), 1);
12437 var import_element29 = __toESM(require_element(), 1);
12438 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
12439 var imageSizes = [
12440 {
12441 value: 120,
12442 breakpoint: 1
12443 },
12444 {
12445 value: 170,
12446 breakpoint: 1
12447 },
12448 {
12449 value: 230,
12450 breakpoint: 1
12451 },
12452 {
12453 value: 290,
12454 breakpoint: 1112
12455 // at minimum image width, 4 images display at this container size
12456 },
12457 {
12458 value: 350,
12459 breakpoint: 1636
12460 // at minimum image width, 6 images display at this container size
12461 },
12462 {
12463 value: 430,
12464 breakpoint: 588
12465 // at minimum image width, 2 images display at this container size
12466 }
12467 ];
12468 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
12469 function useGridColumns() {
12470 const context = (0, import_element29.useContext)(dataviews_context_default);
12471 const view = context.view;
12472 return (0, import_element29.useMemo)(() => {
12473 const containerWidth = context.containerWidth;
12474 const gap = 32;
12475 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
12476 const columns = Math.floor(
12477 (containerWidth + gap) / (previewSize + gap)
12478 );
12479 return Math.max(1, columns);
12480 }, [context.containerWidth, view.layout?.previewSize]);
12481 }
12482
12483 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
12484 var import_element30 = __toESM(require_element(), 1);
12485 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
12486 var GridItems = (0, import_element30.forwardRef)(({ className, previewSize, ...props }, ref) => {
12487 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12488 "div",
12489 {
12490 ref,
12491 className: clsx_default("dataviews-view-grid-items", className),
12492 style: {
12493 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
12494 },
12495 ...props
12496 }
12497 );
12498 });
12499
12500 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
12501 var import_element31 = __toESM(require_element(), 1);
12502 function useIntersectionObserver(elementRef, posinset) {
12503 const { intersectionObserver } = (0, import_element31.useContext)(dataviews_context_default);
12504 (0, import_element31.useEffect)(() => {
12505 const element = elementRef.current;
12506 if (!element || posinset === void 0 || !intersectionObserver) {
12507 return;
12508 }
12509 intersectionObserver.observe(element);
12510 return () => {
12511 intersectionObserver.unobserve(element);
12512 };
12513 }, [elementRef, intersectionObserver, posinset]);
12514 }
12515 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
12516 const hasData = !!data?.length;
12517 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
12518 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
12519 }
12520
12521 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12522 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
12523 var { Badge: WCBadge } = unlock2(import_components8.privateApis);
12524 function chunk(array, size4) {
12525 const chunks = [];
12526 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
12527 chunks.push(array.slice(i2, i2 + size4));
12528 }
12529 return chunks;
12530 }
12531 var GridItem = (0, import_element32.forwardRef)(
12532 function GridItem2({
12533 view,
12534 selection,
12535 onChangeSelection,
12536 onClickItem,
12537 isItemClickable: isItemClickable2,
12538 renderItemLink,
12539 getItemId,
12540 item,
12541 actions,
12542 mediaField,
12543 titleField,
12544 descriptionField: descriptionField2,
12545 regularFields,
12546 badgeFields,
12547 hasBulkActions,
12548 config,
12549 posinset,
12550 setsize,
12551 ...props
12552 }, forwardedRef) {
12553 const {
12554 showTitle = true,
12555 showMedia = true,
12556 showDescription = true
12557 } = view;
12558 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
12559 const id = getItemId(item);
12560 const elementRef = (0, import_element32.useRef)(null);
12561 const setRefs = (0, import_element32.useCallback)(
12562 (node) => {
12563 elementRef.current = node;
12564 if (typeof forwardedRef === "function") {
12565 forwardedRef(node);
12566 } else if (forwardedRef) {
12567 forwardedRef.current = node;
12568 }
12569 },
12570 [forwardedRef]
12571 );
12572 useIntersectionObserver(elementRef, posinset);
12573 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
12574 const isSelected2 = selection.includes(id);
12575 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
12576 const rendersMediaField = showMedia && mediaField?.render;
12577 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12578 mediaField.render,
12579 {
12580 item,
12581 field: mediaField,
12582 config
12583 }
12584 ) : mediaPlaceholder;
12585 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(titleField.render, { item, field: titleField }) : null;
12586 let mediaA11yProps;
12587 let titleA11yProps;
12588 if (isItemClickable2(item) && onClickItem) {
12589 if (renderedTitleField) {
12590 mediaA11yProps = {
12591 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
12592 };
12593 titleA11yProps = {
12594 id: `dataviews-view-grid__title-field-${instanceId}`
12595 };
12596 } else {
12597 mediaA11yProps = {
12598 "aria-label": (0, import_i18n18.__)("Navigate to item")
12599 };
12600 }
12601 }
12602 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12603 Stack,
12604 {
12605 direction: "column",
12606 ...props,
12607 ref: setRefs,
12608 "aria-setsize": setsize,
12609 "aria-posinset": posinset,
12610 className: clsx_default(
12611 props.className,
12612 "dataviews-view-grid__row__gridcell",
12613 "dataviews-view-grid__card",
12614 {
12615 "is-selected": hasBulkAction && isSelected2
12616 }
12617 ),
12618 children: [
12619 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12620 ItemClickWrapper,
12621 {
12622 item,
12623 isItemClickable: isItemClickable2,
12624 onClickItem,
12625 renderItemLink,
12626 className: clsx_default("dataviews-view-grid__media", {
12627 "dataviews-view-grid__media--placeholder": !rendersMediaField
12628 }),
12629 ...mediaA11yProps,
12630 children: renderedMediaField
12631 }
12632 ),
12633 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12634 DataViewsSelectionCheckbox,
12635 {
12636 item,
12637 selection,
12638 onChangeSelection,
12639 getItemId,
12640 titleField,
12641 disabled: !hasBulkAction
12642 }
12643 ),
12644 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12645 ItemActions,
12646 {
12647 item,
12648 actions,
12649 isCompact: true
12650 }
12651 ) }),
12652 showTitle && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12653 ItemClickWrapper,
12654 {
12655 item,
12656 isItemClickable: isItemClickable2,
12657 onClickItem,
12658 renderItemLink,
12659 className: "dataviews-view-grid__title-field dataviews-title-field",
12660 ...titleA11yProps,
12661 title: titleField?.getValueFormatted({
12662 item,
12663 field: titleField
12664 }) || void 0,
12665 children: renderedTitleField
12666 }
12667 ) }),
12668 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(Stack, { direction: "column", gap: "xs", children: [
12669 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12670 descriptionField2.render,
12671 {
12672 item,
12673 field: descriptionField2
12674 }
12675 ),
12676 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12677 Stack,
12678 {
12679 direction: "row",
12680 className: "dataviews-view-grid__badge-fields",
12681 gap: "sm",
12682 wrap: "wrap",
12683 align: "top",
12684 justify: "flex-start",
12685 children: badgeFields.map((field) => {
12686 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12687 WCBadge,
12688 {
12689 className: "dataviews-view-grid__field-value",
12690 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12691 field.render,
12692 {
12693 item,
12694 field
12695 }
12696 )
12697 },
12698 field.id
12699 );
12700 })
12701 }
12702 ),
12703 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12704 Stack,
12705 {
12706 direction: "column",
12707 className: "dataviews-view-grid__fields",
12708 gap: "xs",
12709 children: regularFields.map((field) => {
12710 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12711 import_components8.Flex,
12712 {
12713 className: "dataviews-view-grid__field",
12714 gap: 1,
12715 justify: "flex-start",
12716 expanded: true,
12717 style: { height: "auto" },
12718 direction: "row",
12719 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
12720 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(tooltip_exports.Root, { children: [
12721 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12722 tooltip_exports.Trigger,
12723 {
12724 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
12725 }
12726 ),
12727 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(tooltip_exports.Popup, { children: field.label })
12728 ] }),
12729 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12730 import_components8.FlexItem,
12731 {
12732 className: "dataviews-view-grid__field-value",
12733 style: { maxHeight: "none" },
12734 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12735 field.render,
12736 {
12737 item,
12738 field
12739 }
12740 )
12741 }
12742 )
12743 ] })
12744 },
12745 field.id
12746 );
12747 })
12748 }
12749 )
12750 ] })
12751 ]
12752 }
12753 );
12754 }
12755 );
12756 function CompositeGrid({
12757 data,
12758 isInfiniteScroll,
12759 className,
12760 inert,
12761 isLoading,
12762 view,
12763 fields,
12764 selection,
12765 onChangeSelection,
12766 onClickItem,
12767 isItemClickable: isItemClickable2,
12768 renderItemLink,
12769 getItemId,
12770 actions,
12771 getSelectionProps
12772 }) {
12773 const { paginationInfo, resizeObserverRef } = (0, import_element32.useContext)(dataviews_context_default);
12774 const gridColumns = useGridColumns();
12775 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12776 const titleField = fields.find(
12777 (field) => field.id === view?.titleField
12778 );
12779 const mediaField = fields.find(
12780 (field) => field.id === view?.mediaField
12781 );
12782 const descriptionField2 = fields.find(
12783 (field) => field.id === view?.descriptionField
12784 );
12785 const otherFields = view.fields ?? [];
12786 const { regularFields, badgeFields } = otherFields.reduce(
12787 (accumulator, fieldId) => {
12788 const field = fields.find((f2) => f2.id === fieldId);
12789 if (!field) {
12790 return accumulator;
12791 }
12792 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
12793 accumulator[key].push(field);
12794 return accumulator;
12795 },
12796 { regularFields: [], badgeFields: [] }
12797 );
12798 const size4 = "900px";
12799 const totalRows = Math.ceil(data.length / gridColumns);
12800 const placeholdersNeeded = usePlaceholdersNeeded(
12801 data,
12802 isInfiniteScroll,
12803 gridColumns
12804 );
12805 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, {
12806 // Render infinite scroll layout (no rows, feed semantics)
12807 children: [
12808 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12809 import_components8.Composite,
12810 {
12811 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12812 GridItems,
12813 {
12814 className: clsx_default(
12815 "dataviews-view-grid-infinite-scroll",
12816 className,
12817 {
12818 [`has-${view.layout?.density}-density`]: view.layout?.density && [
12819 "compact",
12820 "comfortable"
12821 ].includes(view.layout.density)
12822 }
12823 ),
12824 previewSize: view.layout?.previewSize,
12825 "aria-busy": isLoading,
12826 ref: resizeObserverRef
12827 }
12828 ),
12829 role: "feed",
12830 focusWrap: true,
12831 inert,
12832 children: [
12833 Array.from({ length: placeholdersNeeded }).map(
12834 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12835 import_components8.Composite.Item,
12836 {
12837 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12838 Stack,
12839 {
12840 ...props,
12841 direction: "column",
12842 role: "article",
12843 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
12844 }
12845 ),
12846 "aria-hidden": true,
12847 tabIndex: -1
12848 },
12849 `placeholder-${index2}`
12850 )
12851 ),
12852 data.map((item) => {
12853 const itemId = getItemId(item);
12854 const selectionProps = getSelectionProps(itemId);
12855 const stablePosition = item.position;
12856 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12857 import_components8.Composite.Item,
12858 {
12859 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12860 GridItem,
12861 {
12862 ...props,
12863 id: itemId,
12864 role: "article",
12865 view,
12866 selection,
12867 onChangeSelection,
12868 onClickItem,
12869 isItemClickable: isItemClickable2,
12870 renderItemLink,
12871 getItemId,
12872 item,
12873 actions,
12874 onMouseDown: (event) => {
12875 props.onMouseDown?.(event);
12876 selectionProps.onMouseDown(
12877 event
12878 );
12879 },
12880 onClickCapture: (event) => {
12881 props.onClickCapture?.(event);
12882 selectionProps.onClickCapture(
12883 event
12884 );
12885 },
12886 mediaField,
12887 titleField,
12888 descriptionField: descriptionField2,
12889 regularFields,
12890 badgeFields,
12891 hasBulkActions,
12892 posinset: stablePosition,
12893 setsize: paginationInfo.totalItems,
12894 config: {
12895 sizes: size4
12896 }
12897 }
12898 )
12899 },
12900 itemId
12901 );
12902 })
12903 ]
12904 }
12905 ),
12906 // Render standard grid layout (with rows, grid semantics)
12907 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12908 import_components8.Composite,
12909 {
12910 role: "grid",
12911 className: clsx_default("dataviews-view-grid", className, {
12912 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12913 view.layout.density
12914 )
12915 }),
12916 focusWrap: true,
12917 "aria-busy": isLoading,
12918 "aria-rowcount": totalRows,
12919 ref: resizeObserverRef,
12920 inert,
12921 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12922 import_components8.Composite.Row,
12923 {
12924 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12925 "div",
12926 {
12927 role: "row",
12928 "aria-rowindex": i2 + 1,
12929 "aria-label": (0, import_i18n18.sprintf)(
12930 /* translators: %d: The row number in the grid */
12931 (0, import_i18n18.__)("Row %d"),
12932 i2 + 1
12933 ),
12934 className: "dataviews-view-grid__row",
12935 style: {
12936 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
12937 }
12938 }
12939 ),
12940 children: row.map((item) => {
12941 const itemId = getItemId(item);
12942 const selectionProps = getSelectionProps(itemId);
12943 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12944 import_components8.Composite.Item,
12945 {
12946 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12947 GridItem,
12948 {
12949 ...props,
12950 id: itemId,
12951 role: "gridcell",
12952 view,
12953 selection,
12954 onChangeSelection,
12955 onClickItem,
12956 isItemClickable: isItemClickable2,
12957 renderItemLink,
12958 getItemId,
12959 item,
12960 actions,
12961 onMouseDown: (event) => {
12962 props.onMouseDown?.(
12963 event
12964 );
12965 selectionProps.onMouseDown(
12966 event
12967 );
12968 },
12969 onClickCapture: (event) => {
12970 props.onClickCapture?.(
12971 event
12972 );
12973 selectionProps.onClickCapture(
12974 event
12975 );
12976 },
12977 mediaField,
12978 titleField,
12979 descriptionField: descriptionField2,
12980 regularFields,
12981 badgeFields,
12982 hasBulkActions,
12983 config: {
12984 sizes: size4
12985 }
12986 }
12987 )
12988 },
12989 itemId
12990 );
12991 })
12992 },
12993 i2
12994 ))
12995 }
12996 )
12997 ]
12998 });
12999 }
13000
13001 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
13002 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
13003 function ViewGrid({
13004 actions,
13005 data,
13006 fields,
13007 getItemId,
13008 isLoading,
13009 onChangeSelection,
13010 onClickItem,
13011 isItemClickable: isItemClickable2,
13012 renderItemLink,
13013 selection,
13014 view,
13015 className,
13016 empty
13017 }) {
13018 const isDelayedLoading = useDelayedLoading(!!isLoading);
13019 const hasData = !!data?.length;
13020 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
13021 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
13022 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13023 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
13024 const { getSelectionProps } = useSelectionProps({
13025 data: orderedData,
13026 getItemId,
13027 isItemSelectable: (item) => hasAPossibleBulkAction(actions, item),
13028 selection,
13029 onChangeSelection,
13030 selectionMode: "multi",
13031 shouldSelectOnClick: false
13032 });
13033 if (!hasData) {
13034 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13035 "div",
13036 {
13037 className: clsx_default("dataviews-no-results", {
13038 "is-refreshing": isDelayedLoading
13039 }),
13040 children: empty
13041 }
13042 );
13043 }
13044 const gridProps = {
13045 className: clsx_default(className, {
13046 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13047 }),
13048 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
13049 isLoading,
13050 view,
13051 fields,
13052 selection,
13053 onChangeSelection,
13054 onClickItem,
13055 isItemClickable: isItemClickable2,
13056 renderItemLink,
13057 getItemId,
13058 actions,
13059 getSelectionProps
13060 };
13061 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, {
13062 // Render multiple groups.
13063 children: [
13064 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
13065 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13066 Stack,
13067 {
13068 direction: "column",
13069 gap: "sm",
13070 children: [
13071 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n19.sprintf)(
13072 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13073 (0, import_i18n19.__)("%1$s: %2$s"),
13074 groupField.label,
13075 groupName
13076 ) }),
13077 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13078 CompositeGrid,
13079 {
13080 ...gridProps,
13081 data: groupItems,
13082 isInfiniteScroll: false
13083 }
13084 )
13085 ]
13086 },
13087 groupName
13088 )
13089 ) }),
13090 // Render a single grid with all data.
13091 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13092 CompositeGrid,
13093 {
13094 ...gridProps,
13095 data,
13096 isInfiniteScroll: !!isInfiniteScroll
13097 }
13098 ),
13099 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components9.Spinner, {}) })
13100 ]
13101 });
13102 }
13103 var grid_default = ViewGrid;
13104
13105 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
13106 var import_compose4 = __toESM(require_compose(), 1);
13107 var import_components10 = __toESM(require_components(), 1);
13108 var import_element33 = __toESM(require_element(), 1);
13109 var import_i18n20 = __toESM(require_i18n(), 1);
13110 var import_data4 = __toESM(require_data(), 1);
13111 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
13112 var { Menu: Menu3 } = unlock2(import_components10.privateApis);
13113 function generateItemWrapperCompositeId(idPrefix) {
13114 return `${idPrefix}-item-wrapper`;
13115 }
13116 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
13117 return `${idPrefix}-primary-action-${primaryActionId}`;
13118 }
13119 function generateDropdownTriggerCompositeId(idPrefix) {
13120 return `${idPrefix}-dropdown`;
13121 }
13122 function PrimaryActionGridCell({
13123 idPrefix,
13124 primaryAction,
13125 item
13126 }) {
13127 const registry = (0, import_data4.useRegistry)();
13128 const [isModalOpen, setIsModalOpen] = (0, import_element33.useState)(false);
13129 const compositeItemId = generatePrimaryActionCompositeId(
13130 idPrefix,
13131 primaryAction.id
13132 );
13133 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
13134 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13135 import_components10.Composite.Item,
13136 {
13137 id: compositeItemId,
13138 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13139 import_components10.Button,
13140 {
13141 disabled: !!primaryAction.disabled,
13142 accessibleWhenDisabled: true,
13143 text: label,
13144 size: "small",
13145 onClick: () => setIsModalOpen(true)
13146 }
13147 ),
13148 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13149 ActionModal,
13150 {
13151 action: primaryAction,
13152 items: [item],
13153 closeModal: () => setIsModalOpen(false)
13154 }
13155 )
13156 }
13157 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13158 import_components10.Composite.Item,
13159 {
13160 id: compositeItemId,
13161 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13162 import_components10.Button,
13163 {
13164 disabled: !!primaryAction.disabled,
13165 accessibleWhenDisabled: true,
13166 size: "small",
13167 onClick: () => {
13168 primaryAction.callback([item], { registry });
13169 },
13170 children: label
13171 }
13172 )
13173 }
13174 ) }, primaryAction.id);
13175 }
13176 function ListItem({
13177 view,
13178 actions,
13179 idPrefix,
13180 isSelected: isSelected2,
13181 item,
13182 titleField,
13183 mediaField,
13184 descriptionField: descriptionField2,
13185 selectionProps,
13186 otherFields,
13187 onDropdownTriggerKeyDown,
13188 posinset
13189 }) {
13190 const {
13191 showTitle = true,
13192 showMedia = true,
13193 showDescription = true,
13194 infiniteScrollEnabled
13195 } = view;
13196 const itemRef = (0, import_element33.useRef)(null);
13197 const labelId = `${idPrefix}-label`;
13198 const descriptionId = `${idPrefix}-description`;
13199 const registry = (0, import_data4.useRegistry)();
13200 const [isHovered, setIsHovered] = (0, import_element33.useState)(false);
13201 const [activeModalAction, setActiveModalAction] = (0, import_element33.useState)(
13202 null
13203 );
13204 const handleHover = ({ type }) => {
13205 const isHover = type === "mouseenter";
13206 setIsHovered(isHover);
13207 };
13208 const { paginationInfo } = (0, import_element33.useContext)(dataviews_context_default);
13209 (0, import_element33.useEffect)(() => {
13210 if (isSelected2) {
13211 itemRef.current?.scrollIntoView({
13212 behavior: "auto",
13213 block: "nearest",
13214 inline: "nearest"
13215 });
13216 }
13217 }, [isSelected2]);
13218 const { primaryAction, eligibleActions } = (0, import_element33.useMemo)(() => {
13219 const _eligibleActions = actions.filter(
13220 (action) => !action.isEligible || action.isEligible(item)
13221 );
13222 const _primaryActions = _eligibleActions.filter(
13223 (action) => action.isPrimary
13224 );
13225 return {
13226 primaryAction: _primaryActions[0],
13227 eligibleActions: _eligibleActions
13228 };
13229 }, [actions, item]);
13230 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
13231 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13232 mediaField.render,
13233 {
13234 item,
13235 field: mediaField,
13236 config: { sizes: "52px" }
13237 }
13238 ) }) : null;
13239 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(titleField.render, { item, field: titleField }) : null;
13240 const renderDescription = showDescription && descriptionField2?.render;
13241 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
13242 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13243 Stack,
13244 {
13245 direction: "row",
13246 gap: "md",
13247 className: "dataviews-view-list__item-actions",
13248 children: [
13249 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13250 PrimaryActionGridCell,
13251 {
13252 idPrefix,
13253 primaryAction,
13254 item
13255 }
13256 ),
13257 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { role: "gridcell", children: [
13258 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Menu3, { placement: "bottom-end", children: [
13259 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13260 Menu3.TriggerButton,
13261 {
13262 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13263 import_components10.Composite.Item,
13264 {
13265 id: generateDropdownTriggerCompositeId(
13266 idPrefix
13267 ),
13268 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13269 import_components10.Button,
13270 {
13271 size: "small",
13272 icon: more_vertical_default,
13273 label: (0, import_i18n20.__)("Actions"),
13274 accessibleWhenDisabled: true,
13275 disabled: !actions.length,
13276 onKeyDown: onDropdownTriggerKeyDown
13277 }
13278 )
13279 }
13280 )
13281 }
13282 ),
13283 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13284 ActionsMenuGroup,
13285 {
13286 actions: eligibleActions,
13287 item,
13288 registry,
13289 setActiveModalAction
13290 }
13291 ) })
13292 ] }),
13293 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13294 ActionModal,
13295 {
13296 action: activeModalAction,
13297 items: [item],
13298 closeModal: () => setActiveModalAction(null)
13299 }
13300 )
13301 ] })
13302 ]
13303 }
13304 );
13305 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13306 import_components10.Composite.Row,
13307 {
13308 ref: itemRef,
13309 render: (
13310 /* aria-posinset breaks Composite.Row if passed to it directly. */
13311 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13312 "div",
13313 {
13314 "aria-posinset": posinset,
13315 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
13316 }
13317 )
13318 ),
13319 role: infiniteScrollEnabled ? "article" : "row",
13320 className: clsx_default({
13321 "is-selected": isSelected2,
13322 "is-hovered": isHovered
13323 }),
13324 onMouseEnter: handleHover,
13325 onMouseLeave: handleHover,
13326 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13327 Stack,
13328 {
13329 direction: "row",
13330 className: "dataviews-view-list__item-wrapper",
13331 children: [
13332 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13333 import_components10.Composite.Item,
13334 {
13335 id: generateItemWrapperCompositeId(idPrefix),
13336 "aria-pressed": isSelected2,
13337 "aria-labelledby": labelId,
13338 "aria-describedby": descriptionId,
13339 className: "dataviews-view-list__item",
13340 ...selectionProps
13341 }
13342 ) }),
13343 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13344 Stack,
13345 {
13346 direction: "row",
13347 gap: "md",
13348 justify: "start",
13349 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
13350 style: { flex: 1, minWidth: 0 },
13351 children: [
13352 renderedMediaField,
13353 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13354 Stack,
13355 {
13356 direction: "column",
13357 gap: "xs",
13358 className: "dataviews-view-list__field-wrapper",
13359 children: [
13360 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Stack, { direction: "row", align: "center", children: [
13361 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13362 "div",
13363 {
13364 className: "dataviews-title-field dataviews-view-list__title-field",
13365 id: labelId,
13366 children: renderedTitleField
13367 }
13368 ),
13369 usedActions
13370 ] }),
13371 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13372 descriptionField2.render,
13373 {
13374 item,
13375 field: descriptionField2
13376 }
13377 ) }),
13378 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13379 "div",
13380 {
13381 className: "dataviews-view-list__fields",
13382 id: descriptionId,
13383 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13384 "div",
13385 {
13386 className: "dataviews-view-list__field",
13387 children: [
13388 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13389 VisuallyHidden,
13390 {
13391 className: "dataviews-view-list__field-label",
13392 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", {}),
13393 children: field.label
13394 }
13395 ),
13396 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13397 field.render,
13398 {
13399 item,
13400 field
13401 }
13402 ) })
13403 ]
13404 },
13405 field.id
13406 ))
13407 }
13408 )
13409 ]
13410 }
13411 )
13412 ]
13413 }
13414 )
13415 ]
13416 }
13417 )
13418 }
13419 );
13420 }
13421 function isDefined2(item) {
13422 return !!item;
13423 }
13424 function ViewList(props) {
13425 const {
13426 actions,
13427 data,
13428 fields,
13429 getItemId,
13430 isLoading,
13431 onChangeSelection,
13432 selection,
13433 view,
13434 className,
13435 empty
13436 } = props;
13437 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
13438 const isDelayedLoading = useDelayedLoading(!!isLoading);
13439 const { paginationInfo } = (0, import_element33.useContext)(dataviews_context_default);
13440 const selectedItem = data?.findLast(
13441 (item) => selection.includes(getItemId(item))
13442 );
13443 const titleField = fields.find((field) => field.id === view.titleField);
13444 const mediaField = fields.find((field) => field.id === view.mediaField);
13445 const descriptionField2 = fields.find(
13446 (field) => field.id === view.descriptionField
13447 );
13448 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
13449 const { getSelectionProps } = useSelectionProps({
13450 data,
13451 getItemId,
13452 isItemSelectable: () => true,
13453 selection,
13454 onChangeSelection,
13455 selectionMode: "single-required",
13456 shouldSelectOnClick: true
13457 });
13458 const generateCompositeItemIdPrefix = (0, import_element33.useCallback)(
13459 (item) => `${baseId}-${getItemId(item)}`,
13460 [baseId, getItemId]
13461 );
13462 const isActiveCompositeItem = (0, import_element33.useCallback)(
13463 (item, idToCheck) => {
13464 return idToCheck.startsWith(
13465 generateCompositeItemIdPrefix(item)
13466 );
13467 },
13468 [generateCompositeItemIdPrefix]
13469 );
13470 const [activeCompositeId, setActiveCompositeId] = (0, import_element33.useState)(void 0);
13471 const compositeRef = (0, import_element33.useRef)(null);
13472 (0, import_element33.useEffect)(() => {
13473 if (selectedItem) {
13474 setActiveCompositeId(
13475 generateItemWrapperCompositeId(
13476 generateCompositeItemIdPrefix(selectedItem)
13477 )
13478 );
13479 }
13480 }, [selectedItem, generateCompositeItemIdPrefix]);
13481 const activeItemIndex = data.findIndex(
13482 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
13483 );
13484 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
13485 const isActiveIdInList = activeItemIndex !== -1;
13486 const selectCompositeItem = (0, import_element33.useCallback)(
13487 (targetIndex, generateCompositeId) => {
13488 const clampedIndex = Math.min(
13489 data.length - 1,
13490 Math.max(0, targetIndex)
13491 );
13492 if (!data[clampedIndex]) {
13493 return;
13494 }
13495 const itemIdPrefix = generateCompositeItemIdPrefix(
13496 data[clampedIndex]
13497 );
13498 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
13499 setActiveCompositeId(targetCompositeItemId);
13500 if (compositeRef.current?.contains(
13501 compositeRef.current.ownerDocument.activeElement
13502 )) {
13503 document.getElementById(targetCompositeItemId)?.focus();
13504 }
13505 },
13506 [data, generateCompositeItemIdPrefix]
13507 );
13508 (0, import_element33.useEffect)(() => {
13509 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
13510 if (!isActiveIdInList && wasActiveIdInList) {
13511 selectCompositeItem(
13512 previousActiveItemIndex,
13513 generateItemWrapperCompositeId
13514 );
13515 }
13516 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
13517 const onDropdownTriggerKeyDown = (0, import_element33.useCallback)(
13518 (event) => {
13519 if (event.key === "ArrowDown") {
13520 event.preventDefault();
13521 selectCompositeItem(
13522 activeItemIndex + 1,
13523 generateDropdownTriggerCompositeId
13524 );
13525 }
13526 if (event.key === "ArrowUp") {
13527 event.preventDefault();
13528 selectCompositeItem(
13529 activeItemIndex - 1,
13530 generateDropdownTriggerCompositeId
13531 );
13532 }
13533 },
13534 [selectCompositeItem, activeItemIndex]
13535 );
13536 const hasData = !!data?.length;
13537 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13538 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13539 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13540 const hasMoreItems = isInfiniteScroll && (view.startPosition ?? 1) + (view.perPage ?? 0) < paginationInfo.totalItems;
13541 const listClassName = clsx_default("dataviews-view-list", className, {
13542 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(view.layout.density),
13543 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13544 });
13545 const compositeProps = {
13546 ref: compositeRef,
13547 id: baseId,
13548 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", {}),
13549 activeId: activeCompositeId,
13550 setActiveId: setActiveCompositeId,
13551 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0
13552 };
13553 if (!hasData) {
13554 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13555 "div",
13556 {
13557 className: clsx_default("dataviews-no-results", {
13558 "is-refreshing": isDelayedLoading
13559 }),
13560 children: empty
13561 }
13562 );
13563 }
13564 if (hasData && groupField && dataByGroup) {
13565 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13566 import_components10.Composite,
13567 {
13568 ...compositeProps,
13569 className: "dataviews-view-list__group",
13570 role: "grid",
13571 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Stack, { direction: "column", gap: "lg", className: listClassName, children: Array.from(dataByGroup.entries()).map(
13572 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Stack, { direction: "column", children: [
13573 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n20.sprintf)(
13574 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13575 (0, import_i18n20.__)("%1$s: %2$s"),
13576 groupField.label,
13577 groupName
13578 ) }),
13579 groupItems.map((item) => {
13580 const id = generateCompositeItemIdPrefix(item);
13581 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13582 ListItem,
13583 {
13584 view,
13585 idPrefix: id,
13586 actions,
13587 item,
13588 isSelected: item === selectedItem,
13589 selectionProps: getSelectionProps(
13590 getItemId(item)
13591 ),
13592 mediaField,
13593 titleField,
13594 descriptionField: descriptionField2,
13595 otherFields,
13596 onDropdownTriggerKeyDown
13597 },
13598 id
13599 );
13600 })
13601 ] }, groupName)
13602 ) })
13603 }
13604 );
13605 }
13606 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [
13607 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13608 import_components10.Composite,
13609 {
13610 ...compositeProps,
13611 className: listClassName,
13612 role: view.infiniteScrollEnabled ? "feed" : "grid",
13613 children: data.map((item, index2) => {
13614 const id = generateCompositeItemIdPrefix(item);
13615 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13616 ListItem,
13617 {
13618 view,
13619 idPrefix: id,
13620 actions,
13621 item,
13622 isSelected: item === selectedItem,
13623 selectionProps: getSelectionProps(
13624 getItemId(item)
13625 ),
13626 mediaField,
13627 titleField,
13628 descriptionField: descriptionField2,
13629 otherFields,
13630 onDropdownTriggerKeyDown,
13631 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13632 },
13633 id
13634 );
13635 })
13636 }
13637 ),
13638 (hasMoreItems || isInfiniteScroll && isLoading) && // Keep the spinner's height reserved while loading more so the
13639 // scroll position doesn't bounce. Hidden, and silent to a11y,
13640 // while idle.
13641 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13642 "p",
13643 {
13644 className: "dataviews-loading-more",
13645 "aria-hidden": !isLoading,
13646 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components10.Spinner, {})
13647 }
13648 )
13649 ] });
13650 }
13651
13652 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13653 var import_components11 = __toESM(require_components(), 1);
13654
13655 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
13656 var import_i18n21 = __toESM(require_i18n(), 1);
13657 var import_element34 = __toESM(require_element(), 1);
13658 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
13659 function ActivityGroup({
13660 groupName,
13661 groupData,
13662 groupField,
13663 showLabel = true,
13664 children
13665 }) {
13666 const groupHeader = showLabel ? (0, import_element34.createInterpolateElement)(
13667 // translators: %s: The label of the field e.g. "Status".
13668 (0, import_i18n21.sprintf)((0, import_i18n21.__)("%s: <groupName />"), groupField.label).trim(),
13669 {
13670 groupName: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13671 groupField.render,
13672 {
13673 item: groupData[0],
13674 field: groupField
13675 }
13676 )
13677 }
13678 ) : /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(groupField.render, { item: groupData[0], field: groupField });
13679 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
13680 Stack,
13681 {
13682 direction: "column",
13683 className: "dataviews-view-activity__group",
13684 children: [
13685 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
13686 children
13687 ]
13688 },
13689 groupName
13690 );
13691 }
13692
13693 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
13694 var import_element35 = __toESM(require_element(), 1);
13695 var import_data5 = __toESM(require_data(), 1);
13696 var import_compose5 = __toESM(require_compose(), 1);
13697 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
13698 function ActivityItem(props) {
13699 const {
13700 view,
13701 actions,
13702 item,
13703 titleField,
13704 mediaField,
13705 descriptionField: descriptionField2,
13706 otherFields,
13707 posinset,
13708 onClickItem,
13709 renderItemLink,
13710 isItemClickable: isItemClickable2
13711 } = props;
13712 const {
13713 showTitle = true,
13714 showMedia = true,
13715 showDescription = true,
13716 infiniteScrollEnabled
13717 } = view;
13718 const itemRef = (0, import_element35.useRef)(null);
13719 const registry = (0, import_data5.useRegistry)();
13720 const { paginationInfo } = (0, import_element35.useContext)(dataviews_context_default);
13721 const { primaryActions, eligibleActions } = (0, import_element35.useMemo)(() => {
13722 const _eligibleActions = actions.filter(
13723 (action) => !action.isEligible || action.isEligible(item)
13724 );
13725 const _primaryActions = _eligibleActions.filter(
13726 (action) => action.isPrimary
13727 );
13728 return {
13729 primaryActions: _primaryActions,
13730 eligibleActions: _eligibleActions
13731 };
13732 }, [actions, item]);
13733 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
13734 const density = view.layout?.density ?? "balanced";
13735 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13736 mediaField.render,
13737 {
13738 item,
13739 field: mediaField,
13740 config: {
13741 sizes: density === "comfortable" ? "32px" : "24px"
13742 }
13743 }
13744 ) : null;
13745 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13746 "span",
13747 {
13748 className: "dataviews-view-activity__item-bullet",
13749 "aria-hidden": "true"
13750 }
13751 ) });
13752 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(titleField.render, { item, field: titleField }) : null;
13753 const verticalGap = (0, import_element35.useMemo)(() => {
13754 switch (density) {
13755 case "comfortable":
13756 return "md";
13757 default:
13758 return "sm";
13759 }
13760 }, [density]);
13761 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13762 "div",
13763 {
13764 ref: itemRef,
13765 role: infiniteScrollEnabled ? "article" : void 0,
13766 "aria-posinset": posinset,
13767 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
13768 className: clsx_default(
13769 "dataviews-view-activity__item",
13770 density === "compact" && "is-compact",
13771 density === "balanced" && "is-balanced",
13772 density === "comfortable" && "is-comfortable"
13773 ),
13774 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
13775 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13776 Stack,
13777 {
13778 direction: "column",
13779 gap: "xs",
13780 align: "center",
13781 className: "dataviews-view-activity__item-type",
13782 children: renderedMediaField
13783 }
13784 ),
13785 /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
13786 Stack,
13787 {
13788 direction: "column",
13789 gap: verticalGap,
13790 align: "flex-start",
13791 className: "dataviews-view-activity__item-content",
13792 children: [
13793 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13794 ItemClickWrapper,
13795 {
13796 item,
13797 isItemClickable: isItemClickable2,
13798 onClickItem,
13799 renderItemLink,
13800 className: "dataviews-view-activity__item-title",
13801 children: renderedTitleField
13802 }
13803 ),
13804 showDescription && descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13805 descriptionField2.render,
13806 {
13807 item,
13808 field: descriptionField2
13809 }
13810 ) }),
13811 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
13812 "div",
13813 {
13814 className: "dataviews-view-activity__item-field",
13815 children: [
13816 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13817 VisuallyHidden,
13818 {
13819 className: "dataviews-view-activity__item-field-label",
13820 render: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", {}),
13821 children: field.label
13822 }
13823 ),
13824 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13825 field.render,
13826 {
13827 item,
13828 field
13829 }
13830 ) })
13831 ]
13832 },
13833 field.id
13834 )) }),
13835 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13836 PrimaryActions,
13837 {
13838 item,
13839 actions: primaryActions,
13840 registry,
13841 buttonVariant: "secondary"
13842 }
13843 )
13844 ]
13845 }
13846 ),
13847 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13848 // there if there are any actions at all.
13849 isMobileViewport && // At the same time, only show the menu if there are actions to show.
13850 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13851 ItemActions,
13852 {
13853 item,
13854 actions: eligibleActions,
13855 isCompact: true
13856 }
13857 ) })
13858 ] })
13859 }
13860 );
13861 }
13862 var activity_item_default = ActivityItem;
13863
13864 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
13865 var import_react6 = __toESM(require_react(), 1);
13866 function isDefined3(item) {
13867 return !!item;
13868 }
13869 function ActivityItems(props) {
13870 const { data, fields, getItemId, view } = props;
13871 const titleField = fields.find((field) => field.id === view.titleField);
13872 const mediaField = fields.find((field) => field.id === view.mediaField);
13873 const descriptionField2 = fields.find(
13874 (field) => field.id === view.descriptionField
13875 );
13876 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
13877 return data.map((item, index2) => {
13878 return /* @__PURE__ */ (0, import_react6.createElement)(
13879 activity_item_default,
13880 {
13881 ...props,
13882 key: getItemId(item),
13883 item,
13884 mediaField,
13885 titleField,
13886 descriptionField: descriptionField2,
13887 otherFields,
13888 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13889 }
13890 );
13891 });
13892 }
13893
13894 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13895 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
13896 function ViewActivity(props) {
13897 const { empty, data, fields, isLoading, view, className } = props;
13898 const isDelayedLoading = useDelayedLoading(!!isLoading);
13899 const hasData = !!data?.length;
13900 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13901 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13902 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13903 if (!hasData) {
13904 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13905 "div",
13906 {
13907 className: clsx_default("dataviews-no-results", {
13908 "is-refreshing": isDelayedLoading
13909 }),
13910 children: empty
13911 }
13912 );
13913 }
13914 const isInert = !isInfiniteScroll && !!isLoading;
13915 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
13916 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13917 });
13918 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
13919 if (hasData && groupField && dataByGroup) {
13920 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13921 Stack,
13922 {
13923 direction: "column",
13924 gap: "sm",
13925 className: wrapperClassName,
13926 inert: isInert ? "true" : void 0,
13927 children: groupedEntries.map(
13928 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13929 ActivityGroup,
13930 {
13931 groupName,
13932 groupData,
13933 groupField,
13934 showLabel: view.groupBy?.showLabel !== false,
13935 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13936 ActivityItems,
13937 {
13938 ...props,
13939 data: groupData
13940 }
13941 )
13942 },
13943 groupName
13944 )
13945 )
13946 }
13947 );
13948 }
13949 return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
13950 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13951 "div",
13952 {
13953 className: wrapperClassName,
13954 role: view.infiniteScrollEnabled ? "feed" : void 0,
13955 inert: isInert ? "true" : void 0,
13956 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(ActivityItems, { ...props })
13957 }
13958 ),
13959 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_components11.Spinner, {}) })
13960 ] });
13961 }
13962
13963 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13964 var import_components14 = __toESM(require_components(), 1);
13965 var import_i18n24 = __toESM(require_i18n(), 1);
13966 var import_compose6 = __toESM(require_compose(), 1);
13967 var import_element38 = __toESM(require_element(), 1);
13968
13969 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13970 var import_components13 = __toESM(require_components(), 1);
13971 var import_data6 = __toESM(require_data(), 1);
13972 var import_element37 = __toESM(require_element(), 1);
13973 var import_i18n23 = __toESM(require_i18n(), 1);
13974
13975 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
13976 var import_components12 = __toESM(require_components(), 1);
13977 var import_element36 = __toESM(require_element(), 1);
13978 var import_i18n22 = __toESM(require_i18n(), 1);
13979 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
13980 function hasPaginationControls(view, paginationInfo) {
13981 return !view.infiniteScrollEnabled && paginationInfo.totalItems > 0 && paginationInfo.totalPages > 1;
13982 }
13983 function DataViewsPagination() {
13984 const { view, onChangeView, paginationInfo } = (0, import_element36.useContext)(dataviews_context_default);
13985 if (!hasPaginationControls(view, paginationInfo)) {
13986 return null;
13987 }
13988 const { totalPages } = paginationInfo;
13989 const currentPage = view.page ?? 1;
13990 const pageSelectOptions = Array.from(Array(totalPages)).map(
13991 (_, i2) => {
13992 const page = i2 + 1;
13993 return {
13994 value: page.toString(),
13995 label: page.toString(),
13996 "aria-label": currentPage === page ? (0, import_i18n22.sprintf)(
13997 // translators: 1: current page number. 2: total number of pages.
13998 (0, import_i18n22.__)("Page %1$d of %2$d"),
13999 currentPage,
14000 totalPages
14001 ) : page.toString()
14002 };
14003 }
14004 );
14005 return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
14006 Stack,
14007 {
14008 direction: "row",
14009 className: "dataviews-pagination",
14010 justify: "end",
14011 align: "center",
14012 gap: "xl",
14013 children: [
14014 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
14015 Stack,
14016 {
14017 direction: "row",
14018 justify: "flex-start",
14019 align: "center",
14020 gap: "xs",
14021 className: "dataviews-pagination__page-select",
14022 children: (0, import_element36.createInterpolateElement)(
14023 (0, import_i18n22.sprintf)(
14024 // translators: 1: Current page number, 2: Total number of pages.
14025 (0, import_i18n22._x)("<div>Page</div>%1$s<div>of %2$d</div>", "paging"),
14026 "<CurrentPage />",
14027 totalPages
14028 ),
14029 {
14030 div: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { "aria-hidden": true }),
14031 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
14032 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
14033 import_components12.SelectControl,
14034 {
14035 "aria-label": (0, import_i18n22.__)("Current page"),
14036 value: currentPage.toString(),
14037 options: pageSelectOptions,
14038 onChange: (newValue) => {
14039 onChangeView({
14040 ...view,
14041 page: +newValue
14042 });
14043 },
14044 size: "small",
14045 variant: "minimal"
14046 }
14047 )
14048 }
14049 )
14050 }
14051 ),
14052 /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
14053 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
14054 import_components12.Button,
14055 {
14056 onClick: () => onChangeView({
14057 ...view,
14058 page: currentPage - 1
14059 }),
14060 disabled: currentPage === 1,
14061 accessibleWhenDisabled: true,
14062 label: (0, import_i18n22.__)("Previous page"),
14063 icon: (0, import_i18n22.isRTL)() ? next_default : previous_default,
14064 showTooltip: true,
14065 size: "compact",
14066 tooltipPosition: "top"
14067 }
14068 ),
14069 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
14070 import_components12.Button,
14071 {
14072 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
14073 disabled: currentPage >= totalPages,
14074 accessibleWhenDisabled: true,
14075 label: (0, import_i18n22.__)("Next page"),
14076 icon: (0, import_i18n22.isRTL)() ? previous_default : next_default,
14077 showTooltip: true,
14078 size: "compact",
14079 tooltipPosition: "top"
14080 }
14081 )
14082 ] })
14083 ]
14084 }
14085 );
14086 }
14087 var dataviews_pagination_default = (0, import_element36.memo)(DataViewsPagination);
14088
14089 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
14090 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
14091 var EMPTY_ARRAY2 = [];
14092 function useIsMultiselectPicker(actions) {
14093 return (0, import_element37.useMemo)(() => {
14094 return !!actions?.length && actions?.every((action) => action.supportsBulk);
14095 }, [actions]);
14096 }
14097 function BulkSelectionCheckbox2({
14098 selection,
14099 selectedItems,
14100 onChangeSelection,
14101 data,
14102 getItemId,
14103 disableSelectAll = false
14104 }) {
14105 const hasSelection = selection.length > 0;
14106 const areAllSelected = selectedItems.length === data.length;
14107 if (disableSelectAll) {
14108 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14109 import_components13.CheckboxControl,
14110 {
14111 className: "dataviews-view-table-selection-checkbox",
14112 checked: hasSelection,
14113 disabled: !hasSelection,
14114 onChange: () => {
14115 onChangeSelection([]);
14116 },
14117 "aria-label": (0, import_i18n23.__)("Deselect all")
14118 }
14119 );
14120 }
14121 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14122 import_components13.CheckboxControl,
14123 {
14124 className: "dataviews-view-table-selection-checkbox",
14125 checked: areAllSelected,
14126 indeterminate: !areAllSelected && !!selectedItems.length,
14127 onChange: () => {
14128 if (areAllSelected) {
14129 onChangeSelection(
14130 selection.filter(
14131 (id) => !data.some(
14132 (item) => id === getItemId(item)
14133 )
14134 )
14135 );
14136 } else {
14137 const selectionSet = /* @__PURE__ */ new Set([
14138 ...selection,
14139 ...data.map((item) => getItemId(item))
14140 ]);
14141 onChangeSelection(Array.from(selectionSet));
14142 }
14143 },
14144 "aria-label": areAllSelected ? (0, import_i18n23.__)("Deselect all") : (0, import_i18n23.__)("Select all")
14145 }
14146 );
14147 }
14148 function ActionButtons({
14149 actions,
14150 items,
14151 selection
14152 }) {
14153 const registry = (0, import_data6.useRegistry)();
14154 const [actionInProgress, setActionInProgress] = (0, import_element37.useState)(
14155 null
14156 );
14157 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(Stack, { direction: "row", gap: "xs", children: actions.map((action) => {
14158 if (!("callback" in action)) {
14159 return null;
14160 }
14161 const { id, label, icon, isPrimary, callback } = action;
14162 const _label = typeof label === "string" ? label : label(items);
14163 const variant = isPrimary ? "primary" : "tertiary";
14164 const isInProgress = id === actionInProgress;
14165 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14166 import_components13.Button,
14167 {
14168 accessibleWhenDisabled: true,
14169 icon,
14170 disabled: isInProgress || !selection?.length,
14171 isBusy: isInProgress,
14172 onClick: async () => {
14173 setActionInProgress(id);
14174 await callback(items, {
14175 registry
14176 });
14177 setActionInProgress(null);
14178 },
14179 size: "compact",
14180 variant,
14181 children: _label
14182 },
14183 id
14184 );
14185 }) });
14186 }
14187 function PickerBulkSelectionInfo() {
14188 const {
14189 data,
14190 selection,
14191 onChangeSelection,
14192 getItemId,
14193 actions = EMPTY_ARRAY2,
14194 paginationInfo,
14195 view
14196 } = (0, import_element37.useContext)(dataviews_context_default);
14197 const isMultiselect = useIsMultiselectPicker(actions);
14198 const selectedItems = (0, import_element37.useMemo)(
14199 () => data.filter((item) => selection.includes(getItemId(item))),
14200 [selection, getItemId, data]
14201 );
14202 if (!actions.length) {
14203 return null;
14204 }
14205 const message2 = getFooterMessage(
14206 selection.length,
14207 data.length,
14208 paginationInfo.totalItems,
14209 !!view.infiniteScrollEnabled
14210 );
14211 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
14212 Stack,
14213 {
14214 direction: "row",
14215 className: "dataviews-picker-footer__bulk-selection",
14216 gap: "md",
14217 align: "center",
14218 children: [
14219 isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14220 BulkSelectionCheckbox2,
14221 {
14222 selection,
14223 selectedItems,
14224 onChangeSelection,
14225 data,
14226 getItemId,
14227 disableSelectAll: !!view.infiniteScrollEnabled
14228 }
14229 ),
14230 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 })
14231 ]
14232 }
14233 );
14234 }
14235 function PickerActions() {
14236 const {
14237 data,
14238 selection,
14239 getItemId,
14240 actions = EMPTY_ARRAY2
14241 } = (0, import_element37.useContext)(dataviews_context_default);
14242 const selectedItems = (0, import_element37.useMemo)(
14243 () => data.filter((item) => selection.includes(getItemId(item))),
14244 [selection, getItemId, data]
14245 );
14246 if (!actions.length) {
14247 return null;
14248 }
14249 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "dataviews-picker-footer__actions", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14250 ActionButtons,
14251 {
14252 actions,
14253 items: selectedItems,
14254 selection
14255 }
14256 ) });
14257 }
14258 function DataViewsPickerBulkActionToolbar() {
14259 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(Stack, { direction: "row", gap: "md", align: "center", children: [
14260 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(PickerBulkSelectionInfo, {}),
14261 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(PickerActions, {})
14262 ] });
14263 }
14264 function DataViewsPickerFooter() {
14265 const {
14266 actions = EMPTY_ARRAY2,
14267 paginationInfo,
14268 view
14269 } = (0, import_element37.useContext)(dataviews_context_default);
14270 const hasPagination = !view.infiniteScrollEnabled && !!paginationInfo.totalItems && paginationInfo.totalPages > 1;
14271 if (!actions.length && !hasPagination) {
14272 return null;
14273 }
14274 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
14275 Stack,
14276 {
14277 direction: "row",
14278 justify: "space-between",
14279 align: "center",
14280 className: "dataviews-footer",
14281 gap: "sm",
14282 children: [
14283 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(PickerBulkSelectionInfo, {}),
14284 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(dataviews_pagination_default, {}),
14285 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(PickerActions, {})
14286 ]
14287 }
14288 );
14289 }
14290
14291 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
14292 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
14293 var { Badge: WCBadge2 } = unlock2(import_components14.privateApis);
14294 function GridItem3({
14295 view,
14296 selection,
14297 onChangeSelection,
14298 selectionProps,
14299 getItemId,
14300 item,
14301 mediaField,
14302 titleField,
14303 descriptionField: descriptionField2,
14304 regularFields,
14305 badgeFields,
14306 config,
14307 posinset,
14308 setsize
14309 }) {
14310 const { showTitle = true, showMedia = true, showDescription = true } = view;
14311 const id = getItemId(item);
14312 const elementRef = (0, import_element38.useRef)(null);
14313 const isSelected2 = selection.includes(id);
14314 useIntersectionObserver(elementRef, posinset);
14315 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14316 mediaField.render,
14317 {
14318 item,
14319 field: mediaField,
14320 config
14321 }
14322 ) : null;
14323 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(titleField.render, { item, field: titleField }) : null;
14324 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14325 import_components14.Composite.Item,
14326 {
14327 ref: elementRef,
14328 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n24.__)("(no title)") : void 0,
14329 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Stack, { direction: "column", children, ...props }),
14330 role: "option",
14331 "aria-posinset": posinset,
14332 "aria-setsize": setsize,
14333 className: clsx_default("dataviews-view-picker-grid__card", {
14334 "is-selected": isSelected2
14335 }),
14336 "aria-selected": isSelected2,
14337 ...selectionProps,
14338 children: [
14339 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
14340 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14341 DataViewsSelectionCheckbox,
14342 {
14343 item,
14344 selection,
14345 onChangeSelection,
14346 getItemId,
14347 titleField,
14348 disabled: false,
14349 "aria-hidden": true,
14350 tabIndex: -1
14351 }
14352 ),
14353 showTitle && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14354 Stack,
14355 {
14356 direction: "row",
14357 justify: "space-between",
14358 className: "dataviews-view-picker-grid__title-actions",
14359 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
14360 }
14361 ),
14362 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(Stack, { direction: "column", gap: "xs", children: [
14363 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14364 descriptionField2.render,
14365 {
14366 item,
14367 field: descriptionField2
14368 }
14369 ),
14370 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14371 Stack,
14372 {
14373 direction: "row",
14374 className: "dataviews-view-picker-grid__badge-fields",
14375 gap: "sm",
14376 wrap: "wrap",
14377 align: "top",
14378 justify: "flex-start",
14379 children: badgeFields.map((field) => {
14380 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14381 WCBadge2,
14382 {
14383 className: "dataviews-view-picker-grid__field-value",
14384 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14385 field.render,
14386 {
14387 item,
14388 field
14389 }
14390 )
14391 },
14392 field.id
14393 );
14394 })
14395 }
14396 ),
14397 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14398 Stack,
14399 {
14400 direction: "column",
14401 className: "dataviews-view-picker-grid__fields",
14402 gap: "xs",
14403 children: regularFields.map((field) => {
14404 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14405 import_components14.Flex,
14406 {
14407 className: "dataviews-view-picker-grid__field",
14408 gap: 1,
14409 justify: "flex-start",
14410 expanded: true,
14411 style: { height: "auto" },
14412 direction: "row",
14413 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
14414 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
14415 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14416 import_components14.FlexItem,
14417 {
14418 className: "dataviews-view-picker-grid__field-value",
14419 style: { maxHeight: "none" },
14420 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14421 field.render,
14422 {
14423 item,
14424 field
14425 }
14426 )
14427 }
14428 )
14429 ] })
14430 },
14431 field.id
14432 );
14433 })
14434 }
14435 )
14436 ] })
14437 ]
14438 },
14439 id
14440 );
14441 }
14442 function GridGroup({
14443 groupName,
14444 groupField,
14445 showLabel = true,
14446 children
14447 }) {
14448 const headerId = (0, import_compose6.useInstanceId)(
14449 GridGroup,
14450 "dataviews-view-picker-grid-group__header"
14451 );
14452 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14453 Stack,
14454 {
14455 direction: "column",
14456 gap: "sm",
14457 role: "group",
14458 "aria-labelledby": headerId,
14459 children: [
14460 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14461 "h3",
14462 {
14463 className: "dataviews-view-picker-grid-group__header",
14464 id: headerId,
14465 children: showLabel ? (0, import_i18n24.sprintf)(
14466 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14467 (0, import_i18n24.__)("%1$s: %2$s"),
14468 groupField.label,
14469 groupName
14470 ) : groupName
14471 }
14472 ),
14473 children
14474 ]
14475 },
14476 groupName
14477 );
14478 }
14479 function ViewPickerGrid({
14480 actions,
14481 data,
14482 fields,
14483 getItemId,
14484 isLoading,
14485 onChangeSelection,
14486 selection,
14487 view,
14488 className,
14489 empty
14490 }) {
14491 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element38.useContext)(dataviews_context_default);
14492 const titleField = fields.find(
14493 (field) => field.id === view?.titleField
14494 );
14495 const mediaField = fields.find(
14496 (field) => field.id === view?.mediaField
14497 );
14498 const descriptionField2 = fields.find(
14499 (field) => field.id === view?.descriptionField
14500 );
14501 const otherFields = view.fields ?? [];
14502 const { regularFields, badgeFields } = otherFields.reduce(
14503 (accumulator, fieldId) => {
14504 const field = fields.find((f2) => f2.id === fieldId);
14505 if (!field) {
14506 return accumulator;
14507 }
14508 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
14509 accumulator[key].push(field);
14510 return accumulator;
14511 },
14512 { regularFields: [], badgeFields: [] }
14513 );
14514 const hasData = !!data?.length;
14515 const usedPreviewSize = view.layout?.previewSize;
14516 const isMultiselect = useIsMultiselectPicker(actions);
14517 const size4 = "900px";
14518 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14519 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14520 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
14521 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
14522 const { getSelectionProps } = useSelectionProps({
14523 data: orderedData,
14524 getItemId,
14525 isItemSelectable: () => true,
14526 selection,
14527 onChangeSelection,
14528 selectionMode: isMultiselect ? "multi" : "single-clearable",
14529 shouldSelectOnClick: true
14530 });
14531 const currentPage = view?.page ?? 1;
14532 const perPage = view?.perPage ?? 0;
14533 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
14534 const gridColumns = useGridColumns();
14535 const placeholdersNeeded = usePlaceholdersNeeded(
14536 data,
14537 isInfiniteScroll,
14538 gridColumns
14539 );
14540 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, {
14541 // Render multiple groups.
14542 children: [
14543 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14544 import_components14.Composite,
14545 {
14546 virtualFocus: true,
14547 orientation: "horizontal",
14548 role: "listbox",
14549 "aria-multiselectable": isMultiselect,
14550 className: clsx_default(
14551 "dataviews-view-picker-grid",
14552 className,
14553 {
14554 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14555 view.layout.density
14556 )
14557 }
14558 ),
14559 "aria-label": itemListLabel,
14560 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14561 Stack,
14562 {
14563 direction: "column",
14564 gap: "lg",
14565 children,
14566 ...props
14567 }
14568 ),
14569 children: Array.from(dataByGroup.entries()).map(
14570 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14571 GridGroup,
14572 {
14573 groupName,
14574 groupField,
14575 showLabel: view.groupBy?.showLabel !== false,
14576 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14577 GridItems,
14578 {
14579 previewSize: usedPreviewSize,
14580 style: {
14581 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
14582 },
14583 "aria-busy": isLoading,
14584 ref: resizeObserverRef,
14585 children: groupItems.map((item) => {
14586 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
14587 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14588 GridItem3,
14589 {
14590 view,
14591 selection,
14592 onChangeSelection,
14593 selectionProps: getSelectionProps(
14594 getItemId(item)
14595 ),
14596 getItemId,
14597 item,
14598 mediaField,
14599 titleField,
14600 descriptionField: descriptionField2,
14601 regularFields,
14602 badgeFields,
14603 config: {
14604 sizes: size4
14605 },
14606 posinset: posInSet,
14607 setsize: setSize
14608 },
14609 getItemId(item)
14610 );
14611 })
14612 }
14613 )
14614 },
14615 groupName
14616 )
14617 )
14618 }
14619 ),
14620 // Render a single grid with all data.
14621 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14622 import_components14.Composite,
14623 {
14624 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14625 GridItems,
14626 {
14627 className: clsx_default(
14628 "dataviews-view-picker-grid",
14629 className,
14630 {
14631 [`has-${view.layout?.density}-density`]: view.layout?.density && [
14632 "compact",
14633 "comfortable"
14634 ].includes(view.layout.density)
14635 }
14636 ),
14637 previewSize: usedPreviewSize,
14638 "aria-busy": isLoading,
14639 ref: resizeObserverRef
14640 }
14641 ),
14642 virtualFocus: true,
14643 orientation: "horizontal",
14644 role: "listbox",
14645 "aria-multiselectable": isMultiselect,
14646 "aria-label": itemListLabel,
14647 children: [
14648 Array.from({ length: placeholdersNeeded }).map(
14649 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14650 import_components14.Composite.Item,
14651 {
14652 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14653 Stack,
14654 {
14655 direction: "column",
14656 children,
14657 ...props
14658 }
14659 ),
14660 role: "option",
14661 "aria-hidden": true,
14662 tabIndex: -1,
14663 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
14664 },
14665 `placeholder-${index2}`
14666 )
14667 ),
14668 data.map((item) => {
14669 const posinset = item.position;
14670 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14671 GridItem3,
14672 {
14673 view,
14674 selection,
14675 onChangeSelection,
14676 selectionProps: getSelectionProps(
14677 getItemId(item)
14678 ),
14679 getItemId,
14680 item,
14681 mediaField,
14682 titleField,
14683 descriptionField: descriptionField2,
14684 regularFields,
14685 badgeFields,
14686 config: {
14687 sizes: size4
14688 },
14689 posinset,
14690 setsize: setSize
14691 },
14692 getItemId(item)
14693 );
14694 })
14695 ]
14696 }
14697 ),
14698 // Render empty state.
14699 !hasData && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14700 "div",
14701 {
14702 className: clsx_default({
14703 "dataviews-loading": isLoading,
14704 "dataviews-no-results": !isLoading
14705 }),
14706 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.Spinner, {}) }) : empty
14707 }
14708 ),
14709 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.Spinner, {}) })
14710 ]
14711 });
14712 }
14713 var picker_grid_default = ViewPickerGrid;
14714
14715 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
14716 var import_i18n25 = __toESM(require_i18n(), 1);
14717 var import_components15 = __toESM(require_components(), 1);
14718 var import_element39 = __toESM(require_element(), 1);
14719 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
14720 function TableColumnField2({
14721 item,
14722 fields,
14723 column,
14724 align
14725 }) {
14726 const field = fields.find((f2) => f2.id === column);
14727 if (!field) {
14728 return null;
14729 }
14730 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
14731 "dataviews-view-table__cell-align-end": align === "end",
14732 "dataviews-view-table__cell-align-center": align === "center"
14733 });
14734 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(field.render, { item, field }) });
14735 }
14736 function TableRow2({
14737 item,
14738 fields,
14739 id,
14740 view,
14741 titleField,
14742 mediaField,
14743 descriptionField: descriptionField2,
14744 selection,
14745 getItemId,
14746 onChangeSelection,
14747 selectionProps,
14748 posinset
14749 }) {
14750 const { paginationInfo } = (0, import_element39.useContext)(dataviews_context_default);
14751 const isSelected2 = selection.includes(id);
14752 const [isHovered, setIsHovered] = (0, import_element39.useState)(false);
14753 const elementRef = (0, import_element39.useRef)(null);
14754 useIntersectionObserver(elementRef, posinset);
14755 const {
14756 showTitle = true,
14757 showMedia = true,
14758 showDescription = true,
14759 infiniteScrollEnabled
14760 } = view;
14761 const handleMouseEnter = () => {
14762 setIsHovered(true);
14763 };
14764 const handleMouseLeave = () => {
14765 setIsHovered(false);
14766 };
14767 const columns = view.fields ?? [];
14768 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
14769 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14770 import_components15.Composite.Item,
14771 {
14772 ref: elementRef,
14773 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14774 "tr",
14775 {
14776 className: clsx_default("dataviews-view-table__row", {
14777 "is-selected": isSelected2,
14778 "is-hovered": isHovered
14779 }),
14780 onMouseEnter: handleMouseEnter,
14781 onMouseLeave: handleMouseLeave,
14782 children,
14783 ...props
14784 }
14785 ),
14786 "aria-selected": isSelected2,
14787 "aria-setsize": paginationInfo.totalItems || void 0,
14788 "aria-posinset": posinset,
14789 role: infiniteScrollEnabled ? "article" : "option",
14790 onClickCapture: selectionProps.onClickCapture,
14791 onClick: selectionProps.onClick,
14792 onMouseDown: (event) => {
14793 if (event.button !== 0) {
14794 return;
14795 }
14796 event.currentTarget.parentElement?.focus({
14797 preventScroll: true
14798 });
14799 selectionProps.onMouseDown(event);
14800 },
14801 children: [
14802 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14803 "td",
14804 {
14805 className: "dataviews-view-table__checkbox-column",
14806 role: "presentation",
14807 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14808 DataViewsSelectionCheckbox,
14809 {
14810 item,
14811 selection,
14812 onChangeSelection,
14813 getItemId,
14814 titleField,
14815 disabled: false,
14816 "aria-hidden": true,
14817 tabIndex: -1
14818 }
14819 ) })
14820 }
14821 ),
14822 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14823 "td",
14824 {
14825 role: "presentation",
14826 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14827 column_primary_default,
14828 {
14829 item,
14830 titleField: showTitle ? titleField : void 0,
14831 mediaField: showMedia ? mediaField : void 0,
14832 descriptionField: showDescription ? descriptionField2 : void 0,
14833 isItemClickable: () => false
14834 }
14835 )
14836 }
14837 ),
14838 columns.map((column) => {
14839 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14840 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14841 "td",
14842 {
14843 style: {
14844 width,
14845 maxWidth,
14846 minWidth
14847 },
14848 role: "presentation",
14849 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14850 TableColumnField2,
14851 {
14852 fields,
14853 item,
14854 column,
14855 align
14856 }
14857 )
14858 },
14859 column
14860 );
14861 })
14862 ]
14863 },
14864 id
14865 );
14866 }
14867 function ViewPickerTable({
14868 actions,
14869 data,
14870 fields,
14871 getItemId,
14872 isLoading = false,
14873 onChangeView,
14874 onChangeSelection,
14875 selection,
14876 setOpenedFilter,
14877 view,
14878 className,
14879 empty
14880 }) {
14881 const headerMenuRefs = (0, import_element39.useRef)(/* @__PURE__ */ new Map());
14882 const headerMenuToFocusRef = (0, import_element39.useRef)(void 0);
14883 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element39.useState)();
14884 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
14885 (0, import_element39.useEffect)(() => {
14886 if (headerMenuToFocusRef.current) {
14887 headerMenuToFocusRef.current.focus();
14888 headerMenuToFocusRef.current = void 0;
14889 }
14890 });
14891 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14892 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14893 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14894 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
14895 const { getSelectionProps } = useSelectionProps({
14896 data: orderedData,
14897 getItemId,
14898 isItemSelectable: () => true,
14899 selection,
14900 onChangeSelection,
14901 selectionMode: isMultiselect ? "multi" : "single-clearable",
14902 shouldSelectOnClick: true
14903 });
14904 const tableNoticeId = (0, import_element39.useId)();
14905 if (nextHeaderMenuToFocus) {
14906 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
14907 setNextHeaderMenuToFocus(void 0);
14908 return;
14909 }
14910 const onHide = (field) => {
14911 const hidden = headerMenuRefs.current.get(field.id);
14912 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
14913 setNextHeaderMenuToFocus(fallback?.node);
14914 };
14915 const hasData = !!data?.length;
14916 const titleField = fields.find((field) => field.id === view.titleField);
14917 const mediaField = fields.find((field) => field.id === view.mediaField);
14918 const descriptionField2 = fields.find(
14919 (field) => field.id === view.descriptionField
14920 );
14921 const { showTitle = true, showMedia = true, showDescription = true } = view;
14922 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
14923 const columns = view.fields ?? [];
14924 const headerMenuRef = (column, index2) => (node) => {
14925 if (node) {
14926 headerMenuRefs.current.set(column, {
14927 node,
14928 fallback: columns[index2 > 0 ? index2 - 1 : 1]
14929 });
14930 } else {
14931 headerMenuRefs.current.delete(column);
14932 }
14933 };
14934 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
14935 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14936 "table",
14937 {
14938 className: clsx_default(
14939 "dataviews-view-table",
14940 "dataviews-view-picker-table",
14941 className,
14942 {
14943 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14944 view.layout.density
14945 )
14946 }
14947 ),
14948 "aria-busy": isLoading,
14949 "aria-describedby": tableNoticeId,
14950 role: isInfiniteScroll ? "feed" : "listbox",
14951 children: [
14952 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14953 "tr",
14954 {
14955 className: "dataviews-view-table__row",
14956 role: "presentation",
14957 children: [
14958 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14959 BulkSelectionCheckbox,
14960 {
14961 selection,
14962 onChangeSelection,
14963 data,
14964 actions,
14965 getItemId,
14966 disableSelectAll: isInfiniteScroll
14967 }
14968 ) }),
14969 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14970 column_header_menu_default,
14971 {
14972 ref: headerMenuRef(
14973 titleField.id,
14974 0
14975 ),
14976 fieldId: titleField.id,
14977 view,
14978 fields,
14979 onChangeView,
14980 onHide,
14981 setOpenedFilter,
14982 canMove: false
14983 }
14984 ) }),
14985 columns.map((column, index2) => {
14986 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14987 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14988 "th",
14989 {
14990 style: {
14991 width,
14992 maxWidth,
14993 minWidth,
14994 textAlign: align
14995 },
14996 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14997 scope: "col",
14998 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14999 column_header_menu_default,
15000 {
15001 ref: headerMenuRef(column, index2),
15002 fieldId: column,
15003 view,
15004 fields,
15005 onChangeView,
15006 onHide,
15007 setOpenedFilter,
15008 canMove: view.layout?.enableMoving ?? true
15009 }
15010 )
15011 },
15012 column
15013 );
15014 })
15015 ]
15016 }
15017 ) }),
15018 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
15019 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
15020 import_components15.Composite,
15021 {
15022 virtualFocus: true,
15023 orientation: "vertical",
15024 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("tbody", { role: "group" }),
15025 children: [
15026 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
15027 "tr",
15028 {
15029 className: "dataviews-view-table__group-header-row",
15030 role: "presentation",
15031 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
15032 "td",
15033 {
15034 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
15035 className: "dataviews-view-table__group-header-cell",
15036 role: "presentation",
15037 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n25.sprintf)(
15038 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
15039 (0, import_i18n25.__)("%1$s: %2$s"),
15040 groupField.label,
15041 groupName
15042 )
15043 }
15044 )
15045 }
15046 ),
15047 groupItems.map((item, index2) => {
15048 const id = getItemId(item) || index2.toString();
15049 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
15050 TableRow2,
15051 {
15052 item,
15053 fields,
15054 id,
15055 view,
15056 titleField,
15057 mediaField,
15058 descriptionField: descriptionField2,
15059 selection,
15060 getItemId,
15061 onChangeSelection,
15062 selectionProps: getSelectionProps(
15063 id
15064 )
15065 },
15066 getItemId(item)
15067 );
15068 })
15069 ]
15070 },
15071 `group-${groupName}`
15072 )
15073 ) : /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
15074 import_components15.Composite,
15075 {
15076 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("tbody", { role: "presentation" }),
15077 virtualFocus: true,
15078 orientation: "vertical",
15079 children: hasData && data.map((item, index2) => {
15080 const itemId = getItemId(item);
15081 const id = itemId || index2.toString();
15082 const posinset = item.position;
15083 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
15084 TableRow2,
15085 {
15086 item,
15087 fields,
15088 id,
15089 view,
15090 titleField,
15091 mediaField,
15092 descriptionField: descriptionField2,
15093 selection,
15094 getItemId,
15095 onChangeSelection,
15096 selectionProps: getSelectionProps(
15097 id
15098 ),
15099 posinset
15100 },
15101 itemId
15102 );
15103 })
15104 }
15105 )
15106 ]
15107 }
15108 ),
15109 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
15110 "div",
15111 {
15112 className: clsx_default({
15113 "dataviews-loading": isLoading,
15114 "dataviews-no-results": !hasData && !isLoading
15115 }),
15116 id: tableNoticeId,
15117 children: [
15118 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components15.Spinner, {}) }) : empty),
15119 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components15.Spinner, {}) })
15120 ]
15121 }
15122 )
15123 ] });
15124 }
15125 var picker_table_default = ViewPickerTable;
15126
15127 // packages/dataviews/build-module/components/dataviews-layouts/picker-activity/index.mjs
15128 var import_components16 = __toESM(require_components(), 1);
15129 var import_element40 = __toESM(require_element(), 1);
15130 var import_compose7 = __toESM(require_compose(), 1);
15131 var import_i18n26 = __toESM(require_i18n(), 1);
15132 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
15133 function isDefined4(item) {
15134 return !!item;
15135 }
15136 function PickerActivityItem({
15137 view,
15138 selection,
15139 selectionProps,
15140 getItemId,
15141 item,
15142 titleField,
15143 mediaField,
15144 descriptionField: descriptionField2,
15145 otherFields,
15146 posinset,
15147 setsize
15148 }) {
15149 const elementRef = (0, import_element40.useRef)(null);
15150 useIntersectionObserver(elementRef, posinset);
15151 const { showTitle = true, showMedia = true, showDescription = true } = view;
15152 const id = getItemId(item);
15153 const isSelected2 = selection.includes(id);
15154 const density = view.layout?.density ?? "balanced";
15155 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15156 mediaField.render,
15157 {
15158 item,
15159 field: mediaField,
15160 config: {
15161 sizes: density === "comfortable" ? "32px" : "24px"
15162 }
15163 }
15164 ) : null;
15165 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15166 "span",
15167 {
15168 className: "dataviews-view-picker-activity__item-bullet",
15169 "aria-hidden": "true"
15170 }
15171 ) });
15172 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(titleField.render, { item, field: titleField }) : null;
15173 const renderedDescriptionField = showDescription && descriptionField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(descriptionField2.render, { item, field: descriptionField2 }) : null;
15174 const verticalGap = (0, import_element40.useMemo)(() => {
15175 switch (density) {
15176 case "comfortable":
15177 return "md";
15178 default:
15179 return "sm";
15180 }
15181 }, [density]);
15182 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15183 import_components16.Composite.Item,
15184 {
15185 ref: elementRef,
15186 role: "option",
15187 "aria-label": titleField ? titleField.getValue({ item }) || void 0 : void 0,
15188 "aria-posinset": posinset,
15189 "aria-setsize": setsize,
15190 "aria-selected": isSelected2,
15191 className: clsx_default(
15192 "dataviews-view-picker-activity__item",
15193 density === "compact" && "is-compact",
15194 density === "balanced" && "is-balanced",
15195 density === "comfortable" && "is-comfortable",
15196 isSelected2 && "is-selected"
15197 ),
15198 ...selectionProps,
15199 render: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", {}),
15200 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
15201 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15202 Stack,
15203 {
15204 direction: "column",
15205 gap: "xs",
15206 align: "center",
15207 className: "dataviews-view-picker-activity__item-type",
15208 children: renderedMediaField
15209 }
15210 ),
15211 /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
15212 Stack,
15213 {
15214 direction: "column",
15215 gap: verticalGap,
15216 align: "flex-start",
15217 className: "dataviews-view-picker-activity__item-content",
15218 children: [
15219 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-title", children: renderedTitleField }),
15220 renderedDescriptionField && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-description", children: renderedDescriptionField }),
15221 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
15222 "div",
15223 {
15224 className: "dataviews-view-picker-activity__item-field",
15225 children: [
15226 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15227 VisuallyHidden,
15228 {
15229 render: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", {}),
15230 className: "dataviews-view-picker-activity__item-field-label",
15231 children: field.label
15232 }
15233 ),
15234 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { className: "dataviews-view-picker-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15235 field.render,
15236 {
15237 item,
15238 field
15239 }
15240 ) })
15241 ]
15242 },
15243 field.id
15244 )) })
15245 ]
15246 }
15247 )
15248 ] })
15249 }
15250 );
15251 }
15252 function PickerActivityGroup({
15253 groupName,
15254 groupField,
15255 showLabel = true,
15256 children
15257 }) {
15258 const headerId = (0, import_compose7.useInstanceId)(
15259 PickerActivityGroup,
15260 "dataviews-view-picker-activity-group__header"
15261 );
15262 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
15263 Stack,
15264 {
15265 direction: "column",
15266 role: "group",
15267 "aria-labelledby": headerId,
15268 className: "dataviews-view-picker-activity-group",
15269 children: [
15270 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15271 "h3",
15272 {
15273 className: "dataviews-view-picker-activity-group__header",
15274 id: headerId,
15275 children: showLabel ? (0, import_i18n26.sprintf)(
15276 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
15277 (0, import_i18n26.__)("%1$s: %2$s"),
15278 groupField.label,
15279 groupName
15280 ) : groupName
15281 }
15282 ),
15283 children
15284 ]
15285 }
15286 );
15287 }
15288 function ViewPickerActivity({
15289 data,
15290 fields,
15291 getItemId,
15292 isLoading,
15293 onChangeSelection,
15294 selection,
15295 view,
15296 actions,
15297 className,
15298 empty
15299 }) {
15300 const { itemListLabel, paginationInfo } = (0, import_element40.useContext)(dataviews_context_default);
15301 const isMultiselect = useIsMultiselectPicker(actions);
15302 const titleField = fields.find(
15303 (field) => field.id === view?.titleField
15304 );
15305 const mediaField = fields.find(
15306 (field) => field.id === view?.mediaField
15307 );
15308 const descriptionField2 = fields.find(
15309 (field) => field.id === view?.descriptionField
15310 );
15311 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined4);
15312 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
15313 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
15314 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
15315 const setsize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
15316 const hasData = !!data?.length;
15317 const isGrouped = !!(groupField && dataByGroup);
15318 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
15319 const { getSelectionProps } = useSelectionProps({
15320 data: orderedData,
15321 getItemId,
15322 isItemSelectable: () => true,
15323 selection,
15324 onChangeSelection,
15325 selectionMode: isMultiselect ? "multi" : "single-clearable",
15326 shouldSelectOnClick: true
15327 });
15328 const renderItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15329 PickerActivityItem,
15330 {
15331 view,
15332 selection,
15333 selectionProps: getSelectionProps(getItemId(item)),
15334 getItemId,
15335 item,
15336 titleField,
15337 mediaField,
15338 descriptionField: descriptionField2,
15339 otherFields,
15340 posinset: item.position,
15341 setsize
15342 },
15343 getItemId(item)
15344 );
15345 if (!hasData) {
15346 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15347 "div",
15348 {
15349 className: clsx_default({
15350 "dataviews-loading": isLoading,
15351 "dataviews-no-results": !isLoading
15352 }),
15353 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components16.Spinner, {}) }) : empty
15354 }
15355 );
15356 }
15357 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(import_jsx_runtime68.Fragment, { children: [
15358 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15359 import_components16.Composite,
15360 {
15361 virtualFocus: true,
15362 orientation: "vertical",
15363 role: "listbox",
15364 "aria-multiselectable": isMultiselect,
15365 "aria-label": itemListLabel,
15366 "aria-busy": isLoading,
15367 render: isGrouped ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Stack, { direction: "column", gap: "sm" }) : void 0,
15368 className: clsx_default(
15369 "dataviews-view-picker-activity",
15370 className
15371 ),
15372 children: isGrouped && dataByGroup ? Array.from(dataByGroup.entries()).map(
15373 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15374 PickerActivityGroup,
15375 {
15376 groupName,
15377 groupField,
15378 showLabel: view.groupBy?.showLabel !== false,
15379 children: groupItems.map(renderItem)
15380 },
15381 groupName
15382 )
15383 ) : data.map(renderItem)
15384 }
15385 ),
15386 isLoading && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components16.Spinner, {}) })
15387 ] });
15388 }
15389
15390 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
15391 var import_components17 = __toESM(require_components(), 1);
15392 var import_i18n27 = __toESM(require_i18n(), 1);
15393 var import_element41 = __toESM(require_element(), 1);
15394 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
15395 function DensityPicker() {
15396 const context = (0, import_element41.useContext)(dataviews_context_default);
15397 const view = context.view;
15398 return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
15399 import_components17.__experimentalToggleGroupControl,
15400 {
15401 label: (0, import_i18n27.__)("Density"),
15402 value: view.layout?.density || "balanced",
15403 onChange: (value) => {
15404 context.onChangeView({
15405 ...view,
15406 layout: {
15407 ...view.layout,
15408 density: value
15409 }
15410 });
15411 },
15412 isBlock: true,
15413 children: [
15414 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15415 import_components17.__experimentalToggleGroupControlOption,
15416 {
15417 value: "comfortable",
15418 label: (0, import_i18n27._x)(
15419 "Comfortable",
15420 "Density option for DataView layout"
15421 )
15422 },
15423 "comfortable"
15424 ),
15425 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15426 import_components17.__experimentalToggleGroupControlOption,
15427 {
15428 value: "balanced",
15429 label: (0, import_i18n27._x)("Balanced", "Density option for DataView layout")
15430 },
15431 "balanced"
15432 ),
15433 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15434 import_components17.__experimentalToggleGroupControlOption,
15435 {
15436 value: "compact",
15437 label: (0, import_i18n27._x)("Compact", "Density option for DataView layout")
15438 },
15439 "compact"
15440 )
15441 ]
15442 }
15443 );
15444 }
15445
15446 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
15447 var import_components18 = __toESM(require_components(), 1);
15448 var import_i18n28 = __toESM(require_i18n(), 1);
15449 var import_element42 = __toESM(require_element(), 1);
15450 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
15451 var imageSizes2 = [
15452 {
15453 value: 120,
15454 breakpoint: 1
15455 },
15456 {
15457 value: 170,
15458 breakpoint: 1
15459 },
15460 {
15461 value: 230,
15462 breakpoint: 1
15463 },
15464 {
15465 value: 290,
15466 breakpoint: 1112
15467 // at minimum image width, 4 images display at this container size
15468 },
15469 {
15470 value: 350,
15471 breakpoint: 1636
15472 // at minimum image width, 6 images display at this container size
15473 },
15474 {
15475 value: 430,
15476 breakpoint: 588
15477 // at minimum image width, 2 images display at this container size
15478 }
15479 ];
15480 function PreviewSizePicker() {
15481 const context = (0, import_element42.useContext)(dataviews_context_default);
15482 const view = context.view;
15483 const breakValues = imageSizes2.filter((size4) => {
15484 return context.containerWidth >= size4.breakpoint;
15485 });
15486 const layoutPreviewSize = view.layout?.previewSize ?? 230;
15487 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
15488 const marks = breakValues.map((size4, index2) => {
15489 return {
15490 value: index2
15491 };
15492 });
15493 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
15494 import_components18.RangeControl,
15495 {
15496 showTooltip: false,
15497 label: (0, import_i18n28.__)("Preview size"),
15498 value: previewSizeToUse,
15499 min: 0,
15500 max: breakValues.length - 1,
15501 withInputField: false,
15502 onChange: (value = 0) => {
15503 context.onChangeView({
15504 ...view,
15505 layout: {
15506 ...view.layout,
15507 previewSize: breakValues[value].value
15508 }
15509 });
15510 },
15511 step: 1,
15512 marks
15513 }
15514 );
15515 }
15516
15517 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
15518 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
15519 function GridConfigOptions() {
15520 return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
15521 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(DensityPicker, {}),
15522 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(PreviewSizePicker, {})
15523 ] });
15524 }
15525
15526 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
15527 var VIEW_LAYOUTS = [
15528 {
15529 type: LAYOUT_TABLE,
15530 label: (0, import_i18n29.__)("Table"),
15531 component: table_default,
15532 icon: block_table_default,
15533 viewConfigOptions: DensityPicker
15534 },
15535 {
15536 type: LAYOUT_GRID,
15537 label: (0, import_i18n29.__)("Grid"),
15538 component: grid_default,
15539 icon: category_default,
15540 viewConfigOptions: GridConfigOptions
15541 },
15542 {
15543 type: LAYOUT_LIST,
15544 label: (0, import_i18n29.__)("List"),
15545 component: ViewList,
15546 icon: (0, import_i18n29.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
15547 viewConfigOptions: DensityPicker
15548 },
15549 {
15550 type: LAYOUT_ACTIVITY,
15551 label: (0, import_i18n29.__)("Activity"),
15552 component: ViewActivity,
15553 icon: scheduled_default,
15554 viewConfigOptions: DensityPicker
15555 },
15556 {
15557 type: LAYOUT_PICKER_GRID,
15558 label: (0, import_i18n29.__)("Grid"),
15559 component: picker_grid_default,
15560 icon: category_default,
15561 viewConfigOptions: GridConfigOptions,
15562 isPicker: true
15563 },
15564 {
15565 type: LAYOUT_PICKER_TABLE,
15566 label: (0, import_i18n29.__)("Table"),
15567 component: picker_table_default,
15568 icon: block_table_default,
15569 viewConfigOptions: DensityPicker,
15570 isPicker: true
15571 },
15572 {
15573 type: LAYOUT_PICKER_ACTIVITY,
15574 label: (0, import_i18n29.__)("Activity"),
15575 component: ViewPickerActivity,
15576 icon: scheduled_default,
15577 viewConfigOptions: DensityPicker,
15578 isPicker: true
15579 }
15580 ];
15581
15582 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
15583 var import_element50 = __toESM(require_element(), 1);
15584
15585 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
15586 var import_components21 = __toESM(require_components(), 1);
15587 var import_i18n32 = __toESM(require_i18n(), 1);
15588 var import_element47 = __toESM(require_element(), 1);
15589
15590 // node_modules/@ariakit/react-components/dist/focusable/focusable-context.js
15591 var import_react7 = __toESM(require_react(), 1);
15592 var FocusableContext = (0, import_react7.createContext)(true);
15593
15594 // node_modules/@ariakit/utils/dist/index.js
15595 function toArray(arg) {
15596 if (Array.isArray(arg)) return arg;
15597 return typeof arg !== "undefined" ? [arg] : [];
15598 }
15599 function flatten2DArray(array) {
15600 const flattened = [];
15601 for (const row of array) flattened.push(...row);
15602 return flattened;
15603 }
15604 function reverseArray(array) {
15605 return array.slice().reverse();
15606 }
15607 function noop5(..._) {
15608 }
15609 function hasOwnProperty(object, prop) {
15610 if (typeof Object.hasOwn === "function") return Object.hasOwn(object, prop);
15611 return Object.prototype.hasOwnProperty.call(object, prop);
15612 }
15613 function chain(...fns) {
15614 return (...args) => {
15615 for (const fn of fns) if (typeof fn === "function") fn(...args);
15616 };
15617 }
15618 function normalizeString(str) {
15619 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
15620 }
15621 function omit(object, keys) {
15622 const result = { ...object };
15623 for (const key of keys) if (hasOwnProperty(result, key)) delete result[key];
15624 return result;
15625 }
15626 function pick(object, paths) {
15627 const result = {};
15628 for (const key of paths) if (hasOwnProperty(object, key)) result[key] = object[key];
15629 return result;
15630 }
15631 function identity(value) {
15632 return value;
15633 }
15634 function afterPaint(cb = noop5) {
15635 let raf = requestAnimationFrame(() => {
15636 raf = requestAnimationFrame(cb);
15637 });
15638 return () => cancelAnimationFrame(raf);
15639 }
15640 function invariant(condition, message2) {
15641 if (condition) return;
15642 if (typeof message2 !== "string") throw new Error("Invariant failed");
15643 throw new Error(message2);
15644 }
15645 function getKeys(obj) {
15646 return Object.keys(obj);
15647 }
15648 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
15649 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
15650 if (result == null) return false;
15651 return !result;
15652 }
15653 function disabledFromProps(props) {
15654 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
15655 }
15656 function removeUndefinedValues(obj) {
15657 const result = {};
15658 for (const key in obj) if (obj[key] !== void 0) result[key] = obj[key];
15659 return result;
15660 }
15661 function defaultValue(...values) {
15662 for (const value of values) if (value !== void 0) return value;
15663 }
15664 var canUseDOM = checkIsBrowser();
15665 function checkIsBrowser() {
15666 return typeof window !== "undefined" && !!window.document?.createElement;
15667 }
15668 function getDocument(node) {
15669 if (!node) return document;
15670 if ("self" in node) return node.document;
15671 return node.ownerDocument || document;
15672 }
15673 function getActiveElement(node, activeDescendant = false) {
15674 const { activeElement: activeElement2 } = getDocument(node);
15675 if (!activeElement2?.nodeName) return null;
15676 if (isFrame(activeElement2) && activeElement2.contentDocument?.body) return getActiveElement(activeElement2.contentDocument.body, activeDescendant);
15677 if (activeDescendant) {
15678 const id = activeElement2.getAttribute("aria-activedescendant");
15679 if (id) {
15680 const element = getDocument(activeElement2).getElementById(id);
15681 if (element) return element;
15682 }
15683 }
15684 return activeElement2;
15685 }
15686 function contains2(parent, child) {
15687 return parent === child || parent.contains(child);
15688 }
15689 function isElement2(target) {
15690 return target?.nodeType === 1;
15691 }
15692 function isNode2(target) {
15693 return typeof target?.nodeType === "number";
15694 }
15695 function isFrame(element) {
15696 return element.tagName === "IFRAME";
15697 }
15698 function isButton(element) {
15699 const tagName = element.tagName.toLowerCase();
15700 if (tagName === "button") return true;
15701 if (tagName === "input" && element.type) return buttonInputTypes.indexOf(element.type) !== -1;
15702 return false;
15703 }
15704 var buttonInputTypes = [
15705 "button",
15706 "color",
15707 "file",
15708 "image",
15709 "reset",
15710 "submit"
15711 ];
15712 function isVisible(element) {
15713 if (typeof element.checkVisibility === "function") return element.checkVisibility();
15714 const htmlElement = element;
15715 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
15716 }
15717 function isTextField(element) {
15718 try {
15719 if (element.tagName === "TEXTAREA") return true;
15720 if (element.tagName !== "INPUT") return false;
15721 return element.selectionStart !== null;
15722 } catch (_error) {
15723 return false;
15724 }
15725 }
15726 function isTextbox(element) {
15727 return element.isContentEditable || isTextField(element);
15728 }
15729 function getTextboxValue(element) {
15730 if (isTextField(element)) return element.value;
15731 if (element.isContentEditable) {
15732 const range = getDocument(element).createRange();
15733 range.selectNodeContents(element);
15734 return range.toString();
15735 }
15736 return "";
15737 }
15738 function getTextboxSelection(element) {
15739 let start = 0;
15740 let end = 0;
15741 if (isTextField(element)) {
15742 start = element.selectionStart || 0;
15743 end = element.selectionEnd || 0;
15744 } else if (element.isContentEditable) {
15745 const selection = getDocument(element).getSelection();
15746 if (selection?.rangeCount && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
15747 const range = selection.getRangeAt(0);
15748 const nextRange = range.cloneRange();
15749 nextRange.selectNodeContents(element);
15750 nextRange.setEnd(range.startContainer, range.startOffset);
15751 start = nextRange.toString().length;
15752 nextRange.setEnd(range.endContainer, range.endOffset);
15753 end = nextRange.toString().length;
15754 }
15755 }
15756 return {
15757 start,
15758 end
15759 };
15760 }
15761 var allowedPopupRoles = [
15762 "dialog",
15763 "menu",
15764 "listbox",
15765 "tree",
15766 "grid"
15767 ];
15768 var itemRoleByPopupRole = {
15769 menu: "menuitem",
15770 listbox: "option",
15771 tree: "treeitem"
15772 };
15773 function getPopupRole(element, fallback) {
15774 const role = element?.getAttribute("role");
15775 if (role && allowedPopupRoles.indexOf(role) !== -1) return role;
15776 return fallback;
15777 }
15778 function getItemRoleByPopupRole(popupRole) {
15779 if (popupRole == null) return;
15780 if (!hasOwnProperty(itemRoleByPopupRole, popupRole)) return;
15781 return itemRoleByPopupRole[popupRole];
15782 }
15783 function getScrollingElement(element) {
15784 if (!element) return null;
15785 const isScrollableOverflow = (overflow) => {
15786 if (overflow === "auto") return true;
15787 if (overflow === "scroll") return true;
15788 return false;
15789 };
15790 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
15791 const { overflowY } = getComputedStyle(element);
15792 if (isScrollableOverflow(overflowY)) return element;
15793 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
15794 const { overflowX } = getComputedStyle(element);
15795 if (isScrollableOverflow(overflowX)) return element;
15796 }
15797 const doc = getDocument(element);
15798 return getScrollingElement(element.parentElement) || doc.scrollingElement || doc.body;
15799 }
15800 function setSelectionRange(element, ...args) {
15801 if (/text|search|password|tel|url/i.test(element.type)) element.setSelectionRange(...args);
15802 }
15803 function sortBasedOnDOMPosition(items, getElement) {
15804 const pairs = items.map((item, index2) => [index2, item]);
15805 let isOrderDifferent = false;
15806 pairs.sort(([indexA, a2], [indexB, b2]) => {
15807 const elementA = getElement(a2);
15808 const elementB = getElement(b2);
15809 if (elementA === elementB) return 0;
15810 if (!elementA || !elementB) return 0;
15811 if (isElementPreceding(elementA, elementB)) {
15812 if (indexA > indexB) isOrderDifferent = true;
15813 return -1;
15814 }
15815 if (indexA < indexB) isOrderDifferent = true;
15816 return 1;
15817 });
15818 if (isOrderDifferent) return pairs.map(([_, item]) => item);
15819 return items;
15820 }
15821 function isElementPreceding(a2, b2) {
15822 return Boolean(b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING);
15823 }
15824 function isTouchDevice() {
15825 return canUseDOM && !!navigator.maxTouchPoints;
15826 }
15827 function isApple() {
15828 if (!canUseDOM) return false;
15829 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
15830 }
15831 function isSafari() {
15832 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
15833 }
15834 function isFirefox() {
15835 return canUseDOM && /firefox\//i.test(navigator.userAgent);
15836 }
15837 function isPortalEvent(event) {
15838 const { currentTarget, target } = event;
15839 if (!currentTarget) return false;
15840 if (!isNode2(target)) return true;
15841 return !contains2(currentTarget, target);
15842 }
15843 function isSelfTarget(event) {
15844 return event.target === event.currentTarget;
15845 }
15846 function isActivatableNavigationTarget(element) {
15847 if (!isElement2(element)) return false;
15848 const target = element;
15849 const tagName = target.tagName.toLowerCase();
15850 if (tagName === "a") return true;
15851 if (tagName === "button" && target.type === "submit") return true;
15852 if (tagName === "input" && target.type === "submit") return true;
15853 return false;
15854 }
15855 function isOpeningInNewTab(event) {
15856 const isAppleDevice = isApple();
15857 if (isAppleDevice && !event.metaKey) return false;
15858 if (!isAppleDevice && !event.ctrlKey) return false;
15859 return isActivatableNavigationTarget(event.currentTarget);
15860 }
15861 function isDownloading(event) {
15862 if (!event.altKey) return false;
15863 return isActivatableNavigationTarget(event.currentTarget);
15864 }
15865 function fireBlurEvent(element, eventInit) {
15866 const event = new FocusEvent("blur", eventInit);
15867 const defaultAllowed = element.dispatchEvent(event);
15868 const bubbleInit = {
15869 ...eventInit,
15870 bubbles: true
15871 };
15872 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
15873 return defaultAllowed;
15874 }
15875 function fireKeyboardEvent(element, type, eventInit) {
15876 const event = new KeyboardEvent(type, eventInit);
15877 return element.dispatchEvent(event);
15878 }
15879 function fireClickEvent(element, eventInit) {
15880 const event = new MouseEvent("click", eventInit);
15881 return element.dispatchEvent(event);
15882 }
15883 function isFocusEventOutside(event, container) {
15884 const containerElement = container || event.currentTarget;
15885 const relatedTarget = event.relatedTarget;
15886 return !isNode2(relatedTarget) || !contains2(containerElement, relatedTarget);
15887 }
15888 function isInputEvent(event) {
15889 return event.type === "input";
15890 }
15891 function queueBeforeEvent(element, type, callback, timeout) {
15892 const createTimer = (callback2) => {
15893 if (timeout) {
15894 const timerId2 = setTimeout(callback2, timeout);
15895 return () => clearTimeout(timerId2);
15896 }
15897 const timerId = requestAnimationFrame(callback2);
15898 return () => cancelAnimationFrame(timerId);
15899 };
15900 const cancelTimer = createTimer(() => {
15901 element.removeEventListener(type, callSync, true);
15902 callback();
15903 });
15904 const callSync = () => {
15905 cancelTimer();
15906 callback();
15907 };
15908 element.addEventListener(type, callSync, {
15909 once: true,
15910 capture: true
15911 });
15912 return () => {
15913 cancelTimer();
15914 element.removeEventListener(type, callSync, true);
15915 };
15916 }
15917 function addGlobalEventListener(type, listener, options, scope = window) {
15918 const children = [];
15919 try {
15920 scope.document.addEventListener(type, listener, options);
15921 for (const frame of Array.from(scope.frames)) children.push(addGlobalEventListener(type, listener, options, frame));
15922 } catch {
15923 }
15924 const removeEventListener = () => {
15925 try {
15926 scope.document.removeEventListener(type, listener, options);
15927 } catch {
15928 }
15929 for (const remove of children) remove();
15930 };
15931 return removeEventListener;
15932 }
15933 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'])";
15934 function isFocusable(element) {
15935 if (!element.matches(selector)) return false;
15936 if (!isVisible(element)) return false;
15937 if (element.closest("[inert]")) return false;
15938 return true;
15939 }
15940 function hasFocus(element) {
15941 const activeElement2 = getActiveElement(element);
15942 if (!activeElement2) return false;
15943 if (activeElement2 === element) return true;
15944 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15945 if (!activeDescendant) return false;
15946 return activeDescendant === element.id;
15947 }
15948 function hasFocusWithin(element) {
15949 const activeElement2 = getActiveElement(element);
15950 if (!activeElement2) return false;
15951 if (contains2(element, activeElement2)) return true;
15952 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15953 if (!activeDescendant) return false;
15954 if (!("id" in element)) return false;
15955 if (activeDescendant === element.id) return true;
15956 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
15957 }
15958 function focusIntoView(element, options) {
15959 if (!("scrollIntoView" in element)) element.focus();
15960 else {
15961 element.focus({ preventScroll: true });
15962 element.scrollIntoView({
15963 block: "nearest",
15964 inline: "nearest",
15965 ...options
15966 });
15967 }
15968 }
15969 function createUndoCallback(callback) {
15970 return async () => {
15971 const redo = await callback?.();
15972 return createUndoCallback(async () => {
15973 await redo?.();
15974 return callback;
15975 });
15976 };
15977 }
15978 var UndoManager = createUndoManager();
15979 function createUndoManager({ limit = 100 } = {}) {
15980 const undoStack = [];
15981 let redoStack = [];
15982 let currentGroup = null;
15983 const canUndo = () => undoStack.length > 0;
15984 const canRedo = () => redoStack.length > 0;
15985 const undo = async () => {
15986 if (!canUndo()) return;
15987 currentGroup = null;
15988 redoStack.push(await undoStack.pop()?.());
15989 };
15990 const redo = async () => {
15991 if (!canRedo()) return;
15992 currentGroup = null;
15993 undoStack.push(await redoStack.pop()?.());
15994 };
15995 const execute = async (callback, group) => {
15996 if (!callback) return;
15997 const sameGroup = group === currentGroup;
15998 currentGroup = group ?? null;
15999 const nextIndex = sameGroup ? Math.max(0, undoStack.length - 1) : undoStack.length;
16000 const undoCallback = await callback();
16001 if (!undoCallback) return;
16002 redoStack = [];
16003 const currentUndo = undoStack[nextIndex];
16004 undoStack[nextIndex] = createUndoCallback(async () => {
16005 await undoCallback?.();
16006 const currentRedo = await currentUndo?.();
16007 return async () => {
16008 await currentRedo?.();
16009 await callback?.();
16010 };
16011 });
16012 while (undoStack.length > limit) undoStack.shift();
16013 };
16014 return {
16015 canUndo,
16016 canRedo,
16017 undo,
16018 redo,
16019 execute
16020 };
16021 }
16022
16023 // node_modules/@ariakit/react-utils/dist/index.js
16024 var React47 = __toESM(require_react(), 1);
16025 var import_react8 = __toESM(require_react(), 1);
16026 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
16027 function setRef(ref, value) {
16028 if (typeof ref === "function") {
16029 const cleanup = ref(value);
16030 if (typeof cleanup === "function") return cleanup;
16031 } else if (ref) ref.current = value;
16032 }
16033 function isValidElementWithRef(element) {
16034 if (!element) return false;
16035 if (!(0, import_react8.isValidElement)(element)) return false;
16036 if ("ref" in element.props) return true;
16037 if ("ref" in element) return true;
16038 return false;
16039 }
16040 function getRefProperty(element) {
16041 if (!isValidElementWithRef(element)) return null;
16042 return { ...element.props }.ref || element.ref;
16043 }
16044 function mergeProps2(base, overrides) {
16045 const props = { ...base };
16046 for (const key in overrides) {
16047 if (!hasOwnProperty(overrides, key)) continue;
16048 if (key === "className") {
16049 const prop = "className";
16050 const baseClass = base[prop];
16051 const overrideClass = overrides[prop];
16052 if (baseClass && overrideClass) props[prop] = `${baseClass} ${overrideClass}`;
16053 else props[prop] = overrideClass || baseClass;
16054 continue;
16055 }
16056 if (key === "style") {
16057 const prop = "style";
16058 props[prop] = base[prop] ? {
16059 ...base[prop],
16060 ...overrides[prop]
16061 } : overrides[prop];
16062 continue;
16063 }
16064 const overrideValue = overrides[key];
16065 if (key.startsWith("on")) {
16066 if (typeof overrideValue !== "function") continue;
16067 const baseValue = base[key];
16068 if (typeof baseValue === "function") {
16069 props[key] = (...args) => {
16070 overrideValue(...args);
16071 baseValue(...args);
16072 };
16073 continue;
16074 }
16075 }
16076 props[key] = overrideValue;
16077 }
16078 return props;
16079 }
16080 var _React = { ...React47 };
16081 var useReactId = _React.useId;
16082 var useReactDeferredValue = _React.useDeferredValue;
16083 var useReactInsertionEffect = _React.useInsertionEffect;
16084 var useSafeLayoutEffect = canUseDOM ? import_react8.useLayoutEffect : import_react8.useEffect;
16085 function useInitialValue(value) {
16086 const [initialValue] = (0, import_react8.useState)(value);
16087 return initialValue;
16088 }
16089 function useLiveRef(value) {
16090 const ref = (0, import_react8.useRef)(value);
16091 useSafeLayoutEffect(() => {
16092 ref.current = value;
16093 });
16094 return ref;
16095 }
16096 function useEvent(callback) {
16097 const ref = (0, import_react8.useRef)(() => {
16098 throw new Error("Cannot call an event handler while rendering.");
16099 });
16100 if (useReactInsertionEffect) useReactInsertionEffect(() => {
16101 ref.current = callback;
16102 });
16103 else ref.current = callback;
16104 return (0, import_react8.useCallback)((...args) => ref.current?.(...args), []);
16105 }
16106 function useTransactionState(callback) {
16107 const [state, setState] = (0, import_react8.useState)(null);
16108 useSafeLayoutEffect(() => {
16109 if (state == null) return;
16110 if (!callback) return;
16111 let prevState = null;
16112 callback((prev) => {
16113 prevState = prev;
16114 return state;
16115 });
16116 return () => {
16117 callback(prevState);
16118 };
16119 }, [state, callback]);
16120 return [state, setState];
16121 }
16122 function useMergeRefs(...refs) {
16123 return (0, import_react8.useMemo)(() => {
16124 if (!refs.some(Boolean)) return;
16125 return (value) => {
16126 const refEffects = [];
16127 for (const ref of refs) {
16128 if (!ref) continue;
16129 const cleanup = setRef(ref, value);
16130 refEffects.push({
16131 ref,
16132 cleanup: typeof cleanup === "function" ? cleanup : void 0
16133 });
16134 }
16135 if (!refEffects.some((effect) => effect.cleanup)) return;
16136 return () => {
16137 for (const { ref, cleanup } of refEffects) if (cleanup) cleanup();
16138 else setRef(ref, null);
16139 };
16140 };
16141 }, refs);
16142 }
16143 function useId4(defaultId) {
16144 if (useReactId) {
16145 const reactId = useReactId();
16146 if (defaultId) return defaultId;
16147 return reactId;
16148 }
16149 const [id, setId] = (0, import_react8.useState)(defaultId);
16150 useSafeLayoutEffect(() => {
16151 if (defaultId || id) return;
16152 setId(`id-${Math.random().toString(36).slice(2, 8)}`);
16153 }, [defaultId, id]);
16154 return defaultId || id;
16155 }
16156 function useTagName(refOrElement, type) {
16157 const stringOrUndefined = (type2) => {
16158 if (typeof type2 !== "string") return;
16159 return type2;
16160 };
16161 const [tagName, setTagName] = (0, import_react8.useState)(() => stringOrUndefined(type));
16162 useSafeLayoutEffect(() => {
16163 setTagName((refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement)?.tagName.toLowerCase() || stringOrUndefined(type));
16164 }, [refOrElement, type]);
16165 return tagName;
16166 }
16167 function useAttribute(refOrElement, attributeName, defaultValue2) {
16168 const initialValue = useInitialValue(defaultValue2);
16169 const [attribute, setAttribute] = (0, import_react8.useState)(initialValue);
16170 (0, import_react8.useEffect)(() => {
16171 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
16172 if (!element) return;
16173 const callback = () => {
16174 const value = element.getAttribute(attributeName);
16175 setAttribute(value == null ? initialValue : value);
16176 };
16177 const observer = new MutationObserver(callback);
16178 observer.observe(element, { attributeFilter: [attributeName] });
16179 callback();
16180 return () => observer.disconnect();
16181 }, [
16182 refOrElement,
16183 attributeName,
16184 initialValue
16185 ]);
16186 return attribute;
16187 }
16188 function useUpdateEffect(effect, deps) {
16189 const mounted = (0, import_react8.useRef)(false);
16190 (0, import_react8.useEffect)(() => {
16191 if (mounted.current) return effect();
16192 mounted.current = true;
16193 }, deps);
16194 (0, import_react8.useEffect)(() => () => {
16195 mounted.current = false;
16196 }, []);
16197 }
16198 function useUpdateLayoutEffect(effect, deps) {
16199 const mounted = (0, import_react8.useRef)(false);
16200 useSafeLayoutEffect(() => {
16201 if (mounted.current) return effect();
16202 mounted.current = true;
16203 }, deps);
16204 useSafeLayoutEffect(() => () => {
16205 mounted.current = false;
16206 }, []);
16207 }
16208 function useForceUpdate() {
16209 return (0, import_react8.useReducer)(() => [], []);
16210 }
16211 function useBooleanEvent(booleanOrCallback) {
16212 return useEvent(typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback);
16213 }
16214 function useWrapElement(props, callback, deps = []) {
16215 const wrapElement = (0, import_react8.useCallback)((element) => {
16216 if (props.wrapElement) element = props.wrapElement(element);
16217 return callback(element);
16218 }, [...deps, props.wrapElement]);
16219 return {
16220 ...props,
16221 wrapElement
16222 };
16223 }
16224 function useMetadataProps(props, key, value) {
16225 const parent = props.onLoadedMetadataCapture;
16226 const onLoadedMetadataCapture = (0, import_react8.useMemo)(() => {
16227 return Object.assign(() => {
16228 }, parent, ...value !== void 0 ? [{ [key]: value }] : []);
16229 }, [
16230 parent,
16231 key,
16232 value
16233 ]);
16234 return [parent?.[key], { onLoadedMetadataCapture }];
16235 }
16236 var hasInstalledGlobalEventListeners = false;
16237 function useIsMouseMoving() {
16238 (0, import_react8.useEffect)(() => {
16239 if (hasInstalledGlobalEventListeners) return;
16240 addGlobalEventListener("mousemove", setMouseMoving, true);
16241 addGlobalEventListener("mousedown", resetMouseMoving, true);
16242 addGlobalEventListener("mouseup", resetMouseMoving, true);
16243 addGlobalEventListener("keydown", resetMouseMoving, true);
16244 addGlobalEventListener("scroll", resetMouseMoving, true);
16245 hasInstalledGlobalEventListeners = true;
16246 }, []);
16247 return useEvent(() => mouseMoving);
16248 }
16249 var mouseMoving = false;
16250 var previousScreenX = 0;
16251 var previousScreenY = 0;
16252 function hasMouseMovement(event) {
16253 const movementX = event.movementX || event.screenX - previousScreenX;
16254 const movementY = event.movementY || event.screenY - previousScreenY;
16255 previousScreenX = event.screenX;
16256 previousScreenY = event.screenY;
16257 return movementX || movementY || false;
16258 }
16259 function setMouseMoving(event) {
16260 if (!hasMouseMovement(event)) return;
16261 mouseMoving = true;
16262 }
16263 function resetMouseMoving() {
16264 mouseMoving = false;
16265 }
16266 function forwardRef21(render4) {
16267 const Role = React47.forwardRef((props, ref) => render4({
16268 ...props,
16269 ref
16270 }));
16271 Role.displayName = render4.displayName || render4.name;
16272 return Role;
16273 }
16274 function memo3(Component2, propsAreEqual) {
16275 return React47.memo(Component2, propsAreEqual);
16276 }
16277 function createElement3(Type, props) {
16278 const { wrapElement, render: render4, ...rest } = props;
16279 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
16280 let element;
16281 if (React47.isValidElement(render4)) {
16282 const renderProps = {
16283 ...render4.props,
16284 ref: mergedRef
16285 };
16286 element = React47.cloneElement(render4, mergeProps2(rest, renderProps));
16287 } else if (render4) element = render4(rest);
16288 else element = /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Type, { ...rest });
16289 if (wrapElement) return wrapElement(element);
16290 return element;
16291 }
16292 function createHook(useProps) {
16293 const useRole = (props = {}) => {
16294 return useProps(props);
16295 };
16296 useRole.displayName = useProps.name;
16297 return useRole;
16298 }
16299 function createStoreContext(providers = [], scopedProviders = []) {
16300 const context = React47.createContext(void 0);
16301 const scopedContext = React47.createContext(void 0);
16302 const useContext37 = () => React47.useContext(context);
16303 const useScopedContext = (onlyScoped = false) => {
16304 const scoped = React47.useContext(scopedContext);
16305 const store = useContext37();
16306 if (onlyScoped) return scoped;
16307 return scoped || store;
16308 };
16309 const useProviderContext = () => {
16310 const scoped = React47.useContext(scopedContext);
16311 const store = useContext37();
16312 if (scoped && scoped === store) return;
16313 return store;
16314 };
16315 const ContextProvider = (props) => {
16316 return providers.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Provider2, {
16317 ...props,
16318 children
16319 }), /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(context.Provider, { ...props }));
16320 };
16321 const ScopedContextProvider = (props) => {
16322 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ContextProvider, {
16323 ...props,
16324 children: scopedProviders.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Provider2, {
16325 ...props,
16326 children
16327 }), /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(scopedContext.Provider, { ...props }))
16328 });
16329 };
16330 return {
16331 context,
16332 scopedContext,
16333 useContext: useContext37,
16334 useScopedContext,
16335 useProviderContext,
16336 ContextProvider,
16337 ScopedContextProvider
16338 };
16339 }
16340
16341 // node_modules/@ariakit/react-components/dist/focusable/focusable.js
16342 var import_react9 = __toESM(require_react(), 1);
16343 var TagName = "div";
16344 var accessibleWhenDisabledSymbol = /* @__PURE__ */ Symbol("accessibleWhenDisabled");
16345 var isSafariBrowser = isSafari();
16346 var alwaysFocusVisibleInputTypes = [
16347 "text",
16348 "search",
16349 "url",
16350 "tel",
16351 "email",
16352 "password",
16353 "number",
16354 "date",
16355 "month",
16356 "week",
16357 "time",
16358 "datetime",
16359 "datetime-local"
16360 ];
16361 function isAlwaysFocusVisible(element) {
16362 const { tagName, readOnly, type } = element;
16363 if (tagName === "TEXTAREA" && !readOnly) return true;
16364 if (tagName === "SELECT" && !readOnly) return true;
16365 if (tagName === "INPUT" && !readOnly) return alwaysFocusVisibleInputTypes.includes(type);
16366 if (element.isContentEditable) return true;
16367 if (element.getAttribute("role") === "combobox" && element.dataset.name) return true;
16368 return false;
16369 }
16370 function isNativeTabbable(tagName) {
16371 if (!tagName) return true;
16372 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
16373 }
16374 function supportsDisabledAttribute(tagName) {
16375 if (!tagName) return true;
16376 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
16377 }
16378 function isNativeSubmitControl(element) {
16379 if (element.tagName === "BUTTON") {
16380 const { type } = element;
16381 return type === "submit";
16382 }
16383 if (element.tagName === "INPUT") {
16384 const { type } = element;
16385 return type === "submit" || type === "image";
16386 }
16387 return false;
16388 }
16389 function getTabIndex2({ focusable: focusable2, trulyDisabled, nativeTabbable, supportsDisabled, safariTabIndex, tabIndexProp }) {
16390 if (!focusable2) return tabIndexProp;
16391 if (trulyDisabled) {
16392 if (nativeTabbable && !supportsDisabled) return -1;
16393 return;
16394 }
16395 if (nativeTabbable) {
16396 if (safariTabIndex && tabIndexProp == null) return 0;
16397 return tabIndexProp;
16398 }
16399 return tabIndexProp ?? 0;
16400 }
16401 function useDisableEvent(onEvent, disabled2) {
16402 return useEvent((event) => {
16403 onEvent?.(event);
16404 if (event.defaultPrevented) return;
16405 if (disabled2) {
16406 event.stopPropagation();
16407 event.preventDefault();
16408 }
16409 });
16410 }
16411 var hasInstalledGlobalEventListeners2 = false;
16412 var isKeyboardModality = true;
16413 function onGlobalMouseDown(event) {
16414 const target = event.target;
16415 if (isElement2(target) && !target.hasAttribute("data-focus-visible")) isKeyboardModality = false;
16416 }
16417 function onGlobalKeyDown(event) {
16418 if (event.metaKey) return;
16419 if (event.ctrlKey) return;
16420 if (event.altKey) return;
16421 isKeyboardModality = true;
16422 }
16423 var useFocusable = createHook(function useFocusable2({ focusable: focusable2 = true, accessibleWhenDisabled, autoFocus, onFocusVisible, ...props }) {
16424 const ref = (0, import_react9.useRef)(null);
16425 const [parentAccessibleWhenDisabled, metadataProps] = useMetadataProps(props, accessibleWhenDisabledSymbol, accessibleWhenDisabled);
16426 accessibleWhenDisabled ??= parentAccessibleWhenDisabled;
16427 (0, import_react9.useEffect)(() => {
16428 if (!focusable2) return;
16429 if (hasInstalledGlobalEventListeners2) return;
16430 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
16431 addGlobalEventListener("keydown", onGlobalKeyDown, true);
16432 hasInstalledGlobalEventListeners2 = true;
16433 }, [focusable2]);
16434 const disabled2 = focusable2 && disabledFromProps(props);
16435 const trulyDisabled = disabled2 && !accessibleWhenDisabled;
16436 const [focusVisible, setFocusVisible] = (0, import_react9.useState)(false);
16437 const focusVisibleRef = (0, import_react9.useRef)(false);
16438 const nativeSubmitObserverCleanupRef = (0, import_react9.useRef)(null);
16439 const cleanupFocusVisible = useEvent((element) => {
16440 nativeSubmitObserverCleanupRef.current?.();
16441 nativeSubmitObserverCleanupRef.current = null;
16442 focusVisibleRef.current = false;
16443 element?.removeAttribute("data-focus-visible");
16444 });
16445 (0, import_react9.useEffect)(() => {
16446 if (!focusable2) return;
16447 if (!trulyDisabled) return;
16448 cleanupFocusVisible(ref.current);
16449 if (focusVisible) setFocusVisible(false);
16450 }, [
16451 focusable2,
16452 trulyDisabled,
16453 focusVisible,
16454 cleanupFocusVisible
16455 ]);
16456 (0, import_react9.useEffect)(() => {
16457 if (!focusable2) return;
16458 if (!focusVisible) return;
16459 const element = ref.current;
16460 if (!element) return;
16461 if (typeof IntersectionObserver === "undefined") return;
16462 const observer = new IntersectionObserver(() => {
16463 if (!isFocusable(element)) {
16464 focusVisibleRef.current = false;
16465 setFocusVisible(false);
16466 }
16467 });
16468 observer.observe(element);
16469 return () => observer.disconnect();
16470 }, [focusable2, focusVisible]);
16471 (0, import_react9.useEffect)(() => {
16472 return () => nativeSubmitObserverCleanupRef.current?.();
16473 }, []);
16474 const onKeyPressCapture = useDisableEvent(props.onKeyPressCapture, disabled2);
16475 const onMouseDownCapture = useDisableEvent(props.onMouseDownCapture, disabled2);
16476 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
16477 const handleFocusVisible = (event, currentTarget) => {
16478 if (currentTarget) event.currentTarget = currentTarget;
16479 if (!focusable2) return;
16480 const element = event.currentTarget;
16481 if (!element) return;
16482 if (!hasFocus(element)) return;
16483 onFocusVisible?.(event);
16484 if (event.defaultPrevented) return;
16485 element.dataset.focusVisible = "true";
16486 focusVisibleRef.current = true;
16487 if (isNativeSubmitControl(element)) {
16488 nativeSubmitObserverCleanupRef.current?.();
16489 nativeSubmitObserverCleanupRef.current = null;
16490 if (typeof IntersectionObserver !== "undefined") {
16491 const observer = new IntersectionObserver(() => {
16492 if (isFocusable(element)) return;
16493 cleanupFocusVisible(element);
16494 });
16495 observer.observe(element);
16496 nativeSubmitObserverCleanupRef.current = () => observer.disconnect();
16497 }
16498 return;
16499 }
16500 setFocusVisible(true);
16501 };
16502 const onKeyDownCaptureProp = props.onKeyDownCapture;
16503 const onKeyDownCapture = useEvent((event) => {
16504 onKeyDownCaptureProp?.(event);
16505 if (event.defaultPrevented) return;
16506 if (!focusable2) return;
16507 if (focusVisible) return;
16508 if (focusVisibleRef.current) return;
16509 if (event.metaKey) return;
16510 if (event.altKey) return;
16511 if (event.ctrlKey) return;
16512 if (!isSelfTarget(event)) return;
16513 const element = event.currentTarget;
16514 const applyFocusVisible = () => handleFocusVisible(event, element);
16515 queueBeforeEvent(element, "focusout", applyFocusVisible);
16516 });
16517 const onFocusCaptureProp = props.onFocusCapture;
16518 const onFocusCapture = useEvent((event) => {
16519 onFocusCaptureProp?.(event);
16520 if (event.defaultPrevented) return;
16521 if (!focusable2) return;
16522 if (!isSelfTarget(event)) {
16523 setFocusVisible(false);
16524 return;
16525 }
16526 const element = event.currentTarget;
16527 const applyFocusVisible = () => handleFocusVisible(event, element);
16528 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) queueBeforeEvent(event.target, "focusout", applyFocusVisible);
16529 else setFocusVisible(false);
16530 });
16531 const onBlurProp = props.onBlur;
16532 const onBlur = useEvent((event) => {
16533 onBlurProp?.(event);
16534 if (!focusable2) return;
16535 if (!isFocusEventOutside(event)) return;
16536 cleanupFocusVisible(event.currentTarget);
16537 setFocusVisible(false);
16538 });
16539 const autoFocusOnShow = (0, import_react9.useContext)(FocusableContext);
16540 const autoFocusRef = useEvent((element) => {
16541 if (!focusable2) return;
16542 if (!autoFocus) return;
16543 if (!element) return;
16544 if (!autoFocusOnShow) return;
16545 queueMicrotask(() => {
16546 if (hasFocus(element)) return;
16547 if (!isFocusable(element)) return;
16548 element.focus();
16549 });
16550 });
16551 const tagName = useTagName(ref);
16552 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
16553 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
16554 const [safariTabIndex, setSafariTabIndex] = (0, import_react9.useState)(false);
16555 if (isSafariBrowser) (0, import_react9.useEffect)(() => {
16556 if (!focusable2) return;
16557 const element = ref.current;
16558 if (!element) return;
16559 const { type } = element;
16560 const isNativeCheckboxOrRadio = element.tagName === "INPUT" && (type === "checkbox" || type === "radio");
16561 setSafariTabIndex(isButton(element) || isNativeCheckboxOrRadio);
16562 }, [focusable2]);
16563 const styleProp = props.style;
16564 const style = (0, import_react9.useMemo)(() => {
16565 if (trulyDisabled) return {
16566 pointerEvents: "none",
16567 ...styleProp
16568 };
16569 return styleProp;
16570 }, [trulyDisabled, styleProp]);
16571 props = {
16572 "data-focus-visible": focusable2 && focusVisible || void 0,
16573 "data-autofocus": autoFocus || void 0,
16574 "aria-disabled": disabled2 || void 0,
16575 ...props,
16576 ...metadataProps,
16577 ref: useMergeRefs(ref, autoFocusRef, props.ref),
16578 style,
16579 tabIndex: getTabIndex2({
16580 focusable: focusable2,
16581 trulyDisabled,
16582 nativeTabbable,
16583 supportsDisabled,
16584 safariTabIndex,
16585 tabIndexProp: props.tabIndex
16586 }),
16587 disabled: supportsDisabled && trulyDisabled ? true : void 0,
16588 contentEditable: disabled2 ? void 0 : props.contentEditable,
16589 onKeyPressCapture,
16590 onClickCapture,
16591 onMouseDownCapture,
16592 onKeyDownCapture,
16593 onFocusCapture,
16594 onBlur
16595 };
16596 return removeUndefinedValues(props);
16597 });
16598 var Focusable = forwardRef21(function Focusable2(props) {
16599 return createElement3(TagName, useFocusable(props));
16600 });
16601
16602 // node_modules/@ariakit/react-components/dist/command/command.js
16603 var import_react10 = __toESM(require_react(), 1);
16604 var TagName2 = "button";
16605 function isNativeClick(event) {
16606 if (!event.isTrusted) return false;
16607 const element = event.currentTarget;
16608 if (event.key === "Enter") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
16609 if (event.key === " ") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
16610 return false;
16611 }
16612 var symbol = /* @__PURE__ */ Symbol("command");
16613 var useCommand = createHook(function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
16614 const ref = (0, import_react10.useRef)(null);
16615 const [isNativeButton, setIsNativeButton] = (0, import_react10.useState)(false);
16616 (0, import_react10.useEffect)(() => {
16617 if (!ref.current) return;
16618 setIsNativeButton(isButton(ref.current));
16619 }, []);
16620 const [active, setActive] = (0, import_react10.useState)(false);
16621 const activeRef = (0, import_react10.useRef)(false);
16622 const disabled2 = disabledFromProps(props);
16623 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
16624 useSafeLayoutEffect(() => {
16625 if (!disabled2) return;
16626 activeRef.current = false;
16627 setActive(false);
16628 }, [disabled2]);
16629 const onKeyDownProp = props.onKeyDown;
16630 const onKeyDown = useEvent((event) => {
16631 onKeyDownProp?.(event);
16632 const element = event.currentTarget;
16633 if (event.defaultPrevented) return;
16634 if (isDuplicate) return;
16635 if (disabled2) return;
16636 if (!isSelfTarget(event)) return;
16637 if (isTextField(element)) return;
16638 if (element.isContentEditable) return;
16639 const isEnter = clickOnEnter && event.key === "Enter";
16640 const isSpace = clickOnSpace && event.key === " ";
16641 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
16642 const shouldPreventSpace = event.key === " " && !clickOnSpace;
16643 if (shouldPreventEnter || shouldPreventSpace) {
16644 event.preventDefault();
16645 return;
16646 }
16647 if (isEnter || isSpace) {
16648 const nativeClick = isNativeClick(event);
16649 if (isEnter) {
16650 if (!nativeClick) {
16651 event.preventDefault();
16652 const { view, ...eventInit } = event;
16653 const click = () => fireClickEvent(element, eventInit);
16654 if (isFirefox()) queueBeforeEvent(element, "keyup", click);
16655 else queueMicrotask(click);
16656 }
16657 } else if (isSpace) {
16658 activeRef.current = true;
16659 if (!nativeClick) {
16660 event.preventDefault();
16661 setActive(true);
16662 }
16663 }
16664 }
16665 });
16666 const onKeyUpProp = props.onKeyUp;
16667 const onKeyUp = useEvent((event) => {
16668 onKeyUpProp?.(event);
16669 if (isDuplicate) return;
16670 const isSpace = clickOnSpace && event.key === " ";
16671 if (!activeRef.current || !isSpace) return;
16672 const nativeClick = isNativeClick(event);
16673 activeRef.current = false;
16674 if (!nativeClick) setActive(false);
16675 if (event.defaultPrevented) return;
16676 if (!isSelfTarget(event)) return;
16677 if (disabled2) return;
16678 if (event.metaKey) return;
16679 if (nativeClick) return;
16680 event.preventDefault();
16681 const element = event.currentTarget;
16682 const { view, ...eventInit } = event;
16683 queueMicrotask(() => fireClickEvent(element, eventInit));
16684 });
16685 const onBlurProp = props.onBlur;
16686 const onBlur = useEvent((event) => {
16687 onBlurProp?.(event);
16688 if (!activeRef.current) return;
16689 activeRef.current = false;
16690 setActive(false);
16691 });
16692 props = {
16693 "data-active": active || void 0,
16694 type: isNativeButton ? "button" : void 0,
16695 ...metadataProps,
16696 ...props,
16697 ref: useMergeRefs(ref, props.ref),
16698 onKeyDown,
16699 onKeyUp,
16700 onBlur
16701 };
16702 props = useFocusable(props);
16703 return props;
16704 });
16705 var Command = forwardRef21(function Command2(props) {
16706 return createElement3(TagName2, useCommand(props));
16707 });
16708
16709 // node_modules/@ariakit/react-components/dist/collection/collection-context.js
16710 var ctx = createStoreContext();
16711 var useCollectionContext = ctx.useContext;
16712 var useCollectionScopedContext = ctx.useScopedContext;
16713 var useCollectionProviderContext = ctx.useProviderContext;
16714 var CollectionContextProvider = ctx.ContextProvider;
16715 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
16716
16717 // node_modules/@ariakit/react-components/dist/collection/collection-item.js
16718 var import_react11 = __toESM(require_react(), 1);
16719 var TagName3 = "div";
16720 var useCollectionItem = createHook(function useCollectionItem2({ store, shouldRegisterItem = true, getItem = identity, element, ...props }) {
16721 const context = useCollectionContext();
16722 store = store || context;
16723 const id = useId4(props.id);
16724 const ref = (0, import_react11.useRef)(element);
16725 (0, import_react11.useEffect)(() => {
16726 const element2 = ref.current;
16727 if (!id) return;
16728 if (!element2) return;
16729 if (!shouldRegisterItem) return;
16730 const item = getItem({
16731 id,
16732 element: element2
16733 });
16734 return store?.renderItem(item);
16735 }, [
16736 id,
16737 shouldRegisterItem,
16738 getItem,
16739 store
16740 ]);
16741 props = {
16742 ...props,
16743 ref: useMergeRefs(ref, props.ref)
16744 };
16745 return removeUndefinedValues(props);
16746 });
16747 var CollectionItem = forwardRef21(function CollectionItem2(props) {
16748 return createElement3(TagName3, useCollectionItem(props));
16749 });
16750
16751 // node_modules/@ariakit/react-components/dist/composite/composite-context.js
16752 var import_react12 = __toESM(require_react(), 1);
16753 var ctx2 = createStoreContext([CollectionContextProvider], [CollectionScopedContextProvider]);
16754 var useCompositeContext = ctx2.useContext;
16755 var useCompositeScopedContext = ctx2.useScopedContext;
16756 var useCompositeProviderContext = ctx2.useProviderContext;
16757 var CompositeContextProvider = ctx2.ContextProvider;
16758 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
16759 var CompositeItemContext = (0, import_react12.createContext)(void 0);
16760 var CompositeRowContext = (0, import_react12.createContext)(void 0);
16761
16762 // node_modules/@ariakit/store/dist/index.js
16763 function getInternal(store, key) {
16764 const internals = store.__unstableInternals;
16765 invariant(internals, "Invalid store");
16766 return internals[key];
16767 }
16768 function hasUpdatedKey(keys, updatedKey) {
16769 if (!keys) return true;
16770 for (const currentKey of keys) if (updatedKey instanceof Set) {
16771 if (updatedKey.has(currentKey)) return true;
16772 } else if (currentKey === updatedKey) return true;
16773 return false;
16774 }
16775 function isSameValue(value, other) {
16776 return value === other || value !== value && other !== other;
16777 }
16778 function getCleanupPrevState(prevState, state, stateBeforeCleanup, updatedKey) {
16779 let cleanupPrevState;
16780 for (const key of getKeys(state)) {
16781 if (isSameValue(state[key], stateBeforeCleanup[key])) continue;
16782 if (updatedKey !== void 0 && hasUpdatedKey([key], updatedKey)) continue;
16783 cleanupPrevState ??= { ...prevState };
16784 cleanupPrevState[key] = state[key];
16785 }
16786 return cleanupPrevState;
16787 }
16788 var MAX_REPAIR_PASSES = 100;
16789 function addKeyedListener(map, keys, listener) {
16790 if (!keys) return;
16791 for (const key of keys) {
16792 let listeners = map.get(key);
16793 if (!listeners) {
16794 listeners = /* @__PURE__ */ new Set();
16795 map.set(key, listeners);
16796 }
16797 listeners.add(listener);
16798 }
16799 }
16800 function deleteKeyedListener(map, keys, listener) {
16801 if (!map) return;
16802 if (!keys) return;
16803 for (const key of keys) {
16804 const listeners = map.get(key);
16805 if (!listeners) continue;
16806 listeners.delete(listener);
16807 if (!listeners.size) map.delete(key);
16808 }
16809 }
16810 function getFastPathNotifiedListeners(frame) {
16811 const notifiedListeners = /* @__PURE__ */ new Set();
16812 const currentListener = frame.currentListener;
16813 if (!currentListener) return notifiedListeners;
16814 for (const listener of frame.keyedListeners) {
16815 notifiedListeners.add(listener);
16816 if (listener === currentListener) return notifiedListeners;
16817 }
16818 notifiedListeners.clear();
16819 notifiedListeners.add(currentListener);
16820 return notifiedListeners;
16821 }
16822 function preserveFastPathNotifiedListeners(frame) {
16823 frame.notifiedListeners ??= getFastPathNotifiedListeners(frame);
16824 }
16825 function hasFastPathPassedListener(frame, listener) {
16826 if (!frame.currentListener) return false;
16827 let foundCurrentKeyedListener = false;
16828 for (const currentListener of frame.keyedListeners) {
16829 if (currentListener === frame.currentListener) {
16830 foundCurrentKeyedListener = true;
16831 continue;
16832 }
16833 if (!foundCurrentKeyedListener) continue;
16834 if (currentListener === listener) return false;
16835 }
16836 let foundListener = false;
16837 for (const currentListener of frame.group.listeners) {
16838 if (currentListener === frame.currentListener) return foundListener;
16839 if (currentListener === listener) foundListener = true;
16840 }
16841 return false;
16842 }
16843 function preserveFastPathFrames(fastPathFrames, group, listener) {
16844 for (const frame of fastPathFrames) {
16845 if (frame.group !== group) continue;
16846 if (frame.recovering) continue;
16847 if (listener && !frame.keyedListeners.has(listener)) continue;
16848 preserveFastPathNotifiedListeners(frame);
16849 for (const currentListener of frame.group.listeners) {
16850 if (currentListener === frame.currentListener) break;
16851 if (!hasFastPathPassedListener(frame, currentListener)) continue;
16852 frame.notifiedListeners?.add(currentListener);
16853 }
16854 }
16855 }
16856 function preserveFastPathPassedListeners(fastPathFrames, group, listener) {
16857 for (const frame of fastPathFrames) {
16858 if (frame.group !== group) continue;
16859 if (frame.recovering) continue;
16860 if (!hasFastPathPassedListener(frame, listener)) continue;
16861 preserveFastPathNotifiedListeners(frame);
16862 frame.notifiedListeners?.add(listener);
16863 }
16864 }
16865 function preserveFastPathPassedKeyedListeners({ fastPathFrames, group, keys, listener }) {
16866 const wasRegistered = group.listeners.has(listener);
16867 for (const frame of fastPathFrames) {
16868 if (frame.group !== group) continue;
16869 if (frame.recovering) continue;
16870 if (!keys.includes(frame.updatedKey)) continue;
16871 if (hasFastPathPassedListener(frame, listener)) {
16872 preserveFastPathNotifiedListeners(frame);
16873 frame.notifiedListeners?.add(listener);
16874 } else if (wasRegistered) {
16875 preserveFastPathNotifiedListeners(frame);
16876 frame.recoverToLive = true;
16877 }
16878 }
16879 }
16880 function clearFastPathNotifiedListener(fastPathFrames, group, listener) {
16881 for (const frame of fastPathFrames) {
16882 if (frame.group !== group) continue;
16883 frame.notifiedListeners?.delete(listener);
16884 }
16885 }
16886 function addFastPathKeyedListener({ fastPathFrames, group, keys, listener }) {
16887 for (const frame of fastPathFrames) {
16888 if (frame.group !== group) continue;
16889 if (frame.recovering) continue;
16890 if (!keys.includes(frame.updatedKey)) continue;
16891 frame.keyedListeners.add(listener);
16892 }
16893 }
16894 function runPendingCleanup(group, listener) {
16895 if (!group.disposables.size) return;
16896 const cleanup = group.disposables.get(listener);
16897 if (!cleanup) return;
16898 group.disposables.delete(listener);
16899 cleanup();
16900 }
16901 function setListenerCleanup(group, listener, cleanup) {
16902 const currentCleanup = group.disposables.get(listener);
16903 if (!currentCleanup) {
16904 group.disposables.set(listener, cleanup);
16905 return;
16906 }
16907 group.disposables.set(listener, () => {
16908 currentCleanup();
16909 cleanup();
16910 });
16911 }
16912 function notifyStoreListener(group, listener, state, prevState, getState, updatedKey) {
16913 if (group.suspendCounts?.has(listener)) return;
16914 const { disposables } = group;
16915 const cleanup = disposables.size ? disposables.get(listener) : void 0;
16916 if (cleanup) {
16917 disposables.delete(listener);
16918 const stateBeforeCleanup = state;
16919 cleanup();
16920 state = getState?.() ?? state;
16921 if (state !== stateBeforeCleanup) prevState = getCleanupPrevState(prevState, state, stateBeforeCleanup, updatedKey) ?? prevState;
16922 }
16923 const result = listener(state, prevState);
16924 if (result) setListenerCleanup(group, listener, result);
16925 }
16926 function runLiveListeners({ group, getState, prevState, updatedKey, notifiedListeners }) {
16927 const allKeysListeners = group.allKeysListeners;
16928 for (const listener of group.listeners) {
16929 if (notifiedListeners?.has(listener)) continue;
16930 if (!allKeysListeners?.has(listener)) {
16931 if (!hasUpdatedKey(group.listenerKeys.get(listener), updatedKey)) continue;
16932 }
16933 notifiedListeners?.add(listener);
16934 notifyStoreListener(group, listener, getState(), prevState, getState, updatedKey);
16935 }
16936 }
16937 function createStore(initialState, ...stores) {
16938 let state = initialState;
16939 let prevStateBatch = state;
16940 let destroy = noop5;
16941 let batchPending = false;
16942 let inDispatch = false;
16943 let updatedKeys = /* @__PURE__ */ new Set();
16944 const instances = /* @__PURE__ */ new Set();
16945 const setups = /* @__PURE__ */ new Set();
16946 const syncListenerGroup = {
16947 listeners: /* @__PURE__ */ new Set(),
16948 disposables: /* @__PURE__ */ new Map(),
16949 listenerKeys: /* @__PURE__ */ new WeakMap()
16950 };
16951 const batchListenerGroup = {
16952 listeners: /* @__PURE__ */ new Set(),
16953 disposables: /* @__PURE__ */ new Map(),
16954 listenerKeys: /* @__PURE__ */ new WeakMap()
16955 };
16956 const storeSetup = (callback) => {
16957 setups.add(callback);
16958 return () => setups.delete(callback);
16959 };
16960 const storeInit = () => {
16961 const initializedInstances = instances.size;
16962 const instance = /* @__PURE__ */ Symbol();
16963 instances.add(instance);
16964 const maybeDestroy = () => {
16965 if (!instances.delete(instance)) return;
16966 if (instances.size) return;
16967 destroy();
16968 };
16969 if (initializedInstances) return maybeDestroy;
16970 const stateKeys = getKeys(state);
16971 const desyncs = [];
16972 for (const store of stores) {
16973 const storeState = store?.getState?.();
16974 if (!storeState) continue;
16975 const keys = stateKeys.filter((key) => hasOwnProperty(storeState, key));
16976 if (!keys.length) continue;
16977 if (stores.length === 1 || keys.length === stateKeys.length) {
16978 for (const key of keys) desyncs.push(sync(store, [key], (state2) => {
16979 setState(key, state2[key], true);
16980 }));
16981 continue;
16982 }
16983 desyncs.push(subscribe(store, keys, (state2, prevState) => {
16984 for (const key of keys) {
16985 if (state2[key] === prevState[key]) continue;
16986 setState(key, state2[key], true);
16987 }
16988 }));
16989 for (const key of keys) {
16990 const liveState = store?.getState?.();
16991 if (!liveState) continue;
16992 setState(key, liveState[key], true);
16993 }
16994 }
16995 const teardowns = [];
16996 for (const setup2 of setups) teardowns.push(setup2());
16997 const cleanups = stores.map(init);
16998 destroy = chain(...desyncs, ...teardowns, ...cleanups);
16999 return maybeDestroy;
17000 };
17001 const deleteListenerIndexes = (group, listener, keys) => {
17002 if (keys === void 0) return;
17003 if (keys) deleteKeyedListener(group.listenersByKey, keys, listener);
17004 else group.allKeysListeners?.delete(listener);
17005 };
17006 const fastPathFrames = [];
17007 const registerListener = (keys, listener, group = syncListenerGroup) => {
17008 const listenerKeysValue = keys ? [...keys] : null;
17009 const wasRegistered = group.listeners.has(listener);
17010 if (!wasRegistered) clearFastPathNotifiedListener(fastPathFrames, group, listener);
17011 if (!listenerKeysValue) {
17012 if (wasRegistered) preserveFastPathFrames(fastPathFrames, group);
17013 preserveFastPathPassedListeners(fastPathFrames, group, listener);
17014 } else preserveFastPathPassedKeyedListeners({
17015 fastPathFrames,
17016 group,
17017 keys: listenerKeysValue,
17018 listener
17019 });
17020 if (wasRegistered) {
17021 preserveFastPathFrames(fastPathFrames, group, listener);
17022 deleteListenerIndexes(group, listener, group.listenerKeys.get(listener));
17023 }
17024 group.listeners.add(listener);
17025 if (listenerKeysValue) {
17026 group.listenersByKey ??= /* @__PURE__ */ new Map();
17027 addKeyedListener(group.listenersByKey, listenerKeysValue, listener);
17028 addFastPathKeyedListener({
17029 fastPathFrames,
17030 group,
17031 keys: listenerKeysValue,
17032 listener
17033 });
17034 } else {
17035 group.allKeysListeners ??= /* @__PURE__ */ new Set();
17036 group.allKeysListeners.add(listener);
17037 }
17038 group.listenerKeys.set(listener, listenerKeysValue);
17039 return () => {
17040 const cleanup = group.disposables.get(listener);
17041 group.disposables.delete(listener);
17042 preserveFastPathFrames(fastPathFrames, group, listener);
17043 const currentKeys = group.listenerKeys.get(listener);
17044 deleteListenerIndexes(group, listener, listenerKeysValue);
17045 if (currentKeys !== listenerKeysValue) deleteListenerIndexes(group, listener, currentKeys);
17046 group.listenerKeys.delete(listener);
17047 group.listeners.delete(listener);
17048 cleanup?.();
17049 };
17050 };
17051 const storeSubscribe = (keys, listener) => registerListener(keys, listener);
17052 const runInitialListener = (group, listener, prevState) => {
17053 const shouldSuspend = group.listeners.has(listener);
17054 if (shouldSuspend) {
17055 group.suspendCounts ??= /* @__PURE__ */ new Map();
17056 const count = group.suspendCounts.get(listener) ?? 0;
17057 group.suspendCounts.set(listener, count + 1);
17058 }
17059 let cleanupPrevState;
17060 try {
17061 const stateBeforeCleanups = state;
17062 runPendingCleanup(group, listener);
17063 if (state !== stateBeforeCleanups) cleanupPrevState = getCleanupPrevState(prevState, state, stateBeforeCleanups);
17064 const cleanup = listener(state, cleanupPrevState ?? prevState);
17065 if (cleanup) setListenerCleanup(group, listener, cleanup);
17066 } finally {
17067 if (shouldSuspend) {
17068 const suspendCounts = group.suspendCounts;
17069 const count = suspendCounts?.get(listener);
17070 if (count && count > 1) suspendCounts?.set(listener, count - 1);
17071 else suspendCounts?.delete(listener);
17072 if (!suspendCounts?.size) delete group.suspendCounts;
17073 }
17074 }
17075 };
17076 const storeSync = (keys, listener) => {
17077 runInitialListener(syncListenerGroup, listener, state);
17078 return registerListener(keys, listener);
17079 };
17080 const storeBatch = (keys, listener) => {
17081 if (!batchListenerGroup.listeners.size && !inDispatch) prevStateBatch = state;
17082 runInitialListener(batchListenerGroup, listener, prevStateBatch);
17083 return registerListener(keys, listener, batchListenerGroup);
17084 };
17085 const storePick = (keys) => createStore(pick(state, keys), finalStore);
17086 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
17087 const getState = () => state;
17088 const runListeners = (group, prevState, updatedKey) => {
17089 if (!(updatedKey instanceof Set) && !group.allKeysListeners?.size) {
17090 const keyedListeners = group.listenersByKey?.get(updatedKey);
17091 if (!keyedListeners) return;
17092 const frame = {
17093 group,
17094 keyedListeners,
17095 updatedKey,
17096 currentListener: null
17097 };
17098 fastPathFrames.push(frame);
17099 try {
17100 for (const listener of keyedListeners) {
17101 if (frame.notifiedListeners?.has(listener)) continue;
17102 frame.currentListener = listener;
17103 frame.notifiedListeners?.add(listener);
17104 notifyStoreListener(group, listener, state, prevState, getState, updatedKey);
17105 if (!group.allKeysListeners?.size && !frame.recoverToLive) continue;
17106 const notifiedListeners = frame.notifiedListeners ?? getFastPathNotifiedListeners(frame);
17107 frame.notifiedListeners = notifiedListeners;
17108 frame.recovering = true;
17109 runLiveListeners({
17110 group,
17111 getState,
17112 prevState,
17113 updatedKey,
17114 notifiedListeners
17115 });
17116 return;
17117 }
17118 } finally {
17119 fastPathFrames.pop();
17120 }
17121 return;
17122 }
17123 runLiveListeners({
17124 group,
17125 getState,
17126 prevState,
17127 updatedKey
17128 });
17129 };
17130 const setState = (key, value, fromStores = false) => {
17131 if (!hasOwnProperty(state, key)) return;
17132 const currentValue = state[key];
17133 const nextValue = typeof value === "function" ? value(currentValue) : value;
17134 if (isSameValue(nextValue, currentValue)) return;
17135 const wasInDispatch = inDispatch;
17136 inDispatch = true;
17137 const prevState = state;
17138 const nextState = {
17139 ...state,
17140 [key]: nextValue
17141 };
17142 state = nextState;
17143 let superseded = false;
17144 try {
17145 if (!fromStores && stores.length) {
17146 for (const store of stores) {
17147 store?.setState?.(key, nextValue);
17148 if (isSameValue(state[key], nextValue)) continue;
17149 superseded = true;
17150 break;
17151 }
17152 if (superseded) {
17153 let pass = 0;
17154 for (; pass < MAX_REPAIR_PASSES; pass += 1) {
17155 let changed = false;
17156 for (const store of stores) {
17157 const previousValue = state[key];
17158 store?.setState?.(key, previousValue);
17159 if (!isSameValue(state[key], previousValue)) changed = true;
17160 }
17161 if (!changed) break;
17162 }
17163 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.");
17164 }
17165 }
17166 if (!superseded) runListeners(syncListenerGroup, state === nextState ? prevState : {
17167 ...state,
17168 [key]: prevState[key]
17169 }, key);
17170 } finally {
17171 inDispatch = wasInDispatch;
17172 }
17173 if (!batchListenerGroup.listeners.size) {
17174 if (!inDispatch) prevStateBatch = state;
17175 return;
17176 }
17177 updatedKeys.add(key);
17178 if (batchPending) return;
17179 batchPending = true;
17180 queueMicrotask(() => {
17181 batchPending = false;
17182 const snapshot = state;
17183 const updatedKeysSnapshot = updatedKeys;
17184 updatedKeys = /* @__PURE__ */ new Set();
17185 const prevStateBatchBefore = prevStateBatch;
17186 runListeners(batchListenerGroup, prevStateBatchBefore, updatedKeysSnapshot);
17187 if (prevStateBatch === prevStateBatchBefore) prevStateBatch = snapshot;
17188 });
17189 };
17190 const finalStore = {
17191 getState,
17192 setState,
17193 __unstableInternals: {
17194 setup: storeSetup,
17195 init: storeInit,
17196 subscribe: storeSubscribe,
17197 sync: storeSync,
17198 batch: storeBatch,
17199 pick: storePick,
17200 omit: storeOmit
17201 }
17202 };
17203 return finalStore;
17204 }
17205 function setup(store, ...args) {
17206 if (!store) return;
17207 return getInternal(store, "setup")(...args);
17208 }
17209 function init(store, ...args) {
17210 if (!store) return;
17211 return getInternal(store, "init")(...args);
17212 }
17213 function subscribe(store, ...args) {
17214 if (!store) return;
17215 return getInternal(store, "subscribe")(...args);
17216 }
17217 function sync(store, ...args) {
17218 if (!store) return;
17219 return getInternal(store, "sync")(...args);
17220 }
17221 function batch(store, ...args) {
17222 if (!store) return;
17223 return getInternal(store, "batch")(...args);
17224 }
17225 function omit2(store, ...args) {
17226 if (!store) return;
17227 return getInternal(store, "omit")(...args);
17228 }
17229 function pick2(store, ...args) {
17230 if (!store) return;
17231 return getInternal(store, "pick")(...args);
17232 }
17233 function mergeStore(...stores) {
17234 const initialState = {};
17235 for (const store2 of stores) {
17236 const nextState = store2?.getState?.();
17237 if (nextState) Object.assign(initialState, nextState);
17238 }
17239 const store = createStore(initialState, ...stores);
17240 return Object.assign({}, ...stores, store);
17241 }
17242 function throwOnConflictingProps(props, store) {
17243 if (false) return;
17244 if (!store) return;
17245 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
17246 const stateKey = key.replace("default", "");
17247 return `${stateKey[0]?.toLowerCase() || ""}${stateKey.slice(1)}`;
17248 });
17249 if (!defaultKeys.length) return;
17250 const storeState = store.getState();
17251 if (!defaultKeys.filter((key) => hasOwnProperty(storeState, key)).length) return;
17252 throw new Error(`Passing a store prop in conjunction with a default state is not supported.
17253
17254 const store = useSelectStore();
17255 <SelectProvider store={store} defaultValue="Apple" />
17256 ^ ^
17257
17258 Instead, pass the default state to the topmost store:
17259
17260 const store = useSelectStore({ defaultValue: "Apple" });
17261 <SelectProvider store={store} />
17262
17263 See https://github.com/ariakit/ariakit/pull/2745 for more details.
17264
17265 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
17266 `);
17267 }
17268
17269 // node_modules/@ariakit/components/dist/collection/collection-store.js
17270 function getCommonParent(items) {
17271 const firstItem = items.find((item) => !!item.element);
17272 const lastElement = [...items].reverse().find((item) => !!item.element)?.element;
17273 let parentElement = firstItem?.element?.parentElement;
17274 if (!lastElement) return getDocument(parentElement).body;
17275 while (parentElement) {
17276 if (parentElement.contains(lastElement)) return parentElement;
17277 parentElement = parentElement.parentElement;
17278 }
17279 return getDocument(parentElement).body;
17280 }
17281 function getPrivateStore(store) {
17282 return store?.__unstablePrivateStore;
17283 }
17284 function createCollectionStore(props = {}) {
17285 throwOnConflictingProps(props, props.store);
17286 const syncState = props.store?.getState();
17287 const items = defaultValue(props.items, syncState?.items, props.defaultItems, []);
17288 const itemsMap = new Map(items.map((item) => [item.id, item]));
17289 const initialState = {
17290 items,
17291 renderedItems: defaultValue(syncState?.renderedItems, [])
17292 };
17293 const syncPrivateStore = getPrivateStore(props.store);
17294 const privateStore = createStore({
17295 items,
17296 renderedItems: initialState.renderedItems
17297 }, syncPrivateStore);
17298 const collection = createStore(initialState, props.store);
17299 const sortItems = (renderedItems) => {
17300 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
17301 privateStore.setState("renderedItems", sortedItems);
17302 collection.setState("renderedItems", sortedItems);
17303 };
17304 setup(collection, () => init(privateStore));
17305 setup(privateStore, () => {
17306 return batch(privateStore, ["items"], (state) => {
17307 collection.setState("items", state.items);
17308 });
17309 });
17310 setup(privateStore, () => {
17311 return batch(privateStore, ["renderedItems"], (state) => {
17312 let firstRun = true;
17313 let raf = requestAnimationFrame(() => {
17314 const { renderedItems } = collection.getState();
17315 if (state.renderedItems === renderedItems) return;
17316 sortItems(state.renderedItems);
17317 });
17318 if (typeof IntersectionObserver !== "function") return () => cancelAnimationFrame(raf);
17319 const ioCallback = () => {
17320 if (firstRun) {
17321 firstRun = false;
17322 return;
17323 }
17324 cancelAnimationFrame(raf);
17325 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
17326 };
17327 const root = getCommonParent(state.renderedItems);
17328 const observer = new IntersectionObserver(ioCallback, { root });
17329 for (const item of state.renderedItems) {
17330 if (!item.element) continue;
17331 observer.observe(item.element);
17332 }
17333 return () => {
17334 cancelAnimationFrame(raf);
17335 observer.disconnect();
17336 };
17337 });
17338 });
17339 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
17340 let prevItem;
17341 setItems((items2) => {
17342 const index2 = items2.findIndex(({ id }) => id === item.id);
17343 const nextItems = items2.slice();
17344 if (index2 !== -1) {
17345 prevItem = items2[index2];
17346 const nextItem = {
17347 ...prevItem,
17348 ...item
17349 };
17350 nextItems[index2] = nextItem;
17351 itemsMap.set(item.id, nextItem);
17352 } else {
17353 nextItems.push(item);
17354 itemsMap.set(item.id, item);
17355 }
17356 return nextItems;
17357 });
17358 const unmergeItem = () => {
17359 setItems((items2) => {
17360 if (!prevItem) {
17361 if (canDeleteFromMap) itemsMap.delete(item.id);
17362 return items2.filter(({ id }) => id !== item.id);
17363 }
17364 const index2 = items2.findIndex(({ id }) => id === item.id);
17365 if (index2 === -1) return items2;
17366 const nextItems = items2.slice();
17367 nextItems[index2] = prevItem;
17368 itemsMap.set(item.id, prevItem);
17369 return nextItems;
17370 });
17371 };
17372 return unmergeItem;
17373 };
17374 const registerItem = (item) => mergeItem(item, (getItems) => privateStore.setState("items", getItems), true);
17375 return {
17376 ...collection,
17377 registerItem,
17378 renderItem: (item) => chain(registerItem(item), mergeItem(item, (getItems) => privateStore.setState("renderedItems", getItems))),
17379 item: (id) => {
17380 if (!id) return null;
17381 let item = itemsMap.get(id);
17382 if (!item) {
17383 const { items: items2 } = privateStore.getState();
17384 item = items2.find((item2) => item2.id === id);
17385 if (item) itemsMap.set(id, item);
17386 }
17387 return item || null;
17388 },
17389 __unstablePrivateStore: privateStore
17390 };
17391 }
17392
17393 // node_modules/@ariakit/components/dist/composite/composite-store.js
17394 var NULL_ITEM = { id: null };
17395 function findFirstEnabledItem(items, excludeId) {
17396 return items.find((item) => {
17397 if (excludeId) return !item.disabled && item.id !== excludeId;
17398 return !item.disabled;
17399 });
17400 }
17401 function getEnabledItems(items, excludeId) {
17402 return items.filter((item) => {
17403 if (excludeId) return !item.disabled && item.id !== excludeId;
17404 return !item.disabled;
17405 });
17406 }
17407 function getItemsInRow(items, rowId) {
17408 return items.filter((item) => item.rowId === rowId);
17409 }
17410 function findEnabledItemId({ items, fromIndex, step, rowId, excludeId }) {
17411 for (let i2 = fromIndex; i2 >= 0 && i2 < items.length; i2 += step) {
17412 const item = items[i2];
17413 if (!item) continue;
17414 if (item.rowId !== rowId) continue;
17415 if (item.disabled) continue;
17416 if (excludeId != null && item.id === excludeId) continue;
17417 return item.id;
17418 }
17419 }
17420 function flipItems(items, activeId, shouldInsertNullItem = false) {
17421 const index2 = items.findIndex((item) => item.id === activeId);
17422 return [
17423 ...items.slice(index2 + 1),
17424 ...shouldInsertNullItem ? [NULL_ITEM] : [],
17425 ...items.slice(0, index2)
17426 ];
17427 }
17428 function groupItemsByRows(items) {
17429 const rows = [];
17430 for (const item of items) {
17431 const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId);
17432 if (row) row.push(item);
17433 else rows.push([item]);
17434 }
17435 return rows;
17436 }
17437 function getMaxRowLength(array) {
17438 let maxLength = 0;
17439 for (const { length } of array) if (length > maxLength) maxLength = length;
17440 return maxLength;
17441 }
17442 function createEmptyItem(rowId) {
17443 return {
17444 id: "__EMPTY_ITEM__",
17445 disabled: true,
17446 rowId
17447 };
17448 }
17449 function normalizeRows(rows, activeId, focusShift) {
17450 const maxLength = getMaxRowLength(rows);
17451 for (const row of rows) for (let i2 = 0; i2 < maxLength; i2 += 1) {
17452 const item = row[i2];
17453 if (!item || focusShift && item.disabled) {
17454 const previousItem = i2 === 0 && focusShift ? findFirstEnabledItem(row) : row[i2 - 1];
17455 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem?.rowId);
17456 }
17457 }
17458 return rows;
17459 }
17460 function verticalizeItems(items) {
17461 const rows = groupItemsByRows(items);
17462 const maxLength = getMaxRowLength(rows);
17463 const verticalized = [];
17464 for (let i2 = 0; i2 < maxLength; i2 += 1) for (const row of rows) {
17465 const item = row[i2];
17466 if (item) verticalized.push({
17467 ...item,
17468 rowId: item.rowId ? `${i2}` : void 0
17469 });
17470 }
17471 return verticalized;
17472 }
17473 function createCompositeStore(props = {}) {
17474 const syncState = props.store?.getState();
17475 const collection = createCollectionStore(props);
17476 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId);
17477 const composite = createStore({
17478 ...collection.getState(),
17479 id: defaultValue(props.id, syncState?.id) ?? `id-${Math.random().toString(36).slice(2, 8)}`,
17480 activeId,
17481 baseElement: defaultValue(syncState?.baseElement, null),
17482 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, activeId === null),
17483 moves: defaultValue(syncState?.moves, 0),
17484 orientation: defaultValue(props.orientation, syncState?.orientation, "both"),
17485 rtl: defaultValue(props.rtl, syncState?.rtl, false),
17486 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, false),
17487 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, false),
17488 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, false),
17489 focusShift: defaultValue(props.focusShift, syncState?.focusShift, false)
17490 }, collection, props.store);
17491 setup(composite, () => sync(composite, ["renderedItems", "activeId"], (state) => {
17492 composite.setState("activeId", (activeId2) => {
17493 if (activeId2 !== void 0) return activeId2;
17494 return findFirstEnabledItem(state.renderedItems)?.id;
17495 });
17496 }));
17497 const getNextId = (direction = "next", options = {}) => {
17498 const defaultState = composite.getState();
17499 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;
17500 const isVerticalDirection = direction === "up" || direction === "down";
17501 const isNextDirection = direction === "next" || direction === "down";
17502 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
17503 const canShift = focusShift && !skip;
17504 if (!skip && !focusWrap && !includesBaseElement && activeId2 != null) {
17505 if (!isVerticalDirection ? true : !canShift && !renderedItems.some((item) => item.rowId != null)) {
17506 const activeIndex2 = renderedItems.findIndex((item) => item.id === activeId2);
17507 const activeItem2 = renderedItems[activeIndex2];
17508 if (activeItem2) {
17509 const step = canReverse ? -1 : 1;
17510 const nextId = findEnabledItemId({
17511 items: renderedItems,
17512 fromIndex: activeIndex2 + step,
17513 step,
17514 rowId: activeItem2.rowId,
17515 excludeId: activeId2
17516 });
17517 if (nextId !== void 0) return nextId;
17518 if (!(focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical"))) return void 0;
17519 return findEnabledItemId({
17520 items: renderedItems,
17521 fromIndex: step === 1 ? 0 : renderedItems.length - 1,
17522 step,
17523 rowId: activeItem2.rowId,
17524 excludeId: activeId2
17525 });
17526 }
17527 }
17528 }
17529 let items = !isVerticalDirection ? renderedItems : flatten2DArray(normalizeRows(groupItemsByRows(renderedItems), activeId2, canShift));
17530 items = canReverse ? reverseArray(items) : items;
17531 items = isVerticalDirection ? verticalizeItems(items) : items;
17532 if (activeId2 == null) return findFirstEnabledItem(items)?.id;
17533 const activeItem = items.find((item) => item.id === activeId2);
17534 if (!activeItem) return findFirstEnabledItem(items)?.id;
17535 const isGrid2 = items.some((item) => item.rowId);
17536 const activeIndex = items.indexOf(activeItem);
17537 const nextItems = items.slice(activeIndex + 1);
17538 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
17539 if (skip) {
17540 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
17541 return (nextEnabledItemsInRow.slice(skip)[0] || nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1])?.id;
17542 }
17543 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
17544 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
17545 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
17546 if (canLoop) return findFirstEnabledItem(flipItems(canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId), activeId2, hasNullItem), activeId2)?.id;
17547 if (canWrap) {
17548 const nextItem2 = findFirstEnabledItem(hasNullItem ? nextItemsInRow : nextItems, activeId2);
17549 return hasNullItem ? nextItem2?.id || null : nextItem2?.id;
17550 }
17551 const nextItem = findFirstEnabledItem(nextItemsInRow, activeId2);
17552 if (!nextItem && hasNullItem) return null;
17553 return nextItem?.id;
17554 };
17555 const getNextIdFromOptions = (direction, options) => {
17556 if (typeof options === "number") return getNextId(direction, { skip: options });
17557 return getNextId(direction, options);
17558 };
17559 return {
17560 ...collection,
17561 ...composite,
17562 setBaseElement: (element) => composite.setState("baseElement", element),
17563 setActiveId: (id) => composite.setState("activeId", id),
17564 move: (id) => {
17565 if (id === void 0) return;
17566 composite.setState("activeId", id);
17567 composite.setState("moves", (moves) => moves + 1);
17568 },
17569 first: () => findFirstEnabledItem(composite.getState().renderedItems)?.id,
17570 last: () => findFirstEnabledItem(reverseArray(composite.getState().renderedItems))?.id,
17571 next: (options) => getNextIdFromOptions("next", options),
17572 previous: (options) => getNextIdFromOptions("previous", options),
17573 down: (options) => getNextIdFromOptions("down", options),
17574 up: (options) => getNextIdFromOptions("up", options)
17575 };
17576 }
17577
17578 // node_modules/@ariakit/react-components/dist/composite/utils.js
17579 var findFirstEnabledItem2 = findFirstEnabledItem;
17580 var groupItemsByRows2 = groupItemsByRows;
17581 function getEnabledItem(store, id) {
17582 if (!id) return null;
17583 return store.item(id) || null;
17584 }
17585 function selectTextField(element, collapseToEnd = false) {
17586 if (isTextField(element)) element.setSelectionRange(collapseToEnd ? element.value.length : 0, element.value.length);
17587 else if (element.isContentEditable) {
17588 const selection = getDocument(element).getSelection();
17589 selection?.selectAllChildren(element);
17590 if (collapseToEnd) selection?.collapseToEnd();
17591 }
17592 }
17593 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
17594 function focusSilently(element) {
17595 element[FOCUS_SILENTLY] = true;
17596 element.focus({ preventScroll: true });
17597 }
17598 function silentlyFocused(element) {
17599 const isSilentlyFocused = element[FOCUS_SILENTLY];
17600 delete element[FOCUS_SILENTLY];
17601 return isSilentlyFocused;
17602 }
17603 function isItem(store, element, exclude) {
17604 if (!element) return false;
17605 if (element === exclude) return false;
17606 const item = store.item(element.id);
17607 if (!item) return false;
17608 if (exclude && item.element === exclude) return false;
17609 return true;
17610 }
17611
17612 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
17613 var import_react13 = __toESM(require_react(), 1);
17614 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
17615
17616 // node_modules/@ariakit/react-store/dist/index.js
17617 var React48 = __toESM(require_react(), 1);
17618 var import_shim2 = __toESM(require_shim(), 1);
17619 var noopSubscribe = () => () => {
17620 };
17621 function useStoreState(store, keyOrSelector = identity) {
17622 const storeSubscribe = React48.useCallback((callback) => {
17623 if (!store) return noopSubscribe();
17624 return subscribe(store, null, callback);
17625 }, [store]);
17626 const getSnapshot = () => {
17627 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
17628 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
17629 const state = store?.getState();
17630 if (selector2) return selector2(state);
17631 if (!state) return;
17632 if (!key) return;
17633 if (!hasOwnProperty(state, key)) return;
17634 return state[key];
17635 };
17636 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
17637 }
17638 function useStoreStateObject(store, object) {
17639 const objRef = React48.useRef({});
17640 const storeSubscribe = React48.useCallback((callback) => {
17641 if (!store) return noopSubscribe();
17642 return subscribe(store, null, callback);
17643 }, [store]);
17644 const getSnapshot = () => {
17645 const state = store?.getState();
17646 let updated = false;
17647 const obj = objRef.current;
17648 for (const prop in object) {
17649 const keyOrSelector = object[prop];
17650 if (typeof keyOrSelector === "function") {
17651 const value = keyOrSelector(state);
17652 if (!Object.is(value, obj[prop])) {
17653 obj[prop] = value;
17654 updated = true;
17655 }
17656 }
17657 if (typeof keyOrSelector === "string") {
17658 if (!state) continue;
17659 if (!hasOwnProperty(state, keyOrSelector)) continue;
17660 const value = state[keyOrSelector];
17661 if (!Object.is(value, obj[prop])) {
17662 obj[prop] = value;
17663 updated = true;
17664 }
17665 }
17666 }
17667 if (updated) objRef.current = { ...obj };
17668 return objRef.current;
17669 };
17670 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
17671 }
17672 function useStoreProps(store, props, key, setKey) {
17673 const value = hasOwnProperty(props, key) ? props[key] : void 0;
17674 const propsRef = useLiveRef({
17675 value,
17676 setValue: setKey ? props[setKey] : void 0
17677 });
17678 useSafeLayoutEffect(() => {
17679 return sync(store, [key], (state, prev) => {
17680 const { value: value2, setValue } = propsRef.current;
17681 if (!setValue) return;
17682 if (state[key] === prev[key]) return;
17683 if (state[key] === value2) return;
17684 setValue(state[key]);
17685 });
17686 }, [store, key]);
17687 useSafeLayoutEffect(() => {
17688 if (value === void 0) return;
17689 store.setState(key, value);
17690 return batch(store, [key], () => {
17691 if (value === void 0) return;
17692 store.setState(key, value);
17693 });
17694 });
17695 }
17696 function useStore2(createStore2, props) {
17697 const [store, setStore] = React48.useState(() => createStore2(props));
17698 useSafeLayoutEffect(() => init(store), [store]);
17699 const useState43 = React48.useCallback((keyOrSelector) => useStoreState(store, keyOrSelector), [store]);
17700 return [React48.useMemo(() => ({
17701 ...store,
17702 useState: useState43
17703 }), [store, useState43]), useEvent(() => {
17704 setStore((store2) => createStore2({
17705 ...props,
17706 ...store2.getState()
17707 }));
17708 })];
17709 }
17710
17711 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
17712 var TagName4 = "button";
17713 function isEditableElement(element) {
17714 if (isTextbox(element)) return true;
17715 return element.tagName === "INPUT" && !isButton(element);
17716 }
17717 function getNextPageOffset(scrollingElement, pageUp = false) {
17718 const height = scrollingElement.clientHeight;
17719 const { top } = scrollingElement.getBoundingClientRect();
17720 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
17721 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
17722 if (scrollingElement.tagName === "HTML") return pageOffset + scrollingElement.scrollTop;
17723 return pageOffset;
17724 }
17725 function getItemOffset(itemElement, pageUp = false) {
17726 const { top } = itemElement.getBoundingClientRect();
17727 if (pageUp) return top + itemElement.clientHeight;
17728 return top;
17729 }
17730 function findNextPageItemId(element, store, next, pageUp = false) {
17731 if (!store) return;
17732 if (!next) return;
17733 const { renderedItems } = store.getState();
17734 const scrollingElement = getScrollingElement(element);
17735 if (!scrollingElement) return;
17736 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
17737 let id;
17738 let prevDifference;
17739 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
17740 const previousId = id;
17741 id = next(i2);
17742 if (!id) break;
17743 if (id === previousId) continue;
17744 const itemElement = getEnabledItem(store, id)?.element;
17745 if (!itemElement) continue;
17746 const difference = getItemOffset(itemElement, pageUp) - nextPageOffset;
17747 const absDifference = Math.abs(difference);
17748 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
17749 if (prevDifference !== void 0 && prevDifference < absDifference) id = previousId;
17750 break;
17751 }
17752 prevDifference = absDifference;
17753 }
17754 return id;
17755 }
17756 function targetIsAnotherItem(event, store) {
17757 if (isSelfTarget(event)) return false;
17758 return isItem(store, event.target);
17759 }
17760 var useCompositeItem = createHook(function useCompositeItem2({ store, rowId: rowIdProp, preventScrollOnKeyDown = false, moveOnKeyPress = true, tabbable: tabbable2 = false, getItem: getItemProp, "aria-setsize": ariaSetSizeProp, "aria-posinset": ariaPosInSetProp, ...props }) {
17761 const context = useCompositeScopedContext();
17762 store = store || context;
17763 const id = useId4(props.id);
17764 const ref = (0, import_react13.useRef)(null);
17765 const row = (0, import_react13.useContext)(CompositeRowContext);
17766 const trulyDisabled = disabledFromProps(props) && !props.accessibleWhenDisabled;
17767 const shouldRegisterItem = props.shouldRegisterItem;
17768 const getRowId = (state) => {
17769 if (rowIdProp) return rowIdProp;
17770 if (!state) return;
17771 if (!row?.baseElement) return;
17772 if (row.baseElement !== state.baseElement) return;
17773 return row.id;
17774 };
17775 const { rowId, baseElement, isActiveItem, ariaSetSize, ariaPosInSet, isTabbable } = useStoreStateObject(store, {
17776 rowId: getRowId,
17777 baseElement(state) {
17778 return state?.baseElement || void 0;
17779 },
17780 isActiveItem(state) {
17781 return !!state && state.activeId === id;
17782 },
17783 ariaSetSize(state) {
17784 if (ariaSetSizeProp != null) return ariaSetSizeProp;
17785 if (!state) return;
17786 if (!row?.ariaSetSize) return;
17787 if (row.baseElement !== state.baseElement) return;
17788 return row.ariaSetSize;
17789 },
17790 ariaPosInSet(state) {
17791 if (ariaPosInSetProp != null) return ariaPosInSetProp;
17792 if (!state) return;
17793 if (!row?.ariaPosInSet) return;
17794 if (row.baseElement !== state.baseElement) return;
17795 const rowId2 = getRowId(state);
17796 const itemsInRow = state.renderedItems.filter((item) => item.rowId === rowId2);
17797 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
17798 },
17799 isTabbable(state) {
17800 if (!state?.renderedItems.length) return true;
17801 if (state.virtualFocus) return false;
17802 if (tabbable2) return true;
17803 if (state.activeId === null) return false;
17804 const item = store?.item(state.activeId);
17805 if (item?.disabled) return true;
17806 if (!item?.element) return true;
17807 return state.activeId === id;
17808 }
17809 });
17810 const getItem = (0, import_react13.useCallback)((item) => {
17811 const nextItem = {
17812 ...item,
17813 id: id || item.id,
17814 rowId,
17815 disabled: trulyDisabled,
17816 children: item.element?.textContent
17817 };
17818 if (getItemProp) return getItemProp(nextItem);
17819 return nextItem;
17820 }, [
17821 id,
17822 rowId,
17823 trulyDisabled,
17824 getItemProp
17825 ]);
17826 const onFocusProp = props.onFocus;
17827 const hasFocusedComposite = (0, import_react13.useRef)(false);
17828 const cancelScheduledFocusRedirectRef = (0, import_react13.useRef)(null);
17829 const onFocus = useEvent((event) => {
17830 onFocusProp?.(event);
17831 if (event.defaultPrevented) return;
17832 if (isPortalEvent(event)) return;
17833 if (!id) return;
17834 if (!store) return;
17835 if (targetIsAnotherItem(event, store)) return;
17836 const { virtualFocus, baseElement: baseElement2 } = store.getState();
17837 store.setActiveId(id);
17838 if (isTextbox(event.currentTarget)) selectTextField(event.currentTarget);
17839 if (!virtualFocus) return;
17840 if (!isSelfTarget(event)) return;
17841 if (isEditableElement(event.currentTarget)) return;
17842 const redirectFocusToBaseElement = (currentTarget2, relatedTarget2, baseElement3) => {
17843 if (isSafari() && currentTarget2.hasAttribute("data-autofocus")) currentTarget2.scrollIntoView({
17844 block: "nearest",
17845 inline: "nearest"
17846 });
17847 hasFocusedComposite.current = true;
17848 if (relatedTarget2 === baseElement3 || isItem(store, relatedTarget2)) focusSilently(baseElement3);
17849 else baseElement3.focus();
17850 };
17851 if (baseElement2?.isConnected) {
17852 redirectFocusToBaseElement(event.currentTarget, event.relatedTarget, baseElement2);
17853 return;
17854 }
17855 if (shouldRegisterItem === false) return;
17856 const { currentTarget, relatedTarget } = event;
17857 const cancelScheduledFocusRedirect = () => {
17858 cancelScheduledFocusRedirectRef.current?.();
17859 cancelScheduledFocusRedirectRef.current = null;
17860 };
17861 cancelScheduledFocusRedirect();
17862 cancelScheduledFocusRedirectRef.current = subscribe(store, null, () => {
17863 if (getActiveElement(currentTarget) !== currentTarget) {
17864 cancelScheduledFocusRedirect();
17865 return;
17866 }
17867 const state = store.getState();
17868 const nextBaseElement = state.baseElement;
17869 if (!nextBaseElement?.isConnected) return;
17870 cancelScheduledFocusRedirect();
17871 if (!state.virtualFocus) return;
17872 redirectFocusToBaseElement(currentTarget, relatedTarget, nextBaseElement);
17873 });
17874 });
17875 const onBlurCaptureProp = props.onBlurCapture;
17876 const onBlurCapture = useEvent((event) => {
17877 onBlurCaptureProp?.(event);
17878 if (event.defaultPrevented) return;
17879 if (store?.getState()?.virtualFocus && hasFocusedComposite.current) {
17880 hasFocusedComposite.current = false;
17881 event.preventDefault();
17882 event.stopPropagation();
17883 }
17884 });
17885 const onKeyDownProp = props.onKeyDown;
17886 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
17887 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
17888 const onKeyDown = useEvent((event) => {
17889 onKeyDownProp?.(event);
17890 if (event.defaultPrevented) return;
17891 if (!isSelfTarget(event)) return;
17892 if (!store) return;
17893 const { currentTarget } = event;
17894 const state = store.getState();
17895 const isGrid2 = !!store.item(id)?.rowId;
17896 const isVertical = state.orientation !== "horizontal";
17897 const isHorizontal = state.orientation !== "vertical";
17898 const canHomeEnd = () => {
17899 if (isGrid2) return true;
17900 if (isHorizontal) return true;
17901 if (!state.baseElement) return true;
17902 if (!isTextField(state.baseElement)) return true;
17903 return false;
17904 };
17905 const action = {
17906 ArrowUp: (isGrid2 || isVertical) && store.up,
17907 ArrowRight: (isGrid2 || isHorizontal) && store.next,
17908 ArrowDown: (isGrid2 || isVertical) && store.down,
17909 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
17910 Home: () => {
17911 if (!canHomeEnd()) return;
17912 if (!isGrid2 || event.ctrlKey) return store?.first();
17913 return store?.previous(-1);
17914 },
17915 End: () => {
17916 if (!canHomeEnd()) return;
17917 if (!isGrid2 || event.ctrlKey) return store?.last();
17918 return store?.next(-1);
17919 },
17920 PageUp: () => {
17921 return findNextPageItemId(currentTarget, store, store?.up, true);
17922 },
17923 PageDown: () => {
17924 return findNextPageItemId(currentTarget, store, store?.down);
17925 }
17926 }[event.key];
17927 if (action) {
17928 if (isTextbox(currentTarget)) {
17929 const selection = getTextboxSelection(currentTarget);
17930 const isLeft = isHorizontal && event.key === "ArrowLeft";
17931 const isRight = isHorizontal && event.key === "ArrowRight";
17932 const isUp = isVertical && event.key === "ArrowUp";
17933 const isDown = isVertical && event.key === "ArrowDown";
17934 if (isRight || isDown) {
17935 const { length: valueLength } = getTextboxValue(currentTarget);
17936 if (selection.end !== valueLength) return;
17937 } else if ((isLeft || isUp) && selection.start !== 0) return;
17938 }
17939 const nextId = action();
17940 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
17941 if (!moveOnKeyPressProp(event)) return;
17942 event.preventDefault();
17943 store.move(nextId);
17944 }
17945 }
17946 });
17947 const providerValue = (0, import_react13.useMemo)(() => ({
17948 id,
17949 baseElement
17950 }), [id, baseElement]);
17951 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(CompositeItemContext.Provider, {
17952 value: providerValue,
17953 children: element
17954 }), [providerValue]);
17955 props = {
17956 "data-active-item": isActiveItem || void 0,
17957 ...props,
17958 id,
17959 ref: useMergeRefs(ref, props.ref),
17960 tabIndex: isTabbable ? props.tabIndex : -1,
17961 onFocus,
17962 onBlurCapture,
17963 onKeyDown
17964 };
17965 props = useCommand(props);
17966 props = useCollectionItem({
17967 store,
17968 ...props,
17969 getItem,
17970 shouldRegisterItem: id ? shouldRegisterItem : false
17971 });
17972 return removeUndefinedValues({
17973 ...props,
17974 "aria-setsize": ariaSetSize,
17975 "aria-posinset": ariaPosInSet
17976 });
17977 });
17978 var CompositeItem = memo3(forwardRef21(function CompositeItem2(props) {
17979 return createElement3(TagName4, useCompositeItem(props));
17980 }));
17981
17982 // node_modules/@ariakit/react-components/dist/composite/composite.js
17983 var import_react14 = __toESM(require_react(), 1);
17984 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
17985 var TagName5 = "div";
17986 function isGrid(items) {
17987 return items.some((item) => !!item.rowId);
17988 }
17989 function isPrintableKey(event) {
17990 const target = event.target;
17991 if (target && !isTextField(target)) return false;
17992 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
17993 }
17994 function isModifierKey(event) {
17995 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
17996 }
17997 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
17998 return useEvent((event) => {
17999 onKeyboardEvent?.(event);
18000 if (event.defaultPrevented) return;
18001 if (event.isPropagationStopped()) return;
18002 if (!isSelfTarget(event)) return;
18003 if (isModifierKey(event)) return;
18004 if (isPrintableKey(event)) return;
18005 const activeElement2 = getEnabledItem(store, store.getState().activeId)?.element;
18006 if (!activeElement2) return;
18007 const { view, ...eventInit } = event;
18008 if (activeElement2 !== previousElementRef?.current) activeElement2.focus();
18009 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) event.preventDefault();
18010 if (event.currentTarget.contains(activeElement2)) event.stopPropagation();
18011 });
18012 }
18013 function findFirstEnabledItemInTheLastRow(items) {
18014 return findFirstEnabledItem2(flatten2DArray(reverseArray(groupItemsByRows2(items))));
18015 }
18016 function withBaseScrollPreserved(store, callback) {
18017 const { virtualFocus, baseElement } = store.getState();
18018 if (!virtualFocus || !baseElement || !isTextField(baseElement)) {
18019 callback();
18020 return;
18021 }
18022 const savedScrollLeft = baseElement.scrollLeft;
18023 const savedScrollTop = baseElement.scrollTop;
18024 callback();
18025 baseElement.scrollLeft = savedScrollLeft;
18026 baseElement.scrollTop = savedScrollTop;
18027 }
18028 function useScheduleFocus(store) {
18029 const [scheduled, setScheduled] = (0, import_react14.useState)(false);
18030 const schedule = (0, import_react14.useCallback)(() => setScheduled(true), []);
18031 const activeItem = useStoreState(store, (state) => scheduled ? getEnabledItem(store, state.activeId) : null);
18032 (0, import_react14.useEffect)(() => {
18033 const activeElement2 = activeItem?.element;
18034 if (!scheduled) return;
18035 if (!activeElement2) return;
18036 setScheduled(false);
18037 withBaseScrollPreserved(store, () => {
18038 activeElement2.focus({ preventScroll: true });
18039 });
18040 }, [
18041 store,
18042 activeItem,
18043 scheduled
18044 ]);
18045 return schedule;
18046 }
18047 var CompositeFocusOnMove = memo3(function CompositeFocusOnMove2({ store, focusOnMove, previousElementRef }) {
18048 const moves = useStoreState(store, "moves");
18049 const baseElement = useStoreState(store, "baseElement");
18050 (0, import_react14.useEffect)(() => {
18051 if (!moves) return;
18052 if (!focusOnMove) return;
18053 const { activeId } = store.getState();
18054 const itemElement = getEnabledItem(store, activeId)?.element;
18055 if (!itemElement) return;
18056 withBaseScrollPreserved(store, () => focusIntoView(itemElement));
18057 }, [
18058 store,
18059 moves,
18060 focusOnMove
18061 ]);
18062 useSafeLayoutEffect(() => {
18063 if (!moves) return;
18064 if (!baseElement) return;
18065 const { activeId } = store.getState();
18066 if (!(activeId === null)) return;
18067 const previousElement = previousElementRef.current;
18068 previousElementRef.current = null;
18069 if (previousElement) fireBlurEvent(previousElement, { relatedTarget: baseElement });
18070 if (!hasFocus(baseElement)) baseElement.focus();
18071 }, [
18072 store,
18073 moves,
18074 baseElement
18075 ]);
18076 return null;
18077 });
18078 var useComposite = createHook(function useComposite2({ store, composite = true, focusOnMove = composite, moveOnKeyPress = true, ...props }) {
18079 const context = useCompositeProviderContext();
18080 store = store || context;
18081 invariant(store, "Composite must receive a `store` prop or be wrapped in a CompositeProvider component.");
18082 const ref = (0, import_react14.useRef)(null);
18083 const previousElementRef = (0, import_react14.useRef)(null);
18084 const scheduleFocus = useScheduleFocus(store);
18085 const [, setBaseElement] = useTransactionState(composite ? store.setBaseElement : null);
18086 const virtualFocus = useStoreState(store, "virtualFocus");
18087 const activeId = useStoreState(store, (state) => state.virtualFocus ? state.activeId : null);
18088 useSafeLayoutEffect(() => {
18089 if (!store) return;
18090 if (!composite) return;
18091 if (!virtualFocus) return;
18092 const previousElement = previousElementRef.current;
18093 previousElementRef.current = null;
18094 if (!previousElement) return;
18095 const relatedTarget = getEnabledItem(store, activeId)?.element || getActiveElement(previousElement);
18096 if (relatedTarget === previousElement) return;
18097 fireBlurEvent(previousElement, { relatedTarget });
18098 }, [
18099 store,
18100 activeId,
18101 virtualFocus,
18102 composite
18103 ]);
18104 const onKeyDownCapture = useKeyboardEventProxy(store, props.onKeyDownCapture, previousElementRef);
18105 const onKeyUpCapture = useKeyboardEventProxy(store, props.onKeyUpCapture, previousElementRef);
18106 const onFocusCaptureProp = props.onFocusCapture;
18107 const onFocusCapture = useEvent((event) => {
18108 onFocusCaptureProp?.(event);
18109 if (event.defaultPrevented) return;
18110 if (!store) return;
18111 const { virtualFocus: virtualFocus2 } = store.getState();
18112 if (!virtualFocus2) return;
18113 const previousActiveElement = event.relatedTarget;
18114 const isSilentlyFocused = silentlyFocused(event.currentTarget);
18115 if (isSelfTarget(event) && isSilentlyFocused) {
18116 event.stopPropagation();
18117 previousElementRef.current = previousActiveElement;
18118 }
18119 });
18120 const onFocusProp = props.onFocus;
18121 const onFocus = useEvent((event) => {
18122 onFocusProp?.(event);
18123 if (event.defaultPrevented) return;
18124 if (!composite) return;
18125 if (!store) return;
18126 const { relatedTarget } = event;
18127 const { virtualFocus: virtualFocus2 } = store.getState();
18128 if (virtualFocus2) {
18129 if (isSelfTarget(event) && !isItem(store, relatedTarget)) queueMicrotask(scheduleFocus);
18130 } else if (isSelfTarget(event)) store.setActiveId(null);
18131 });
18132 const onBlurCaptureProp = props.onBlurCapture;
18133 const onBlurCapture = useEvent((event) => {
18134 onBlurCaptureProp?.(event);
18135 if (event.defaultPrevented) return;
18136 if (!store) return;
18137 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
18138 if (!virtualFocus2) return;
18139 const activeElement2 = getEnabledItem(store, activeId2)?.element;
18140 const nextActiveElement = event.relatedTarget;
18141 const nextActiveElementIsItem = isItem(store, nextActiveElement);
18142 const previousElement = previousElementRef.current;
18143 previousElementRef.current = null;
18144 if (isSelfTarget(event) && nextActiveElementIsItem) {
18145 if (nextActiveElement === activeElement2) {
18146 if (previousElement && previousElement !== nextActiveElement) fireBlurEvent(previousElement, event);
18147 } else if (activeElement2) fireBlurEvent(activeElement2, event);
18148 else if (previousElement) fireBlurEvent(previousElement, event);
18149 event.stopPropagation();
18150 } else if (!isItem(store, event.target) && activeElement2) fireBlurEvent(activeElement2, event);
18151 });
18152 const onKeyDownProp = props.onKeyDown;
18153 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
18154 const onKeyDown = useEvent((event) => {
18155 onKeyDownProp?.(event);
18156 if (event.nativeEvent.isComposing) return;
18157 if (event.defaultPrevented) return;
18158 if (!store) return;
18159 if (!isSelfTarget(event)) return;
18160 const { orientation, renderedItems, activeId: activeId2, rtl } = store.getState();
18161 if (getEnabledItem(store, activeId2)?.element?.isConnected) return;
18162 const isVertical = orientation !== "horizontal";
18163 const isHorizontal = orientation !== "vertical";
18164 const grid = isGrid(renderedItems);
18165 if ((event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End") && isTextField(event.currentTarget)) return;
18166 const up = () => {
18167 if (grid) return findFirstEnabledItemInTheLastRow(renderedItems)?.id;
18168 return store?.last();
18169 };
18170 const action = {
18171 ArrowUp: (grid || isVertical) && up,
18172 ArrowRight: (grid || isHorizontal) && (rtl ? store.last : store.first),
18173 ArrowDown: (grid || isVertical) && store.first,
18174 ArrowLeft: (grid || isHorizontal) && (rtl ? store.first : store.last),
18175 Home: store.first,
18176 End: store.last,
18177 PageUp: store.first,
18178 PageDown: store.last
18179 }[event.key];
18180 if (action) {
18181 const id = action();
18182 if (id !== void 0) {
18183 if (!moveOnKeyPressProp(event)) return;
18184 event.preventDefault();
18185 store.move(id);
18186 }
18187 }
18188 });
18189 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(CompositeScopedContextProvider, {
18190 value: store,
18191 children: [element, composite && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(CompositeFocusOnMove, {
18192 store,
18193 focusOnMove,
18194 previousElementRef
18195 })]
18196 }), [
18197 store,
18198 composite,
18199 focusOnMove
18200 ]);
18201 props = {
18202 "aria-activedescendant": useStoreState(store, (state) => {
18203 if (!store) return;
18204 if (!composite) return;
18205 if (!state.virtualFocus) return;
18206 return getEnabledItem(store, state.activeId)?.id;
18207 }),
18208 ...props,
18209 ref: useMergeRefs(ref, setBaseElement, props.ref),
18210 onKeyDownCapture,
18211 onKeyUpCapture,
18212 onFocusCapture,
18213 onFocus,
18214 onBlurCapture,
18215 onKeyDown
18216 };
18217 props = useFocusable({
18218 focusable: useStoreState(store, (state) => composite && (state.virtualFocus || state.activeId === null)),
18219 ...props
18220 });
18221 return props;
18222 });
18223 var Composite6 = forwardRef21(function Composite7(props) {
18224 return createElement3(TagName5, useComposite(props));
18225 });
18226
18227 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-context.js
18228 var ctx3 = createStoreContext();
18229 var useDisclosureContext = ctx3.useContext;
18230 var useDisclosureScopedContext = ctx3.useScopedContext;
18231 var useDisclosureProviderContext = ctx3.useProviderContext;
18232 var DisclosureContextProvider = ctx3.ContextProvider;
18233 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
18234
18235 // node_modules/@ariakit/react-components/dist/dialog/dialog-context.js
18236 var import_react15 = __toESM(require_react(), 1);
18237 var ctx4 = createStoreContext([DisclosureContextProvider], [DisclosureScopedContextProvider]);
18238 var useDialogContext = ctx4.useContext;
18239 var useDialogScopedContext = ctx4.useScopedContext;
18240 var useDialogProviderContext = ctx4.useProviderContext;
18241 var DialogContextProvider = ctx4.ContextProvider;
18242 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
18243 var DialogHeadingContext = (0, import_react15.createContext)(void 0);
18244 var DialogDescriptionContext = (0, import_react15.createContext)(void 0);
18245
18246 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-content.js
18247 var import_react16 = __toESM(require_react(), 1);
18248 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
18249 var import_react_dom4 = __toESM(require_react_dom(), 1);
18250 var TagName6 = "div";
18251 function afterTimeout(timeoutMs, cb) {
18252 const timeoutId = setTimeout(cb, timeoutMs);
18253 return () => clearTimeout(timeoutId);
18254 }
18255 function parseCSSTime(time) {
18256 const value = time?.trim() || "0s";
18257 const multiplier = value.endsWith("ms") ? 1 : 1e3;
18258 const parsed = Number.parseFloat(value) * multiplier;
18259 return Number.isNaN(parsed) ? 0 : parsed;
18260 }
18261 function getEndTime(names, delays, durations) {
18262 const nameList = names.split(",");
18263 const delayList = delays.split(",");
18264 const durationList = durations.split(",");
18265 let endTime = 0;
18266 for (const [index2, name] of nameList.entries()) {
18267 if (name.trim() === "none") continue;
18268 const delay = parseCSSTime(delayList[index2 % delayList.length]);
18269 const duration = parseCSSTime(durationList[index2 % durationList.length]);
18270 endTime = Math.max(endTime, delay + duration);
18271 }
18272 return endTime;
18273 }
18274 function getElementEndTime(element) {
18275 const { transitionProperty, transitionDuration, transitionDelay, animationName, animationDuration, animationDelay } = getComputedStyle(element);
18276 return Math.max(getEndTime(transitionProperty, transitionDelay, transitionDuration), getEndTime(animationName, animationDelay, animationDuration));
18277 }
18278 function isHidden(mounted, hidden, alwaysVisible) {
18279 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
18280 }
18281 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, unstable_otherElementRef: otherElementRef, ...props }) {
18282 const context = useDisclosureProviderContext();
18283 store = store || context;
18284 invariant(store, "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component.");
18285 const ref = (0, import_react16.useRef)(null);
18286 const id = useId4(props.id);
18287 const [transition, setTransition] = (0, import_react16.useState)(null);
18288 const open = useStoreState(store, "open");
18289 const mounted = useStoreState(store, "mounted");
18290 const animated = useStoreState(store, "animated");
18291 const contentElement = useStoreState(store, "contentElement");
18292 const otherElement = useStoreState(store.disclosure, "contentElement");
18293 const hasClosedRef = (0, import_react16.useRef)(false);
18294 useSafeLayoutEffect(() => {
18295 if (!ref.current) return;
18296 store?.setContentElement(ref.current);
18297 }, [store]);
18298 useSafeLayoutEffect(() => {
18299 let previousAnimated;
18300 store?.setState("animated", (animated2) => {
18301 previousAnimated = animated2;
18302 return true;
18303 });
18304 return () => {
18305 if (previousAnimated === void 0) return;
18306 store?.setState("animated", previousAnimated);
18307 };
18308 }, [store]);
18309 useSafeLayoutEffect(() => {
18310 if (!animated) {
18311 if (!open) {
18312 hasClosedRef.current = true;
18313 setTransition(null);
18314 } else if (hasClosedRef.current) {
18315 hasClosedRef.current = false;
18316 setTransition("enter");
18317 }
18318 return;
18319 }
18320 if (!contentElement?.isConnected) {
18321 setTransition(null);
18322 return;
18323 }
18324 return afterPaint(() => {
18325 setTransition(open ? "enter" : mounted ? "leave" : null);
18326 });
18327 }, [
18328 animated,
18329 contentElement,
18330 open,
18331 mounted
18332 ]);
18333 useSafeLayoutEffect(() => {
18334 if (!store) return;
18335 if (!animated) return;
18336 if (!transition) return;
18337 if (!contentElement) return;
18338 const stopAnimation = () => store?.setState("animating", false);
18339 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
18340 if (transition === "leave" && open) return;
18341 if (transition === "enter" && !open) return;
18342 if (typeof animated === "number") return afterTimeout(animated, stopAnimationSync);
18343 const elements = [contentElement];
18344 if (otherElement) elements.push(otherElement);
18345 const relatedElement = otherElementRef?.current;
18346 if (relatedElement) elements.push(relatedElement);
18347 const timeout = Math.max(...elements.map(getElementEndTime));
18348 if (!timeout) {
18349 if (transition === "enter") store.setState("animated", false);
18350 stopAnimation();
18351 return;
18352 }
18353 return afterTimeout(Math.max(timeout - 1e3 / 60, 0), stopAnimationSync);
18354 }, [
18355 store,
18356 animated,
18357 contentElement,
18358 otherElement,
18359 otherElementRef,
18360 open,
18361 transition
18362 ]);
18363 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DialogScopedContextProvider, {
18364 value: store,
18365 children: element
18366 }), [store]);
18367 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
18368 const styleProp = props.style;
18369 const style = (0, import_react16.useMemo)(() => {
18370 if (hidden) return {
18371 ...styleProp,
18372 display: "none"
18373 };
18374 return styleProp;
18375 }, [hidden, styleProp]);
18376 props = {
18377 "data-open": open || void 0,
18378 "data-enter": transition === "enter" || void 0,
18379 "data-leave": transition === "leave" || void 0,
18380 hidden,
18381 ...props,
18382 id,
18383 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
18384 style
18385 };
18386 return removeUndefinedValues(props);
18387 });
18388 var DisclosureContentImpl = forwardRef21(function DisclosureContentImpl2(props) {
18389 return createElement3(TagName6, useDisclosureContent(props));
18390 });
18391 var DisclosureContent = forwardRef21(function DisclosureContent2({ unmountOnHide, ...props }) {
18392 const context = useDisclosureProviderContext();
18393 if (useStoreState(props.store || context, (state) => !unmountOnHide || state?.mounted) === false) return null;
18394 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DisclosureContentImpl, { ...props });
18395 });
18396
18397 // node_modules/@ariakit/components/dist/disclosure/disclosure-store.js
18398 function createDisclosureStore(props = {}) {
18399 const store = mergeStore(props.store, omit2(props.disclosure, ["contentElement", "disclosureElement"]));
18400 throwOnConflictingProps(props, store);
18401 const syncState = store?.getState();
18402 const open = defaultValue(props.open, syncState?.open, props.defaultOpen, false);
18403 const animated = defaultValue(props.animated, syncState?.animated, false);
18404 const disclosure = createStore({
18405 open,
18406 animated,
18407 animating: !!animated && open,
18408 mounted: open,
18409 contentElement: defaultValue(syncState?.contentElement, null),
18410 disclosureElement: defaultValue(syncState?.disclosureElement, null)
18411 }, store);
18412 setup(disclosure, () => sync(disclosure, ["animated", "animating"], (state) => {
18413 if (state.animated) return;
18414 disclosure.setState("animating", false);
18415 }));
18416 setup(disclosure, () => subscribe(disclosure, ["open"], () => {
18417 if (!disclosure.getState().animated) return;
18418 disclosure.setState("animating", true);
18419 }));
18420 setup(disclosure, () => sync(disclosure, ["open", "animating"], (state) => {
18421 disclosure.setState("mounted", state.open || state.animating);
18422 }));
18423 return {
18424 ...disclosure,
18425 disclosure: props.disclosure,
18426 setOpen: (value) => disclosure.setState("open", value),
18427 show: () => disclosure.setState("open", true),
18428 hide: () => disclosure.setState("open", false),
18429 toggle: () => disclosure.setState("open", (open2) => !open2),
18430 stopAnimation: () => disclosure.setState("animating", false),
18431 setContentElement: (value) => disclosure.setState("contentElement", value),
18432 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
18433 };
18434 }
18435
18436 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-store.js
18437 function useDisclosureStoreProps(store, update2, props) {
18438 useUpdateEffect(update2, [props.store, props.disclosure]);
18439 useStoreProps(store, props, "open", "setOpen");
18440 useStoreProps(store, props, "mounted", "setMounted");
18441 useStoreProps(store, props, "animated");
18442 return Object.assign(store, { disclosure: props.disclosure });
18443 }
18444
18445 // node_modules/@ariakit/react-components/dist/popover/popover-context.js
18446 var ctx5 = createStoreContext([DialogContextProvider], [DialogScopedContextProvider]);
18447 var usePopoverContext = ctx5.useContext;
18448 var usePopoverScopedContext = ctx5.useScopedContext;
18449 var usePopoverProviderContext = ctx5.useProviderContext;
18450 var PopoverContextProvider = ctx5.ContextProvider;
18451 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
18452
18453 // node_modules/@ariakit/react-components/dist/combobox/combobox-context.js
18454 var import_react17 = __toESM(require_react(), 1);
18455 var ComboboxListRoleContext = (0, import_react17.createContext)(void 0);
18456 var ctx6 = createStoreContext([PopoverContextProvider, CompositeContextProvider], [PopoverScopedContextProvider, CompositeScopedContextProvider]);
18457 var useComboboxContext = ctx6.useContext;
18458 var useComboboxScopedContext = ctx6.useScopedContext;
18459 var useComboboxProviderContext = ctx6.useProviderContext;
18460 var ComboboxContextProvider = ctx6.ContextProvider;
18461 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
18462 var ComboboxItemValueContext = (0, import_react17.createContext)(void 0);
18463 var ComboboxItemCheckedContext = (0, import_react17.createContext)(false);
18464
18465 // node_modules/@ariakit/react-components/dist/collection/collection-store.js
18466 function useCollectionStoreProps(store, update2, props) {
18467 useUpdateEffect(update2, [props.store]);
18468 useStoreProps(store, props, "items", "setItems");
18469 return store;
18470 }
18471
18472 // node_modules/@ariakit/react-components/dist/composite/composite-store.js
18473 function useCompositeStoreOptions(props) {
18474 return {
18475 id: useId4(props.id),
18476 ...props
18477 };
18478 }
18479 function useCompositeStoreProps(store, update2, props) {
18480 store = useCollectionStoreProps(store, update2, props);
18481 useStoreProps(store, props, "activeId", "setActiveId");
18482 useStoreProps(store, props, "includesBaseElement");
18483 useStoreProps(store, props, "virtualFocus");
18484 useStoreProps(store, props, "orientation");
18485 useStoreProps(store, props, "rtl");
18486 useStoreProps(store, props, "focusLoop");
18487 useStoreProps(store, props, "focusWrap");
18488 useStoreProps(store, props, "focusShift");
18489 return store;
18490 }
18491
18492 // node_modules/@ariakit/components/dist/dialog/dialog-store.js
18493 function createDialogStore(props = {}) {
18494 return createDisclosureStore(props);
18495 }
18496
18497 // node_modules/@ariakit/react-components/dist/dialog/dialog-store.js
18498 function useDialogStoreProps(store, update2, props) {
18499 return useDisclosureStoreProps(store, update2, props);
18500 }
18501
18502 // node_modules/@ariakit/components/dist/popover/popover-store.js
18503 function createPopoverStore({ popover: otherPopover, ...props } = {}) {
18504 const store = mergeStore(props.store, omit2(otherPopover, [
18505 "arrowElement",
18506 "anchorElement",
18507 "contentElement",
18508 "popoverElement",
18509 "disclosureElement"
18510 ]));
18511 throwOnConflictingProps(props, store);
18512 const syncState = store?.getState();
18513 const dialog = createDialogStore({
18514 ...props,
18515 store
18516 });
18517 const placement = defaultValue(props.placement, syncState?.placement, "bottom");
18518 const popover = createStore({
18519 ...dialog.getState(),
18520 placement,
18521 currentPlacement: placement,
18522 anchorElement: defaultValue(syncState?.anchorElement, null),
18523 popoverElement: defaultValue(syncState?.popoverElement, null),
18524 arrowElement: defaultValue(syncState?.arrowElement, null),
18525 rendered: /* @__PURE__ */ Symbol("rendered")
18526 }, dialog, store);
18527 return {
18528 ...dialog,
18529 ...popover,
18530 setAnchorElement: (element) => popover.setState("anchorElement", element),
18531 setPopoverElement: (element) => popover.setState("popoverElement", element),
18532 setArrowElement: (element) => popover.setState("arrowElement", element),
18533 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
18534 };
18535 }
18536
18537 // node_modules/@ariakit/react-components/dist/popover/popover-store.js
18538 function usePopoverStoreProps(store, update2, props) {
18539 useUpdateEffect(update2, [props.popover]);
18540 useStoreProps(store, props, "placement");
18541 return useDialogStoreProps(store, update2, props);
18542 }
18543
18544 // node_modules/@ariakit/react-components/dist/popover/popover-anchor.js
18545 var TagName7 = "div";
18546 var usePopoverAnchor = createHook(function usePopoverAnchor2({ store, ...props }) {
18547 const context = usePopoverProviderContext();
18548 store = store || context;
18549 props = {
18550 ...props,
18551 ref: useMergeRefs(store?.setAnchorElement, props.ref)
18552 };
18553 return props;
18554 });
18555 var PopoverAnchor = forwardRef21(function PopoverAnchor2(props) {
18556 return createElement3(TagName7, usePopoverAnchor(props));
18557 });
18558
18559 // node_modules/@ariakit/react-components/dist/composite/composite-hover.js
18560 var import_react18 = __toESM(require_react(), 1);
18561 var TagName8 = "div";
18562 function hoveringInside(event) {
18563 const nextElement = event.relatedTarget;
18564 if (!isElement2(nextElement)) return false;
18565 return contains2(event.currentTarget, nextElement);
18566 }
18567 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
18568 function movingToAnotherItem(event) {
18569 const { relatedTarget } = event;
18570 if (!isElement2(relatedTarget)) return false;
18571 let dest = relatedTarget;
18572 do {
18573 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
18574 dest = dest.parentElement;
18575 } while (dest);
18576 return false;
18577 }
18578 var useCompositeHover = createHook(function useCompositeHover2({ store, focusOnHover = true, blurOnHoverEnd = !!focusOnHover, ...props }) {
18579 const context = useCompositeScopedContext();
18580 store = store || context;
18581 invariant(store, "CompositeHover must be wrapped in a Composite component.");
18582 const isMouseMoving = useIsMouseMoving();
18583 const onMouseMoveProp = props.onMouseMove;
18584 const focusOnHoverProp = useBooleanEvent(focusOnHover);
18585 const onMouseMove = useEvent((event) => {
18586 onMouseMoveProp?.(event);
18587 if (event.defaultPrevented) return;
18588 if (!isMouseMoving()) return;
18589 if (!focusOnHoverProp(event)) return;
18590 if (!hasFocusWithin(event.currentTarget)) {
18591 const baseElement = store?.getState().baseElement;
18592 if (baseElement && !hasFocus(baseElement)) baseElement.focus();
18593 }
18594 store?.setActiveId(event.currentTarget.id);
18595 });
18596 const onMouseLeaveProp = props.onMouseLeave;
18597 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
18598 const onMouseLeave = useEvent((event) => {
18599 onMouseLeaveProp?.(event);
18600 if (event.defaultPrevented) return;
18601 if (!isMouseMoving()) return;
18602 if (hoveringInside(event)) return;
18603 if (movingToAnotherItem(event)) return;
18604 if (!focusOnHoverProp(event)) return;
18605 if (!blurOnHoverEndProp(event)) return;
18606 store?.setActiveId(null);
18607 store?.getState().baseElement?.focus();
18608 });
18609 const ref = (0, import_react18.useCallback)((element) => {
18610 if (!element) return;
18611 element[symbol2] = true;
18612 }, []);
18613 props = {
18614 ...props,
18615 ref: useMergeRefs(ref, props.ref),
18616 onMouseMove,
18617 onMouseLeave
18618 };
18619 return removeUndefinedValues(props);
18620 });
18621 var CompositeHover = memo3(forwardRef21(function CompositeHover2(props) {
18622 return createElement3(TagName8, useCompositeHover(props));
18623 }));
18624
18625 // node_modules/@ariakit/react-components/dist/combobox/combobox.js
18626 var import_react19 = __toESM(require_react(), 1);
18627 var TagName9 = "input";
18628 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
18629 if (!autoSelect) return false;
18630 return items.find((item) => !item.disabled && item.value)?.value === activeValue;
18631 }
18632 function hasCompletionString(value, activeValue) {
18633 if (!activeValue) return false;
18634 if (value == null) return false;
18635 const normalizedValue = normalizeString(value);
18636 const normalizedActiveValue = normalizeString(activeValue);
18637 if (normalizedValue.length !== value.length) return false;
18638 if (normalizedActiveValue.length !== activeValue.length) return false;
18639 return normalizedActiveValue.length > normalizedValue.length && normalizedActiveValue.toLowerCase().startsWith(normalizedValue.toLowerCase());
18640 }
18641 function isAriaAutoCompleteValue(value) {
18642 return value === "inline" || value === "list" || value === "both" || value === "none";
18643 }
18644 function getDefaultAutoSelectId(items) {
18645 return items.find((item) => {
18646 if (item.disabled) return false;
18647 return item.element?.getAttribute("role") !== "tab";
18648 })?.id;
18649 }
18650 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 }) {
18651 const context = useComboboxProviderContext();
18652 store = store || context;
18653 invariant(store, "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component.");
18654 const ref = (0, import_react19.useRef)(null);
18655 const [valueUpdated, forceValueUpdate] = useForceUpdate();
18656 const canAutoSelectRef = (0, import_react19.useRef)(false);
18657 const composingRef = (0, import_react19.useRef)(false);
18658 const autoSelect = useStoreState(store, (state) => state.virtualFocus && autoSelectProp);
18659 const inline4 = autoComplete === "inline" || autoComplete === "both";
18660 const [canInline, setCanInline] = (0, import_react19.useState)(inline4);
18661 useUpdateLayoutEffect(() => {
18662 if (!inline4) return;
18663 setCanInline(true);
18664 }, [inline4]);
18665 const storeValue = useStoreState(store, "value");
18666 const prevSelectedValueRef = (0, import_react19.useRef)(void 0);
18667 (0, import_react19.useEffect)(() => {
18668 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
18669 prevSelectedValueRef.current = prev.selectedValue;
18670 });
18671 }, [store]);
18672 const inlineActiveValue = useStoreState(store, (state) => {
18673 if (!inline4) return;
18674 if (!canInline) return;
18675 if (state.activeValue && Array.isArray(state.selectedValue)) {
18676 if (state.selectedValue.includes(state.activeValue)) return;
18677 if (prevSelectedValueRef.current?.includes(state.activeValue)) return;
18678 }
18679 return state.activeValue;
18680 });
18681 const items = useStoreState(store, "renderedItems");
18682 const open = useStoreState(store, "open");
18683 const contentElement = useStoreState(store, "contentElement");
18684 const value = (0, import_react19.useMemo)(() => {
18685 if (!inline4) return storeValue;
18686 if (!canInline) return storeValue;
18687 if (isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) {
18688 if (hasCompletionString(storeValue, inlineActiveValue)) return storeValue + (inlineActiveValue?.slice(storeValue.length) || "");
18689 return storeValue;
18690 }
18691 return inlineActiveValue || storeValue;
18692 }, [
18693 inline4,
18694 canInline,
18695 items,
18696 inlineActiveValue,
18697 autoSelect,
18698 storeValue
18699 ]);
18700 (0, import_react19.useEffect)(() => {
18701 const element = ref.current;
18702 if (!element) return;
18703 const onCompositeItemMove = () => setCanInline(true);
18704 element.addEventListener("combobox-item-move", onCompositeItemMove);
18705 return () => {
18706 element.removeEventListener("combobox-item-move", onCompositeItemMove);
18707 };
18708 }, []);
18709 (0, import_react19.useEffect)(() => {
18710 if (!inline4) return;
18711 if (!canInline) return;
18712 if (!inlineActiveValue) return;
18713 if (!isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) return;
18714 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
18715 let cleanup = noop5;
18716 queueMicrotask(() => {
18717 const element = ref.current;
18718 if (!element) return;
18719 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
18720 const nextStart = storeValue.length;
18721 const nextEnd = inlineActiveValue.length;
18722 setSelectionRange(element, nextStart, nextEnd);
18723 cleanup = () => {
18724 if (!hasFocus(element)) return;
18725 const { start, end } = getTextboxSelection(element);
18726 if (start !== nextStart) return;
18727 if (end !== nextEnd) return;
18728 setSelectionRange(element, prevStart, prevEnd);
18729 };
18730 });
18731 return () => cleanup();
18732 }, [
18733 valueUpdated,
18734 inline4,
18735 canInline,
18736 inlineActiveValue,
18737 items,
18738 autoSelect,
18739 storeValue
18740 ]);
18741 const getAutoSelectIdProp = useEvent(getAutoSelectId);
18742 const autoSelectIdRef = (0, import_react19.useRef)(null);
18743 const autoSelectMovedRef = (0, import_react19.useRef)(void 0);
18744 const userScrolledRef = (0, import_react19.useRef)(false);
18745 const isAutoScrollingRef = (0, import_react19.useRef)(false);
18746 (0, import_react19.useEffect)(() => {
18747 if (!open) return;
18748 if (!contentElement) return;
18749 const scrollingElement = getScrollingElement(contentElement);
18750 if (!scrollingElement) return;
18751 const onUserScroll = () => {
18752 canAutoSelectRef.current = false;
18753 userScrolledRef.current = true;
18754 };
18755 const onScroll = () => {
18756 if (!isAutoScrollingRef.current) userScrolledRef.current = true;
18757 if (!store) return;
18758 if (!canAutoSelectRef.current) return;
18759 const { activeId } = store.getState();
18760 if (activeId === null) return;
18761 if (activeId === autoSelectIdRef.current) return;
18762 canAutoSelectRef.current = false;
18763 };
18764 const options = {
18765 passive: true,
18766 capture: true
18767 };
18768 scrollingElement.addEventListener("wheel", onUserScroll, options);
18769 scrollingElement.addEventListener("touchmove", onUserScroll, options);
18770 scrollingElement.addEventListener("scroll", onScroll, options);
18771 return () => {
18772 scrollingElement.removeEventListener("wheel", onUserScroll, true);
18773 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
18774 scrollingElement.removeEventListener("scroll", onScroll, true);
18775 };
18776 }, [
18777 open,
18778 contentElement,
18779 store
18780 ]);
18781 useSafeLayoutEffect(() => {
18782 userScrolledRef.current = false;
18783 if (!storeValue) return;
18784 if (composingRef.current) return;
18785 canAutoSelectRef.current = true;
18786 }, [storeValue]);
18787 useSafeLayoutEffect(() => {
18788 if (autoSelect !== "always" && open) return;
18789 canAutoSelectRef.current = open;
18790 }, [autoSelect, open]);
18791 useSafeLayoutEffect(() => {
18792 if (open) return;
18793 autoSelectMovedRef.current = void 0;
18794 }, [open]);
18795 const resetValueOnSelect = useStoreState(store, "resetValueOnSelect");
18796 useUpdateEffect(() => {
18797 const canAutoSelect = canAutoSelectRef.current;
18798 if (!store) return;
18799 if (!open) return;
18800 if (!canAutoSelect && (!resetValueOnSelect || userScrolledRef.current)) return;
18801 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
18802 if (baseElement && !hasFocus(baseElement)) return;
18803 if (contentElement2?.hasAttribute("data-placing")) {
18804 const observer = new MutationObserver(forceValueUpdate);
18805 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
18806 return () => observer.disconnect();
18807 }
18808 if (autoSelect && canAutoSelect) {
18809 const userAutoSelectId = getAutoSelectIdProp(items);
18810 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : getDefaultAutoSelectId(items) ?? store.first();
18811 autoSelectIdRef.current = autoSelectId;
18812 const nextActiveId = autoSelectId ?? null;
18813 const nextActiveValue = store.item(nextActiveId)?.value;
18814 const moved = autoSelectMovedRef.current;
18815 if (nextActiveId !== activeId || moved?.id !== nextActiveId || moved?.value !== nextActiveValue) {
18816 autoSelectMovedRef.current = {
18817 id: nextActiveId,
18818 value: nextActiveValue
18819 };
18820 store.move(nextActiveId);
18821 } else store.setState("activeValue", nextActiveValue);
18822 } else {
18823 const element = store.item(activeId || store.first())?.element;
18824 if (element && "scrollIntoView" in element) {
18825 isAutoScrollingRef.current = true;
18826 element.scrollIntoView({
18827 block: "nearest",
18828 inline: "nearest"
18829 });
18830 requestAnimationFrame(() => {
18831 isAutoScrollingRef.current = false;
18832 });
18833 }
18834 }
18835 }, [
18836 store,
18837 open,
18838 valueUpdated,
18839 storeValue,
18840 autoSelect,
18841 resetValueOnSelect,
18842 getAutoSelectIdProp,
18843 items
18844 ]);
18845 (0, import_react19.useEffect)(() => {
18846 if (!inline4) return;
18847 const combobox = ref.current;
18848 if (!combobox) return;
18849 const elements = [combobox, contentElement].filter((value2) => !!value2);
18850 const onBlur2 = (event) => {
18851 if (elements.every((el) => isFocusEventOutside(event, el))) store?.setValue(value);
18852 };
18853 for (const element of elements) element.addEventListener("focusout", onBlur2);
18854 return () => {
18855 for (const element of elements) element.removeEventListener("focusout", onBlur2);
18856 };
18857 }, [
18858 inline4,
18859 contentElement,
18860 store,
18861 value
18862 ]);
18863 const canShow = (event) => {
18864 return event.currentTarget.value.length >= showMinLength;
18865 };
18866 const onChangeProp = props.onChange;
18867 const showOnChangeProp = useBooleanEvent(showOnChange ?? canShow);
18868 const setValueOnChangeProp = useBooleanEvent(setValueOnChange ?? !store.tag);
18869 const onChange = useEvent((event) => {
18870 onChangeProp?.(event);
18871 if (event.defaultPrevented) return;
18872 if (!store) return;
18873 const currentTarget = event.currentTarget;
18874 const { value: value2, selectionStart, selectionEnd } = currentTarget;
18875 const nativeEvent = event.nativeEvent;
18876 canAutoSelectRef.current = true;
18877 if (isInputEvent(nativeEvent)) {
18878 if (nativeEvent.isComposing) {
18879 canAutoSelectRef.current = false;
18880 composingRef.current = true;
18881 }
18882 if (inline4) {
18883 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
18884 const caretAtEnd = selectionStart === value2.length;
18885 setCanInline(textInserted && caretAtEnd);
18886 }
18887 }
18888 if (setValueOnChangeProp(event)) {
18889 const isSameValue2 = value2 === store.getState().value;
18890 store.setValue(value2);
18891 queueMicrotask(() => {
18892 setSelectionRange(currentTarget, selectionStart, selectionEnd);
18893 });
18894 if (inline4 && autoSelect && isSameValue2) forceValueUpdate();
18895 }
18896 if (showOnChangeProp(event)) store.show();
18897 if (!autoSelect || !canAutoSelectRef.current) store.setActiveId(null);
18898 });
18899 const onCompositionEndProp = props.onCompositionEnd;
18900 const onCompositionEnd = useEvent((event) => {
18901 canAutoSelectRef.current = true;
18902 composingRef.current = false;
18903 onCompositionEndProp?.(event);
18904 if (event.defaultPrevented) return;
18905 if (!autoSelect) return;
18906 forceValueUpdate();
18907 });
18908 const onMouseDownProp = props.onMouseDown;
18909 const blurActiveItemOnClickProp = useBooleanEvent(blurActiveItemOnClick ?? (() => store.getState().includesBaseElement));
18910 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18911 const showOnClickProp = useBooleanEvent(showOnClick ?? canShow);
18912 const onMouseDown = useEvent((event) => {
18913 onMouseDownProp?.(event);
18914 if (event.defaultPrevented) return;
18915 if (event.button) return;
18916 if (event.ctrlKey) return;
18917 if (!store) return;
18918 if (blurActiveItemOnClickProp(event)) store.setActiveId(null);
18919 if (setValueOnClickProp(event)) store.setValue(value);
18920 if (showOnClickProp(event)) queueBeforeEvent(event.currentTarget, "mouseup", store.show);
18921 });
18922 const onKeyDownProp = props.onKeyDown;
18923 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress ?? canShow);
18924 const onKeyDown = useEvent((event) => {
18925 onKeyDownProp?.(event);
18926 if (!event.repeat) canAutoSelectRef.current = false;
18927 if (event.defaultPrevented) return;
18928 if (!store) return;
18929 const { open: open2 } = store.getState();
18930 if (open2 && event.key === "Enter") {
18931 event.preventDefault();
18932 return;
18933 }
18934 if (event.ctrlKey) return;
18935 if (event.altKey) return;
18936 if (event.shiftKey) return;
18937 if (event.metaKey) return;
18938 if (open2) return;
18939 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
18940 if (showOnKeyPressProp(event)) {
18941 event.preventDefault();
18942 store.show();
18943 }
18944 }
18945 });
18946 const onBlurProp = props.onBlur;
18947 const onBlur = useEvent((event) => {
18948 canAutoSelectRef.current = false;
18949 onBlurProp?.(event);
18950 });
18951 const id = useId4(props.id);
18952 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
18953 const isActiveItem = useStoreState(store, (state) => state.activeId === null);
18954 props = {
18955 role: "combobox",
18956 "aria-autocomplete": ariaAutoComplete,
18957 "aria-haspopup": getPopupRole(contentElement, "listbox"),
18958 "aria-expanded": open,
18959 "aria-controls": contentElement?.id,
18960 "data-active-item": isActiveItem || void 0,
18961 value,
18962 ...props,
18963 id,
18964 ref: useMergeRefs(ref, props.ref),
18965 onChange,
18966 onCompositionEnd,
18967 onMouseDown,
18968 onKeyDown,
18969 onBlur
18970 };
18971 props = useComposite({
18972 store,
18973 focusable: focusable2,
18974 ...props,
18975 moveOnKeyPress: (event) => {
18976 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
18977 if (inline4) setCanInline(true);
18978 return true;
18979 }
18980 });
18981 props = usePopoverAnchor({
18982 store,
18983 ...props
18984 });
18985 return {
18986 autoComplete: "off",
18987 ...props
18988 };
18989 });
18990 var Combobox = forwardRef21(function Combobox2(props) {
18991 return createElement3(TagName9, useCombobox(props));
18992 });
18993
18994 // node_modules/@ariakit/react-components/dist/combobox/combobox-item.js
18995 var import_react20 = __toESM(require_react(), 1);
18996 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
18997 var TagName10 = "div";
18998 function isSelected(storeValue, itemValue) {
18999 if (itemValue == null) return;
19000 if (storeValue == null) return false;
19001 if (Array.isArray(storeValue)) return storeValue.includes(itemValue);
19002 return storeValue === itemValue;
19003 }
19004 function getItemRole(popupRole) {
19005 return getItemRoleByPopupRole(popupRole) ?? "option";
19006 }
19007 var useComboboxItem = createHook(function useComboboxItem2({ store, value, hideOnClick, setValueOnClick, selectValueOnClick = true, resetValueOnSelect, focusOnHover = false, moveOnKeyPress = true, getItem: getItemProp, ...props }) {
19008 const context = useComboboxScopedContext();
19009 store = store || context;
19010 invariant(store, "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component.");
19011 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
19012 resetValueOnSelectState: "resetValueOnSelect",
19013 multiSelectable(state) {
19014 return Array.isArray(state.selectedValue);
19015 },
19016 selected(state) {
19017 return isSelected(state.selectedValue, value);
19018 }
19019 });
19020 const getItem = (0, import_react20.useCallback)((item) => {
19021 const nextItem = {
19022 ...item,
19023 value
19024 };
19025 if (getItemProp) return getItemProp(nextItem);
19026 return nextItem;
19027 }, [value, getItemProp]);
19028 setValueOnClick = setValueOnClick ?? !multiSelectable;
19029 hideOnClick = hideOnClick ?? (value != null && !multiSelectable);
19030 const onClickProp = props.onClick;
19031 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
19032 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
19033 const resetValueOnSelectProp = useBooleanEvent(resetValueOnSelect ?? resetValueOnSelectState ?? multiSelectable);
19034 const hideOnClickProp = useBooleanEvent(hideOnClick);
19035 const onClick = useEvent((event) => {
19036 onClickProp?.(event);
19037 if (event.defaultPrevented) return;
19038 if (isDownloading(event)) return;
19039 if (isOpeningInNewTab(event)) return;
19040 if (value != null) {
19041 if (selectValueOnClickProp(event)) {
19042 if (resetValueOnSelectProp(event)) store?.resetValue();
19043 store?.setSelectedValue((prevValue) => {
19044 if (!Array.isArray(prevValue)) return value;
19045 if (prevValue.includes(value)) return prevValue.filter((v2) => v2 !== value);
19046 return [...prevValue, value];
19047 });
19048 }
19049 if (setValueOnClickProp(event)) store?.setValue(value);
19050 }
19051 if (hideOnClickProp(event)) store?.hide();
19052 });
19053 const onKeyDownProp = props.onKeyDown;
19054 const onKeyDown = useEvent((event) => {
19055 onKeyDownProp?.(event);
19056 if (event.defaultPrevented) return;
19057 const baseElement = store?.getState().baseElement;
19058 if (!baseElement) return;
19059 if (hasFocus(baseElement)) return;
19060 const printable = event.key.length === 1 && !event.ctrlKey && !event.metaKey;
19061 const paste = (!isApple() ? event.ctrlKey : event.metaKey) && event.key.toLowerCase() === "v";
19062 const deleteKey = event.key === "Backspace" || event.key === "Delete";
19063 if (printable || paste || deleteKey) {
19064 queueMicrotask(() => baseElement.focus());
19065 if (isTextField(baseElement)) store?.setValue(baseElement.value);
19066 }
19067 });
19068 if (multiSelectable && selected != null) props = {
19069 "aria-selected": selected,
19070 ...props
19071 };
19072 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ComboboxItemValueContext.Provider, {
19073 value,
19074 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ComboboxItemCheckedContext.Provider, {
19075 value: selected ?? false,
19076 children: element
19077 })
19078 }), [value, selected]);
19079 props = {
19080 role: getItemRole((0, import_react20.useContext)(ComboboxListRoleContext)),
19081 children: value,
19082 ...props,
19083 onClick,
19084 onKeyDown
19085 };
19086 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
19087 props = useCompositeItem({
19088 store,
19089 ...props,
19090 getItem,
19091 moveOnKeyPress: (event) => {
19092 if (!moveOnKeyPressProp(event)) return false;
19093 const moveEvent = new Event("combobox-item-move");
19094 store?.getState().baseElement?.dispatchEvent(moveEvent);
19095 return true;
19096 }
19097 });
19098 props = useCompositeHover({
19099 store,
19100 focusOnHover,
19101 ...props
19102 });
19103 return props;
19104 });
19105 var ComboboxItem = memo3(forwardRef21(function ComboboxItem2(props) {
19106 return createElement3(TagName10, useComboboxItem(props));
19107 }));
19108
19109 // node_modules/@ariakit/react-components/dist/combobox/combobox-item-value.js
19110 var import_react21 = __toESM(require_react(), 1);
19111 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
19112 var TagName11 = "span";
19113 function normalizeValue(value) {
19114 return normalizeString(value).toLowerCase();
19115 }
19116 function getOffsets(string, values) {
19117 const offsets = [];
19118 for (const value of values) {
19119 if (!value) continue;
19120 let pos = 0;
19121 const length = value.length;
19122 let index2 = string.indexOf(value, pos);
19123 while (index2 !== -1) {
19124 offsets.push([index2, length]);
19125 pos = index2 + 1;
19126 index2 = string.indexOf(value, pos);
19127 }
19128 }
19129 return offsets;
19130 }
19131 function mergeOverlappingOffsets(offsets) {
19132 offsets.sort(([a2], [b2]) => a2 - b2);
19133 const merged = [];
19134 for (const [offset4, length] of offsets) {
19135 const last = merged[merged.length - 1];
19136 if (last && offset4 < last[0] + last[1]) last[1] = Math.max(last[1], offset4 + length - last[0]);
19137 else merged.push([offset4, length]);
19138 }
19139 return merged;
19140 }
19141 function getNormalizedIndexes(itemValue) {
19142 const starts = [];
19143 const ends = [];
19144 let index2 = 0;
19145 for (const char of itemValue) {
19146 const normalizedLength = normalizeValue(char).length;
19147 for (let i2 = 0; i2 < normalizedLength; i2 += 1) {
19148 starts.push(i2 === 0 ? index2 : -1);
19149 ends.push(index2);
19150 }
19151 index2 += char.length;
19152 }
19153 starts.push(itemValue.length);
19154 ends.push(itemValue.length);
19155 let nextBoundary = itemValue.length;
19156 for (let i2 = starts.length - 1; i2 >= 0; i2 -= 1) {
19157 const start = starts[i2];
19158 if (start == null) continue;
19159 if (start === -1) starts[i2] = nextBoundary;
19160 else nextBoundary = start;
19161 }
19162 return {
19163 starts,
19164 ends
19165 };
19166 }
19167 function toOriginalOffsets(itemValue, normalizedOffsets) {
19168 if (!normalizedOffsets.length) return normalizedOffsets;
19169 const { starts, ends } = getNormalizedIndexes(itemValue);
19170 const offsets = [];
19171 for (const [normalizedOffset, normalizedLength] of normalizedOffsets) {
19172 const start = starts[normalizedOffset];
19173 const end = ends[normalizedOffset + normalizedLength];
19174 if (start == null || end == null) continue;
19175 if (end <= start) continue;
19176 offsets.push([start, end - start]);
19177 }
19178 return offsets;
19179 }
19180 function splitValue(itemValue, userValue) {
19181 if (!itemValue) return itemValue;
19182 if (!userValue) return itemValue;
19183 const userValues = toArray(userValue).map(normalizeValue);
19184 const parts = [];
19185 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("span", {
19186 "data-autocomplete-value": autocomplete ? "" : void 0,
19187 "data-user-value": autocomplete ? void 0 : "",
19188 children: value
19189 }, parts.length);
19190 const offsets = toOriginalOffsets(itemValue, mergeOverlappingOffsets(getOffsets(normalizeValue(itemValue), new Set(userValues))));
19191 const firstEntry = offsets[0];
19192 if (!firstEntry) {
19193 parts.push(span(itemValue, true));
19194 return parts;
19195 }
19196 const [firstOffset] = firstEntry;
19197 [itemValue.slice(0, firstOffset), ...offsets.flatMap(([offset4, length], i2) => {
19198 const value = itemValue.slice(offset4, offset4 + length);
19199 const nextOffset = offsets[i2 + 1]?.[0];
19200 return [value, itemValue.slice(offset4 + length, nextOffset)];
19201 })].forEach((value, i2) => {
19202 if (!value) return;
19203 parts.push(span(value, i2 % 2 === 0));
19204 });
19205 return parts;
19206 }
19207 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
19208 const context = useComboboxScopedContext();
19209 store = store || context;
19210 const itemContext = (0, import_react21.useContext)(ComboboxItemValueContext);
19211 const itemValue = value ?? itemContext;
19212 const inputValue = useStoreState(store, (state) => userValue ?? state?.value);
19213 props = {
19214 children: (0, import_react21.useMemo)(() => {
19215 if (!itemValue) return;
19216 if (!inputValue) return itemValue;
19217 return splitValue(itemValue, inputValue);
19218 }, [itemValue, inputValue]),
19219 ...props
19220 };
19221 return removeUndefinedValues(props);
19222 });
19223 var ComboboxItemValue = forwardRef21(function ComboboxItemValue2(props) {
19224 return createElement3(TagName11, useComboboxItemValue(props));
19225 });
19226
19227 // node_modules/@ariakit/react-components/dist/combobox/combobox-label.js
19228 var TagName12 = "label";
19229 var useComboboxLabel = createHook(function useComboboxLabel2({ store, ...props }) {
19230 const context = useComboboxProviderContext();
19231 store = store || context;
19232 invariant(store, "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component.");
19233 props = {
19234 htmlFor: useStoreState(store, (state) => state.baseElement?.id),
19235 ...props
19236 };
19237 return removeUndefinedValues(props);
19238 });
19239 var ComboboxLabel = memo3(forwardRef21(function ComboboxLabel2(props) {
19240 return createElement3(TagName12, useComboboxLabel(props));
19241 }));
19242
19243 // node_modules/@ariakit/react-components/dist/combobox/combobox-list.js
19244 var import_react22 = __toESM(require_react(), 1);
19245 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
19246 var TagName13 = "div";
19247 var useComboboxList = createHook(function useComboboxList2({ store, alwaysVisible, ...props }) {
19248 const scopedContext = useComboboxScopedContext(true);
19249 const context = useComboboxContext();
19250 store = store || context;
19251 const scopedContextSameStore = !!store && store === scopedContext;
19252 invariant(store, "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component.");
19253 const ref = (0, import_react22.useRef)(null);
19254 const id = useId4(props.id);
19255 const mounted = useStoreState(store, "mounted");
19256 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
19257 const style = hidden ? {
19258 ...props.style,
19259 display: "none"
19260 } : props.style;
19261 const multiSelectable = useStoreState(store, (state) => Array.isArray(state.selectedValue));
19262 const role = useAttribute(ref, "role", props.role);
19263 const ariaMultiSelectable = role === "listbox" || role === "tree" || role === "grid" ? multiSelectable || void 0 : void 0;
19264 const [hasListboxInside, setHasListboxInside] = (0, import_react22.useState)(false);
19265 const contentElement = useStoreState(store, "contentElement");
19266 useSafeLayoutEffect(() => {
19267 if (!mounted) return;
19268 const element = ref.current;
19269 if (!element) return;
19270 if (contentElement !== element) return;
19271 const callback = () => {
19272 setHasListboxInside(!!element.querySelector("[role='listbox']"));
19273 };
19274 const observer = new MutationObserver(callback);
19275 observer.observe(element, {
19276 subtree: true,
19277 childList: true,
19278 attributeFilter: ["role"]
19279 });
19280 callback();
19281 return () => observer.disconnect();
19282 }, [mounted, contentElement]);
19283 if (!hasListboxInside) props = {
19284 role: "listbox",
19285 "aria-multiselectable": ariaMultiSelectable,
19286 ...props
19287 };
19288 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ComboboxScopedContextProvider, {
19289 value: store,
19290 children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ComboboxListRoleContext.Provider, {
19291 value: role,
19292 children: element
19293 })
19294 }), [store, role]);
19295 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
19296 props = {
19297 hidden,
19298 ...props,
19299 id,
19300 ref: useMergeRefs(setContentElement, ref, props.ref),
19301 style
19302 };
19303 return removeUndefinedValues(props);
19304 });
19305 var ComboboxList = forwardRef21(function ComboboxList2(props) {
19306 return createElement3(TagName13, useComboboxList(props));
19307 });
19308
19309 // node_modules/@ariakit/react-components/dist/tag/tag-context.js
19310 var import_react23 = __toESM(require_react(), 1);
19311 var TagValueContext = (0, import_react23.createContext)(null);
19312 var TagRemoveIdContext = (0, import_react23.createContext)(null);
19313 var ctx7 = createStoreContext([CompositeContextProvider], [CompositeScopedContextProvider]);
19314 var useTagContext = ctx7.useContext;
19315 var useTagScopedContext = ctx7.useScopedContext;
19316 var useTagProviderContext = ctx7.useProviderContext;
19317 var TagContextProvider = ctx7.ContextProvider;
19318 var TagScopedContextProvider = ctx7.ScopedContextProvider;
19319
19320 // node_modules/@ariakit/components/dist/combobox/combobox-store.js
19321 var isTouchSafari = isSafari() && isTouchDevice();
19322 function createComboboxStore({ tag, ...props } = {}) {
19323 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
19324 throwOnConflictingProps(props, store);
19325 const tagState = tag?.getState();
19326 const syncState = store?.getState();
19327 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId, null);
19328 const composite = createCompositeStore({
19329 ...props,
19330 activeId,
19331 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, true),
19332 orientation: defaultValue(props.orientation, syncState?.orientation, "vertical"),
19333 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, true),
19334 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, true),
19335 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, true)
19336 });
19337 const popover = createPopoverStore({
19338 ...props,
19339 placement: defaultValue(props.placement, syncState?.placement, "bottom-start")
19340 });
19341 const value = defaultValue(props.value, syncState?.value, props.defaultValue, "");
19342 const selectedValue = defaultValue(props.selectedValue, syncState?.selectedValue, tagState?.values, props.defaultSelectedValue, "");
19343 const multiSelectable = Array.isArray(selectedValue);
19344 const initialState = {
19345 ...composite.getState(),
19346 ...popover.getState(),
19347 value,
19348 selectedValue,
19349 resetValueOnSelect: defaultValue(props.resetValueOnSelect, syncState?.resetValueOnSelect, multiSelectable),
19350 resetValueOnHide: defaultValue(props.resetValueOnHide, syncState?.resetValueOnHide, multiSelectable && !tag),
19351 activeValue: syncState?.activeValue
19352 };
19353 const combobox = createStore(initialState, composite, popover, store);
19354 if (isTouchSafari) setup(combobox, () => sync(combobox, ["virtualFocus"], () => {
19355 combobox.setState("virtualFocus", false);
19356 }));
19357 setup(combobox, () => {
19358 if (!tag) return;
19359 return chain(sync(combobox, ["selectedValue"], (state) => {
19360 if (!Array.isArray(state.selectedValue)) return;
19361 tag.setValues(state.selectedValue);
19362 }), sync(tag, ["values"], (state) => {
19363 combobox.setState("selectedValue", state.values);
19364 }));
19365 });
19366 setup(combobox, () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
19367 if (!state.resetValueOnHide) return;
19368 if (state.mounted) return;
19369 combobox.setState("value", value);
19370 }));
19371 setup(combobox, () => sync(combobox, ["open"], (state) => {
19372 if (state.open) return;
19373 combobox.setState("activeId", activeId);
19374 combobox.setState("moves", 0);
19375 }));
19376 setup(combobox, () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
19377 if (state.moves === prevState.moves) combobox.setState("activeValue", void 0);
19378 }));
19379 setup(combobox, () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
19380 if (state.moves === prev.moves) return;
19381 const { activeId: activeId2 } = combobox.getState();
19382 const activeItem = composite.item(activeId2);
19383 combobox.setState("activeValue", activeItem?.value);
19384 }));
19385 return {
19386 ...popover,
19387 ...composite,
19388 ...combobox,
19389 tag,
19390 setValue: (value2) => combobox.setState("value", value2),
19391 resetValue: () => combobox.setState("value", initialState.value),
19392 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
19393 };
19394 }
19395
19396 // node_modules/@ariakit/react-components/dist/combobox/combobox-store.js
19397 function useComboboxStoreOptions(props) {
19398 const tag = useTagContext();
19399 props = {
19400 ...props,
19401 tag: props.tag !== void 0 ? props.tag : tag
19402 };
19403 return useCompositeStoreOptions(props);
19404 }
19405 function useComboboxStoreProps(store, update2, props) {
19406 useUpdateEffect(update2, [props.tag]);
19407 useStoreProps(store, props, "value", "setValue");
19408 useStoreProps(store, props, "selectedValue", "setSelectedValue");
19409 useStoreProps(store, props, "resetValueOnHide");
19410 useStoreProps(store, props, "resetValueOnSelect");
19411 return Object.assign(useCompositeStoreProps(usePopoverStoreProps(store, update2, props), update2, props), { tag: props.tag });
19412 }
19413 function useComboboxStore(props = {}) {
19414 props = useComboboxStoreOptions(props);
19415 const [store, update2] = useStore2(createComboboxStore, props);
19416 return useComboboxStoreProps(store, update2, props);
19417 }
19418
19419 // node_modules/@ariakit/react-components/dist/combobox/combobox-provider.js
19420 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
19421 function ComboboxProvider(props = {}) {
19422 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(ComboboxContextProvider, {
19423 value: useComboboxStore(props),
19424 children: props.children
19425 });
19426 }
19427
19428 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
19429 var import_remove_accents = __toESM(require_remove_accents(), 1);
19430 var import_compose8 = __toESM(require_compose(), 1);
19431 var import_i18n30 = __toESM(require_i18n(), 1);
19432 var import_element44 = __toESM(require_element(), 1);
19433 var import_components19 = __toESM(require_components(), 1);
19434
19435 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
19436 var EMPTY_ARRAY3 = [];
19437 var getCurrentValue = (filterDefinition, currentFilter) => {
19438 if (filterDefinition.singleSelection) {
19439 return currentFilter?.value;
19440 }
19441 if (Array.isArray(currentFilter?.value)) {
19442 return currentFilter.value;
19443 }
19444 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
19445 return [currentFilter.value];
19446 }
19447 return EMPTY_ARRAY3;
19448 };
19449
19450 // packages/dataviews/build-module/hooks/use-elements.mjs
19451 var import_element43 = __toESM(require_element(), 1);
19452 var EMPTY_ARRAY4 = [];
19453 function useElements({
19454 elements,
19455 getElements
19456 }) {
19457 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
19458 const [records, setRecords] = (0, import_element43.useState)(staticElements);
19459 const [isLoading, setIsLoading] = (0, import_element43.useState)(false);
19460 (0, import_element43.useEffect)(() => {
19461 if (!getElements) {
19462 setRecords(staticElements);
19463 return;
19464 }
19465 let cancelled = false;
19466 setIsLoading(true);
19467 getElements().then((fetchedElements) => {
19468 if (!cancelled) {
19469 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
19470 setRecords(dynamicElements);
19471 }
19472 }).catch(() => {
19473 if (!cancelled) {
19474 setRecords(staticElements);
19475 }
19476 }).finally(() => {
19477 if (!cancelled) {
19478 setIsLoading(false);
19479 }
19480 });
19481 return () => {
19482 cancelled = true;
19483 };
19484 }, [getElements, staticElements]);
19485 return {
19486 elements: records,
19487 isLoading
19488 };
19489 }
19490
19491 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
19492 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
19493 function normalizeSearchInput(input = "") {
19494 return (0, import_remove_accents.default)(input.trim().toLowerCase());
19495 }
19496 var getNewValue = (filterDefinition, currentFilter, value) => {
19497 if (filterDefinition.singleSelection) {
19498 return value;
19499 }
19500 if (Array.isArray(currentFilter?.value)) {
19501 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
19502 }
19503 return [value];
19504 };
19505 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
19506 return `${prefix}-${filterElementValue}`;
19507 }
19508 var MultiSelectionOption = ({ selected }) => {
19509 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19510 "span",
19511 {
19512 className: clsx_default(
19513 "dataviews-filters__search-widget-listitem-multi-selection",
19514 { "is-selected": selected }
19515 ),
19516 children: selected && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Icon, { icon: check_default })
19517 }
19518 );
19519 };
19520 var SingleSelectionOption = ({ selected }) => {
19521 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19522 "span",
19523 {
19524 className: clsx_default(
19525 "dataviews-filters__search-widget-listitem-single-selection",
19526 { "is-selected": selected }
19527 )
19528 }
19529 );
19530 };
19531 function ListBox({ view, filter, onChangeView }) {
19532 const baseId = (0, import_compose8.useInstanceId)(ListBox, "dataviews-filter-list-box");
19533 const [activeCompositeId, setActiveCompositeId] = (0, import_element44.useState)(
19534 // When there are one or less operators, the first item is set as active
19535 // (by setting the initial `activeId` to `undefined`).
19536 // With 2 or more operators, the focus is moved on the operators control
19537 // (by setting the initial `activeId` to `null`), meaning that there won't
19538 // be an active item initially. Focus is then managed via the
19539 // `onFocusVisible` callback.
19540 filter.operators?.length === 1 ? void 0 : null
19541 );
19542 const currentFilter = view.filters?.find(
19543 (f2) => f2.field === filter.field
19544 );
19545 const currentValue = getCurrentValue(filter, currentFilter);
19546 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19547 import_components19.Composite,
19548 {
19549 virtualFocus: true,
19550 focusLoop: true,
19551 activeId: activeCompositeId,
19552 setActiveId: setActiveCompositeId,
19553 role: "listbox",
19554 className: "dataviews-filters__search-widget-listbox",
19555 "aria-label": (0, import_i18n30.sprintf)(
19556 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
19557 (0, import_i18n30.__)("List of: %1$s"),
19558 filter.name
19559 ),
19560 onFocusVisible: () => {
19561 if (!activeCompositeId && filter.elements.length) {
19562 setActiveCompositeId(
19563 generateFilterElementCompositeItemId(
19564 baseId,
19565 filter.elements[0].value
19566 )
19567 );
19568 }
19569 },
19570 render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Composite.Typeahead, {}),
19571 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19572 import_components19.Composite.Hover,
19573 {
19574 render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19575 import_components19.Composite.Item,
19576 {
19577 id: generateFilterElementCompositeItemId(
19578 baseId,
19579 element.value
19580 ),
19581 render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19582 "div",
19583 {
19584 "aria-label": element.label,
19585 role: "option",
19586 className: "dataviews-filters__search-widget-listitem"
19587 }
19588 ),
19589 onClick: () => {
19590 const newFilters = currentFilter ? [
19591 ...(view.filters ?? []).map(
19592 (_filter) => {
19593 if (_filter.field === filter.field) {
19594 return {
19595 ..._filter,
19596 operator: currentFilter.operator || filter.operators[0],
19597 value: getNewValue(
19598 filter,
19599 currentFilter,
19600 element.value
19601 )
19602 };
19603 }
19604 return _filter;
19605 }
19606 )
19607 ] : [
19608 ...view.filters ?? [],
19609 {
19610 field: filter.field,
19611 operator: filter.operators[0],
19612 value: getNewValue(
19613 filter,
19614 currentFilter,
19615 element.value
19616 )
19617 }
19618 ];
19619 onChangeView({
19620 ...view,
19621 page: 1,
19622 filters: newFilters
19623 });
19624 }
19625 }
19626 ),
19627 children: [
19628 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19629 SingleSelectionOption,
19630 {
19631 selected: currentValue === element.value
19632 }
19633 ),
19634 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19635 MultiSelectionOption,
19636 {
19637 selected: currentValue.includes(element.value)
19638 }
19639 ),
19640 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19641 "span",
19642 {
19643 className: "dataviews-filters__search-widget-listitem-value",
19644 title: element.label,
19645 children: element.label
19646 }
19647 )
19648 ]
19649 },
19650 element.value
19651 ))
19652 }
19653 );
19654 }
19655 function ComboboxList22({ view, filter, onChangeView }) {
19656 const [searchValue, setSearchValue] = (0, import_element44.useState)("");
19657 const deferredSearchValue = (0, import_element44.useDeferredValue)(searchValue);
19658 const currentFilter = view.filters?.find(
19659 (_filter) => _filter.field === filter.field
19660 );
19661 const currentValue = getCurrentValue(filter, currentFilter);
19662 const matches = (0, import_element44.useMemo)(() => {
19663 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
19664 return filter.elements.filter(
19665 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
19666 );
19667 }, [filter.elements, deferredSearchValue]);
19668 return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19669 ComboboxProvider,
19670 {
19671 selectedValue: currentValue,
19672 setSelectedValue: (value) => {
19673 const newFilters = currentFilter ? [
19674 ...(view.filters ?? []).map((_filter) => {
19675 if (_filter.field === filter.field) {
19676 return {
19677 ..._filter,
19678 operator: currentFilter.operator || filter.operators[0],
19679 value
19680 };
19681 }
19682 return _filter;
19683 })
19684 ] : [
19685 ...view.filters ?? [],
19686 {
19687 field: filter.field,
19688 operator: filter.operators[0],
19689 value
19690 }
19691 ];
19692 onChangeView({
19693 ...view,
19694 page: 1,
19695 filters: newFilters
19696 });
19697 },
19698 setValue: setSearchValue,
19699 children: [
19700 /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
19701 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(ComboboxLabel, {}), children: (0, import_i18n30.__)("Search items") }),
19702 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19703 Combobox,
19704 {
19705 autoSelect: "always",
19706 placeholder: (0, import_i18n30.__)("Search"),
19707 className: "dataviews-filters__search-widget-filter-combobox__input"
19708 }
19709 ),
19710 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Icon, { icon: search_default }) })
19711 ] }),
19712 /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19713 ComboboxList,
19714 {
19715 className: "dataviews-filters__search-widget-filter-combobox-list",
19716 alwaysVisible: true,
19717 children: [
19718 matches.map((element) => {
19719 return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19720 ComboboxItem,
19721 {
19722 resetValueOnSelect: false,
19723 value: element.value,
19724 className: "dataviews-filters__search-widget-listitem",
19725 hideOnClick: false,
19726 setValueOnClick: false,
19727 focusOnHover: true,
19728 children: [
19729 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19730 SingleSelectionOption,
19731 {
19732 selected: currentValue === element.value
19733 }
19734 ),
19735 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19736 MultiSelectionOption,
19737 {
19738 selected: currentValue.includes(
19739 element.value
19740 )
19741 }
19742 ),
19743 /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19744 "span",
19745 {
19746 className: "dataviews-filters__search-widget-listitem-value",
19747 title: element.label,
19748 children: [
19749 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19750 ComboboxItemValue,
19751 {
19752 className: "dataviews-filters__search-widget-filter-combobox-item-value",
19753 value: element.label
19754 }
19755 ),
19756 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
19757 ]
19758 }
19759 )
19760 ]
19761 },
19762 element.value
19763 );
19764 }),
19765 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("p", { children: (0, import_i18n30.__)("No results found") })
19766 ]
19767 }
19768 )
19769 ]
19770 }
19771 );
19772 }
19773 function SearchWidget(props) {
19774 const { elements, isLoading } = useElements({
19775 elements: props.filter.elements,
19776 getElements: props.filter.getElements
19777 });
19778 if (isLoading) {
19779 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Spinner, {}) });
19780 }
19781 if (elements.length === 0) {
19782 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n30.__)("No elements found") });
19783 }
19784 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
19785 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
19786 }
19787
19788 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
19789 var import_es6 = __toESM(require_es6(), 1);
19790 var import_compose9 = __toESM(require_compose(), 1);
19791 var import_element45 = __toESM(require_element(), 1);
19792 var import_components20 = __toESM(require_components(), 1);
19793 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
19794 function InputWidget({
19795 filter,
19796 view,
19797 onChangeView,
19798 fields
19799 }) {
19800 const currentFilter = view.filters?.find(
19801 (f2) => f2.field === filter.field
19802 );
19803 const currentValue = getCurrentValue(filter, currentFilter);
19804 const field = (0, import_element45.useMemo)(() => {
19805 const currentField = fields.find((f2) => f2.id === filter.field);
19806 if (currentField) {
19807 return {
19808 ...currentField,
19809 // Deactivate validation for filters.
19810 isValid: {},
19811 // Filter controls are always enabled.
19812 isDisabled: () => false,
19813 // Filter controls are always visible.
19814 isVisible: () => true,
19815 // Configure getValue/setValue as if Item was a plain object.
19816 getValue: ({ item }) => item[currentField.id],
19817 setValue: ({ value }) => ({
19818 [currentField.id]: value
19819 })
19820 };
19821 }
19822 return currentField;
19823 }, [fields, filter.field]);
19824 const data = (0, import_element45.useMemo)(() => {
19825 return (view.filters ?? []).reduce(
19826 (acc, activeFilter) => {
19827 acc[activeFilter.field] = activeFilter.value;
19828 return acc;
19829 },
19830 {}
19831 );
19832 }, [view.filters]);
19833 const handleChange = (0, import_compose9.useEvent)((updatedData) => {
19834 if (!field || !currentFilter) {
19835 return;
19836 }
19837 const nextValue = field.getValue({ item: updatedData });
19838 if ((0, import_es6.default)(nextValue, currentValue)) {
19839 return;
19840 }
19841 onChangeView({
19842 ...view,
19843 filters: (view.filters ?? []).map(
19844 (_filter) => _filter.field === filter.field ? {
19845 ..._filter,
19846 operator: currentFilter.operator || filter.operators[0],
19847 // Consider empty strings as undefined:
19848 //
19849 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
19850 // - empty string as value means "search empty string": returns only the records that have an empty string as value
19851 //
19852 // In practice, this means the filter will not be able to find an empty string as the value.
19853 value: nextValue === "" ? void 0 : nextValue
19854 } : _filter
19855 )
19856 });
19857 });
19858 if (!field || !field.Edit || !currentFilter) {
19859 return null;
19860 }
19861 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
19862 import_components20.Flex,
19863 {
19864 className: "dataviews-filters__user-input-widget",
19865 gap: 2.5,
19866 direction: "column",
19867 children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
19868 field.Edit,
19869 {
19870 hideLabelFromVision: true,
19871 data,
19872 field,
19873 operator: currentFilter.operator,
19874 onChange: handleChange
19875 }
19876 )
19877 }
19878 );
19879 }
19880
19881 // packages/dataviews/node_modules/date-fns/constants.js
19882 var daysInYear = 365.2425;
19883 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
19884 var minTime = -maxTime;
19885 var millisecondsInWeek = 6048e5;
19886 var millisecondsInDay = 864e5;
19887 var secondsInHour = 3600;
19888 var secondsInDay = secondsInHour * 24;
19889 var secondsInWeek = secondsInDay * 7;
19890 var secondsInYear = secondsInDay * daysInYear;
19891 var secondsInMonth = secondsInYear / 12;
19892 var secondsInQuarter = secondsInMonth * 3;
19893 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
19894
19895 // packages/dataviews/node_modules/date-fns/constructFrom.js
19896 function constructFrom(date, value) {
19897 if (typeof date === "function") return date(value);
19898 if (date && typeof date === "object" && constructFromSymbol in date)
19899 return date[constructFromSymbol](value);
19900 if (date instanceof Date) return new date.constructor(value);
19901 return new Date(value);
19902 }
19903
19904 // packages/dataviews/node_modules/date-fns/toDate.js
19905 function toDate(argument, context) {
19906 return constructFrom(context || argument, argument);
19907 }
19908
19909 // packages/dataviews/node_modules/date-fns/addDays.js
19910 function addDays(date, amount, options) {
19911 const _date = toDate(date, options?.in);
19912 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19913 if (!amount) return _date;
19914 _date.setDate(_date.getDate() + amount);
19915 return _date;
19916 }
19917
19918 // packages/dataviews/node_modules/date-fns/addMonths.js
19919 function addMonths(date, amount, options) {
19920 const _date = toDate(date, options?.in);
19921 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19922 if (!amount) {
19923 return _date;
19924 }
19925 const dayOfMonth = _date.getDate();
19926 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
19927 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
19928 const daysInMonth = endOfDesiredMonth.getDate();
19929 if (dayOfMonth >= daysInMonth) {
19930 return endOfDesiredMonth;
19931 } else {
19932 _date.setFullYear(
19933 endOfDesiredMonth.getFullYear(),
19934 endOfDesiredMonth.getMonth(),
19935 dayOfMonth
19936 );
19937 return _date;
19938 }
19939 }
19940
19941 // packages/dataviews/node_modules/date-fns/_lib/defaultOptions.js
19942 var defaultOptions = {};
19943 function getDefaultOptions() {
19944 return defaultOptions;
19945 }
19946
19947 // packages/dataviews/node_modules/date-fns/startOfWeek.js
19948 function startOfWeek(date, options) {
19949 const defaultOptions2 = getDefaultOptions();
19950 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
19951 const _date = toDate(date, options?.in);
19952 const day = _date.getDay();
19953 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
19954 _date.setDate(_date.getDate() - diff);
19955 _date.setHours(0, 0, 0, 0);
19956 return _date;
19957 }
19958
19959 // packages/dataviews/node_modules/date-fns/startOfISOWeek.js
19960 function startOfISOWeek(date, options) {
19961 return startOfWeek(date, { ...options, weekStartsOn: 1 });
19962 }
19963
19964 // packages/dataviews/node_modules/date-fns/getISOWeekYear.js
19965 function getISOWeekYear(date, options) {
19966 const _date = toDate(date, options?.in);
19967 const year = _date.getFullYear();
19968 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
19969 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
19970 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
19971 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
19972 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
19973 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
19974 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
19975 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
19976 if (_date.getTime() >= startOfNextYear.getTime()) {
19977 return year + 1;
19978 } else if (_date.getTime() >= startOfThisYear.getTime()) {
19979 return year;
19980 } else {
19981 return year - 1;
19982 }
19983 }
19984
19985 // packages/dataviews/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
19986 function getTimezoneOffsetInMilliseconds(date) {
19987 const _date = toDate(date);
19988 const utcDate = new Date(
19989 Date.UTC(
19990 _date.getFullYear(),
19991 _date.getMonth(),
19992 _date.getDate(),
19993 _date.getHours(),
19994 _date.getMinutes(),
19995 _date.getSeconds(),
19996 _date.getMilliseconds()
19997 )
19998 );
19999 utcDate.setUTCFullYear(_date.getFullYear());
20000 return +date - +utcDate;
20001 }
20002
20003 // packages/dataviews/node_modules/date-fns/_lib/normalizeDates.js
20004 function normalizeDates(context, ...dates) {
20005 const normalize = constructFrom.bind(
20006 null,
20007 context || dates.find((date) => typeof date === "object")
20008 );
20009 return dates.map(normalize);
20010 }
20011
20012 // packages/dataviews/node_modules/date-fns/startOfDay.js
20013 function startOfDay(date, options) {
20014 const _date = toDate(date, options?.in);
20015 _date.setHours(0, 0, 0, 0);
20016 return _date;
20017 }
20018
20019 // packages/dataviews/node_modules/date-fns/differenceInCalendarDays.js
20020 function differenceInCalendarDays(laterDate, earlierDate, options) {
20021 const [laterDate_, earlierDate_] = normalizeDates(
20022 options?.in,
20023 laterDate,
20024 earlierDate
20025 );
20026 const laterStartOfDay = startOfDay(laterDate_);
20027 const earlierStartOfDay = startOfDay(earlierDate_);
20028 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
20029 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
20030 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
20031 }
20032
20033 // packages/dataviews/node_modules/date-fns/startOfISOWeekYear.js
20034 function startOfISOWeekYear(date, options) {
20035 const year = getISOWeekYear(date, options);
20036 const fourthOfJanuary = constructFrom(options?.in || date, 0);
20037 fourthOfJanuary.setFullYear(year, 0, 4);
20038 fourthOfJanuary.setHours(0, 0, 0, 0);
20039 return startOfISOWeek(fourthOfJanuary);
20040 }
20041
20042 // packages/dataviews/node_modules/date-fns/addWeeks.js
20043 function addWeeks(date, amount, options) {
20044 return addDays(date, amount * 7, options);
20045 }
20046
20047 // packages/dataviews/node_modules/date-fns/addYears.js
20048 function addYears(date, amount, options) {
20049 return addMonths(date, amount * 12, options);
20050 }
20051
20052 // packages/dataviews/node_modules/date-fns/isDate.js
20053 function isDate(value) {
20054 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
20055 }
20056
20057 // packages/dataviews/node_modules/date-fns/isValid.js
20058 function isValid(date) {
20059 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
20060 }
20061
20062 // packages/dataviews/node_modules/date-fns/startOfMonth.js
20063 function startOfMonth(date, options) {
20064 const _date = toDate(date, options?.in);
20065 _date.setDate(1);
20066 _date.setHours(0, 0, 0, 0);
20067 return _date;
20068 }
20069
20070 // packages/dataviews/node_modules/date-fns/startOfYear.js
20071 function startOfYear(date, options) {
20072 const date_ = toDate(date, options?.in);
20073 date_.setFullYear(date_.getFullYear(), 0, 1);
20074 date_.setHours(0, 0, 0, 0);
20075 return date_;
20076 }
20077
20078 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatDistance.js
20079 var formatDistanceLocale = {
20080 lessThanXSeconds: {
20081 one: "less than a second",
20082 other: "less than {{count}} seconds"
20083 },
20084 xSeconds: {
20085 one: "1 second",
20086 other: "{{count}} seconds"
20087 },
20088 halfAMinute: "half a minute",
20089 lessThanXMinutes: {
20090 one: "less than a minute",
20091 other: "less than {{count}} minutes"
20092 },
20093 xMinutes: {
20094 one: "1 minute",
20095 other: "{{count}} minutes"
20096 },
20097 aboutXHours: {
20098 one: "about 1 hour",
20099 other: "about {{count}} hours"
20100 },
20101 xHours: {
20102 one: "1 hour",
20103 other: "{{count}} hours"
20104 },
20105 xDays: {
20106 one: "1 day",
20107 other: "{{count}} days"
20108 },
20109 aboutXWeeks: {
20110 one: "about 1 week",
20111 other: "about {{count}} weeks"
20112 },
20113 xWeeks: {
20114 one: "1 week",
20115 other: "{{count}} weeks"
20116 },
20117 aboutXMonths: {
20118 one: "about 1 month",
20119 other: "about {{count}} months"
20120 },
20121 xMonths: {
20122 one: "1 month",
20123 other: "{{count}} months"
20124 },
20125 aboutXYears: {
20126 one: "about 1 year",
20127 other: "about {{count}} years"
20128 },
20129 xYears: {
20130 one: "1 year",
20131 other: "{{count}} years"
20132 },
20133 overXYears: {
20134 one: "over 1 year",
20135 other: "over {{count}} years"
20136 },
20137 almostXYears: {
20138 one: "almost 1 year",
20139 other: "almost {{count}} years"
20140 }
20141 };
20142 var formatDistance = (token, count, options) => {
20143 let result;
20144 const tokenValue = formatDistanceLocale[token];
20145 if (typeof tokenValue === "string") {
20146 result = tokenValue;
20147 } else if (count === 1) {
20148 result = tokenValue.one;
20149 } else {
20150 result = tokenValue.other.replace("{{count}}", count.toString());
20151 }
20152 if (options?.addSuffix) {
20153 if (options.comparison && options.comparison > 0) {
20154 return "in " + result;
20155 } else {
20156 return result + " ago";
20157 }
20158 }
20159 return result;
20160 };
20161
20162 // packages/dataviews/node_modules/date-fns/locale/_lib/buildFormatLongFn.js
20163 function buildFormatLongFn(args) {
20164 return (options = {}) => {
20165 const width = options.width ? String(options.width) : args.defaultWidth;
20166 const format6 = args.formats[width] || args.formats[args.defaultWidth];
20167 return format6;
20168 };
20169 }
20170
20171 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatLong.js
20172 var dateFormats = {
20173 full: "EEEE, MMMM do, y",
20174 long: "MMMM do, y",
20175 medium: "MMM d, y",
20176 short: "MM/dd/yyyy"
20177 };
20178 var timeFormats = {
20179 full: "h:mm:ss a zzzz",
20180 long: "h:mm:ss a z",
20181 medium: "h:mm:ss a",
20182 short: "h:mm a"
20183 };
20184 var dateTimeFormats = {
20185 full: "{{date}} 'at' {{time}}",
20186 long: "{{date}} 'at' {{time}}",
20187 medium: "{{date}}, {{time}}",
20188 short: "{{date}}, {{time}}"
20189 };
20190 var formatLong = {
20191 date: buildFormatLongFn({
20192 formats: dateFormats,
20193 defaultWidth: "full"
20194 }),
20195 time: buildFormatLongFn({
20196 formats: timeFormats,
20197 defaultWidth: "full"
20198 }),
20199 dateTime: buildFormatLongFn({
20200 formats: dateTimeFormats,
20201 defaultWidth: "full"
20202 })
20203 };
20204
20205 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatRelative.js
20206 var formatRelativeLocale = {
20207 lastWeek: "'last' eeee 'at' p",
20208 yesterday: "'yesterday at' p",
20209 today: "'today at' p",
20210 tomorrow: "'tomorrow at' p",
20211 nextWeek: "eeee 'at' p",
20212 other: "P"
20213 };
20214 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
20215
20216 // packages/dataviews/node_modules/date-fns/locale/_lib/buildLocalizeFn.js
20217 function buildLocalizeFn(args) {
20218 return (value, options) => {
20219 const context = options?.context ? String(options.context) : "standalone";
20220 let valuesArray;
20221 if (context === "formatting" && args.formattingValues) {
20222 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
20223 const width = options?.width ? String(options.width) : defaultWidth;
20224 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
20225 } else {
20226 const defaultWidth = args.defaultWidth;
20227 const width = options?.width ? String(options.width) : args.defaultWidth;
20228 valuesArray = args.values[width] || args.values[defaultWidth];
20229 }
20230 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
20231 return valuesArray[index2];
20232 };
20233 }
20234
20235 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/localize.js
20236 var eraValues = {
20237 narrow: ["B", "A"],
20238 abbreviated: ["BC", "AD"],
20239 wide: ["Before Christ", "Anno Domini"]
20240 };
20241 var quarterValues = {
20242 narrow: ["1", "2", "3", "4"],
20243 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
20244 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
20245 };
20246 var monthValues = {
20247 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
20248 abbreviated: [
20249 "Jan",
20250 "Feb",
20251 "Mar",
20252 "Apr",
20253 "May",
20254 "Jun",
20255 "Jul",
20256 "Aug",
20257 "Sep",
20258 "Oct",
20259 "Nov",
20260 "Dec"
20261 ],
20262 wide: [
20263 "January",
20264 "February",
20265 "March",
20266 "April",
20267 "May",
20268 "June",
20269 "July",
20270 "August",
20271 "September",
20272 "October",
20273 "November",
20274 "December"
20275 ]
20276 };
20277 var dayValues = {
20278 narrow: ["S", "M", "T", "W", "T", "F", "S"],
20279 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
20280 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
20281 wide: [
20282 "Sunday",
20283 "Monday",
20284 "Tuesday",
20285 "Wednesday",
20286 "Thursday",
20287 "Friday",
20288 "Saturday"
20289 ]
20290 };
20291 var dayPeriodValues = {
20292 narrow: {
20293 am: "a",
20294 pm: "p",
20295 midnight: "mi",
20296 noon: "n",
20297 morning: "morning",
20298 afternoon: "afternoon",
20299 evening: "evening",
20300 night: "night"
20301 },
20302 abbreviated: {
20303 am: "AM",
20304 pm: "PM",
20305 midnight: "midnight",
20306 noon: "noon",
20307 morning: "morning",
20308 afternoon: "afternoon",
20309 evening: "evening",
20310 night: "night"
20311 },
20312 wide: {
20313 am: "a.m.",
20314 pm: "p.m.",
20315 midnight: "midnight",
20316 noon: "noon",
20317 morning: "morning",
20318 afternoon: "afternoon",
20319 evening: "evening",
20320 night: "night"
20321 }
20322 };
20323 var formattingDayPeriodValues = {
20324 narrow: {
20325 am: "a",
20326 pm: "p",
20327 midnight: "mi",
20328 noon: "n",
20329 morning: "in the morning",
20330 afternoon: "in the afternoon",
20331 evening: "in the evening",
20332 night: "at night"
20333 },
20334 abbreviated: {
20335 am: "AM",
20336 pm: "PM",
20337 midnight: "midnight",
20338 noon: "noon",
20339 morning: "in the morning",
20340 afternoon: "in the afternoon",
20341 evening: "in the evening",
20342 night: "at night"
20343 },
20344 wide: {
20345 am: "a.m.",
20346 pm: "p.m.",
20347 midnight: "midnight",
20348 noon: "noon",
20349 morning: "in the morning",
20350 afternoon: "in the afternoon",
20351 evening: "in the evening",
20352 night: "at night"
20353 }
20354 };
20355 var ordinalNumber = (dirtyNumber, _options) => {
20356 const number = Number(dirtyNumber);
20357 const rem100 = number % 100;
20358 if (rem100 > 20 || rem100 < 10) {
20359 switch (rem100 % 10) {
20360 case 1:
20361 return number + "st";
20362 case 2:
20363 return number + "nd";
20364 case 3:
20365 return number + "rd";
20366 }
20367 }
20368 return number + "th";
20369 };
20370 var localize = {
20371 ordinalNumber,
20372 era: buildLocalizeFn({
20373 values: eraValues,
20374 defaultWidth: "wide"
20375 }),
20376 quarter: buildLocalizeFn({
20377 values: quarterValues,
20378 defaultWidth: "wide",
20379 argumentCallback: (quarter) => quarter - 1
20380 }),
20381 month: buildLocalizeFn({
20382 values: monthValues,
20383 defaultWidth: "wide"
20384 }),
20385 day: buildLocalizeFn({
20386 values: dayValues,
20387 defaultWidth: "wide"
20388 }),
20389 dayPeriod: buildLocalizeFn({
20390 values: dayPeriodValues,
20391 defaultWidth: "wide",
20392 formattingValues: formattingDayPeriodValues,
20393 defaultFormattingWidth: "wide"
20394 })
20395 };
20396
20397 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchFn.js
20398 function buildMatchFn(args) {
20399 return (string, options = {}) => {
20400 const width = options.width;
20401 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
20402 const matchResult = string.match(matchPattern);
20403 if (!matchResult) {
20404 return null;
20405 }
20406 const matchedString = matchResult[0];
20407 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
20408 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
20409 // [TODO] -- I challenge you to fix the type
20410 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
20411 );
20412 let value;
20413 value = args.valueCallback ? args.valueCallback(key) : key;
20414 value = options.valueCallback ? (
20415 // [TODO] -- I challenge you to fix the type
20416 options.valueCallback(value)
20417 ) : value;
20418 const rest = string.slice(matchedString.length);
20419 return { value, rest };
20420 };
20421 }
20422 function findKey(object, predicate) {
20423 for (const key in object) {
20424 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
20425 return key;
20426 }
20427 }
20428 return void 0;
20429 }
20430 function findIndex(array, predicate) {
20431 for (let key = 0; key < array.length; key++) {
20432 if (predicate(array[key])) {
20433 return key;
20434 }
20435 }
20436 return void 0;
20437 }
20438
20439 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
20440 function buildMatchPatternFn(args) {
20441 return (string, options = {}) => {
20442 const matchResult = string.match(args.matchPattern);
20443 if (!matchResult) return null;
20444 const matchedString = matchResult[0];
20445 const parseResult = string.match(args.parsePattern);
20446 if (!parseResult) return null;
20447 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
20448 value = options.valueCallback ? options.valueCallback(value) : value;
20449 const rest = string.slice(matchedString.length);
20450 return { value, rest };
20451 };
20452 }
20453
20454 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/match.js
20455 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
20456 var parseOrdinalNumberPattern = /\d+/i;
20457 var matchEraPatterns = {
20458 narrow: /^(b|a)/i,
20459 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
20460 wide: /^(before christ|before common era|anno domini|common era)/i
20461 };
20462 var parseEraPatterns = {
20463 any: [/^b/i, /^(a|c)/i]
20464 };
20465 var matchQuarterPatterns = {
20466 narrow: /^[1234]/i,
20467 abbreviated: /^q[1234]/i,
20468 wide: /^[1234](th|st|nd|rd)? quarter/i
20469 };
20470 var parseQuarterPatterns = {
20471 any: [/1/i, /2/i, /3/i, /4/i]
20472 };
20473 var matchMonthPatterns = {
20474 narrow: /^[jfmasond]/i,
20475 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
20476 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
20477 };
20478 var parseMonthPatterns = {
20479 narrow: [
20480 /^j/i,
20481 /^f/i,
20482 /^m/i,
20483 /^a/i,
20484 /^m/i,
20485 /^j/i,
20486 /^j/i,
20487 /^a/i,
20488 /^s/i,
20489 /^o/i,
20490 /^n/i,
20491 /^d/i
20492 ],
20493 any: [
20494 /^ja/i,
20495 /^f/i,
20496 /^mar/i,
20497 /^ap/i,
20498 /^may/i,
20499 /^jun/i,
20500 /^jul/i,
20501 /^au/i,
20502 /^s/i,
20503 /^o/i,
20504 /^n/i,
20505 /^d/i
20506 ]
20507 };
20508 var matchDayPatterns = {
20509 narrow: /^[smtwf]/i,
20510 short: /^(su|mo|tu|we|th|fr|sa)/i,
20511 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
20512 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
20513 };
20514 var parseDayPatterns = {
20515 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
20516 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
20517 };
20518 var matchDayPeriodPatterns = {
20519 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
20520 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
20521 };
20522 var parseDayPeriodPatterns = {
20523 any: {
20524 am: /^a/i,
20525 pm: /^p/i,
20526 midnight: /^mi/i,
20527 noon: /^no/i,
20528 morning: /morning/i,
20529 afternoon: /afternoon/i,
20530 evening: /evening/i,
20531 night: /night/i
20532 }
20533 };
20534 var match = {
20535 ordinalNumber: buildMatchPatternFn({
20536 matchPattern: matchOrdinalNumberPattern,
20537 parsePattern: parseOrdinalNumberPattern,
20538 valueCallback: (value) => parseInt(value, 10)
20539 }),
20540 era: buildMatchFn({
20541 matchPatterns: matchEraPatterns,
20542 defaultMatchWidth: "wide",
20543 parsePatterns: parseEraPatterns,
20544 defaultParseWidth: "any"
20545 }),
20546 quarter: buildMatchFn({
20547 matchPatterns: matchQuarterPatterns,
20548 defaultMatchWidth: "wide",
20549 parsePatterns: parseQuarterPatterns,
20550 defaultParseWidth: "any",
20551 valueCallback: (index2) => index2 + 1
20552 }),
20553 month: buildMatchFn({
20554 matchPatterns: matchMonthPatterns,
20555 defaultMatchWidth: "wide",
20556 parsePatterns: parseMonthPatterns,
20557 defaultParseWidth: "any"
20558 }),
20559 day: buildMatchFn({
20560 matchPatterns: matchDayPatterns,
20561 defaultMatchWidth: "wide",
20562 parsePatterns: parseDayPatterns,
20563 defaultParseWidth: "any"
20564 }),
20565 dayPeriod: buildMatchFn({
20566 matchPatterns: matchDayPeriodPatterns,
20567 defaultMatchWidth: "any",
20568 parsePatterns: parseDayPeriodPatterns,
20569 defaultParseWidth: "any"
20570 })
20571 };
20572
20573 // packages/dataviews/node_modules/date-fns/locale/en-US.js
20574 var enUS = {
20575 code: "en-US",
20576 formatDistance,
20577 formatLong,
20578 formatRelative,
20579 localize,
20580 match,
20581 options: {
20582 weekStartsOn: 0,
20583 firstWeekContainsDate: 1
20584 }
20585 };
20586
20587 // packages/dataviews/node_modules/date-fns/getDayOfYear.js
20588 function getDayOfYear(date, options) {
20589 const _date = toDate(date, options?.in);
20590 const diff = differenceInCalendarDays(_date, startOfYear(_date));
20591 const dayOfYear = diff + 1;
20592 return dayOfYear;
20593 }
20594
20595 // packages/dataviews/node_modules/date-fns/getISOWeek.js
20596 function getISOWeek(date, options) {
20597 const _date = toDate(date, options?.in);
20598 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
20599 return Math.round(diff / millisecondsInWeek) + 1;
20600 }
20601
20602 // packages/dataviews/node_modules/date-fns/getWeekYear.js
20603 function getWeekYear(date, options) {
20604 const _date = toDate(date, options?.in);
20605 const year = _date.getFullYear();
20606 const defaultOptions2 = getDefaultOptions();
20607 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20608 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
20609 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
20610 firstWeekOfNextYear.setHours(0, 0, 0, 0);
20611 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
20612 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
20613 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
20614 firstWeekOfThisYear.setHours(0, 0, 0, 0);
20615 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
20616 if (+_date >= +startOfNextYear) {
20617 return year + 1;
20618 } else if (+_date >= +startOfThisYear) {
20619 return year;
20620 } else {
20621 return year - 1;
20622 }
20623 }
20624
20625 // packages/dataviews/node_modules/date-fns/startOfWeekYear.js
20626 function startOfWeekYear(date, options) {
20627 const defaultOptions2 = getDefaultOptions();
20628 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20629 const year = getWeekYear(date, options);
20630 const firstWeek = constructFrom(options?.in || date, 0);
20631 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
20632 firstWeek.setHours(0, 0, 0, 0);
20633 const _date = startOfWeek(firstWeek, options);
20634 return _date;
20635 }
20636
20637 // packages/dataviews/node_modules/date-fns/getWeek.js
20638 function getWeek(date, options) {
20639 const _date = toDate(date, options?.in);
20640 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
20641 return Math.round(diff / millisecondsInWeek) + 1;
20642 }
20643
20644 // packages/dataviews/node_modules/date-fns/_lib/addLeadingZeros.js
20645 function addLeadingZeros(number, targetLength) {
20646 const sign = number < 0 ? "-" : "";
20647 const output = Math.abs(number).toString().padStart(targetLength, "0");
20648 return sign + output;
20649 }
20650
20651 // packages/dataviews/node_modules/date-fns/_lib/format/lightFormatters.js
20652 var lightFormatters = {
20653 // Year
20654 y(date, token) {
20655 const signedYear = date.getFullYear();
20656 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20657 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
20658 },
20659 // Month
20660 M(date, token) {
20661 const month = date.getMonth();
20662 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
20663 },
20664 // Day of the month
20665 d(date, token) {
20666 return addLeadingZeros(date.getDate(), token.length);
20667 },
20668 // AM or PM
20669 a(date, token) {
20670 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
20671 switch (token) {
20672 case "a":
20673 case "aa":
20674 return dayPeriodEnumValue.toUpperCase();
20675 case "aaa":
20676 return dayPeriodEnumValue;
20677 case "aaaaa":
20678 return dayPeriodEnumValue[0];
20679 case "aaaa":
20680 default:
20681 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
20682 }
20683 },
20684 // Hour [1-12]
20685 h(date, token) {
20686 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
20687 },
20688 // Hour [0-23]
20689 H(date, token) {
20690 return addLeadingZeros(date.getHours(), token.length);
20691 },
20692 // Minute
20693 m(date, token) {
20694 return addLeadingZeros(date.getMinutes(), token.length);
20695 },
20696 // Second
20697 s(date, token) {
20698 return addLeadingZeros(date.getSeconds(), token.length);
20699 },
20700 // Fraction of second
20701 S(date, token) {
20702 const numberOfDigits = token.length;
20703 const milliseconds = date.getMilliseconds();
20704 const fractionalSeconds = Math.trunc(
20705 milliseconds * Math.pow(10, numberOfDigits - 3)
20706 );
20707 return addLeadingZeros(fractionalSeconds, token.length);
20708 }
20709 };
20710
20711 // packages/dataviews/node_modules/date-fns/_lib/format/formatters.js
20712 var dayPeriodEnum = {
20713 am: "am",
20714 pm: "pm",
20715 midnight: "midnight",
20716 noon: "noon",
20717 morning: "morning",
20718 afternoon: "afternoon",
20719 evening: "evening",
20720 night: "night"
20721 };
20722 var formatters = {
20723 // Era
20724 G: function(date, token, localize2) {
20725 const era = date.getFullYear() > 0 ? 1 : 0;
20726 switch (token) {
20727 // AD, BC
20728 case "G":
20729 case "GG":
20730 case "GGG":
20731 return localize2.era(era, { width: "abbreviated" });
20732 // A, B
20733 case "GGGGG":
20734 return localize2.era(era, { width: "narrow" });
20735 // Anno Domini, Before Christ
20736 case "GGGG":
20737 default:
20738 return localize2.era(era, { width: "wide" });
20739 }
20740 },
20741 // Year
20742 y: function(date, token, localize2) {
20743 if (token === "yo") {
20744 const signedYear = date.getFullYear();
20745 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20746 return localize2.ordinalNumber(year, { unit: "year" });
20747 }
20748 return lightFormatters.y(date, token);
20749 },
20750 // Local week-numbering year
20751 Y: function(date, token, localize2, options) {
20752 const signedWeekYear = getWeekYear(date, options);
20753 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
20754 if (token === "YY") {
20755 const twoDigitYear = weekYear % 100;
20756 return addLeadingZeros(twoDigitYear, 2);
20757 }
20758 if (token === "Yo") {
20759 return localize2.ordinalNumber(weekYear, { unit: "year" });
20760 }
20761 return addLeadingZeros(weekYear, token.length);
20762 },
20763 // ISO week-numbering year
20764 R: function(date, token) {
20765 const isoWeekYear = getISOWeekYear(date);
20766 return addLeadingZeros(isoWeekYear, token.length);
20767 },
20768 // Extended year. This is a single number designating the year of this calendar system.
20769 // The main difference between `y` and `u` localizers are B.C. years:
20770 // | Year | `y` | `u` |
20771 // |------|-----|-----|
20772 // | AC 1 | 1 | 1 |
20773 // | BC 1 | 1 | 0 |
20774 // | BC 2 | 2 | -1 |
20775 // Also `yy` always returns the last two digits of a year,
20776 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
20777 u: function(date, token) {
20778 const year = date.getFullYear();
20779 return addLeadingZeros(year, token.length);
20780 },
20781 // Quarter
20782 Q: function(date, token, localize2) {
20783 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20784 switch (token) {
20785 // 1, 2, 3, 4
20786 case "Q":
20787 return String(quarter);
20788 // 01, 02, 03, 04
20789 case "QQ":
20790 return addLeadingZeros(quarter, 2);
20791 // 1st, 2nd, 3rd, 4th
20792 case "Qo":
20793 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20794 // Q1, Q2, Q3, Q4
20795 case "QQQ":
20796 return localize2.quarter(quarter, {
20797 width: "abbreviated",
20798 context: "formatting"
20799 });
20800 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20801 case "QQQQQ":
20802 return localize2.quarter(quarter, {
20803 width: "narrow",
20804 context: "formatting"
20805 });
20806 // 1st quarter, 2nd quarter, ...
20807 case "QQQQ":
20808 default:
20809 return localize2.quarter(quarter, {
20810 width: "wide",
20811 context: "formatting"
20812 });
20813 }
20814 },
20815 // Stand-alone quarter
20816 q: function(date, token, localize2) {
20817 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20818 switch (token) {
20819 // 1, 2, 3, 4
20820 case "q":
20821 return String(quarter);
20822 // 01, 02, 03, 04
20823 case "qq":
20824 return addLeadingZeros(quarter, 2);
20825 // 1st, 2nd, 3rd, 4th
20826 case "qo":
20827 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20828 // Q1, Q2, Q3, Q4
20829 case "qqq":
20830 return localize2.quarter(quarter, {
20831 width: "abbreviated",
20832 context: "standalone"
20833 });
20834 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20835 case "qqqqq":
20836 return localize2.quarter(quarter, {
20837 width: "narrow",
20838 context: "standalone"
20839 });
20840 // 1st quarter, 2nd quarter, ...
20841 case "qqqq":
20842 default:
20843 return localize2.quarter(quarter, {
20844 width: "wide",
20845 context: "standalone"
20846 });
20847 }
20848 },
20849 // Month
20850 M: function(date, token, localize2) {
20851 const month = date.getMonth();
20852 switch (token) {
20853 case "M":
20854 case "MM":
20855 return lightFormatters.M(date, token);
20856 // 1st, 2nd, ..., 12th
20857 case "Mo":
20858 return localize2.ordinalNumber(month + 1, { unit: "month" });
20859 // Jan, Feb, ..., Dec
20860 case "MMM":
20861 return localize2.month(month, {
20862 width: "abbreviated",
20863 context: "formatting"
20864 });
20865 // J, F, ..., D
20866 case "MMMMM":
20867 return localize2.month(month, {
20868 width: "narrow",
20869 context: "formatting"
20870 });
20871 // January, February, ..., December
20872 case "MMMM":
20873 default:
20874 return localize2.month(month, { width: "wide", context: "formatting" });
20875 }
20876 },
20877 // Stand-alone month
20878 L: function(date, token, localize2) {
20879 const month = date.getMonth();
20880 switch (token) {
20881 // 1, 2, ..., 12
20882 case "L":
20883 return String(month + 1);
20884 // 01, 02, ..., 12
20885 case "LL":
20886 return addLeadingZeros(month + 1, 2);
20887 // 1st, 2nd, ..., 12th
20888 case "Lo":
20889 return localize2.ordinalNumber(month + 1, { unit: "month" });
20890 // Jan, Feb, ..., Dec
20891 case "LLL":
20892 return localize2.month(month, {
20893 width: "abbreviated",
20894 context: "standalone"
20895 });
20896 // J, F, ..., D
20897 case "LLLLL":
20898 return localize2.month(month, {
20899 width: "narrow",
20900 context: "standalone"
20901 });
20902 // January, February, ..., December
20903 case "LLLL":
20904 default:
20905 return localize2.month(month, { width: "wide", context: "standalone" });
20906 }
20907 },
20908 // Local week of year
20909 w: function(date, token, localize2, options) {
20910 const week = getWeek(date, options);
20911 if (token === "wo") {
20912 return localize2.ordinalNumber(week, { unit: "week" });
20913 }
20914 return addLeadingZeros(week, token.length);
20915 },
20916 // ISO week of year
20917 I: function(date, token, localize2) {
20918 const isoWeek = getISOWeek(date);
20919 if (token === "Io") {
20920 return localize2.ordinalNumber(isoWeek, { unit: "week" });
20921 }
20922 return addLeadingZeros(isoWeek, token.length);
20923 },
20924 // Day of the month
20925 d: function(date, token, localize2) {
20926 if (token === "do") {
20927 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
20928 }
20929 return lightFormatters.d(date, token);
20930 },
20931 // Day of year
20932 D: function(date, token, localize2) {
20933 const dayOfYear = getDayOfYear(date);
20934 if (token === "Do") {
20935 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
20936 }
20937 return addLeadingZeros(dayOfYear, token.length);
20938 },
20939 // Day of week
20940 E: function(date, token, localize2) {
20941 const dayOfWeek = date.getDay();
20942 switch (token) {
20943 // Tue
20944 case "E":
20945 case "EE":
20946 case "EEE":
20947 return localize2.day(dayOfWeek, {
20948 width: "abbreviated",
20949 context: "formatting"
20950 });
20951 // T
20952 case "EEEEE":
20953 return localize2.day(dayOfWeek, {
20954 width: "narrow",
20955 context: "formatting"
20956 });
20957 // Tu
20958 case "EEEEEE":
20959 return localize2.day(dayOfWeek, {
20960 width: "short",
20961 context: "formatting"
20962 });
20963 // Tuesday
20964 case "EEEE":
20965 default:
20966 return localize2.day(dayOfWeek, {
20967 width: "wide",
20968 context: "formatting"
20969 });
20970 }
20971 },
20972 // Local day of week
20973 e: function(date, token, localize2, options) {
20974 const dayOfWeek = date.getDay();
20975 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20976 switch (token) {
20977 // Numerical value (Nth day of week with current locale or weekStartsOn)
20978 case "e":
20979 return String(localDayOfWeek);
20980 // Padded numerical value
20981 case "ee":
20982 return addLeadingZeros(localDayOfWeek, 2);
20983 // 1st, 2nd, ..., 7th
20984 case "eo":
20985 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20986 case "eee":
20987 return localize2.day(dayOfWeek, {
20988 width: "abbreviated",
20989 context: "formatting"
20990 });
20991 // T
20992 case "eeeee":
20993 return localize2.day(dayOfWeek, {
20994 width: "narrow",
20995 context: "formatting"
20996 });
20997 // Tu
20998 case "eeeeee":
20999 return localize2.day(dayOfWeek, {
21000 width: "short",
21001 context: "formatting"
21002 });
21003 // Tuesday
21004 case "eeee":
21005 default:
21006 return localize2.day(dayOfWeek, {
21007 width: "wide",
21008 context: "formatting"
21009 });
21010 }
21011 },
21012 // Stand-alone local day of week
21013 c: function(date, token, localize2, options) {
21014 const dayOfWeek = date.getDay();
21015 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
21016 switch (token) {
21017 // Numerical value (same as in `e`)
21018 case "c":
21019 return String(localDayOfWeek);
21020 // Padded numerical value
21021 case "cc":
21022 return addLeadingZeros(localDayOfWeek, token.length);
21023 // 1st, 2nd, ..., 7th
21024 case "co":
21025 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
21026 case "ccc":
21027 return localize2.day(dayOfWeek, {
21028 width: "abbreviated",
21029 context: "standalone"
21030 });
21031 // T
21032 case "ccccc":
21033 return localize2.day(dayOfWeek, {
21034 width: "narrow",
21035 context: "standalone"
21036 });
21037 // Tu
21038 case "cccccc":
21039 return localize2.day(dayOfWeek, {
21040 width: "short",
21041 context: "standalone"
21042 });
21043 // Tuesday
21044 case "cccc":
21045 default:
21046 return localize2.day(dayOfWeek, {
21047 width: "wide",
21048 context: "standalone"
21049 });
21050 }
21051 },
21052 // ISO day of week
21053 i: function(date, token, localize2) {
21054 const dayOfWeek = date.getDay();
21055 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
21056 switch (token) {
21057 // 2
21058 case "i":
21059 return String(isoDayOfWeek);
21060 // 02
21061 case "ii":
21062 return addLeadingZeros(isoDayOfWeek, token.length);
21063 // 2nd
21064 case "io":
21065 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
21066 // Tue
21067 case "iii":
21068 return localize2.day(dayOfWeek, {
21069 width: "abbreviated",
21070 context: "formatting"
21071 });
21072 // T
21073 case "iiiii":
21074 return localize2.day(dayOfWeek, {
21075 width: "narrow",
21076 context: "formatting"
21077 });
21078 // Tu
21079 case "iiiiii":
21080 return localize2.day(dayOfWeek, {
21081 width: "short",
21082 context: "formatting"
21083 });
21084 // Tuesday
21085 case "iiii":
21086 default:
21087 return localize2.day(dayOfWeek, {
21088 width: "wide",
21089 context: "formatting"
21090 });
21091 }
21092 },
21093 // AM or PM
21094 a: function(date, token, localize2) {
21095 const hours = date.getHours();
21096 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
21097 switch (token) {
21098 case "a":
21099 case "aa":
21100 return localize2.dayPeriod(dayPeriodEnumValue, {
21101 width: "abbreviated",
21102 context: "formatting"
21103 });
21104 case "aaa":
21105 return localize2.dayPeriod(dayPeriodEnumValue, {
21106 width: "abbreviated",
21107 context: "formatting"
21108 }).toLowerCase();
21109 case "aaaaa":
21110 return localize2.dayPeriod(dayPeriodEnumValue, {
21111 width: "narrow",
21112 context: "formatting"
21113 });
21114 case "aaaa":
21115 default:
21116 return localize2.dayPeriod(dayPeriodEnumValue, {
21117 width: "wide",
21118 context: "formatting"
21119 });
21120 }
21121 },
21122 // AM, PM, midnight, noon
21123 b: function(date, token, localize2) {
21124 const hours = date.getHours();
21125 let dayPeriodEnumValue;
21126 if (hours === 12) {
21127 dayPeriodEnumValue = dayPeriodEnum.noon;
21128 } else if (hours === 0) {
21129 dayPeriodEnumValue = dayPeriodEnum.midnight;
21130 } else {
21131 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
21132 }
21133 switch (token) {
21134 case "b":
21135 case "bb":
21136 return localize2.dayPeriod(dayPeriodEnumValue, {
21137 width: "abbreviated",
21138 context: "formatting"
21139 });
21140 case "bbb":
21141 return localize2.dayPeriod(dayPeriodEnumValue, {
21142 width: "abbreviated",
21143 context: "formatting"
21144 }).toLowerCase();
21145 case "bbbbb":
21146 return localize2.dayPeriod(dayPeriodEnumValue, {
21147 width: "narrow",
21148 context: "formatting"
21149 });
21150 case "bbbb":
21151 default:
21152 return localize2.dayPeriod(dayPeriodEnumValue, {
21153 width: "wide",
21154 context: "formatting"
21155 });
21156 }
21157 },
21158 // in the morning, in the afternoon, in the evening, at night
21159 B: function(date, token, localize2) {
21160 const hours = date.getHours();
21161 let dayPeriodEnumValue;
21162 if (hours >= 17) {
21163 dayPeriodEnumValue = dayPeriodEnum.evening;
21164 } else if (hours >= 12) {
21165 dayPeriodEnumValue = dayPeriodEnum.afternoon;
21166 } else if (hours >= 4) {
21167 dayPeriodEnumValue = dayPeriodEnum.morning;
21168 } else {
21169 dayPeriodEnumValue = dayPeriodEnum.night;
21170 }
21171 switch (token) {
21172 case "B":
21173 case "BB":
21174 case "BBB":
21175 return localize2.dayPeriod(dayPeriodEnumValue, {
21176 width: "abbreviated",
21177 context: "formatting"
21178 });
21179 case "BBBBB":
21180 return localize2.dayPeriod(dayPeriodEnumValue, {
21181 width: "narrow",
21182 context: "formatting"
21183 });
21184 case "BBBB":
21185 default:
21186 return localize2.dayPeriod(dayPeriodEnumValue, {
21187 width: "wide",
21188 context: "formatting"
21189 });
21190 }
21191 },
21192 // Hour [1-12]
21193 h: function(date, token, localize2) {
21194 if (token === "ho") {
21195 let hours = date.getHours() % 12;
21196 if (hours === 0) hours = 12;
21197 return localize2.ordinalNumber(hours, { unit: "hour" });
21198 }
21199 return lightFormatters.h(date, token);
21200 },
21201 // Hour [0-23]
21202 H: function(date, token, localize2) {
21203 if (token === "Ho") {
21204 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
21205 }
21206 return lightFormatters.H(date, token);
21207 },
21208 // Hour [0-11]
21209 K: function(date, token, localize2) {
21210 const hours = date.getHours() % 12;
21211 if (token === "Ko") {
21212 return localize2.ordinalNumber(hours, { unit: "hour" });
21213 }
21214 return addLeadingZeros(hours, token.length);
21215 },
21216 // Hour [1-24]
21217 k: function(date, token, localize2) {
21218 let hours = date.getHours();
21219 if (hours === 0) hours = 24;
21220 if (token === "ko") {
21221 return localize2.ordinalNumber(hours, { unit: "hour" });
21222 }
21223 return addLeadingZeros(hours, token.length);
21224 },
21225 // Minute
21226 m: function(date, token, localize2) {
21227 if (token === "mo") {
21228 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
21229 }
21230 return lightFormatters.m(date, token);
21231 },
21232 // Second
21233 s: function(date, token, localize2) {
21234 if (token === "so") {
21235 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
21236 }
21237 return lightFormatters.s(date, token);
21238 },
21239 // Fraction of second
21240 S: function(date, token) {
21241 return lightFormatters.S(date, token);
21242 },
21243 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
21244 X: function(date, token, _localize) {
21245 const timezoneOffset = date.getTimezoneOffset();
21246 if (timezoneOffset === 0) {
21247 return "Z";
21248 }
21249 switch (token) {
21250 // Hours and optional minutes
21251 case "X":
21252 return formatTimezoneWithOptionalMinutes(timezoneOffset);
21253 // Hours, minutes and optional seconds without `:` delimiter
21254 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21255 // so this token always has the same output as `XX`
21256 case "XXXX":
21257 case "XX":
21258 return formatTimezone(timezoneOffset);
21259 // Hours, minutes and optional seconds with `:` delimiter
21260 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21261 // so this token always has the same output as `XXX`
21262 case "XXXXX":
21263 case "XXX":
21264 // Hours and minutes with `:` delimiter
21265 default:
21266 return formatTimezone(timezoneOffset, ":");
21267 }
21268 },
21269 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
21270 x: function(date, token, _localize) {
21271 const timezoneOffset = date.getTimezoneOffset();
21272 switch (token) {
21273 // Hours and optional minutes
21274 case "x":
21275 return formatTimezoneWithOptionalMinutes(timezoneOffset);
21276 // Hours, minutes and optional seconds without `:` delimiter
21277 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21278 // so this token always has the same output as `xx`
21279 case "xxxx":
21280 case "xx":
21281 return formatTimezone(timezoneOffset);
21282 // Hours, minutes and optional seconds with `:` delimiter
21283 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21284 // so this token always has the same output as `xxx`
21285 case "xxxxx":
21286 case "xxx":
21287 // Hours and minutes with `:` delimiter
21288 default:
21289 return formatTimezone(timezoneOffset, ":");
21290 }
21291 },
21292 // Timezone (GMT)
21293 O: function(date, token, _localize) {
21294 const timezoneOffset = date.getTimezoneOffset();
21295 switch (token) {
21296 // Short
21297 case "O":
21298 case "OO":
21299 case "OOO":
21300 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
21301 // Long
21302 case "OOOO":
21303 default:
21304 return "GMT" + formatTimezone(timezoneOffset, ":");
21305 }
21306 },
21307 // Timezone (specific non-location)
21308 z: function(date, token, _localize) {
21309 const timezoneOffset = date.getTimezoneOffset();
21310 switch (token) {
21311 // Short
21312 case "z":
21313 case "zz":
21314 case "zzz":
21315 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
21316 // Long
21317 case "zzzz":
21318 default:
21319 return "GMT" + formatTimezone(timezoneOffset, ":");
21320 }
21321 },
21322 // Seconds timestamp
21323 t: function(date, token, _localize) {
21324 const timestamp = Math.trunc(+date / 1e3);
21325 return addLeadingZeros(timestamp, token.length);
21326 },
21327 // Milliseconds timestamp
21328 T: function(date, token, _localize) {
21329 return addLeadingZeros(+date, token.length);
21330 }
21331 };
21332 function formatTimezoneShort(offset4, delimiter = "") {
21333 const sign = offset4 > 0 ? "-" : "+";
21334 const absOffset = Math.abs(offset4);
21335 const hours = Math.trunc(absOffset / 60);
21336 const minutes = absOffset % 60;
21337 if (minutes === 0) {
21338 return sign + String(hours);
21339 }
21340 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
21341 }
21342 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
21343 if (offset4 % 60 === 0) {
21344 const sign = offset4 > 0 ? "-" : "+";
21345 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
21346 }
21347 return formatTimezone(offset4, delimiter);
21348 }
21349 function formatTimezone(offset4, delimiter = "") {
21350 const sign = offset4 > 0 ? "-" : "+";
21351 const absOffset = Math.abs(offset4);
21352 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
21353 const minutes = addLeadingZeros(absOffset % 60, 2);
21354 return sign + hours + delimiter + minutes;
21355 }
21356
21357 // packages/dataviews/node_modules/date-fns/_lib/format/longFormatters.js
21358 var dateLongFormatter = (pattern, formatLong2) => {
21359 switch (pattern) {
21360 case "P":
21361 return formatLong2.date({ width: "short" });
21362 case "PP":
21363 return formatLong2.date({ width: "medium" });
21364 case "PPP":
21365 return formatLong2.date({ width: "long" });
21366 case "PPPP":
21367 default:
21368 return formatLong2.date({ width: "full" });
21369 }
21370 };
21371 var timeLongFormatter = (pattern, formatLong2) => {
21372 switch (pattern) {
21373 case "p":
21374 return formatLong2.time({ width: "short" });
21375 case "pp":
21376 return formatLong2.time({ width: "medium" });
21377 case "ppp":
21378 return formatLong2.time({ width: "long" });
21379 case "pppp":
21380 default:
21381 return formatLong2.time({ width: "full" });
21382 }
21383 };
21384 var dateTimeLongFormatter = (pattern, formatLong2) => {
21385 const matchResult = pattern.match(/(P+)(p+)?/) || [];
21386 const datePattern = matchResult[1];
21387 const timePattern = matchResult[2];
21388 if (!timePattern) {
21389 return dateLongFormatter(pattern, formatLong2);
21390 }
21391 let dateTimeFormat;
21392 switch (datePattern) {
21393 case "P":
21394 dateTimeFormat = formatLong2.dateTime({ width: "short" });
21395 break;
21396 case "PP":
21397 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
21398 break;
21399 case "PPP":
21400 dateTimeFormat = formatLong2.dateTime({ width: "long" });
21401 break;
21402 case "PPPP":
21403 default:
21404 dateTimeFormat = formatLong2.dateTime({ width: "full" });
21405 break;
21406 }
21407 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
21408 };
21409 var longFormatters = {
21410 p: timeLongFormatter,
21411 P: dateTimeLongFormatter
21412 };
21413
21414 // packages/dataviews/node_modules/date-fns/_lib/protectedTokens.js
21415 var dayOfYearTokenRE = /^D+$/;
21416 var weekYearTokenRE = /^Y+$/;
21417 var throwTokens = ["D", "DD", "YY", "YYYY"];
21418 function isProtectedDayOfYearToken(token) {
21419 return dayOfYearTokenRE.test(token);
21420 }
21421 function isProtectedWeekYearToken(token) {
21422 return weekYearTokenRE.test(token);
21423 }
21424 function warnOrThrowProtectedError(token, format6, input) {
21425 const _message = message(token, format6, input);
21426 console.warn(_message);
21427 if (throwTokens.includes(token)) throw new RangeError(_message);
21428 }
21429 function message(token, format6, input) {
21430 const subject = token[0] === "Y" ? "years" : "days of the month";
21431 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`;
21432 }
21433
21434 // packages/dataviews/node_modules/date-fns/format.js
21435 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
21436 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
21437 var escapedStringRegExp = /^'([^]*?)'?$/;
21438 var doubleQuoteRegExp = /''/g;
21439 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
21440 function format(date, formatStr, options) {
21441 const defaultOptions2 = getDefaultOptions();
21442 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
21443 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
21444 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
21445 const originalDate = toDate(date, options?.in);
21446 if (!isValid(originalDate)) {
21447 throw new RangeError("Invalid time value");
21448 }
21449 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
21450 const firstCharacter = substring[0];
21451 if (firstCharacter === "p" || firstCharacter === "P") {
21452 const longFormatter = longFormatters[firstCharacter];
21453 return longFormatter(substring, locale.formatLong);
21454 }
21455 return substring;
21456 }).join("").match(formattingTokensRegExp).map((substring) => {
21457 if (substring === "''") {
21458 return { isToken: false, value: "'" };
21459 }
21460 const firstCharacter = substring[0];
21461 if (firstCharacter === "'") {
21462 return { isToken: false, value: cleanEscapedString(substring) };
21463 }
21464 if (formatters[firstCharacter]) {
21465 return { isToken: true, value: substring };
21466 }
21467 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
21468 throw new RangeError(
21469 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
21470 );
21471 }
21472 return { isToken: false, value: substring };
21473 });
21474 if (locale.localize.preprocessor) {
21475 parts = locale.localize.preprocessor(originalDate, parts);
21476 }
21477 const formatterOptions = {
21478 firstWeekContainsDate,
21479 weekStartsOn,
21480 locale
21481 };
21482 return parts.map((part) => {
21483 if (!part.isToken) return part.value;
21484 const token = part.value;
21485 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
21486 warnOrThrowProtectedError(token, formatStr, String(date));
21487 }
21488 const formatter = formatters[token[0]];
21489 return formatter(originalDate, token, locale.localize, formatterOptions);
21490 }).join("");
21491 }
21492 function cleanEscapedString(input) {
21493 const matched = input.match(escapedStringRegExp);
21494 if (!matched) {
21495 return input;
21496 }
21497 return matched[1].replace(doubleQuoteRegExp, "'");
21498 }
21499
21500 // packages/dataviews/node_modules/date-fns/subDays.js
21501 function subDays(date, amount, options) {
21502 return addDays(date, -amount, options);
21503 }
21504
21505 // packages/dataviews/node_modules/date-fns/subMonths.js
21506 function subMonths(date, amount, options) {
21507 return addMonths(date, -amount, options);
21508 }
21509
21510 // packages/dataviews/node_modules/date-fns/subWeeks.js
21511 function subWeeks(date, amount, options) {
21512 return addWeeks(date, -amount, options);
21513 }
21514
21515 // packages/dataviews/node_modules/date-fns/subYears.js
21516 function subYears(date, amount, options) {
21517 return addYears(date, -amount, options);
21518 }
21519
21520 // packages/dataviews/build-module/utils/operators.mjs
21521 var import_i18n31 = __toESM(require_i18n(), 1);
21522 var import_element46 = __toESM(require_element(), 1);
21523 var import_date = __toESM(require_date(), 1);
21524 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
21525 var filterTextWrappers = {
21526 Name: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
21527 Value: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
21528 };
21529 function getRelativeDate(value, unit) {
21530 switch (unit) {
21531 case "days":
21532 return subDays(/* @__PURE__ */ new Date(), value);
21533 case "weeks":
21534 return subWeeks(/* @__PURE__ */ new Date(), value);
21535 case "months":
21536 return subMonths(/* @__PURE__ */ new Date(), value);
21537 case "years":
21538 return subYears(/* @__PURE__ */ new Date(), value);
21539 default:
21540 return /* @__PURE__ */ new Date();
21541 }
21542 }
21543 var isNoneOperatorDefinition = {
21544 /* translators: DataViews operator name */
21545 label: (0, import_i18n31.__)("Is none of"),
21546 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21547 (0, import_i18n31.sprintf)(
21548 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
21549 (0, import_i18n31.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
21550 filter.name,
21551 activeElements.map((element) => element.label).join(", ")
21552 ),
21553 filterTextWrappers
21554 ),
21555 filter: ((item, field, filterValue) => {
21556 if (!filterValue?.length) {
21557 return true;
21558 }
21559 const fieldValue = field.getValue({ item });
21560 if (Array.isArray(fieldValue)) {
21561 return !filterValue.some(
21562 (fv) => fieldValue.includes(fv)
21563 );
21564 } else if (typeof fieldValue === "string") {
21565 return !filterValue.includes(fieldValue);
21566 }
21567 return false;
21568 }),
21569 selection: "multi"
21570 };
21571 var OPERATORS = [
21572 {
21573 name: OPERATOR_IS_ANY,
21574 /* translators: DataViews operator name */
21575 label: (0, import_i18n31.__)("Includes"),
21576 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21577 (0, import_i18n31.sprintf)(
21578 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
21579 (0, import_i18n31.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
21580 filter.name,
21581 activeElements.map((element) => element.label).join(", ")
21582 ),
21583 filterTextWrappers
21584 ),
21585 filter(item, field, filterValue) {
21586 if (!filterValue?.length) {
21587 return true;
21588 }
21589 const fieldValue = field.getValue({ item });
21590 if (Array.isArray(fieldValue)) {
21591 return filterValue.some(
21592 (fv) => fieldValue.includes(fv)
21593 );
21594 } else if (typeof fieldValue === "string") {
21595 return filterValue.includes(fieldValue);
21596 }
21597 return false;
21598 },
21599 selection: "multi"
21600 },
21601 {
21602 name: OPERATOR_IS_NONE,
21603 ...isNoneOperatorDefinition
21604 },
21605 {
21606 name: OPERATOR_IS_ALL,
21607 /* translators: DataViews operator name */
21608 label: (0, import_i18n31.__)("Includes all"),
21609 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21610 (0, import_i18n31.sprintf)(
21611 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
21612 (0, import_i18n31.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
21613 filter.name,
21614 activeElements.map((element) => element.label).join(", ")
21615 ),
21616 filterTextWrappers
21617 ),
21618 filter(item, field, filterValue) {
21619 if (!filterValue?.length) {
21620 return true;
21621 }
21622 return filterValue.every((value) => {
21623 return field.getValue({ item })?.includes(value);
21624 });
21625 },
21626 selection: "multi"
21627 },
21628 {
21629 name: OPERATOR_IS_NOT_ALL,
21630 ...isNoneOperatorDefinition
21631 },
21632 {
21633 name: OPERATOR_BETWEEN,
21634 /* translators: DataViews operator name */
21635 label: (0, import_i18n31.__)("Between (inc)"),
21636 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21637 (0, import_i18n31.sprintf)(
21638 /* 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". */
21639 (0, import_i18n31.__)(
21640 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
21641 ),
21642 filter.name,
21643 activeElements[0].label[0],
21644 activeElements[0].label[1]
21645 ),
21646 filterTextWrappers
21647 ),
21648 filter(item, field, filterValue) {
21649 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
21650 return true;
21651 }
21652 const fieldValue = field.getValue({ item });
21653 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
21654 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
21655 }
21656 return false;
21657 },
21658 selection: "custom"
21659 },
21660 {
21661 name: OPERATOR_IN_THE_PAST,
21662 /* translators: DataViews operator name */
21663 label: (0, import_i18n31.__)("In the past"),
21664 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21665 (0, import_i18n31.sprintf)(
21666 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
21667 (0, import_i18n31.__)(
21668 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
21669 ),
21670 filter.name,
21671 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21672 ),
21673 filterTextWrappers
21674 ),
21675 filter(item, field, filterValue) {
21676 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21677 return true;
21678 }
21679 const targetDate = getRelativeDate(
21680 filterValue.value,
21681 filterValue.unit
21682 );
21683 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21684 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
21685 },
21686 selection: "custom"
21687 },
21688 {
21689 name: OPERATOR_OVER,
21690 /* translators: DataViews operator name */
21691 label: (0, import_i18n31.__)("Over"),
21692 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21693 (0, import_i18n31.sprintf)(
21694 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
21695 (0, import_i18n31.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
21696 filter.name,
21697 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21698 ),
21699 filterTextWrappers
21700 ),
21701 filter(item, field, filterValue) {
21702 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21703 return true;
21704 }
21705 const targetDate = getRelativeDate(
21706 filterValue.value,
21707 filterValue.unit
21708 );
21709 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21710 return fieldValue < targetDate;
21711 },
21712 selection: "custom"
21713 },
21714 {
21715 name: OPERATOR_IS,
21716 /* translators: DataViews operator name */
21717 label: (0, import_i18n31.__)("Is"),
21718 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21719 (0, import_i18n31.sprintf)(
21720 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
21721 (0, import_i18n31.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21722 filter.name,
21723 activeElements[0].label
21724 ),
21725 filterTextWrappers
21726 ),
21727 filter(item, field, filterValue) {
21728 return filterValue === field.getValue({ item }) || filterValue === void 0;
21729 },
21730 selection: "single"
21731 },
21732 {
21733 name: OPERATOR_IS_NOT,
21734 /* translators: DataViews operator name */
21735 label: (0, import_i18n31.__)("Is not"),
21736 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21737 (0, import_i18n31.sprintf)(
21738 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
21739 (0, import_i18n31.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21740 filter.name,
21741 activeElements[0].label
21742 ),
21743 filterTextWrappers
21744 ),
21745 filter(item, field, filterValue) {
21746 return filterValue !== field.getValue({ item });
21747 },
21748 selection: "single"
21749 },
21750 {
21751 name: OPERATOR_LESS_THAN,
21752 /* translators: DataViews operator name */
21753 label: (0, import_i18n31.__)("Less than"),
21754 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21755 (0, import_i18n31.sprintf)(
21756 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
21757 (0, import_i18n31.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
21758 filter.name,
21759 activeElements[0].label
21760 ),
21761 filterTextWrappers
21762 ),
21763 filter(item, field, filterValue) {
21764 if (filterValue === void 0) {
21765 return true;
21766 }
21767 const fieldValue = field.getValue({ item });
21768 return fieldValue < filterValue;
21769 },
21770 selection: "single"
21771 },
21772 {
21773 name: OPERATOR_GREATER_THAN,
21774 /* translators: DataViews operator name */
21775 label: (0, import_i18n31.__)("Greater than"),
21776 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21777 (0, import_i18n31.sprintf)(
21778 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
21779 (0, import_i18n31.__)(
21780 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
21781 ),
21782 filter.name,
21783 activeElements[0].label
21784 ),
21785 filterTextWrappers
21786 ),
21787 filter(item, field, filterValue) {
21788 if (filterValue === void 0) {
21789 return true;
21790 }
21791 const fieldValue = field.getValue({ item });
21792 return fieldValue > filterValue;
21793 },
21794 selection: "single"
21795 },
21796 {
21797 name: OPERATOR_LESS_THAN_OR_EQUAL,
21798 /* translators: DataViews operator name */
21799 label: (0, import_i18n31.__)("Less than or equal"),
21800 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21801 (0, import_i18n31.sprintf)(
21802 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
21803 (0, import_i18n31.__)(
21804 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
21805 ),
21806 filter.name,
21807 activeElements[0].label
21808 ),
21809 filterTextWrappers
21810 ),
21811 filter(item, field, filterValue) {
21812 if (filterValue === void 0) {
21813 return true;
21814 }
21815 const fieldValue = field.getValue({ item });
21816 return fieldValue <= filterValue;
21817 },
21818 selection: "single"
21819 },
21820 {
21821 name: OPERATOR_GREATER_THAN_OR_EQUAL,
21822 /* translators: DataViews operator name */
21823 label: (0, import_i18n31.__)("Greater than or equal"),
21824 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21825 (0, import_i18n31.sprintf)(
21826 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
21827 (0, import_i18n31.__)(
21828 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
21829 ),
21830 filter.name,
21831 activeElements[0].label
21832 ),
21833 filterTextWrappers
21834 ),
21835 filter(item, field, filterValue) {
21836 if (filterValue === void 0) {
21837 return true;
21838 }
21839 const fieldValue = field.getValue({ item });
21840 return fieldValue >= filterValue;
21841 },
21842 selection: "single"
21843 },
21844 {
21845 name: OPERATOR_BEFORE,
21846 /* translators: DataViews operator name */
21847 label: (0, import_i18n31.__)("Before"),
21848 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21849 (0, import_i18n31.sprintf)(
21850 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
21851 (0, import_i18n31.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
21852 filter.name,
21853 activeElements[0].label
21854 ),
21855 filterTextWrappers
21856 ),
21857 filter(item, field, filterValue) {
21858 if (filterValue === void 0) {
21859 return true;
21860 }
21861 const filterDate = (0, import_date.getDate)(filterValue);
21862 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21863 return fieldDate < filterDate;
21864 },
21865 selection: "single"
21866 },
21867 {
21868 name: OPERATOR_AFTER,
21869 /* translators: DataViews operator name */
21870 label: (0, import_i18n31.__)("After"),
21871 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21872 (0, import_i18n31.sprintf)(
21873 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
21874 (0, import_i18n31.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
21875 filter.name,
21876 activeElements[0].label
21877 ),
21878 filterTextWrappers
21879 ),
21880 filter(item, field, filterValue) {
21881 if (filterValue === void 0) {
21882 return true;
21883 }
21884 const filterDate = (0, import_date.getDate)(filterValue);
21885 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21886 return fieldDate > filterDate;
21887 },
21888 selection: "single"
21889 },
21890 {
21891 name: OPERATOR_BEFORE_INC,
21892 /* translators: DataViews operator name */
21893 label: (0, import_i18n31.__)("Before (inc)"),
21894 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21895 (0, import_i18n31.sprintf)(
21896 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
21897 (0, import_i18n31.__)(
21898 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
21899 ),
21900 filter.name,
21901 activeElements[0].label
21902 ),
21903 filterTextWrappers
21904 ),
21905 filter(item, field, filterValue) {
21906 if (filterValue === void 0) {
21907 return true;
21908 }
21909 const filterDate = (0, import_date.getDate)(filterValue);
21910 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21911 return fieldDate <= filterDate;
21912 },
21913 selection: "single"
21914 },
21915 {
21916 name: OPERATOR_AFTER_INC,
21917 /* translators: DataViews operator name */
21918 label: (0, import_i18n31.__)("After (inc)"),
21919 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21920 (0, import_i18n31.sprintf)(
21921 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
21922 (0, import_i18n31.__)(
21923 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
21924 ),
21925 filter.name,
21926 activeElements[0].label
21927 ),
21928 filterTextWrappers
21929 ),
21930 filter(item, field, filterValue) {
21931 if (filterValue === void 0) {
21932 return true;
21933 }
21934 const filterDate = (0, import_date.getDate)(filterValue);
21935 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21936 return fieldDate >= filterDate;
21937 },
21938 selection: "single"
21939 },
21940 {
21941 name: OPERATOR_CONTAINS,
21942 /* translators: DataViews operator name */
21943 label: (0, import_i18n31.__)("Contains"),
21944 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21945 (0, import_i18n31.sprintf)(
21946 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
21947 (0, import_i18n31.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
21948 filter.name,
21949 activeElements[0].label
21950 ),
21951 filterTextWrappers
21952 ),
21953 filter(item, field, filterValue) {
21954 if (filterValue === void 0) {
21955 return true;
21956 }
21957 const fieldValue = field.getValue({ item });
21958 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21959 },
21960 selection: "single"
21961 },
21962 {
21963 name: OPERATOR_NOT_CONTAINS,
21964 /* translators: DataViews operator name */
21965 label: (0, import_i18n31.__)("Doesn't contain"),
21966 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21967 (0, import_i18n31.sprintf)(
21968 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
21969 (0, import_i18n31.__)(
21970 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
21971 ),
21972 filter.name,
21973 activeElements[0].label
21974 ),
21975 filterTextWrappers
21976 ),
21977 filter(item, field, filterValue) {
21978 if (filterValue === void 0) {
21979 return true;
21980 }
21981 const fieldValue = field.getValue({ item });
21982 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21983 },
21984 selection: "single"
21985 },
21986 {
21987 name: OPERATOR_STARTS_WITH,
21988 /* translators: DataViews operator name */
21989 label: (0, import_i18n31.__)("Starts with"),
21990 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
21991 (0, import_i18n31.sprintf)(
21992 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
21993 (0, import_i18n31.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
21994 filter.name,
21995 activeElements[0].label
21996 ),
21997 filterTextWrappers
21998 ),
21999 filter(item, field, filterValue) {
22000 if (filterValue === void 0) {
22001 return true;
22002 }
22003 const fieldValue = field.getValue({ item });
22004 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
22005 },
22006 selection: "single"
22007 },
22008 {
22009 name: OPERATOR_ON,
22010 /* translators: DataViews operator name */
22011 label: (0, import_i18n31.__)("On"),
22012 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
22013 (0, import_i18n31.sprintf)(
22014 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
22015 (0, import_i18n31.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
22016 filter.name,
22017 activeElements[0].label
22018 ),
22019 filterTextWrappers
22020 ),
22021 filter(item, field, filterValue) {
22022 if (filterValue === void 0) {
22023 return true;
22024 }
22025 const filterDate = (0, import_date.getDate)(filterValue);
22026 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
22027 return filterDate.getTime() === fieldDate.getTime();
22028 },
22029 selection: "single"
22030 },
22031 {
22032 name: OPERATOR_NOT_ON,
22033 /* translators: DataViews operator name */
22034 label: (0, import_i18n31.__)("Not on"),
22035 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
22036 (0, import_i18n31.sprintf)(
22037 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
22038 (0, import_i18n31.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
22039 filter.name,
22040 activeElements[0].label
22041 ),
22042 filterTextWrappers
22043 ),
22044 filter(item, field, filterValue) {
22045 if (filterValue === void 0) {
22046 return true;
22047 }
22048 const filterDate = (0, import_date.getDate)(filterValue);
22049 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
22050 return filterDate.getTime() !== fieldDate.getTime();
22051 },
22052 selection: "single"
22053 }
22054 ];
22055 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
22056 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
22057 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
22058 (op) => op.name === name
22059 );
22060 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
22061
22062 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
22063 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
22064 var ENTER = "Enter";
22065 var SPACE = " ";
22066 var FilterText = ({
22067 activeElements,
22068 filterInView,
22069 filter
22070 }) => {
22071 if (activeElements === void 0 || activeElements.length === 0) {
22072 return filter.name;
22073 }
22074 const operator = getOperatorByName(filterInView?.operator);
22075 if (operator !== void 0) {
22076 return operator.filterText(filter, activeElements);
22077 }
22078 return (0, import_i18n32.sprintf)(
22079 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
22080 (0, import_i18n32.__)("Unknown status for %1$s"),
22081 filter.name
22082 );
22083 };
22084 function OperatorSelector({
22085 filter,
22086 view,
22087 onChangeView
22088 }) {
22089 const operatorOptions = filter.operators?.map((operator) => ({
22090 value: operator,
22091 label: getOperatorByName(operator)?.label || operator
22092 }));
22093 const currentFilter = view.filters?.find(
22094 (_filter) => _filter.field === filter.field
22095 );
22096 const value = currentFilter?.operator || filter.operators[0];
22097 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
22098 Stack,
22099 {
22100 direction: "row",
22101 gap: "sm",
22102 justify: "flex-start",
22103 className: "dataviews-filters__summary-operators-container",
22104 align: "center",
22105 children: [
22106 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components21.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
22107 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22108 import_components21.SelectControl,
22109 {
22110 className: "dataviews-filters__summary-operators-filter-select",
22111 label: (0, import_i18n32.__)("Conditions"),
22112 value,
22113 options: operatorOptions,
22114 onChange: (newValue) => {
22115 const newOperator = newValue;
22116 const currentOperator = currentFilter?.operator;
22117 const newFilters = currentFilter ? [
22118 ...(view.filters ?? []).map(
22119 (_filter) => {
22120 if (_filter.field === filter.field) {
22121 const currentOpSelectionModel = getOperatorByName(
22122 currentOperator
22123 )?.selection;
22124 const newOpSelectionModel = getOperatorByName(
22125 newOperator
22126 )?.selection;
22127 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
22128 currentOpSelectionModel,
22129 newOpSelectionModel
22130 ].includes("custom");
22131 return {
22132 ..._filter,
22133 value: shouldResetValue ? void 0 : _filter.value,
22134 operator: newOperator
22135 };
22136 }
22137 return _filter;
22138 }
22139 )
22140 ] : [
22141 ...view.filters ?? [],
22142 {
22143 field: filter.field,
22144 operator: newOperator,
22145 value: void 0
22146 }
22147 ];
22148 onChangeView({
22149 ...view,
22150 page: 1,
22151 filters: newFilters
22152 });
22153 },
22154 size: "small",
22155 variant: "minimal",
22156 hideLabelFromVision: true
22157 }
22158 )
22159 ]
22160 }
22161 );
22162 }
22163 function Filter({
22164 addFilterRef,
22165 openedFilter,
22166 fields,
22167 ...commonProps
22168 }) {
22169 const toggleRef = (0, import_element47.useRef)(null);
22170 const { filter, view, onChangeView } = commonProps;
22171 const filterInView = view.filters?.find(
22172 (f2) => f2.field === filter.field
22173 );
22174 let activeElements = [];
22175 const field = (0, import_element47.useMemo)(() => {
22176 const currentField = fields.find((f2) => f2.id === filter.field);
22177 if (currentField) {
22178 return {
22179 ...currentField,
22180 // Configure getValue as if Item was a plain object.
22181 // See related input-widget.tsx
22182 getValue: ({ item }) => item[currentField.id]
22183 };
22184 }
22185 return currentField;
22186 }, [fields, filter.field]);
22187 const { elements } = useElements({
22188 elements: filter.elements,
22189 getElements: filter.getElements
22190 });
22191 if (elements.length > 0) {
22192 activeElements = elements.filter((element) => {
22193 if (filter.singleSelection) {
22194 return element.value === filterInView?.value;
22195 }
22196 return filterInView?.value?.includes(element.value);
22197 });
22198 } else if (Array.isArray(filterInView?.value)) {
22199 const label = filterInView.value.map((v2) => {
22200 const formattedValue = field?.getValueFormatted({
22201 item: { [field.id]: v2 },
22202 field
22203 });
22204 return formattedValue || String(v2);
22205 });
22206 activeElements = [
22207 {
22208 value: filterInView.value,
22209 // @ts-ignore
22210 label
22211 }
22212 ];
22213 } else if (typeof filterInView?.value === "object") {
22214 activeElements = [
22215 { value: filterInView.value, label: filterInView.value }
22216 ];
22217 } else if (filterInView?.value !== void 0) {
22218 const label = field !== void 0 ? field.getValueFormatted({
22219 item: { [field.id]: filterInView.value },
22220 field
22221 }) : String(filterInView.value);
22222 activeElements = [
22223 {
22224 value: filterInView.value,
22225 label
22226 }
22227 ];
22228 }
22229 const isPrimary = filter.isPrimary;
22230 const isLocked = filterInView?.isLocked;
22231 const hasValues = !isLocked && filterInView?.value !== void 0;
22232 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
22233 const resetOrRemoveLabel = isPrimary ? (0, import_i18n32.__)("Reset") : (0, import_i18n32.__)("Remove");
22234 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22235 import_components21.Dropdown,
22236 {
22237 defaultOpen: openedFilter === filter.field,
22238 contentClassName: "dataviews-filters__summary-popover",
22239 popoverProps: { placement: "bottom-start", role: "dialog" },
22240 onClose: () => {
22241 toggleRef.current?.focus();
22242 },
22243 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
22244 /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(tooltip_exports.Root, { children: [
22245 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22246 tooltip_exports.Trigger,
22247 {
22248 render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22249 "div",
22250 {
22251 className: clsx_default(
22252 "dataviews-filters__summary-chip",
22253 {
22254 "has-reset": canResetOrRemove,
22255 "has-values": hasValues,
22256 "is-not-clickable": isLocked
22257 }
22258 ),
22259 role: "button",
22260 tabIndex: isLocked ? -1 : 0,
22261 onClick: () => {
22262 if (!isLocked) {
22263 onToggle();
22264 }
22265 },
22266 onKeyDown: (event) => {
22267 if (!isLocked && [ENTER, SPACE].includes(
22268 event.key
22269 )) {
22270 onToggle();
22271 event.preventDefault();
22272 }
22273 },
22274 "aria-disabled": isLocked,
22275 "aria-pressed": isOpen,
22276 "aria-expanded": isOpen,
22277 ref: toggleRef,
22278 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22279 FilterText,
22280 {
22281 activeElements,
22282 filterInView,
22283 filter
22284 }
22285 )
22286 }
22287 )
22288 }
22289 ),
22290 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(tooltip_exports.Popup, { children: (0, import_i18n32.sprintf)(
22291 /* translators: 1: Filter name. */
22292 (0, import_i18n32.__)("Filter by: %1$s"),
22293 filter.name.toLowerCase()
22294 ) })
22295 ] }),
22296 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(tooltip_exports.Root, { children: [
22297 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22298 tooltip_exports.Trigger,
22299 {
22300 render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22301 "button",
22302 {
22303 className: clsx_default(
22304 "dataviews-filters__summary-chip-remove",
22305 { "has-values": hasValues }
22306 ),
22307 "aria-label": resetOrRemoveLabel,
22308 onClick: () => {
22309 onChangeView({
22310 ...view,
22311 page: 1,
22312 filters: view.filters?.filter(
22313 (_filter) => _filter.field !== filter.field
22314 )
22315 });
22316 if (!isPrimary) {
22317 addFilterRef.current?.focus();
22318 } else {
22319 toggleRef.current?.focus();
22320 }
22321 },
22322 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components21.Icon, { icon: close_small_default })
22323 }
22324 )
22325 }
22326 ),
22327 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
22328 ] })
22329 ] }),
22330 renderContent: () => {
22331 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
22332 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(OperatorSelector, { ...commonProps }),
22333 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22334 SearchWidget,
22335 {
22336 ...commonProps,
22337 filter: {
22338 ...commonProps.filter,
22339 elements
22340 }
22341 }
22342 ) : /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(InputWidget, { ...commonProps, fields })
22343 ] });
22344 }
22345 }
22346 );
22347 }
22348
22349 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
22350 var import_components22 = __toESM(require_components(), 1);
22351 var import_i18n33 = __toESM(require_i18n(), 1);
22352 var import_element48 = __toESM(require_element(), 1);
22353 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
22354 var { Menu: Menu4 } = unlock2(import_components22.privateApis);
22355 function AddFilterMenu({
22356 filters,
22357 view,
22358 onChangeView,
22359 setOpenedFilter,
22360 triggerProps
22361 }) {
22362 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
22363 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(Menu4, { children: [
22364 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu4.TriggerButton, { ...triggerProps }),
22365 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
22366 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22367 Menu4.Item,
22368 {
22369 onClick: () => {
22370 setOpenedFilter(filter.field);
22371 onChangeView({
22372 ...view,
22373 page: 1,
22374 filters: [
22375 ...view.filters || [],
22376 {
22377 field: filter.field,
22378 value: void 0,
22379 operator: filter.operators[0]
22380 }
22381 ]
22382 });
22383 },
22384 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu4.ItemLabel, { children: filter.name })
22385 },
22386 filter.field
22387 );
22388 }) })
22389 ] });
22390 }
22391 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
22392 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
22393 return null;
22394 }
22395 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
22396 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22397 AddFilterMenu,
22398 {
22399 triggerProps: {
22400 render: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22401 import_components22.Button,
22402 {
22403 accessibleWhenDisabled: true,
22404 size: "compact",
22405 className: "dataviews-filters-button",
22406 variant: "tertiary",
22407 disabled: !inactiveFilters.length,
22408 ref
22409 }
22410 ),
22411 children: (0, import_i18n33.__)("Add filter")
22412 },
22413 ...{ filters, view, onChangeView, setOpenedFilter }
22414 }
22415 );
22416 }
22417 var add_filter_default = (0, import_element48.forwardRef)(AddFilter);
22418
22419 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
22420 var import_components23 = __toESM(require_components(), 1);
22421 var import_i18n34 = __toESM(require_i18n(), 1);
22422 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
22423 function ResetFilter({
22424 filters,
22425 view,
22426 onChangeView
22427 }) {
22428 const isPrimary = (field) => filters.some(
22429 (_filter) => _filter.field === field && _filter.isPrimary
22430 );
22431 const isDisabled = !view.search && !view.filters?.some(
22432 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
22433 );
22434 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
22435 import_components23.Button,
22436 {
22437 disabled: isDisabled,
22438 accessibleWhenDisabled: true,
22439 size: "compact",
22440 variant: "tertiary",
22441 className: "dataviews-filters__reset-button",
22442 onClick: () => {
22443 onChangeView({
22444 ...view,
22445 page: 1,
22446 search: "",
22447 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
22448 });
22449 },
22450 children: (0, import_i18n34.__)("Reset")
22451 }
22452 );
22453 }
22454
22455 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
22456 var import_element49 = __toESM(require_element(), 1);
22457 function useFilters(fields, view) {
22458 return (0, import_element49.useMemo)(() => {
22459 const filters = [];
22460 fields.forEach((field) => {
22461 if (field.filterBy === false || !field.hasElements && !field.Edit) {
22462 return;
22463 }
22464 const operators = field.filterBy.operators;
22465 const isPrimary = !!field.filterBy?.isPrimary;
22466 const isLocked = view.filters?.some(
22467 (f2) => f2.field === field.id && !!f2.isLocked
22468 ) ?? false;
22469 filters.push({
22470 field: field.id,
22471 name: field.label,
22472 elements: field.elements,
22473 getElements: field.getElements,
22474 hasElements: field.hasElements,
22475 singleSelection: operators.some(
22476 (op) => isSingleSelectionOperator(op)
22477 ),
22478 operators,
22479 isVisible: isLocked || isPrimary || !!view.filters?.some(
22480 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
22481 ),
22482 isPrimary,
22483 isLocked
22484 });
22485 });
22486 filters.sort((a2, b2) => {
22487 if (a2.isLocked && !b2.isLocked) {
22488 return -1;
22489 }
22490 if (!a2.isLocked && b2.isLocked) {
22491 return 1;
22492 }
22493 if (a2.isPrimary && !b2.isPrimary) {
22494 return -1;
22495 }
22496 if (!a2.isPrimary && b2.isPrimary) {
22497 return 1;
22498 }
22499 return a2.name.localeCompare(b2.name);
22500 });
22501 return filters;
22502 }, [fields, view]);
22503 }
22504 var use_filters_default = useFilters;
22505
22506 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
22507 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
22508 function Filters({ className }) {
22509 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element50.useContext)(dataviews_context_default);
22510 const addFilterRef = (0, import_element50.useRef)(null);
22511 const filters = use_filters_default(fields, view);
22512 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22513 add_filter_default,
22514 {
22515 filters,
22516 view,
22517 onChangeView,
22518 ref: addFilterRef,
22519 setOpenedFilter
22520 },
22521 "add-filter"
22522 );
22523 const visibleFilters = filters.filter((filter) => filter.isVisible);
22524 if (visibleFilters.length === 0) {
22525 return null;
22526 }
22527 const filterComponents = [
22528 ...visibleFilters.map((filter) => {
22529 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22530 Filter,
22531 {
22532 filter,
22533 view,
22534 fields,
22535 onChangeView,
22536 addFilterRef,
22537 openedFilter
22538 },
22539 filter.field
22540 );
22541 }),
22542 addFilter
22543 ];
22544 filterComponents.push(
22545 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22546 ResetFilter,
22547 {
22548 filters,
22549 view,
22550 onChangeView
22551 },
22552 "reset-filters"
22553 )
22554 );
22555 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22556 Stack,
22557 {
22558 direction: "row",
22559 justify: "flex-start",
22560 gap: "sm",
22561 style: { width: "fit-content" },
22562 wrap: "wrap",
22563 className,
22564 children: filterComponents
22565 }
22566 );
22567 }
22568 var filters_default = (0, import_element50.memo)(Filters);
22569
22570 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
22571 var import_element51 = __toESM(require_element(), 1);
22572 var import_components24 = __toESM(require_components(), 1);
22573 var import_i18n35 = __toESM(require_i18n(), 1);
22574 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
22575 function FiltersToggle() {
22576 const {
22577 filters,
22578 view,
22579 onChangeView,
22580 setOpenedFilter,
22581 isShowingFilter,
22582 setIsShowingFilter
22583 } = (0, import_element51.useContext)(dataviews_context_default);
22584 const buttonRef = (0, import_element51.useRef)(null);
22585 const onChangeViewWithFilterVisibility = (0, import_element51.useCallback)(
22586 (_view) => {
22587 onChangeView(_view);
22588 setIsShowingFilter(true);
22589 },
22590 [onChangeView, setIsShowingFilter]
22591 );
22592 if (filters.length === 0) {
22593 return null;
22594 }
22595 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
22596 const addFilterButtonProps = {
22597 label: (0, import_i18n35.__)("Add filter"),
22598 "aria-expanded": false,
22599 isPressed: false
22600 };
22601 const toggleFiltersButtonProps = {
22602 label: (0, import_i18n35._x)("Filter", "verb"),
22603 "aria-expanded": isShowingFilter,
22604 isPressed: isShowingFilter,
22605 onClick: () => {
22606 if (!isShowingFilter) {
22607 setOpenedFilter(null);
22608 }
22609 setIsShowingFilter(!isShowingFilter);
22610 }
22611 };
22612 const hasPrimaryOrLockedFilters = filters.some(
22613 (filter) => filter.isPrimary || filter.isLocked
22614 );
22615 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22616 import_components24.Button,
22617 {
22618 ref: buttonRef,
22619 className: "dataviews-filters__visibility-toggle",
22620 size: "compact",
22621 icon: funnel_default,
22622 disabled: hasPrimaryOrLockedFilters,
22623 accessibleWhenDisabled: true,
22624 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
22625 }
22626 );
22627 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22628 AddFilterMenu,
22629 {
22630 filters,
22631 view,
22632 onChangeView: onChangeViewWithFilterVisibility,
22633 setOpenedFilter,
22634 triggerProps: { render: buttonComponent }
22635 }
22636 ) : /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22637 FilterVisibilityToggle,
22638 {
22639 buttonRef,
22640 filtersCount: view.filters?.length,
22641 children: buttonComponent
22642 }
22643 ) });
22644 }
22645 function FilterVisibilityToggle({
22646 buttonRef,
22647 filtersCount,
22648 children
22649 }) {
22650 (0, import_element51.useEffect)(
22651 () => () => {
22652 buttonRef.current?.focus();
22653 },
22654 [buttonRef]
22655 );
22656 return /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(import_jsx_runtime87.Fragment, { children: [
22657 children,
22658 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
22659 ] });
22660 }
22661 var toggle_default = FiltersToggle;
22662
22663 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
22664 var import_element52 = __toESM(require_element(), 1);
22665 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
22666 function FiltersToggled(props) {
22667 const { isShowingFilter } = (0, import_element52.useContext)(dataviews_context_default);
22668 if (!isShowingFilter) {
22669 return null;
22670 }
22671 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(filters_default, { ...props });
22672 }
22673 var filters_toggled_default = FiltersToggled;
22674
22675 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
22676 var import_element53 = __toESM(require_element(), 1);
22677 var import_components25 = __toESM(require_components(), 1);
22678 var import_i18n36 = __toESM(require_i18n(), 1);
22679 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
22680 function DataViewsLayout({ className }) {
22681 const {
22682 actions = [],
22683 data,
22684 fields,
22685 getItemId,
22686 getItemLevel,
22687 hasInitiallyLoaded,
22688 isLoading,
22689 view,
22690 onChangeView,
22691 selection,
22692 onChangeSelection,
22693 setOpenedFilter,
22694 onClickItem,
22695 isItemClickable: isItemClickable2,
22696 renderItemLink,
22697 defaultLayouts: defaultLayouts2,
22698 containerRef,
22699 empty = /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("p", { children: (0, import_i18n36.__)("No results") })
22700 } = (0, import_element53.useContext)(dataviews_context_default);
22701 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
22702 delay: 200
22703 });
22704 if (!hasInitiallyLoaded) {
22705 if (!isDelayedInitialLoading) {
22706 return null;
22707 }
22708 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components25.Spinner, {}) }) });
22709 }
22710 const ViewComponent = VIEW_LAYOUTS.find(
22711 (v2) => v2.type === view.type && defaultLayouts2[v2.type]
22712 )?.component;
22713 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22714 ViewComponent,
22715 {
22716 className,
22717 actions,
22718 data,
22719 fields,
22720 getItemId,
22721 getItemLevel,
22722 isLoading,
22723 onChangeView,
22724 onChangeSelection,
22725 selection,
22726 setOpenedFilter,
22727 onClickItem,
22728 renderItemLink,
22729 isItemClickable: isItemClickable2,
22730 view,
22731 empty
22732 }
22733 ) });
22734 }
22735
22736 // packages/dataviews/build-module/components/dataviews-search/index.mjs
22737 var import_i18n37 = __toESM(require_i18n(), 1);
22738 var import_element54 = __toESM(require_element(), 1);
22739 var import_components26 = __toESM(require_components(), 1);
22740 var import_compose10 = __toESM(require_compose(), 1);
22741 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
22742 var DataViewsSearch = (0, import_element54.memo)(function Search({ label }) {
22743 const { view, onChangeView } = (0, import_element54.useContext)(dataviews_context_default);
22744 const [search, setSearch, debouncedSearch] = (0, import_compose10.useDebouncedInput)(
22745 view.search
22746 );
22747 (0, import_element54.useEffect)(() => {
22748 if (view.search !== debouncedSearch) {
22749 setSearch(view.search ?? "");
22750 }
22751 }, [view.search, setSearch]);
22752 const onChangeViewRef = (0, import_element54.useRef)(onChangeView);
22753 const viewRef = (0, import_element54.useRef)(view);
22754 (0, import_element54.useEffect)(() => {
22755 onChangeViewRef.current = onChangeView;
22756 viewRef.current = view;
22757 }, [onChangeView, view]);
22758 (0, import_element54.useEffect)(() => {
22759 if (debouncedSearch !== viewRef.current?.search) {
22760 onChangeViewRef.current({
22761 ...viewRef.current,
22762 page: view.page ? 1 : void 0,
22763 startPosition: view.startPosition ? 1 : void 0,
22764 search: debouncedSearch
22765 });
22766 }
22767 }, [debouncedSearch]);
22768 const searchLabel = label || (0, import_i18n37.__)("Search");
22769 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22770 import_components26.SearchControl,
22771 {
22772 className: "dataviews-search",
22773 onChange: setSearch,
22774 value: search,
22775 label: searchLabel,
22776 placeholder: searchLabel,
22777 size: "compact"
22778 }
22779 );
22780 });
22781 var dataviews_search_default = DataViewsSearch;
22782
22783 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
22784 var import_components27 = __toESM(require_components(), 1);
22785 var import_i18n38 = __toESM(require_i18n(), 1);
22786 var import_element55 = __toESM(require_element(), 1);
22787 var import_warning = __toESM(require_warning(), 1);
22788 var import_compose11 = __toESM(require_compose(), 1);
22789 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
22790 var { Menu: Menu5 } = unlock2(import_components27.privateApis);
22791 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
22792 className: "dataviews-config__popover",
22793 placement: "bottom-end",
22794 offset: 9
22795 };
22796 function ViewTypeMenu() {
22797 const { view, onChangeView, defaultLayouts: defaultLayouts2 } = (0, import_element55.useContext)(dataviews_context_default);
22798 const availableLayouts = Object.keys(defaultLayouts2);
22799 if (availableLayouts.length <= 1) {
22800 return null;
22801 }
22802 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
22803 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(Menu5, { children: [
22804 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22805 Menu5.TriggerButton,
22806 {
22807 render: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22808 import_components27.Button,
22809 {
22810 size: "compact",
22811 icon: activeView?.icon,
22812 label: (0, import_i18n38.__)("Layout")
22813 }
22814 )
22815 }
22816 ),
22817 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
22818 const config = VIEW_LAYOUTS.find(
22819 (v2) => v2.type === layout
22820 );
22821 if (!config) {
22822 return null;
22823 }
22824 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22825 Menu5.RadioItem,
22826 {
22827 value: layout,
22828 name: "view-actions-available-view",
22829 checked: layout === view.type,
22830 hideOnClick: true,
22831 onChange: (e2) => {
22832 switch (e2.target.value) {
22833 case "list":
22834 case "grid":
22835 case "table":
22836 case "pickerGrid":
22837 case "pickerTable":
22838 case "pickerActivity":
22839 case "activity":
22840 const viewWithoutLayout = { ...view };
22841 if ("layout" in viewWithoutLayout) {
22842 delete viewWithoutLayout.layout;
22843 }
22844 return onChangeView({
22845 ...viewWithoutLayout,
22846 type: e2.target.value,
22847 ...defaultLayouts2[e2.target.value]
22848 });
22849 }
22850 (0, import_warning.default)("Invalid dataview");
22851 },
22852 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Menu5.ItemLabel, { children: config.label })
22853 },
22854 layout
22855 );
22856 }) })
22857 ] });
22858 }
22859 function SortFieldControl() {
22860 const { view, fields, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
22861 const orderOptions = (0, import_element55.useMemo)(() => {
22862 const sortableFields = fields.filter(
22863 (field) => field.enableSorting !== false
22864 );
22865 return sortableFields.map((field) => {
22866 return {
22867 label: field.label,
22868 value: field.id
22869 };
22870 });
22871 }, [fields]);
22872 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22873 import_components27.SelectControl,
22874 {
22875 label: (0, import_i18n38.__)("Sort by"),
22876 value: view.sort?.field,
22877 options: orderOptions,
22878 onChange: (value) => {
22879 onChangeView({
22880 ...view,
22881 sort: {
22882 direction: view?.sort?.direction || "desc",
22883 field: value
22884 },
22885 showLevels: false
22886 });
22887 }
22888 }
22889 );
22890 }
22891 function SortDirectionControl() {
22892 const { view, fields, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
22893 const sortableFields = fields.filter(
22894 (field) => field.enableSorting !== false
22895 );
22896 if (sortableFields.length === 0) {
22897 return null;
22898 }
22899 let value = view.sort?.direction;
22900 if (!value && view.sort?.field) {
22901 value = "desc";
22902 }
22903 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22904 import_components27.__experimentalToggleGroupControl,
22905 {
22906 className: "dataviews-view-config__sort-direction",
22907 isBlock: true,
22908 label: (0, import_i18n38.__)("Order"),
22909 value,
22910 onChange: (newDirection) => {
22911 if (newDirection === "asc" || newDirection === "desc") {
22912 onChangeView({
22913 ...view,
22914 sort: {
22915 direction: newDirection,
22916 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
22917 fields.find(
22918 (field) => field.enableSorting !== false
22919 )?.id || ""
22920 },
22921 showLevels: false
22922 });
22923 return;
22924 }
22925 (0, import_warning.default)("Invalid direction");
22926 },
22927 children: SORTING_DIRECTIONS.map((direction) => {
22928 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22929 import_components27.__experimentalToggleGroupControlOptionIcon,
22930 {
22931 value: direction,
22932 icon: sortIcons[direction],
22933 label: sortLabels[direction]
22934 },
22935 direction
22936 );
22937 })
22938 }
22939 );
22940 }
22941 function ItemsPerPageControl() {
22942 const { view, config, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
22943 const { infiniteScrollEnabled } = view;
22944 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
22945 return null;
22946 }
22947 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22948 import_components27.__experimentalToggleGroupControl,
22949 {
22950 isBlock: true,
22951 label: (0, import_i18n38.__)("Items per page"),
22952 value: view.perPage || 10,
22953 disabled: !view?.sort?.field,
22954 onChange: (newItemsPerPage) => {
22955 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
22956 onChangeView({
22957 ...view,
22958 perPage: newItemsPerPageNumber,
22959 page: 1
22960 });
22961 },
22962 children: config.perPageSizes.map((value) => {
22963 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22964 import_components27.__experimentalToggleGroupControlOption,
22965 {
22966 value,
22967 label: value.toString()
22968 },
22969 value
22970 );
22971 })
22972 }
22973 );
22974 }
22975 function ResetViewButton() {
22976 const { onReset } = (0, import_element55.useContext)(dataviews_context_default);
22977 if (onReset === void 0) {
22978 return null;
22979 }
22980 const isDisabled = onReset === false;
22981 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22982 import_components27.Button,
22983 {
22984 variant: "tertiary",
22985 size: "compact",
22986 disabled: isDisabled,
22987 accessibleWhenDisabled: true,
22988 className: "dataviews-view-config__reset-button",
22989 onClick: () => {
22990 if (typeof onReset === "function") {
22991 onReset();
22992 }
22993 },
22994 children: (0, import_i18n38.__)("Reset view")
22995 }
22996 );
22997 }
22998 function DataviewsViewConfigDropdown() {
22999 const { view, onReset } = (0, import_element55.useContext)(dataviews_context_default);
23000 const popoverId = (0, import_compose11.useInstanceId)(
23001 _DataViewsViewConfig,
23002 "dataviews-view-config-dropdown"
23003 );
23004 const activeLayout = VIEW_LAYOUTS.find(
23005 (layout) => layout.type === view.type
23006 );
23007 const isModified = typeof onReset === "function";
23008 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
23009 import_components27.Dropdown,
23010 {
23011 expandOnMobile: true,
23012 popoverProps: {
23013 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
23014 id: popoverId
23015 },
23016 renderToggle: ({ onToggle, isOpen }) => {
23017 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
23018 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
23019 import_components27.Button,
23020 {
23021 size: "compact",
23022 icon: cog_default,
23023 label: (0, import_i18n38._x)(
23024 "View options",
23025 "View is used as a noun"
23026 ),
23027 onClick: onToggle,
23028 "aria-expanded": isOpen ? "true" : "false",
23029 "aria-controls": popoverId
23030 }
23031 ),
23032 isModified && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
23033 ] });
23034 },
23035 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
23036 import_components27.__experimentalDropdownContentWrapper,
23037 {
23038 paddingSize: "medium",
23039 className: "dataviews-config__popover-content-wrapper",
23040 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
23041 Stack,
23042 {
23043 direction: "column",
23044 className: "dataviews-view-config",
23045 gap: "xl",
23046 children: [
23047 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
23048 Stack,
23049 {
23050 direction: "row",
23051 justify: "space-between",
23052 align: "center",
23053 className: "dataviews-view-config__header",
23054 children: [
23055 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
23056 import_components27.__experimentalHeading,
23057 {
23058 level: 2,
23059 className: "dataviews-settings-section__title",
23060 children: (0, import_i18n38.__)("Appearance")
23061 }
23062 ),
23063 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ResetViewButton, {})
23064 ]
23065 }
23066 ),
23067 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23068 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
23069 Stack,
23070 {
23071 direction: "row",
23072 gap: "sm",
23073 className: "dataviews-view-config__sort-controls",
23074 children: [
23075 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(SortFieldControl, {}),
23076 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(SortDirectionControl, {})
23077 ]
23078 }
23079 ),
23080 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(activeLayout.viewConfigOptions, {}),
23081 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ItemsPerPageControl, {}),
23082 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(PropertiesSection, {})
23083 ] })
23084 ]
23085 }
23086 )
23087 }
23088 )
23089 }
23090 );
23091 }
23092 function _DataViewsViewConfig() {
23093 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(import_jsx_runtime91.Fragment, { children: [
23094 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ViewTypeMenu, {}),
23095 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(DataviewsViewConfigDropdown, {})
23096 ] });
23097 }
23098 var DataViewsViewConfig = (0, import_element55.memo)(_DataViewsViewConfig);
23099 var dataviews_view_config_default = DataViewsViewConfig;
23100
23101 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
23102 var import_components28 = __toESM(require_components(), 1);
23103 var import_element56 = __toESM(require_element(), 1);
23104
23105 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
23106 function getCustomValidity(isValid2, validity) {
23107 let customValidity;
23108 if (isValid2?.required && validity?.required) {
23109 customValidity = validity?.required?.message ? validity.required : void 0;
23110 } else if (isValid2?.pattern && validity?.pattern) {
23111 customValidity = validity.pattern;
23112 } else if (isValid2?.min && validity?.min) {
23113 customValidity = validity.min;
23114 } else if (isValid2?.max && validity?.max) {
23115 customValidity = validity.max;
23116 } else if (isValid2?.minLength && validity?.minLength) {
23117 customValidity = validity.minLength;
23118 } else if (isValid2?.maxLength && validity?.maxLength) {
23119 customValidity = validity.maxLength;
23120 } else if (isValid2?.elements && validity?.elements) {
23121 customValidity = validity.elements;
23122 } else if (validity?.custom) {
23123 customValidity = validity.custom;
23124 }
23125 return customValidity;
23126 }
23127
23128 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
23129 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
23130 var { ValidatedCheckboxControl } = unlock2(import_components28.privateApis);
23131 function Checkbox({
23132 field,
23133 onChange,
23134 data,
23135 hideLabelFromVision,
23136 markWhenOptional,
23137 validity
23138 }) {
23139 const { getValue, setValue, label, description, isValid: isValid2 } = field;
23140 const disabled2 = field.isDisabled({ item: data, field });
23141 const onChangeControl = (0, import_element56.useCallback)(() => {
23142 onChange(
23143 setValue({ item: data, value: !getValue({ item: data }) })
23144 );
23145 }, [data, getValue, onChange, setValue]);
23146 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
23147 ValidatedCheckboxControl,
23148 {
23149 required: !!field.isValid?.required,
23150 markWhenOptional,
23151 customValidity: getCustomValidity(isValid2, validity),
23152 hidden: hideLabelFromVision,
23153 label,
23154 help: description,
23155 checked: getValue({ item: data }),
23156 onChange: onChangeControl,
23157 disabled: disabled2
23158 }
23159 );
23160 }
23161
23162 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
23163 var import_components29 = __toESM(require_components(), 1);
23164 var import_element57 = __toESM(require_element(), 1);
23165 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
23166 var { ValidatedComboboxControl } = unlock2(import_components29.privateApis);
23167 function Combobox3({
23168 data,
23169 field,
23170 onChange,
23171 hideLabelFromVision,
23172 validity
23173 }) {
23174 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
23175 const value = getValue({ item: data }) ?? "";
23176 const onChangeControl = (0, import_element57.useCallback)(
23177 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
23178 [data, onChange, setValue]
23179 );
23180 const { elements, isLoading } = useElements({
23181 elements: field.elements,
23182 getElements: field.getElements
23183 });
23184 if (isLoading) {
23185 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components29.Spinner, {});
23186 }
23187 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
23188 ValidatedComboboxControl,
23189 {
23190 required: !!field.isValid?.required,
23191 customValidity: getCustomValidity(isValid2, validity),
23192 label,
23193 value,
23194 help: description,
23195 placeholder,
23196 options: elements,
23197 onChange: onChangeControl,
23198 hideLabelFromVision,
23199 allowReset: true,
23200 expandOnFocus: true
23201 }
23202 );
23203 }
23204
23205 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
23206 var import_components31 = __toESM(require_components(), 1);
23207 var import_element60 = __toESM(require_element(), 1);
23208 var import_i18n40 = __toESM(require_i18n(), 1);
23209 var import_date3 = __toESM(require_date(), 1);
23210
23211 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
23212 var import_components30 = __toESM(require_components(), 1);
23213 var import_element58 = __toESM(require_element(), 1);
23214 var import_i18n39 = __toESM(require_i18n(), 1);
23215 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
23216 var TIME_UNITS_OPTIONS = {
23217 [OPERATOR_IN_THE_PAST]: [
23218 { value: "days", label: (0, import_i18n39.__)("Days") },
23219 { value: "weeks", label: (0, import_i18n39.__)("Weeks") },
23220 { value: "months", label: (0, import_i18n39.__)("Months") },
23221 { value: "years", label: (0, import_i18n39.__)("Years") }
23222 ],
23223 [OPERATOR_OVER]: [
23224 { value: "days", label: (0, import_i18n39.__)("Days ago") },
23225 { value: "weeks", label: (0, import_i18n39.__)("Weeks ago") },
23226 { value: "months", label: (0, import_i18n39.__)("Months ago") },
23227 { value: "years", label: (0, import_i18n39.__)("Years ago") }
23228 ]
23229 };
23230 function RelativeDateControl({
23231 className,
23232 data,
23233 field,
23234 onChange,
23235 hideLabelFromVision,
23236 operator
23237 }) {
23238 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
23239 const { id, label, description, getValue, setValue } = field;
23240 const disabled2 = field.isDisabled({ item: data, field });
23241 const fieldValue = getValue({ item: data });
23242 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
23243 const onChangeValue = (0, import_element58.useCallback)(
23244 (newValue) => onChange(
23245 setValue({
23246 item: data,
23247 value: { value: Number(newValue), unit }
23248 })
23249 ),
23250 [onChange, setValue, data, unit]
23251 );
23252 const onChangeUnit = (0, import_element58.useCallback)(
23253 (newUnit) => onChange(
23254 setValue({
23255 item: data,
23256 value: { value: relValue, unit: newUnit }
23257 })
23258 ),
23259 [onChange, setValue, data, relValue]
23260 );
23261 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23262 import_components30.BaseControl,
23263 {
23264 id,
23265 className: clsx_default(className, "dataviews-controls__relative-date"),
23266 label,
23267 hideLabelFromVision,
23268 help: description,
23269 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Stack, { direction: "row", gap: "sm", children: [
23270 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23271 import_components30.__experimentalNumberControl,
23272 {
23273 className: "dataviews-controls__relative-date-number",
23274 spinControls: "none",
23275 min: 1,
23276 step: 1,
23277 value: relValue,
23278 onChange: onChangeValue,
23279 disabled: disabled2
23280 }
23281 ),
23282 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23283 import_components30.SelectControl,
23284 {
23285 className: "dataviews-controls__relative-date-unit",
23286 label: (0, import_i18n39.__)("Unit"),
23287 value: unit,
23288 options,
23289 onChange: onChangeUnit,
23290 hideLabelFromVision: true,
23291 disabled: disabled2
23292 }
23293 )
23294 ] })
23295 }
23296 );
23297 }
23298
23299 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
23300 var import_element59 = __toESM(require_element(), 1);
23301 function useDisabledDateMatchers(isValid2, parseDateFn) {
23302 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
23303 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
23304 const disabledMatchers = (0, import_element59.useMemo)(() => {
23305 const matchers = [];
23306 if (minConstraint) {
23307 const minDate = parseDateFn(minConstraint);
23308 if (minDate) {
23309 matchers.push({ before: minDate });
23310 }
23311 }
23312 if (maxConstraint) {
23313 const maxDate = parseDateFn(maxConstraint);
23314 if (maxDate) {
23315 matchers.push({ after: maxDate });
23316 }
23317 }
23318 return matchers.length > 0 ? matchers : void 0;
23319 }, [minConstraint, maxConstraint, parseDateFn]);
23320 return { minConstraint, maxConstraint, disabledMatchers };
23321 }
23322
23323 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
23324 var import_date2 = __toESM(require_date(), 1);
23325 function parseDateTime(dateTimeString) {
23326 if (!dateTimeString) {
23327 return null;
23328 }
23329 const parsed = (0, import_date2.getDate)(dateTimeString);
23330 return parsed && isValid(parsed) ? parsed : null;
23331 }
23332
23333 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
23334 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
23335 var { DateCalendar, ValidatedInputControl } = unlock2(import_components31.privateApis);
23336 var formatDateTime = (value) => {
23337 if (!value) {
23338 return "";
23339 }
23340 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
23341 };
23342 function CalendarDateTimeControl({
23343 data,
23344 field,
23345 onChange,
23346 hideLabelFromVision,
23347 markWhenOptional,
23348 validity,
23349 config
23350 }) {
23351 const { compact } = config || {};
23352 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
23353 const disabled2 = field.isDisabled({ item: data, field });
23354 const fieldValue = getValue({ item: data });
23355 const value = typeof fieldValue === "string" ? fieldValue : void 0;
23356 const [calendarMonth, setCalendarMonth] = (0, import_element60.useState)(() => {
23357 const parsedDate = parseDateTime(value);
23358 return parsedDate || /* @__PURE__ */ new Date();
23359 });
23360 const inputControlRef = (0, import_element60.useRef)(null);
23361 const validationTimeoutRef = (0, import_element60.useRef)(void 0);
23362 const previousFocusRef = (0, import_element60.useRef)(null);
23363 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
23364 const onChangeCallback = (0, import_element60.useCallback)(
23365 (newValue) => onChange(setValue({ item: data, value: newValue })),
23366 [data, onChange, setValue]
23367 );
23368 (0, import_element60.useEffect)(() => {
23369 return () => {
23370 if (validationTimeoutRef.current) {
23371 clearTimeout(validationTimeoutRef.current);
23372 }
23373 };
23374 }, []);
23375 const onSelectDate = (0, import_element60.useCallback)(
23376 (newDate) => {
23377 let dateTimeValue;
23378 if (newDate) {
23379 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
23380 let wpTime;
23381 if (value) {
23382 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
23383 } else {
23384 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
23385 }
23386 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
23387 dateTimeValue = finalDateTime.toISOString();
23388 onChangeCallback(dateTimeValue);
23389 if (validationTimeoutRef.current) {
23390 clearTimeout(validationTimeoutRef.current);
23391 }
23392 } else {
23393 onChangeCallback(void 0);
23394 }
23395 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
23396 validationTimeoutRef.current = setTimeout(() => {
23397 if (inputControlRef.current) {
23398 inputControlRef.current.focus();
23399 inputControlRef.current.blur();
23400 onChangeCallback(dateTimeValue);
23401 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
23402 previousFocusRef.current.focus();
23403 }
23404 }
23405 }, 0);
23406 },
23407 [onChangeCallback, value]
23408 );
23409 const handleManualDateTimeChange = (0, import_element60.useCallback)(
23410 (newValue) => {
23411 if (newValue) {
23412 const dateTime = (0, import_date3.getDate)(newValue);
23413 onChangeCallback(dateTime.toISOString());
23414 const parsedDate = parseDateTime(dateTime.toISOString());
23415 if (parsedDate) {
23416 setCalendarMonth(parsedDate);
23417 }
23418 } else {
23419 onChangeCallback(void 0);
23420 }
23421 },
23422 [onChangeCallback]
23423 );
23424 const { format: fieldFormat } = field;
23425 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
23426 const {
23427 timezone: { string: timezoneString }
23428 } = (0, import_date3.getSettings)();
23429 let displayLabel = label;
23430 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
23431 displayLabel = `${label} (${(0, import_i18n40.__)("Required")})`;
23432 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
23433 displayLabel = `${label} (${(0, import_i18n40.__)("Optional")})`;
23434 }
23435 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23436 import_components31.BaseControl,
23437 {
23438 id,
23439 label: displayLabel,
23440 help: description,
23441 hideLabelFromVision,
23442 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23443 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23444 ValidatedInputControl,
23445 {
23446 ref: inputControlRef,
23447 required: !!isValid2?.required,
23448 customValidity: getCustomValidity(isValid2, validity),
23449 type: "datetime-local",
23450 label: (0, import_i18n40.__)("Date time"),
23451 hideLabelFromVision: true,
23452 value: formatDateTime(value),
23453 onChange: handleManualDateTimeChange,
23454 disabled: disabled2,
23455 min: minConstraint ? formatDateTime(minConstraint) : void 0,
23456 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
23457 }
23458 ),
23459 !compact && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23460 DateCalendar,
23461 {
23462 style: { width: "100%" },
23463 selected: value ? parseDateTime(value) || void 0 : void 0,
23464 onSelect: onSelectDate,
23465 month: calendarMonth,
23466 onMonthChange: setCalendarMonth,
23467 timeZone: timezoneString || void 0,
23468 weekStartsOn,
23469 disabled: disabled2 || disabledMatchers
23470 }
23471 )
23472 ] })
23473 }
23474 );
23475 }
23476 function DateTime({
23477 data,
23478 field,
23479 onChange,
23480 hideLabelFromVision,
23481 markWhenOptional,
23482 operator,
23483 validity,
23484 config
23485 }) {
23486 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23487 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23488 RelativeDateControl,
23489 {
23490 className: "dataviews-controls__datetime",
23491 data,
23492 field,
23493 onChange,
23494 hideLabelFromVision,
23495 operator
23496 }
23497 );
23498 }
23499 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23500 CalendarDateTimeControl,
23501 {
23502 data,
23503 field,
23504 onChange,
23505 hideLabelFromVision,
23506 markWhenOptional,
23507 validity,
23508 config
23509 }
23510 );
23511 }
23512
23513 // packages/dataviews/build-module/components/dataform-controls/date.mjs
23514 var import_components32 = __toESM(require_components(), 1);
23515 var import_a11y = __toESM(require_a11y(), 1);
23516 var import_element61 = __toESM(require_element(), 1);
23517 var import_i18n41 = __toESM(require_i18n(), 1);
23518 var import_date4 = __toESM(require_date(), 1);
23519 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
23520 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components32.privateApis);
23521 var DATE_PRESETS = [
23522 {
23523 id: "today",
23524 label: (0, import_i18n41.__)("Today"),
23525 getValue: () => (0, import_date4.getDate)(null)
23526 },
23527 {
23528 id: "yesterday",
23529 label: (0, import_i18n41.__)("Yesterday"),
23530 getValue: () => {
23531 const today = (0, import_date4.getDate)(null);
23532 return subDays(today, 1);
23533 }
23534 },
23535 {
23536 id: "past-week",
23537 label: (0, import_i18n41.__)("Past week"),
23538 getValue: () => {
23539 const today = (0, import_date4.getDate)(null);
23540 return subDays(today, 7);
23541 }
23542 },
23543 {
23544 id: "past-month",
23545 label: (0, import_i18n41.__)("Past month"),
23546 getValue: () => {
23547 const today = (0, import_date4.getDate)(null);
23548 return subMonths(today, 1);
23549 }
23550 }
23551 ];
23552 var DATE_RANGE_PRESETS = [
23553 {
23554 id: "last-7-days",
23555 label: (0, import_i18n41.__)("Last 7 days"),
23556 getValue: () => {
23557 const today = (0, import_date4.getDate)(null);
23558 return [subDays(today, 7), today];
23559 }
23560 },
23561 {
23562 id: "last-30-days",
23563 label: (0, import_i18n41.__)("Last 30 days"),
23564 getValue: () => {
23565 const today = (0, import_date4.getDate)(null);
23566 return [subDays(today, 30), today];
23567 }
23568 },
23569 {
23570 id: "month-to-date",
23571 label: (0, import_i18n41.__)("Month to date"),
23572 getValue: () => {
23573 const today = (0, import_date4.getDate)(null);
23574 return [startOfMonth(today), today];
23575 }
23576 },
23577 {
23578 id: "last-year",
23579 label: (0, import_i18n41.__)("Last year"),
23580 getValue: () => {
23581 const today = (0, import_date4.getDate)(null);
23582 return [subYears(today, 1), today];
23583 }
23584 },
23585 {
23586 id: "year-to-date",
23587 label: (0, import_i18n41.__)("Year to date"),
23588 getValue: () => {
23589 const today = (0, import_date4.getDate)(null);
23590 return [startOfYear(today), today];
23591 }
23592 }
23593 ];
23594 var parseDate = (dateString) => {
23595 if (!dateString) {
23596 return null;
23597 }
23598 const parsed = (0, import_date4.getDate)(dateString);
23599 return parsed && isValid(parsed) ? parsed : null;
23600 };
23601 var formatDate = (date) => {
23602 if (!date) {
23603 return "";
23604 }
23605 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
23606 };
23607 function ValidatedDateControl({
23608 field,
23609 validity,
23610 inputRefs,
23611 isTouched,
23612 setIsTouched,
23613 children
23614 }) {
23615 const { isValid: isValid2 } = field;
23616 const [customValidity, setCustomValidity] = (0, import_element61.useState)(void 0);
23617 const validateRefs = (0, import_element61.useCallback)(() => {
23618 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23619 for (const ref of refs) {
23620 const input = ref.current;
23621 if (input && !input.validity.valid) {
23622 setCustomValidity({
23623 type: "invalid",
23624 message: input.validationMessage
23625 });
23626 return;
23627 }
23628 }
23629 setCustomValidity(void 0);
23630 }, [inputRefs]);
23631 (0, import_element61.useEffect)(() => {
23632 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23633 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23634 for (const ref of refs) {
23635 const input = ref.current;
23636 if (input) {
23637 input.setCustomValidity(
23638 result?.type === "invalid" && result.message ? result.message : ""
23639 );
23640 }
23641 }
23642 }, [inputRefs, isValid2, validity]);
23643 (0, import_element61.useEffect)(() => {
23644 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23645 const handleInvalid = (event) => {
23646 event.preventDefault();
23647 setIsTouched(true);
23648 };
23649 for (const ref of refs) {
23650 ref.current?.addEventListener("invalid", handleInvalid);
23651 }
23652 return () => {
23653 for (const ref of refs) {
23654 ref.current?.removeEventListener("invalid", handleInvalid);
23655 }
23656 };
23657 }, [inputRefs, setIsTouched]);
23658 (0, import_element61.useEffect)(() => {
23659 if (!isTouched) {
23660 return;
23661 }
23662 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23663 if (result) {
23664 setCustomValidity(result);
23665 } else {
23666 validateRefs();
23667 }
23668 }, [isTouched, isValid2, validity, validateRefs]);
23669 (0, import_element61.useEffect)(() => {
23670 if (isTouched && customValidity?.message) {
23671 (0, import_a11y.speak)(customValidity.message);
23672 }
23673 }, [isTouched, customValidity?.message]);
23674 const onBlur = (event) => {
23675 if (isTouched) {
23676 return;
23677 }
23678 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
23679 setIsTouched(true);
23680 }
23681 };
23682 return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("div", { onBlur, children: [
23683 children,
23684 customValidity && /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23685 "p",
23686 {
23687 className: clsx_default(
23688 "components-validated-control__indicator",
23689 customValidity.type === "invalid" ? "is-invalid" : void 0
23690 ),
23691 children: [
23692 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23693 import_components32.Icon,
23694 {
23695 className: "components-validated-control__indicator-icon",
23696 icon: error_default,
23697 size: 16,
23698 fill: "currentColor"
23699 }
23700 ),
23701 customValidity.message
23702 ]
23703 }
23704 )
23705 ] });
23706 }
23707 function CalendarDateControl({
23708 data,
23709 field,
23710 onChange,
23711 hideLabelFromVision,
23712 markWhenOptional,
23713 validity
23714 }) {
23715 const {
23716 id,
23717 label,
23718 description,
23719 setValue,
23720 getValue,
23721 isValid: isValid2,
23722 format: fieldFormat
23723 } = field;
23724 const disabled2 = field.isDisabled({ item: data, field });
23725 const [selectedPresetId, setSelectedPresetId] = (0, import_element61.useState)(
23726 null
23727 );
23728 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23729 const fieldValue = getValue({ item: data });
23730 const value = typeof fieldValue === "string" ? fieldValue : void 0;
23731 const [calendarMonth, setCalendarMonth] = (0, import_element61.useState)(() => {
23732 const parsedDate = parseDate(value);
23733 return parsedDate || /* @__PURE__ */ new Date();
23734 });
23735 const [isTouched, setIsTouched] = (0, import_element61.useState)(false);
23736 const validityTargetRef = (0, import_element61.useRef)(null);
23737 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23738 const onChangeCallback = (0, import_element61.useCallback)(
23739 (newValue) => onChange(setValue({ item: data, value: newValue })),
23740 [data, onChange, setValue]
23741 );
23742 const onSelectDate = (0, import_element61.useCallback)(
23743 (newDate) => {
23744 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
23745 onChangeCallback(dateValue);
23746 setSelectedPresetId(null);
23747 setIsTouched(true);
23748 },
23749 [onChangeCallback]
23750 );
23751 const handlePresetClick = (0, import_element61.useCallback)(
23752 (preset) => {
23753 const presetDate = preset.getValue();
23754 const dateValue = formatDate(presetDate);
23755 setCalendarMonth(presetDate);
23756 onChangeCallback(dateValue);
23757 setSelectedPresetId(preset.id);
23758 setIsTouched(true);
23759 },
23760 [onChangeCallback]
23761 );
23762 const handleManualDateChange = (0, import_element61.useCallback)(
23763 (newValue) => {
23764 onChangeCallback(newValue);
23765 if (newValue) {
23766 const parsedDate = parseDate(newValue);
23767 if (parsedDate) {
23768 setCalendarMonth(parsedDate);
23769 }
23770 }
23771 setSelectedPresetId(null);
23772 setIsTouched(true);
23773 },
23774 [onChangeCallback]
23775 );
23776 const {
23777 timezone: { string: timezoneString }
23778 } = (0, import_date4.getSettings)();
23779 let displayLabel = label;
23780 if (isValid2?.required && !markWhenOptional) {
23781 displayLabel = `${label} (${(0, import_i18n41.__)("Required")})`;
23782 } else if (!isValid2?.required && markWhenOptional) {
23783 displayLabel = `${label} (${(0, import_i18n41.__)("Optional")})`;
23784 }
23785 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23786 ValidatedDateControl,
23787 {
23788 field,
23789 validity,
23790 inputRefs: validityTargetRef,
23791 isTouched,
23792 setIsTouched,
23793 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23794 import_components32.BaseControl,
23795 {
23796 id,
23797 className: "dataviews-controls__date",
23798 label: displayLabel,
23799 help: description,
23800 hideLabelFromVision,
23801 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23802 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23803 Stack,
23804 {
23805 direction: "row",
23806 gap: "sm",
23807 wrap: "wrap",
23808 justify: "flex-start",
23809 children: [
23810 DATE_PRESETS.map((preset) => {
23811 const isSelected2 = selectedPresetId === preset.id;
23812 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23813 import_components32.Button,
23814 {
23815 className: "dataviews-controls__date-preset",
23816 variant: "tertiary",
23817 isPressed: isSelected2,
23818 size: "small",
23819 disabled: disabled2,
23820 accessibleWhenDisabled: true,
23821 onClick: () => handlePresetClick(preset),
23822 children: preset.label
23823 },
23824 preset.id
23825 );
23826 }),
23827 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23828 import_components32.Button,
23829 {
23830 className: "dataviews-controls__date-preset",
23831 variant: "tertiary",
23832 isPressed: !selectedPresetId,
23833 size: "small",
23834 disabled: !!selectedPresetId || disabled2,
23835 accessibleWhenDisabled: true,
23836 children: (0, import_i18n41.__)("Custom")
23837 }
23838 )
23839 ]
23840 }
23841 ),
23842 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23843 import_components32.__experimentalInputControl,
23844 {
23845 ref: validityTargetRef,
23846 type: "date",
23847 label: (0, import_i18n41.__)("Date"),
23848 hideLabelFromVision: true,
23849 value,
23850 onChange: handleManualDateChange,
23851 required: !!field.isValid?.required,
23852 disabled: disabled2,
23853 min: minConstraint,
23854 max: maxConstraint
23855 }
23856 ),
23857 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23858 DateCalendar2,
23859 {
23860 style: { width: "100%" },
23861 selected: value ? parseDate(value) || void 0 : void 0,
23862 onSelect: onSelectDate,
23863 month: calendarMonth,
23864 onMonthChange: setCalendarMonth,
23865 timeZone: timezoneString || void 0,
23866 weekStartsOn,
23867 disabled: disabled2 || disabledMatchers,
23868 disableNavigation: disabled2
23869 }
23870 )
23871 ] })
23872 }
23873 )
23874 }
23875 );
23876 }
23877 function CalendarDateRangeControl({
23878 data,
23879 field,
23880 onChange,
23881 hideLabelFromVision,
23882 markWhenOptional,
23883 validity
23884 }) {
23885 const {
23886 id,
23887 label,
23888 description,
23889 getValue,
23890 setValue,
23891 isValid: isValid2,
23892 format: fieldFormat
23893 } = field;
23894 const disabled2 = field.isDisabled({ item: data, field });
23895 let value;
23896 const fieldValue = getValue({ item: data });
23897 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
23898 value = fieldValue;
23899 }
23900 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23901 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23902 const onChangeCallback = (0, import_element61.useCallback)(
23903 (newValue) => {
23904 onChange(
23905 setValue({
23906 item: data,
23907 value: newValue
23908 })
23909 );
23910 },
23911 [data, onChange, setValue]
23912 );
23913 const [selectedPresetId, setSelectedPresetId] = (0, import_element61.useState)(
23914 null
23915 );
23916 const selectedRange = (0, import_element61.useMemo)(() => {
23917 if (!value) {
23918 return { from: void 0, to: void 0 };
23919 }
23920 const [from, to] = value;
23921 return {
23922 from: parseDate(from) || void 0,
23923 to: parseDate(to) || void 0
23924 };
23925 }, [value]);
23926 const [calendarMonth, setCalendarMonth] = (0, import_element61.useState)(() => {
23927 return selectedRange.from || /* @__PURE__ */ new Date();
23928 });
23929 const [isTouched, setIsTouched] = (0, import_element61.useState)(false);
23930 const fromInputRef = (0, import_element61.useRef)(null);
23931 const toInputRef = (0, import_element61.useRef)(null);
23932 const updateDateRange = (0, import_element61.useCallback)(
23933 (fromDate, toDate2) => {
23934 if (fromDate && toDate2) {
23935 onChangeCallback([
23936 formatDate(fromDate),
23937 formatDate(toDate2)
23938 ]);
23939 } else if (!fromDate && !toDate2) {
23940 onChangeCallback(void 0);
23941 }
23942 },
23943 [onChangeCallback]
23944 );
23945 const onSelectCalendarRange = (0, import_element61.useCallback)(
23946 (newRange) => {
23947 updateDateRange(newRange?.from, newRange?.to);
23948 setSelectedPresetId(null);
23949 setIsTouched(true);
23950 },
23951 [updateDateRange]
23952 );
23953 const handlePresetClick = (0, import_element61.useCallback)(
23954 (preset) => {
23955 const [startDate, endDate] = preset.getValue();
23956 setCalendarMonth(startDate);
23957 updateDateRange(startDate, endDate);
23958 setSelectedPresetId(preset.id);
23959 setIsTouched(true);
23960 },
23961 [updateDateRange]
23962 );
23963 const handleManualDateChange = (0, import_element61.useCallback)(
23964 (fromOrTo, newValue) => {
23965 const [currentFrom, currentTo] = value || [
23966 void 0,
23967 void 0
23968 ];
23969 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
23970 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
23971 updateDateRange(updatedFrom, updatedTo);
23972 if (newValue) {
23973 const parsedDate = parseDate(newValue);
23974 if (parsedDate) {
23975 setCalendarMonth(parsedDate);
23976 }
23977 }
23978 setSelectedPresetId(null);
23979 setIsTouched(true);
23980 },
23981 [value, updateDateRange]
23982 );
23983 const { timezone } = (0, import_date4.getSettings)();
23984 let displayLabel = label;
23985 if (field.isValid?.required && !markWhenOptional) {
23986 displayLabel = `${label} (${(0, import_i18n41.__)("Required")})`;
23987 } else if (!field.isValid?.required && markWhenOptional) {
23988 displayLabel = `${label} (${(0, import_i18n41.__)("Optional")})`;
23989 }
23990 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23991 ValidatedDateControl,
23992 {
23993 field,
23994 validity,
23995 inputRefs: [fromInputRef, toInputRef],
23996 isTouched,
23997 setIsTouched,
23998 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23999 import_components32.BaseControl,
24000 {
24001 id,
24002 className: "dataviews-controls__date",
24003 label: displayLabel,
24004 help: description,
24005 hideLabelFromVision,
24006 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "column", gap: "lg", children: [
24007 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
24008 Stack,
24009 {
24010 direction: "row",
24011 gap: "sm",
24012 wrap: "wrap",
24013 justify: "flex-start",
24014 children: [
24015 DATE_RANGE_PRESETS.map((preset) => {
24016 const isSelected2 = selectedPresetId === preset.id;
24017 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24018 import_components32.Button,
24019 {
24020 className: "dataviews-controls__date-preset",
24021 variant: "tertiary",
24022 isPressed: isSelected2,
24023 size: "small",
24024 disabled: disabled2,
24025 accessibleWhenDisabled: true,
24026 onClick: () => handlePresetClick(preset),
24027 children: preset.label
24028 },
24029 preset.id
24030 );
24031 }),
24032 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24033 import_components32.Button,
24034 {
24035 className: "dataviews-controls__date-preset",
24036 variant: "tertiary",
24037 isPressed: !selectedPresetId,
24038 size: "small",
24039 accessibleWhenDisabled: true,
24040 disabled: !!selectedPresetId || disabled2,
24041 children: (0, import_i18n41.__)("Custom")
24042 }
24043 )
24044 ]
24045 }
24046 ),
24047 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
24048 Stack,
24049 {
24050 direction: "row",
24051 gap: "sm",
24052 justify: "space-between",
24053 className: "dataviews-controls__date-range-inputs",
24054 children: [
24055 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24056 import_components32.__experimentalInputControl,
24057 {
24058 ref: fromInputRef,
24059 type: "date",
24060 label: (0, import_i18n41.__)("From"),
24061 hideLabelFromVision: true,
24062 value: value?.[0],
24063 onChange: (newValue) => handleManualDateChange("from", newValue),
24064 required: !!field.isValid?.required,
24065 disabled: disabled2,
24066 min: minConstraint,
24067 max: maxConstraint
24068 }
24069 ),
24070 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24071 import_components32.__experimentalInputControl,
24072 {
24073 ref: toInputRef,
24074 type: "date",
24075 label: (0, import_i18n41.__)("To"),
24076 hideLabelFromVision: true,
24077 value: value?.[1],
24078 onChange: (newValue) => handleManualDateChange("to", newValue),
24079 required: !!field.isValid?.required,
24080 disabled: disabled2,
24081 min: minConstraint,
24082 max: maxConstraint
24083 }
24084 )
24085 ]
24086 }
24087 ),
24088 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24089 DateRangeCalendar,
24090 {
24091 style: { width: "100%" },
24092 selected: selectedRange,
24093 onSelect: onSelectCalendarRange,
24094 month: calendarMonth,
24095 onMonthChange: setCalendarMonth,
24096 timeZone: timezone.string || void 0,
24097 weekStartsOn,
24098 disabled: disabled2 || disabledMatchers
24099 }
24100 )
24101 ] })
24102 }
24103 )
24104 }
24105 );
24106 }
24107 function DateControl({
24108 data,
24109 field,
24110 onChange,
24111 hideLabelFromVision,
24112 markWhenOptional,
24113 operator,
24114 validity
24115 }) {
24116 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
24117 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24118 RelativeDateControl,
24119 {
24120 className: "dataviews-controls__date",
24121 data,
24122 field,
24123 onChange,
24124 hideLabelFromVision,
24125 operator
24126 }
24127 );
24128 }
24129 if (operator === OPERATOR_BETWEEN) {
24130 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24131 CalendarDateRangeControl,
24132 {
24133 data,
24134 field,
24135 onChange,
24136 hideLabelFromVision,
24137 markWhenOptional,
24138 validity
24139 }
24140 );
24141 }
24142 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
24143 CalendarDateControl,
24144 {
24145 data,
24146 field,
24147 onChange,
24148 hideLabelFromVision,
24149 markWhenOptional,
24150 validity
24151 }
24152 );
24153 }
24154
24155 // packages/dataviews/build-module/components/dataform-controls/select.mjs
24156 var import_components33 = __toESM(require_components(), 1);
24157 var import_element62 = __toESM(require_element(), 1);
24158 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
24159 var { ValidatedSelectControl } = unlock2(import_components33.privateApis);
24160 function Select({
24161 data,
24162 field,
24163 onChange,
24164 hideLabelFromVision,
24165 markWhenOptional,
24166 validity
24167 }) {
24168 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
24169 const disabled2 = field.isDisabled({ item: data, field });
24170 const isMultiple = type === "array";
24171 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
24172 const onChangeControl = (0, import_element62.useCallback)(
24173 (newValue) => onChange(setValue({ item: data, value: newValue })),
24174 [data, onChange, setValue]
24175 );
24176 const { elements, isLoading } = useElements({
24177 elements: field.elements,
24178 getElements: field.getElements
24179 });
24180 if (isLoading) {
24181 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components33.Spinner, {});
24182 }
24183 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
24184 ValidatedSelectControl,
24185 {
24186 required: !!field.isValid?.required,
24187 markWhenOptional,
24188 customValidity: getCustomValidity(isValid2, validity),
24189 label,
24190 value,
24191 help: description,
24192 options: elements,
24193 onChange: onChangeControl,
24194 hideLabelFromVision,
24195 multiple: isMultiple,
24196 disabled: disabled2
24197 }
24198 );
24199 }
24200
24201 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
24202 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
24203 var ELEMENTS_THRESHOLD = 10;
24204 function AdaptiveSelect(props) {
24205 const { field } = props;
24206 const { elements } = useElements({
24207 elements: field.elements,
24208 getElements: field.getElements
24209 });
24210 if (elements.length >= ELEMENTS_THRESHOLD) {
24211 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Combobox3, { ...props });
24212 }
24213 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Select, { ...props });
24214 }
24215
24216 // packages/dataviews/build-module/components/dataform-controls/email.mjs
24217 var import_components35 = __toESM(require_components(), 1);
24218
24219 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
24220 var import_components34 = __toESM(require_components(), 1);
24221 var import_element63 = __toESM(require_element(), 1);
24222 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
24223 var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components34.privateApis);
24224 function ValidatedText({
24225 data,
24226 field,
24227 onChange,
24228 hideLabelFromVision,
24229 markWhenOptional,
24230 type,
24231 prefix,
24232 suffix,
24233 validity
24234 }) {
24235 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
24236 const value = getValue({ item: data });
24237 const disabled2 = field.isDisabled({ item: data, field });
24238 const onChangeControl = (0, import_element63.useCallback)(
24239 (newValue) => onChange(
24240 setValue({
24241 item: data,
24242 value: newValue
24243 })
24244 ),
24245 [data, setValue, onChange]
24246 );
24247 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
24248 ValidatedInputControl2,
24249 {
24250 required: !!isValid2.required,
24251 markWhenOptional,
24252 customValidity: getCustomValidity(isValid2, validity),
24253 label,
24254 placeholder,
24255 value: value ?? "",
24256 help: description,
24257 onChange: onChangeControl,
24258 hideLabelFromVision,
24259 type,
24260 prefix,
24261 suffix,
24262 disabled: disabled2,
24263 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
24264 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
24265 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0
24266 }
24267 );
24268 }
24269
24270 // packages/dataviews/build-module/components/dataform-controls/email.mjs
24271 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
24272 function Email({
24273 data,
24274 field,
24275 onChange,
24276 hideLabelFromVision,
24277 markWhenOptional,
24278 validity
24279 }) {
24280 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24281 ValidatedText,
24282 {
24283 ...{
24284 data,
24285 field,
24286 onChange,
24287 hideLabelFromVision,
24288 markWhenOptional,
24289 validity,
24290 type: "email",
24291 prefix: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components35.Icon, { icon: envelope_default }) })
24292 }
24293 }
24294 );
24295 }
24296
24297 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
24298 var import_components36 = __toESM(require_components(), 1);
24299 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
24300 function Telephone({
24301 data,
24302 field,
24303 onChange,
24304 hideLabelFromVision,
24305 markWhenOptional,
24306 validity
24307 }) {
24308 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24309 ValidatedText,
24310 {
24311 ...{
24312 data,
24313 field,
24314 onChange,
24315 hideLabelFromVision,
24316 markWhenOptional,
24317 validity,
24318 type: "tel",
24319 prefix: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components36.Icon, { icon: mobile_default }) })
24320 }
24321 }
24322 );
24323 }
24324
24325 // packages/dataviews/build-module/components/dataform-controls/url.mjs
24326 var import_components37 = __toESM(require_components(), 1);
24327 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
24328 function Url({
24329 data,
24330 field,
24331 onChange,
24332 hideLabelFromVision,
24333 markWhenOptional,
24334 validity
24335 }) {
24336 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
24337 ValidatedText,
24338 {
24339 ...{
24340 data,
24341 field,
24342 onChange,
24343 hideLabelFromVision,
24344 markWhenOptional,
24345 validity,
24346 type: "url",
24347 prefix: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components37.Icon, { icon: link_default }) })
24348 }
24349 }
24350 );
24351 }
24352
24353 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
24354 var import_components38 = __toESM(require_components(), 1);
24355 var import_element64 = __toESM(require_element(), 1);
24356 var import_i18n42 = __toESM(require_i18n(), 1);
24357 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
24358 var { ValidatedNumberControl } = unlock2(import_components38.privateApis);
24359 function toNumberOrEmpty(value) {
24360 if (value === "" || value === void 0) {
24361 return "";
24362 }
24363 const number = Number(value);
24364 return Number.isFinite(number) ? number : "";
24365 }
24366 function BetweenControls({
24367 value,
24368 onChange,
24369 hideLabelFromVision,
24370 step
24371 }) {
24372 const [min2 = "", max2 = ""] = value;
24373 const onChangeMin = (0, import_element64.useCallback)(
24374 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
24375 [onChange, max2]
24376 );
24377 const onChangeMax = (0, import_element64.useCallback)(
24378 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
24379 [onChange, min2]
24380 );
24381 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24382 import_components38.BaseControl,
24383 {
24384 help: (0, import_i18n42.__)("The max. value must be greater than the min. value."),
24385 children: /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(import_components38.Flex, { direction: "row", gap: 4, children: [
24386 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24387 import_components38.__experimentalNumberControl,
24388 {
24389 label: (0, import_i18n42.__)("Min."),
24390 value: min2,
24391 max: max2 ? Number(max2) - step : void 0,
24392 onChange: onChangeMin,
24393 hideLabelFromVision,
24394 step
24395 }
24396 ),
24397 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24398 import_components38.__experimentalNumberControl,
24399 {
24400 label: (0, import_i18n42.__)("Max."),
24401 value: max2,
24402 min: min2 ? Number(min2) + step : void 0,
24403 onChange: onChangeMax,
24404 hideLabelFromVision,
24405 step
24406 }
24407 )
24408 ] })
24409 }
24410 );
24411 }
24412 function ValidatedNumber({
24413 data,
24414 field,
24415 onChange,
24416 hideLabelFromVision,
24417 markWhenOptional,
24418 operator,
24419 validity
24420 }) {
24421 const decimals = field.format?.decimals ?? 0;
24422 const step = Math.pow(10, Math.abs(decimals) * -1);
24423 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24424 const value = getValue({ item: data }) ?? "";
24425 const disabled2 = field.isDisabled({ item: data, field });
24426 const onChangeControl = (0, import_element64.useCallback)(
24427 (newValue) => {
24428 onChange(
24429 setValue({
24430 item: data,
24431 // Do not convert an empty string or undefined to a number,
24432 // otherwise there's a mismatch between the UI control (empty)
24433 // and the data relied by onChange (0).
24434 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
24435 })
24436 );
24437 },
24438 [data, onChange, setValue]
24439 );
24440 const onChangeBetweenControls = (0, import_element64.useCallback)(
24441 (newValue) => {
24442 onChange(
24443 setValue({
24444 item: data,
24445 value: newValue
24446 })
24447 );
24448 },
24449 [data, onChange, setValue]
24450 );
24451 if (operator === OPERATOR_BETWEEN) {
24452 let valueBetween = ["", ""];
24453 if (Array.isArray(value) && value.length === 2 && value.every(
24454 (element) => typeof element === "number" || element === ""
24455 )) {
24456 valueBetween = value;
24457 }
24458 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24459 BetweenControls,
24460 {
24461 value: valueBetween,
24462 onChange: onChangeBetweenControls,
24463 hideLabelFromVision,
24464 step
24465 }
24466 );
24467 }
24468 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24469 ValidatedNumberControl,
24470 {
24471 required: !!isValid2.required,
24472 markWhenOptional,
24473 customValidity: getCustomValidity(isValid2, validity),
24474 label,
24475 help: description,
24476 value,
24477 onChange: onChangeControl,
24478 hideLabelFromVision,
24479 step,
24480 min: isValid2.min ? isValid2.min.constraint : void 0,
24481 max: isValid2.max ? isValid2.max.constraint : void 0,
24482 disabled: disabled2
24483 }
24484 );
24485 }
24486
24487 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
24488 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
24489 function Integer(props) {
24490 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(ValidatedNumber, { ...props });
24491 }
24492
24493 // packages/dataviews/build-module/components/dataform-controls/number.mjs
24494 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
24495 function Number2(props) {
24496 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(ValidatedNumber, { ...props });
24497 }
24498
24499 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
24500 var import_components39 = __toESM(require_components(), 1);
24501 var import_element65 = __toESM(require_element(), 1);
24502 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
24503 var { ValidatedRadioControl } = unlock2(import_components39.privateApis);
24504 function Radio({
24505 data,
24506 field,
24507 onChange,
24508 hideLabelFromVision,
24509 markWhenOptional,
24510 validity
24511 }) {
24512 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24513 const disabled2 = field.isDisabled({ item: data, field });
24514 const { elements, isLoading } = useElements({
24515 elements: field.elements,
24516 getElements: field.getElements
24517 });
24518 const value = getValue({ item: data });
24519 const onChangeControl = (0, import_element65.useCallback)(
24520 (newValue) => onChange(setValue({ item: data, value: newValue })),
24521 [data, onChange, setValue]
24522 );
24523 if (isLoading) {
24524 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components39.Spinner, {});
24525 }
24526 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
24527 ValidatedRadioControl,
24528 {
24529 required: !!field.isValid?.required,
24530 markWhenOptional,
24531 customValidity: getCustomValidity(isValid2, validity),
24532 label,
24533 help: description,
24534 onChange: onChangeControl,
24535 options: elements,
24536 selected: value,
24537 hideLabelFromVision,
24538 disabled: disabled2
24539 }
24540 );
24541 }
24542
24543 // packages/dataviews/build-module/components/dataform-controls/text.mjs
24544 var import_element66 = __toESM(require_element(), 1);
24545 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
24546 function Text({
24547 data,
24548 field,
24549 onChange,
24550 hideLabelFromVision,
24551 markWhenOptional,
24552 config,
24553 validity
24554 }) {
24555 const { prefix, suffix } = config || {};
24556 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
24557 ValidatedText,
24558 {
24559 ...{
24560 data,
24561 field,
24562 onChange,
24563 hideLabelFromVision,
24564 markWhenOptional,
24565 validity,
24566 prefix: prefix ? (0, import_element66.createElement)(prefix) : void 0,
24567 suffix: suffix ? (0, import_element66.createElement)(suffix) : void 0
24568 }
24569 }
24570 );
24571 }
24572
24573 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
24574 var import_components40 = __toESM(require_components(), 1);
24575 var import_element67 = __toESM(require_element(), 1);
24576 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
24577 var { ValidatedToggleControl } = unlock2(import_components40.privateApis);
24578 function Toggle({
24579 field,
24580 onChange,
24581 data,
24582 hideLabelFromVision,
24583 markWhenOptional,
24584 validity
24585 }) {
24586 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24587 const disabled2 = field.isDisabled({ item: data, field });
24588 const onChangeControl = (0, import_element67.useCallback)(() => {
24589 onChange(
24590 setValue({ item: data, value: !getValue({ item: data }) })
24591 );
24592 }, [onChange, setValue, data, getValue]);
24593 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24594 ValidatedToggleControl,
24595 {
24596 required: !!isValid2.required,
24597 markWhenOptional,
24598 customValidity: getCustomValidity(isValid2, validity),
24599 hidden: hideLabelFromVision,
24600 label,
24601 help: description,
24602 checked: getValue({ item: data }),
24603 onChange: onChangeControl,
24604 disabled: disabled2
24605 }
24606 );
24607 }
24608
24609 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
24610 var import_components41 = __toESM(require_components(), 1);
24611 var import_element68 = __toESM(require_element(), 1);
24612 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
24613 var { ValidatedTextareaControl } = unlock2(import_components41.privateApis);
24614 function Textarea({
24615 data,
24616 field,
24617 onChange,
24618 hideLabelFromVision,
24619 markWhenOptional,
24620 config,
24621 validity
24622 }) {
24623 const { rows = 4 } = config || {};
24624 const disabled2 = field.isDisabled({ item: data, field });
24625 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24626 const value = field.getValue({ item: data });
24627 const onChangeControl = (0, import_element68.useCallback)(
24628 (newValue) => onChange(setValue({ item: data, value: newValue })),
24629 [data, onChange, setValue]
24630 );
24631 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24632 ValidatedTextareaControl,
24633 {
24634 required: !!isValid2.required,
24635 markWhenOptional,
24636 customValidity: getCustomValidity(isValid2, validity),
24637 label,
24638 placeholder,
24639 value: value ?? "",
24640 help: description,
24641 onChange: onChangeControl,
24642 rows,
24643 disabled: disabled2,
24644 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
24645 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
24646 hideLabelFromVision
24647 }
24648 );
24649 }
24650
24651 // packages/dataviews/build-module/components/dataform-controls/richtext/index.mjs
24652 var import_element70 = __toESM(require_element(), 1);
24653
24654 // packages/dataviews/build-module/components/dataform-controls/richtext/control.mjs
24655 var import_components42 = __toESM(require_components(), 1);
24656 var import_compose12 = __toESM(require_compose(), 1);
24657 var import_element69 = __toESM(require_element(), 1);
24658 var import_rich_text2 = __toESM(require_rich_text(), 1);
24659
24660 // packages/dataviews/build-module/components/dataform-controls/richtext/utils.mjs
24661 var EMPTY_ARRAY5 = [];
24662 function getAllowedFormats({
24663 allowedFormats,
24664 disableFormats
24665 }) {
24666 if (disableFormats) {
24667 return EMPTY_ARRAY5;
24668 }
24669 return allowedFormats;
24670 }
24671
24672 // packages/dataviews/build-module/components/dataform-controls/richtext/format-edit.mjs
24673 var import_rich_text = __toESM(require_rich_text(), 1);
24674 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
24675 var import_react24 = __toESM(require_react(), 1);
24676 var EMPTY_CONTEXT = {};
24677 function Edit({
24678 onChange,
24679 onFocus,
24680 value,
24681 forwardedRef,
24682 settings,
24683 isVisible: isVisible2
24684 }) {
24685 const { name, edit: EditFunction } = settings;
24686 if (!EditFunction) {
24687 return null;
24688 }
24689 const activeFormat = (0, import_rich_text.getActiveFormat)(value, name);
24690 const isActive = activeFormat !== void 0;
24691 const activeObject = (0, import_rich_text.getActiveObject)(value);
24692 const isObjectActive = activeObject !== void 0 && activeObject.type === name;
24693 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
24694 EditFunction,
24695 {
24696 isActive,
24697 isVisible: isVisible2,
24698 activeAttributes: isActive ? activeFormat.attributes || {} : {},
24699 isObjectActive,
24700 activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {},
24701 value,
24702 onChange,
24703 onFocus,
24704 contentRef: forwardedRef,
24705 context: EMPTY_CONTEXT
24706 },
24707 name
24708 );
24709 }
24710 function FormatEdit({
24711 formatTypes,
24712 ...props
24713 }) {
24714 return formatTypes.map((settings) => /* @__PURE__ */ (0, import_react24.createElement)(Edit, { settings, ...props, key: settings.name }));
24715 }
24716
24717 // packages/dataviews/build-module/components/dataform-controls/richtext/control.mjs
24718 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
24719 var {
24720 ValidatedContentEditableControl: RichTextControlShell,
24721 withIgnoreIMEEvents
24722 } = unlock2(import_components42.privateApis);
24723 var {
24724 useRichText,
24725 KeyboardShortcutContext,
24726 InputEventContext,
24727 shortcutsListener,
24728 inputEventsListener
24729 } = unlock2(import_rich_text2.privateApis);
24730 var EMPTY_COMPLETERS = [];
24731 function RichTextControl({
24732 label,
24733 value: attrValue,
24734 onChange,
24735 placeholder,
24736 id,
24737 clientId,
24738 className,
24739 hideLabelFromVision,
24740 help,
24741 disabled: disabled2,
24742 required,
24743 markWhenOptional,
24744 customValidity,
24745 allowedFormats,
24746 disableFormats,
24747 withoutInteractiveFormatting,
24748 preserveWhiteSpace,
24749 disableLineBreaks,
24750 focusOnMount,
24751 completers = EMPTY_COMPLETERS
24752 }) {
24753 const [selection, setSelection] = (0, import_element69.useState)({
24754 start: void 0,
24755 end: void 0
24756 });
24757 const [isSelected2, setIsSelected] = (0, import_element69.useState)(false);
24758 const anchorRef = (0, import_element69.useRef)(void 0);
24759 const inputEvents = (0, import_element69.useRef)(/* @__PURE__ */ new Set());
24760 const keyboardShortcuts = (0, import_element69.useRef)(
24761 /* @__PURE__ */ new Set()
24762 );
24763 const focusOutside = (0, import_compose12.__experimentalUseFocusOutside)(() => setIsSelected(false));
24764 const adjustedAllowedFormats = getAllowedFormats({
24765 allowedFormats,
24766 disableFormats
24767 });
24768 const {
24769 value,
24770 onChange: onRichTextChange,
24771 ref: richTextRef,
24772 formatTypes,
24773 getValue
24774 } = useRichText({
24775 value: attrValue,
24776 onChange,
24777 selectionStart: selection.start,
24778 selectionEnd: selection.end,
24779 onSelectionChange: (start, end) => setSelection({ start, end }),
24780 __unstableIsSelected: isSelected2,
24781 preserveWhiteSpace: !!preserveWhiteSpace,
24782 placeholder,
24783 __unstableDisableFormats: disableFormats,
24784 allowedFormats: adjustedAllowedFormats,
24785 withoutInteractiveFormatting,
24786 __unstableFormatTypeHandlerContext: (0, import_element69.useMemo)(
24787 () => ({
24788 richTextIdentifier: id,
24789 blockClientId: clientId
24790 }),
24791 [id, clientId]
24792 )
24793 });
24794 function onFocus() {
24795 anchorRef.current?.focus();
24796 }
24797 const eventListenersPropsRef = (0, import_element69.useRef)({
24798 keyboardShortcuts,
24799 inputEvents
24800 });
24801 const inputRulePropsRef = (0, import_element69.useRef)({
24802 formatTypes,
24803 getValue,
24804 onChange: onRichTextChange
24805 });
24806 (0, import_element69.useInsertionEffect)(() => {
24807 inputRulePropsRef.current = {
24808 formatTypes,
24809 getValue,
24810 onChange: onRichTextChange
24811 };
24812 });
24813 const enterRef = (0, import_compose12.useRefEffect)(
24814 (element) => {
24815 if (disabled2) {
24816 return;
24817 }
24818 const onKeyDown = withIgnoreIMEEvents((event) => {
24819 if (event.key !== "Enter" || event.defaultPrevented || event.metaKey || event.ctrlKey) {
24820 return;
24821 }
24822 event.preventDefault();
24823 if (disableLineBreaks) {
24824 return;
24825 }
24826 const { getValue: getCurrentValue2, onChange: handleChange } = inputRulePropsRef.current;
24827 const current = getCurrentValue2();
24828 handleChange(
24829 (0, import_rich_text2.insert)(
24830 current,
24831 "\n",
24832 current.start ?? current.text.length,
24833 current.end ?? current.text.length
24834 )
24835 );
24836 });
24837 element.addEventListener("keydown", onKeyDown);
24838 return () => element.removeEventListener("keydown", onKeyDown);
24839 },
24840 [disableLineBreaks, disabled2]
24841 );
24842 const eventListenersRef = (0, import_compose12.useRefEffect)(
24843 (element) => {
24844 if (!isSelected2) {
24845 return;
24846 }
24847 const cleanupShortcuts = shortcutsListener(
24848 eventListenersPropsRef
24849 )(element);
24850 const cleanupInputEvents = inputEventsListener(
24851 eventListenersPropsRef
24852 )(element);
24853 function onFormatInput(event) {
24854 if (event.inputType !== "insertText" && event.type !== "compositionend") {
24855 return;
24856 }
24857 const {
24858 formatTypes: types,
24859 getValue: getCurrentValue2,
24860 onChange: handleChange
24861 } = inputRulePropsRef.current;
24862 const current = getCurrentValue2();
24863 const transformed = types.reduce(
24864 (accumulator, {
24865 __unstableInputRule
24866 }) => __unstableInputRule ? __unstableInputRule(accumulator) : accumulator,
24867 current
24868 );
24869 if (transformed !== current) {
24870 handleChange({
24871 ...transformed,
24872 activeFormats: current.activeFormats
24873 });
24874 }
24875 }
24876 element.addEventListener("input", onFormatInput);
24877 element.addEventListener("compositionend", onFormatInput);
24878 return () => {
24879 cleanupShortcuts();
24880 cleanupInputEvents();
24881 element.removeEventListener("input", onFormatInput);
24882 element.removeEventListener("compositionend", onFormatInput);
24883 };
24884 },
24885 [isSelected2]
24886 );
24887 const { ref: autocompleteRef, ...autocompleteProps } = (0, import_components42.__unstableUseAutocompleteProps)(
24888 {
24889 completers,
24890 record: value,
24891 onChange: onRichTextChange,
24892 // This control's completers insert their completion into the value;
24893 // none replace the whole value, so the required `onReplace` is a
24894 // no-op here.
24895 onReplace: () => {
24896 }
24897 }
24898 );
24899 const focusOnMountRef = (0, import_compose12.useRefEffect)(
24900 (element) => {
24901 if (focusOnMount && !disabled2) {
24902 element.focus();
24903 }
24904 },
24905 [focusOnMount, disabled2]
24906 );
24907 const editableRef = (0, import_compose12.useMergeRefs)([
24908 richTextRef,
24909 anchorRef,
24910 eventListenersRef,
24911 enterRef,
24912 focusOnMountRef,
24913 autocompleteRef
24914 ]);
24915 return (
24916 // Focus boundary for the field's selection: `onFocus` selects on entry;
24917 // the spread `useFocusOutside` handlers deselect once focus leaves.
24918 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24919 "div",
24920 {
24921 ...focusOutside,
24922 onFocus: (event) => {
24923 setIsSelected(true);
24924 focusOutside.onFocus(event);
24925 },
24926 children: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(import_components42.SlotFillProvider, { children: [
24927 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24928 RichTextControlShell,
24929 {
24930 label,
24931 id,
24932 className: clsx_default(
24933 "dataviews-controls__richtext",
24934 className
24935 ),
24936 placeholder,
24937 hideLabelFromVision,
24938 help,
24939 disabled: disabled2,
24940 required,
24941 markWhenOptional,
24942 customValidity,
24943 value: value.text,
24944 "aria-multiline": !disableLineBreaks,
24945 ...autocompleteProps,
24946 ref: editableRef
24947 }
24948 ),
24949 isSelected2 && !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24950 KeyboardShortcutContext.Provider,
24951 {
24952 value: keyboardShortcuts,
24953 children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(InputEventContext.Provider, { value: inputEvents, children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24954 FormatEdit,
24955 {
24956 value,
24957 onChange: onRichTextChange,
24958 onFocus,
24959 formatTypes,
24960 forwardedRef: anchorRef,
24961 isVisible: true
24962 }
24963 ) })
24964 }
24965 )
24966 ] })
24967 }
24968 )
24969 );
24970 }
24971
24972 // packages/dataviews/build-module/components/dataform-controls/richtext/index.mjs
24973 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
24974 function RichText({
24975 data,
24976 field,
24977 onChange,
24978 hideLabelFromVision,
24979 markWhenOptional,
24980 config,
24981 validity
24982 }) {
24983 const {
24984 className,
24985 clientId,
24986 allowedFormats,
24987 disableFormats,
24988 withoutInteractiveFormatting,
24989 preserveWhiteSpace,
24990 disableLineBreaks
24991 } = config || {};
24992 const disabled2 = field.isDisabled({ item: data, field });
24993 const { label, placeholder, description, id, setValue, isValid: isValid2 } = field;
24994 const value = field.getValue({ item: data }) ?? "";
24995 const onChangeControl = (0, import_element70.useCallback)(
24996 (newValue) => onChange(setValue({ item: data, value: newValue })),
24997 [data, onChange, setValue]
24998 );
24999 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
25000 RichTextControl,
25001 {
25002 label,
25003 value,
25004 onChange: onChangeControl,
25005 placeholder,
25006 id,
25007 hideLabelFromVision,
25008 help: description,
25009 disabled: disabled2,
25010 required: !!isValid2.required,
25011 markWhenOptional,
25012 customValidity: getCustomValidity(isValid2, validity),
25013 className,
25014 clientId,
25015 allowedFormats,
25016 disableFormats,
25017 withoutInteractiveFormatting,
25018 preserveWhiteSpace,
25019 disableLineBreaks
25020 }
25021 );
25022 }
25023
25024 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
25025 var import_components43 = __toESM(require_components(), 1);
25026 var import_element71 = __toESM(require_element(), 1);
25027 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
25028 var { ValidatedToggleGroupControl } = unlock2(import_components43.privateApis);
25029 function ToggleGroup({
25030 data,
25031 field,
25032 onChange,
25033 hideLabelFromVision,
25034 markWhenOptional,
25035 validity
25036 }) {
25037 const { getValue, setValue, isValid: isValid2 } = field;
25038 const disabled2 = field.isDisabled({ item: data, field });
25039 const value = getValue({ item: data });
25040 const onChangeControl = (0, import_element71.useCallback)(
25041 (newValue) => onChange(setValue({ item: data, value: newValue })),
25042 [data, onChange, setValue]
25043 );
25044 const { elements, isLoading } = useElements({
25045 elements: field.elements,
25046 getElements: field.getElements
25047 });
25048 if (isLoading) {
25049 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(import_components43.Spinner, {});
25050 }
25051 if (elements.length === 0) {
25052 return null;
25053 }
25054 const selectedOption = elements.find((el) => el.value === value);
25055 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25056 ValidatedToggleGroupControl,
25057 {
25058 required: !!field.isValid?.required,
25059 markWhenOptional,
25060 customValidity: getCustomValidity(isValid2, validity),
25061 isBlock: true,
25062 label: field.label,
25063 help: selectedOption?.description || field.description,
25064 onChange: onChangeControl,
25065 value,
25066 hideLabelFromVision,
25067 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25068 import_components43.__experimentalToggleGroupControlOption,
25069 {
25070 label: el.label,
25071 value: el.value,
25072 disabled: disabled2
25073 },
25074 el.value
25075 ))
25076 }
25077 );
25078 }
25079
25080 // packages/dataviews/build-module/components/dataform-controls/array.mjs
25081 var import_components44 = __toESM(require_components(), 1);
25082 var import_element72 = __toESM(require_element(), 1);
25083 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
25084 var { ValidatedFormTokenField } = unlock2(import_components44.privateApis);
25085 function ArrayControl({
25086 data,
25087 field,
25088 onChange,
25089 hideLabelFromVision,
25090 markWhenOptional,
25091 validity
25092 }) {
25093 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
25094 const value = getValue({ item: data });
25095 const disabled2 = field.isDisabled({ item: data, field });
25096 const { elements, isLoading } = useElements({
25097 elements: field.elements,
25098 getElements: field.getElements
25099 });
25100 const arrayValueAsElements = (0, import_element72.useMemo)(
25101 () => Array.isArray(value) ? value.map((token) => {
25102 const element = elements?.find(
25103 (suggestion) => suggestion.value === token
25104 );
25105 return element || { value: token, label: token };
25106 }) : [],
25107 [value, elements]
25108 );
25109 const onChangeControl = (0, import_element72.useCallback)(
25110 (tokens) => {
25111 const valueTokens = tokens.map((token) => {
25112 if (typeof token === "object" && "value" in token) {
25113 return token.value;
25114 }
25115 return token;
25116 });
25117 onChange(setValue({ item: data, value: valueTokens }));
25118 },
25119 [onChange, setValue, data]
25120 );
25121 if (isLoading) {
25122 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_components44.Spinner, {});
25123 }
25124 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25125 ValidatedFormTokenField,
25126 {
25127 required: !!isValid2?.required,
25128 markWhenOptional,
25129 customValidity: getCustomValidity(isValid2, validity),
25130 label: hideLabelFromVision ? void 0 : label,
25131 value: arrayValueAsElements,
25132 onChange: onChangeControl,
25133 placeholder,
25134 suggestions: elements?.map((element) => element.value),
25135 disabled: disabled2,
25136 __experimentalValidateInput: (token) => {
25137 if (field.isValid?.elements && elements) {
25138 return elements.some(
25139 (element) => element.value === token || element.label === token
25140 );
25141 }
25142 return true;
25143 },
25144 __experimentalExpandOnFocus: elements && elements.length > 0,
25145 help: description ?? (field.isValid?.elements ? "" : void 0),
25146 displayTransform: (token) => {
25147 if (typeof token === "object" && "label" in token) {
25148 return token.label;
25149 }
25150 if (typeof token === "string" && elements) {
25151 const element = elements.find(
25152 (el) => el.value === token
25153 );
25154 return element?.label || token;
25155 }
25156 return token;
25157 },
25158 __experimentalRenderItem: ({ item }) => {
25159 if (typeof item === "string" && elements) {
25160 const element = elements.find(
25161 (el) => el.value === item
25162 );
25163 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)("span", { children: element?.label || item });
25164 }
25165 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)("span", { children: item });
25166 }
25167 }
25168 );
25169 }
25170
25171 // node_modules/colord/index.mjs
25172 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
25173 var t = function(r3) {
25174 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
25175 };
25176 var n = function(r3, t2, n2) {
25177 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
25178 };
25179 var e = function(r3, t2, n2) {
25180 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
25181 };
25182 var u = function(r3) {
25183 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
25184 };
25185 var a = function(r3) {
25186 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
25187 };
25188 var o = function(r3) {
25189 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
25190 };
25191 var i = /^#([0-9a-f]{3,8})$/i;
25192 var s = function(r3) {
25193 var t2 = r3.toString(16);
25194 return t2.length < 2 ? "0" + t2 : t2;
25195 };
25196 var h = function(r3) {
25197 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;
25198 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
25199 };
25200 var b = function(r3) {
25201 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
25202 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
25203 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;
25204 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 };
25205 };
25206 var g = function(r3) {
25207 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
25208 };
25209 var d = function(r3) {
25210 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
25211 };
25212 var f = function(r3) {
25213 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 }));
25214 var t2, n2, e2;
25215 };
25216 var c = function(r3) {
25217 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 };
25218 var t2, n2, e2, u2;
25219 };
25220 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
25221 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
25222 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
25223 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
25224 var y = { string: [[function(r3) {
25225 var t2 = i.exec(r3);
25226 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;
25227 }, "hex"], [function(r3) {
25228 var t2 = v.exec(r3) || m.exec(r3);
25229 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;
25230 }, "rgb"], [function(t2) {
25231 var n2 = l.exec(t2) || p.exec(t2);
25232 if (!n2) return null;
25233 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) });
25234 return f(a2);
25235 }, "hsl"]], object: [[function(r3) {
25236 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
25237 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
25238 }, "rgb"], [function(r3) {
25239 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
25240 if (!t(n2) || !t(e2) || !t(u2)) return null;
25241 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
25242 return f(i2);
25243 }, "hsl"], [function(r3) {
25244 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
25245 if (!t(n2) || !t(a2) || !t(o2)) return null;
25246 var h2 = (function(r4) {
25247 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
25248 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
25249 return b(h2);
25250 }, "hsv"]] };
25251 var N = function(r3, t2) {
25252 for (var n2 = 0; n2 < t2.length; n2++) {
25253 var e2 = t2[n2][0](r3);
25254 if (e2) return [e2, t2[n2][1]];
25255 }
25256 return [null, void 0];
25257 };
25258 var x = function(r3) {
25259 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
25260 };
25261 var M = function(r3, t2) {
25262 var n2 = c(r3);
25263 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
25264 };
25265 var H = function(r3) {
25266 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
25267 };
25268 var $ = function(r3, t2) {
25269 var n2 = c(r3);
25270 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
25271 };
25272 var j = (function() {
25273 function r3(r4) {
25274 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
25275 }
25276 return r3.prototype.isValid = function() {
25277 return null !== this.parsed;
25278 }, r3.prototype.brightness = function() {
25279 return n(H(this.rgba), 2);
25280 }, r3.prototype.isDark = function() {
25281 return H(this.rgba) < 0.5;
25282 }, r3.prototype.isLight = function() {
25283 return H(this.rgba) >= 0.5;
25284 }, r3.prototype.toHex = function() {
25285 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;
25286 var r4, t2, e2, u2, a2, i2;
25287 }, r3.prototype.toRgb = function() {
25288 return o(this.rgba);
25289 }, r3.prototype.toRgbString = function() {
25290 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 + ")";
25291 var r4, t2, n2, e2, u2;
25292 }, r3.prototype.toHsl = function() {
25293 return d(c(this.rgba));
25294 }, r3.prototype.toHslString = function() {
25295 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 + "%)";
25296 var r4, t2, n2, e2, u2;
25297 }, r3.prototype.toHsv = function() {
25298 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
25299 var r4;
25300 }, r3.prototype.invert = function() {
25301 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
25302 var r4;
25303 }, r3.prototype.saturate = function(r4) {
25304 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
25305 }, r3.prototype.desaturate = function(r4) {
25306 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
25307 }, r3.prototype.grayscale = function() {
25308 return w(M(this.rgba, -1));
25309 }, r3.prototype.lighten = function(r4) {
25310 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
25311 }, r3.prototype.darken = function(r4) {
25312 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
25313 }, r3.prototype.rotate = function(r4) {
25314 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
25315 }, r3.prototype.alpha = function(r4) {
25316 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
25317 var t2;
25318 }, r3.prototype.hue = function(r4) {
25319 var t2 = c(this.rgba);
25320 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
25321 }, r3.prototype.isEqual = function(r4) {
25322 return this.toHex() === w(r4).toHex();
25323 }, r3;
25324 })();
25325 var w = function(r3) {
25326 return r3 instanceof j ? r3 : new j(r3);
25327 };
25328
25329 // packages/dataviews/build-module/components/dataform-controls/color.mjs
25330 var import_components45 = __toESM(require_components(), 1);
25331 var import_element73 = __toESM(require_element(), 1);
25332 var import_i18n43 = __toESM(require_i18n(), 1);
25333 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
25334 var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components45.privateApis);
25335 var ColorPickerDropdown = ({
25336 color,
25337 onColorChange,
25338 disabled: disabled2
25339 }) => {
25340 const validColor = color && w(color).isValid() ? color : "#ffffff";
25341 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
25342 import_components45.Dropdown,
25343 {
25344 className: "dataviews-controls__color-picker-dropdown",
25345 popoverProps: { resize: false },
25346 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
25347 import_components45.Button,
25348 {
25349 onClick: onToggle,
25350 "aria-label": (0, import_i18n43.__)("Open color picker"),
25351 size: "small",
25352 disabled: disabled2,
25353 accessibleWhenDisabled: true,
25354 icon: () => /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_components45.ColorIndicator, { colorValue: validColor })
25355 }
25356 ),
25357 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_components45.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
25358 import_components45.ColorPicker,
25359 {
25360 color: validColor,
25361 onChange: onColorChange,
25362 enableAlpha: true
25363 }
25364 ) })
25365 }
25366 );
25367 };
25368 function Color({
25369 data,
25370 field,
25371 onChange,
25372 hideLabelFromVision,
25373 markWhenOptional,
25374 validity
25375 }) {
25376 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
25377 const disabled2 = field.isDisabled({ item: data, field });
25378 const value = field.getValue({ item: data }) || "";
25379 const handleColorChange = (0, import_element73.useCallback)(
25380 (newColor) => {
25381 onChange(setValue({ item: data, value: newColor }));
25382 },
25383 [data, onChange, setValue]
25384 );
25385 const handleInputChange = (0, import_element73.useCallback)(
25386 (newValue) => {
25387 onChange(setValue({ item: data, value: newValue || "" }));
25388 },
25389 [data, onChange, setValue]
25390 );
25391 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
25392 ValidatedInputControl3,
25393 {
25394 required: !!field.isValid?.required,
25395 markWhenOptional,
25396 customValidity: getCustomValidity(isValid2, validity),
25397 label,
25398 placeholder,
25399 value,
25400 help: description,
25401 onChange: handleInputChange,
25402 hideLabelFromVision,
25403 type: "text",
25404 disabled: disabled2,
25405 prefix: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_components45.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
25406 ColorPickerDropdown,
25407 {
25408 color: value,
25409 onColorChange: handleColorChange,
25410 disabled: disabled2
25411 }
25412 ) })
25413 }
25414 );
25415 }
25416
25417 // packages/dataviews/build-module/components/dataform-controls/password.mjs
25418 var import_components46 = __toESM(require_components(), 1);
25419 var import_element74 = __toESM(require_element(), 1);
25420 var import_i18n44 = __toESM(require_i18n(), 1);
25421 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
25422 function Password({
25423 data,
25424 field,
25425 onChange,
25426 hideLabelFromVision,
25427 markWhenOptional,
25428 validity
25429 }) {
25430 const [isVisible2, setIsVisible] = (0, import_element74.useState)(false);
25431 const disabled2 = field.isDisabled({ item: data, field });
25432 const toggleVisibility = (0, import_element74.useCallback)(() => {
25433 setIsVisible((prev) => !prev);
25434 }, []);
25435 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
25436 ValidatedText,
25437 {
25438 ...{
25439 data,
25440 field,
25441 onChange,
25442 hideLabelFromVision,
25443 markWhenOptional,
25444 validity,
25445 type: isVisible2 ? "text" : "password",
25446 suffix: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(import_components46.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
25447 import_components46.Button,
25448 {
25449 icon: isVisible2 ? unseen_default : seen_default,
25450 onClick: toggleVisibility,
25451 size: "small",
25452 label: isVisible2 ? (0, import_i18n44.__)("Hide password") : (0, import_i18n44.__)("Show password"),
25453 disabled: disabled2,
25454 accessibleWhenDisabled: true
25455 }
25456 ) })
25457 }
25458 }
25459 );
25460 }
25461
25462 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
25463 function hasElements(field) {
25464 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
25465 }
25466
25467 // packages/dataviews/build-module/components/dataform-controls/index.mjs
25468 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
25469 var FORM_CONTROLS = {
25470 adaptiveSelect: AdaptiveSelect,
25471 array: ArrayControl,
25472 checkbox: Checkbox,
25473 color: Color,
25474 combobox: Combobox3,
25475 datetime: DateTime,
25476 date: DateControl,
25477 email: Email,
25478 telephone: Telephone,
25479 url: Url,
25480 integer: Integer,
25481 number: Number2,
25482 password: Password,
25483 radio: Radio,
25484 select: Select,
25485 text: Text,
25486 toggle: Toggle,
25487 textarea: Textarea,
25488 richtext: RichText,
25489 toggleGroup: ToggleGroup
25490 };
25491 function isEditConfig(value) {
25492 return value && typeof value === "object" && typeof value.control === "string";
25493 }
25494 function createConfiguredControl(config) {
25495 const { control, ...controlConfig } = config;
25496 const BaseControlType = getControlByType(control);
25497 if (BaseControlType === null) {
25498 return null;
25499 }
25500 return function ConfiguredControl(props) {
25501 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(BaseControlType, { ...props, config: controlConfig });
25502 };
25503 }
25504 function getControl(field, fallback) {
25505 if (typeof field.Edit === "function") {
25506 return field.Edit;
25507 }
25508 if (typeof field.Edit === "string") {
25509 return getControlByType(field.Edit);
25510 }
25511 if (isEditConfig(field.Edit)) {
25512 return createConfiguredControl(field.Edit);
25513 }
25514 if (hasElements(field) && field.type !== "array") {
25515 return getControlByType("adaptiveSelect");
25516 }
25517 if (fallback === null) {
25518 return null;
25519 }
25520 return getControlByType(fallback);
25521 }
25522 function getControlByType(type) {
25523 if (Object.keys(FORM_CONTROLS).includes(type)) {
25524 return FORM_CONTROLS[type];
25525 }
25526 return null;
25527 }
25528
25529 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
25530 function getFilterBy(field, defaultOperators, validOperators) {
25531 if (field.filterBy === false) {
25532 return false;
25533 }
25534 const operators = field.filterBy?.operators?.filter(
25535 (op) => validOperators.includes(op)
25536 ) ?? defaultOperators;
25537 if (operators.length === 0) {
25538 return false;
25539 }
25540 return {
25541 isPrimary: !!field.filterBy?.isPrimary,
25542 operators
25543 };
25544 }
25545 var get_filter_by_default = getFilterBy;
25546
25547 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
25548 var getValueFromId = (id) => ({ item }) => {
25549 const path = id.split(".");
25550 let value = item;
25551 for (const segment of path) {
25552 if (value.hasOwnProperty(segment)) {
25553 value = value[segment];
25554 } else {
25555 value = void 0;
25556 }
25557 }
25558 return value;
25559 };
25560 var get_value_from_id_default = getValueFromId;
25561
25562 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
25563 var setValueFromId = (id) => ({ value }) => {
25564 const path = id.split(".");
25565 const result = {};
25566 let current = result;
25567 for (const segment of path.slice(0, -1)) {
25568 current[segment] = {};
25569 current = current[segment];
25570 }
25571 current[path.at(-1)] = value;
25572 return result;
25573 };
25574 var set_value_from_id_default = setValueFromId;
25575
25576 // packages/dataviews/build-module/field-types/email.mjs
25577 var import_i18n45 = __toESM(require_i18n(), 1);
25578
25579 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
25580 function RenderFromElements({
25581 item,
25582 field
25583 }) {
25584 const { elements, isLoading } = useElements({
25585 elements: field.elements,
25586 getElements: field.getElements
25587 });
25588 const value = field.getValue({ item });
25589 if (isLoading) {
25590 return value;
25591 }
25592 if (elements.length === 0) {
25593 return value;
25594 }
25595 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
25596 }
25597
25598 // packages/dataviews/build-module/field-types/utils/render-default.mjs
25599 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1);
25600 function render({
25601 item,
25602 field
25603 }) {
25604 if (field.hasElements) {
25605 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(RenderFromElements, { item, field });
25606 }
25607 return field.getValueFormatted({ item, field });
25608 }
25609
25610 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
25611 var sort_text_default = (a2, b2, direction) => {
25612 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
25613 };
25614
25615 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
25616 function isValidRequired(item, field) {
25617 const value = field.getValue({ item });
25618 return ![void 0, "", null].includes(value);
25619 }
25620
25621 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
25622 function isValidMinLength(item, field) {
25623 if (typeof field.isValid.minLength?.constraint !== "number") {
25624 return false;
25625 }
25626 const value = field.getValue({ item });
25627 if ([void 0, "", null].includes(value)) {
25628 return true;
25629 }
25630 return String(value).length >= field.isValid.minLength.constraint;
25631 }
25632
25633 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
25634 function isValidMaxLength(item, field) {
25635 if (typeof field.isValid.maxLength?.constraint !== "number") {
25636 return false;
25637 }
25638 const value = field.getValue({ item });
25639 if ([void 0, "", null].includes(value)) {
25640 return true;
25641 }
25642 return String(value).length <= field.isValid.maxLength.constraint;
25643 }
25644
25645 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
25646 function isValidPattern(item, field) {
25647 if (field.isValid.pattern?.constraint === void 0) {
25648 return true;
25649 }
25650 try {
25651 const regexp = new RegExp(field.isValid.pattern.constraint);
25652 const value = field.getValue({ item });
25653 if ([void 0, "", null].includes(value)) {
25654 return true;
25655 }
25656 return regexp.test(String(value));
25657 } catch {
25658 return false;
25659 }
25660 }
25661
25662 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
25663 function isValidElements(item, field) {
25664 const elements = field.elements ?? [];
25665 const validValues = elements.map((el) => el.value);
25666 if (validValues.length === 0) {
25667 return true;
25668 }
25669 const value = field.getValue({ item });
25670 return [].concat(value).every((v2) => validValues.includes(v2));
25671 }
25672
25673 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
25674 function getValueFormatted({
25675 item,
25676 field
25677 }) {
25678 return field.getValue({ item });
25679 }
25680 var get_value_formatted_default_default = getValueFormatted;
25681
25682 // packages/dataviews/build-module/field-types/email.mjs
25683 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])?)*$/;
25684 function isValidCustom(item, field) {
25685 const value = field.getValue({ item });
25686 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
25687 return (0, import_i18n45.__)("Value must be a valid email address.");
25688 }
25689 return null;
25690 }
25691 var email_default = {
25692 type: "email",
25693 render,
25694 Edit: "email",
25695 sort: sort_text_default,
25696 enableSorting: true,
25697 enableGlobalSearch: false,
25698 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25699 validOperators: [
25700 OPERATOR_IS,
25701 OPERATOR_IS_NOT,
25702 OPERATOR_CONTAINS,
25703 OPERATOR_NOT_CONTAINS,
25704 OPERATOR_STARTS_WITH,
25705 // Multiple selection
25706 OPERATOR_IS_ANY,
25707 OPERATOR_IS_NONE,
25708 OPERATOR_IS_ALL,
25709 OPERATOR_IS_NOT_ALL
25710 ],
25711 format: {},
25712 getValueFormatted: get_value_formatted_default_default,
25713 validate: {
25714 required: isValidRequired,
25715 pattern: isValidPattern,
25716 minLength: isValidMinLength,
25717 maxLength: isValidMaxLength,
25718 elements: isValidElements,
25719 custom: isValidCustom
25720 }
25721 };
25722
25723 // packages/dataviews/build-module/field-types/integer.mjs
25724 var import_i18n46 = __toESM(require_i18n(), 1);
25725
25726 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
25727 var sort_number_default = (a2, b2, direction) => {
25728 return direction === "asc" ? a2 - b2 : b2 - a2;
25729 };
25730
25731 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
25732 function isValidMin(item, field) {
25733 if (typeof field.isValid.min?.constraint !== "number") {
25734 return false;
25735 }
25736 const value = field.getValue({ item });
25737 if ([void 0, "", null].includes(value)) {
25738 return true;
25739 }
25740 return Number(value) >= field.isValid.min.constraint;
25741 }
25742
25743 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
25744 function isValidMax(item, field) {
25745 if (typeof field.isValid.max?.constraint !== "number") {
25746 return false;
25747 }
25748 const value = field.getValue({ item });
25749 if ([void 0, "", null].includes(value)) {
25750 return true;
25751 }
25752 return Number(value) <= field.isValid.max.constraint;
25753 }
25754
25755 // packages/dataviews/build-module/field-types/integer.mjs
25756 var format2 = {
25757 separatorThousand: ","
25758 };
25759 function getValueFormatted2({
25760 item,
25761 field
25762 }) {
25763 let value = field.getValue({ item });
25764 if (value === null || value === void 0) {
25765 return "";
25766 }
25767 value = Number(value);
25768 if (!Number.isFinite(value)) {
25769 return String(value);
25770 }
25771 let formatInteger;
25772 if (field.type !== "integer") {
25773 formatInteger = format2;
25774 } else {
25775 formatInteger = field.format;
25776 }
25777 const { separatorThousand } = formatInteger;
25778 const integerValue = Math.trunc(value);
25779 if (!separatorThousand) {
25780 return String(integerValue);
25781 }
25782 return String(integerValue).replace(
25783 /\B(?=(\d{3})+(?!\d))/g,
25784 separatorThousand
25785 );
25786 }
25787 function isValidCustom2(item, field) {
25788 const value = field.getValue({ item });
25789 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
25790 return (0, import_i18n46.__)("Value must be an integer.");
25791 }
25792 return null;
25793 }
25794 var integer_default = {
25795 type: "integer",
25796 render,
25797 Edit: "integer",
25798 sort: sort_number_default,
25799 enableSorting: true,
25800 enableGlobalSearch: false,
25801 defaultOperators: [
25802 OPERATOR_IS,
25803 OPERATOR_IS_NOT,
25804 OPERATOR_LESS_THAN,
25805 OPERATOR_GREATER_THAN,
25806 OPERATOR_LESS_THAN_OR_EQUAL,
25807 OPERATOR_GREATER_THAN_OR_EQUAL,
25808 OPERATOR_BETWEEN
25809 ],
25810 validOperators: [
25811 // Single-selection
25812 OPERATOR_IS,
25813 OPERATOR_IS_NOT,
25814 OPERATOR_LESS_THAN,
25815 OPERATOR_GREATER_THAN,
25816 OPERATOR_LESS_THAN_OR_EQUAL,
25817 OPERATOR_GREATER_THAN_OR_EQUAL,
25818 OPERATOR_BETWEEN,
25819 // Multiple-selection
25820 OPERATOR_IS_ANY,
25821 OPERATOR_IS_NONE,
25822 OPERATOR_IS_ALL,
25823 OPERATOR_IS_NOT_ALL
25824 ],
25825 format: format2,
25826 getValueFormatted: getValueFormatted2,
25827 validate: {
25828 required: isValidRequired,
25829 min: isValidMin,
25830 max: isValidMax,
25831 elements: isValidElements,
25832 custom: isValidCustom2
25833 }
25834 };
25835
25836 // packages/dataviews/build-module/field-types/number.mjs
25837 var import_i18n47 = __toESM(require_i18n(), 1);
25838 var format3 = {
25839 separatorThousand: ",",
25840 separatorDecimal: ".",
25841 decimals: 2
25842 };
25843 function getValueFormatted3({
25844 item,
25845 field
25846 }) {
25847 let value = field.getValue({ item });
25848 if (value === null || value === void 0) {
25849 return "";
25850 }
25851 value = Number(value);
25852 if (!Number.isFinite(value)) {
25853 return String(value);
25854 }
25855 let formatNumber;
25856 if (field.type !== "number") {
25857 formatNumber = format3;
25858 } else {
25859 formatNumber = field.format;
25860 }
25861 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
25862 const fixedValue = value.toFixed(decimals);
25863 const [integerPart, decimalPart] = fixedValue.split(".");
25864 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
25865 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
25866 }
25867 function isEmpty(value) {
25868 return value === "" || value === void 0 || value === null;
25869 }
25870 function isValidCustom3(item, field) {
25871 const value = field.getValue({ item });
25872 if (!isEmpty(value) && !Number.isFinite(value)) {
25873 return (0, import_i18n47.__)("Value must be a number.");
25874 }
25875 return null;
25876 }
25877 var number_default = {
25878 type: "number",
25879 render,
25880 Edit: "number",
25881 sort: sort_number_default,
25882 enableSorting: true,
25883 enableGlobalSearch: false,
25884 defaultOperators: [
25885 OPERATOR_IS,
25886 OPERATOR_IS_NOT,
25887 OPERATOR_LESS_THAN,
25888 OPERATOR_GREATER_THAN,
25889 OPERATOR_LESS_THAN_OR_EQUAL,
25890 OPERATOR_GREATER_THAN_OR_EQUAL,
25891 OPERATOR_BETWEEN
25892 ],
25893 validOperators: [
25894 // Single-selection
25895 OPERATOR_IS,
25896 OPERATOR_IS_NOT,
25897 OPERATOR_LESS_THAN,
25898 OPERATOR_GREATER_THAN,
25899 OPERATOR_LESS_THAN_OR_EQUAL,
25900 OPERATOR_GREATER_THAN_OR_EQUAL,
25901 OPERATOR_BETWEEN,
25902 // Multiple-selection
25903 OPERATOR_IS_ANY,
25904 OPERATOR_IS_NONE,
25905 OPERATOR_IS_ALL,
25906 OPERATOR_IS_NOT_ALL
25907 ],
25908 format: format3,
25909 getValueFormatted: getValueFormatted3,
25910 validate: {
25911 required: isValidRequired,
25912 min: isValidMin,
25913 max: isValidMax,
25914 elements: isValidElements,
25915 custom: isValidCustom3
25916 }
25917 };
25918
25919 // packages/dataviews/build-module/field-types/text.mjs
25920 var text_default = {
25921 type: "text",
25922 render,
25923 Edit: "text",
25924 sort: sort_text_default,
25925 enableSorting: true,
25926 enableGlobalSearch: false,
25927 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25928 validOperators: [
25929 // Single selection
25930 OPERATOR_IS,
25931 OPERATOR_IS_NOT,
25932 OPERATOR_CONTAINS,
25933 OPERATOR_NOT_CONTAINS,
25934 OPERATOR_STARTS_WITH,
25935 // Multiple selection
25936 OPERATOR_IS_ANY,
25937 OPERATOR_IS_NONE,
25938 OPERATOR_IS_ALL,
25939 OPERATOR_IS_NOT_ALL
25940 ],
25941 format: {},
25942 getValueFormatted: get_value_formatted_default_default,
25943 validate: {
25944 required: isValidRequired,
25945 pattern: isValidPattern,
25946 minLength: isValidMinLength,
25947 maxLength: isValidMaxLength,
25948 elements: isValidElements
25949 }
25950 };
25951
25952 // packages/dataviews/build-module/field-types/datetime.mjs
25953 var import_date7 = __toESM(require_date(), 1);
25954
25955 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
25956 var import_date6 = __toESM(require_date(), 1);
25957 function parseDateLike(value) {
25958 if (!value) {
25959 return null;
25960 }
25961 if (!isValid(new Date(value))) {
25962 return null;
25963 }
25964 const parsed = (0, import_date6.getDate)(value);
25965 return parsed && isValid(parsed) ? parsed : null;
25966 }
25967 function validateDateLikeBoundary(item, field, boundary) {
25968 const constraint = field.isValid[boundary]?.constraint;
25969 if (typeof constraint !== "string") {
25970 return false;
25971 }
25972 const value = field.getValue({ item });
25973 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
25974 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
25975 return true;
25976 }
25977 const parsedConstraint = parseDateLike(constraint);
25978 const parsedValue = parseDateLike(String(boundaryValue));
25979 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
25980 }
25981 function isValidMinDate(item, field) {
25982 return validateDateLikeBoundary(item, field, "min");
25983 }
25984 function isValidMaxDate(item, field) {
25985 return validateDateLikeBoundary(item, field, "max");
25986 }
25987
25988 // packages/dataviews/build-module/field-types/datetime.mjs
25989 var format4 = {
25990 datetime: (0, import_date7.getSettings)().formats.datetime,
25991 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
25992 };
25993 function getValueFormatted4({
25994 item,
25995 field
25996 }) {
25997 const value = field.getValue({ item });
25998 if (["", void 0, null].includes(value)) {
25999 return "";
26000 }
26001 let formatDatetime;
26002 if (field.type !== "datetime") {
26003 formatDatetime = format4;
26004 } else {
26005 formatDatetime = field.format;
26006 }
26007 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
26008 }
26009 var sort = (a2, b2, direction) => {
26010 const timeA = new Date(a2).getTime();
26011 const timeB = new Date(b2).getTime();
26012 return direction === "asc" ? timeA - timeB : timeB - timeA;
26013 };
26014 var datetime_default = {
26015 type: "datetime",
26016 render,
26017 Edit: "datetime",
26018 sort,
26019 enableSorting: true,
26020 enableGlobalSearch: false,
26021 defaultOperators: [
26022 OPERATOR_ON,
26023 OPERATOR_NOT_ON,
26024 OPERATOR_BEFORE,
26025 OPERATOR_AFTER,
26026 OPERATOR_BEFORE_INC,
26027 OPERATOR_AFTER_INC,
26028 OPERATOR_IN_THE_PAST,
26029 OPERATOR_OVER
26030 ],
26031 validOperators: [
26032 OPERATOR_ON,
26033 OPERATOR_NOT_ON,
26034 OPERATOR_BEFORE,
26035 OPERATOR_AFTER,
26036 OPERATOR_BEFORE_INC,
26037 OPERATOR_AFTER_INC,
26038 OPERATOR_IN_THE_PAST,
26039 OPERATOR_OVER
26040 ],
26041 format: format4,
26042 getValueFormatted: getValueFormatted4,
26043 validate: {
26044 required: isValidRequired,
26045 elements: isValidElements,
26046 min: isValidMinDate,
26047 max: isValidMaxDate
26048 }
26049 };
26050
26051 // packages/dataviews/build-module/field-types/date.mjs
26052 var import_date8 = __toESM(require_date(), 1);
26053 var format5 = {
26054 date: (0, import_date8.getSettings)().formats.date,
26055 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
26056 };
26057 function getValueFormatted5({
26058 item,
26059 field
26060 }) {
26061 const value = field.getValue({ item });
26062 if (["", void 0, null].includes(value)) {
26063 return "";
26064 }
26065 let formatDate2;
26066 if (field.type !== "date") {
26067 formatDate2 = format5;
26068 } else {
26069 formatDate2 = field.format;
26070 }
26071 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
26072 }
26073 var sort2 = (a2, b2, direction) => {
26074 const timeA = new Date(a2).getTime();
26075 const timeB = new Date(b2).getTime();
26076 return direction === "asc" ? timeA - timeB : timeB - timeA;
26077 };
26078 var date_default = {
26079 type: "date",
26080 render,
26081 Edit: "date",
26082 sort: sort2,
26083 enableSorting: true,
26084 enableGlobalSearch: false,
26085 defaultOperators: [
26086 OPERATOR_ON,
26087 OPERATOR_NOT_ON,
26088 OPERATOR_BEFORE,
26089 OPERATOR_AFTER,
26090 OPERATOR_BEFORE_INC,
26091 OPERATOR_AFTER_INC,
26092 OPERATOR_IN_THE_PAST,
26093 OPERATOR_OVER,
26094 OPERATOR_BETWEEN
26095 ],
26096 validOperators: [
26097 OPERATOR_ON,
26098 OPERATOR_NOT_ON,
26099 OPERATOR_BEFORE,
26100 OPERATOR_AFTER,
26101 OPERATOR_BEFORE_INC,
26102 OPERATOR_AFTER_INC,
26103 OPERATOR_IN_THE_PAST,
26104 OPERATOR_OVER,
26105 OPERATOR_BETWEEN
26106 ],
26107 format: format5,
26108 getValueFormatted: getValueFormatted5,
26109 validate: {
26110 required: isValidRequired,
26111 elements: isValidElements,
26112 min: isValidMinDate,
26113 max: isValidMaxDate
26114 }
26115 };
26116
26117 // packages/dataviews/build-module/field-types/boolean.mjs
26118 var import_i18n48 = __toESM(require_i18n(), 1);
26119
26120 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
26121 function isValidRequiredForBool(item, field) {
26122 const value = field.getValue({ item });
26123 return value === true;
26124 }
26125
26126 // packages/dataviews/build-module/field-types/boolean.mjs
26127 function getValueFormatted6({
26128 item,
26129 field
26130 }) {
26131 const value = field.getValue({ item });
26132 if (value === true) {
26133 return (0, import_i18n48.__)("True");
26134 }
26135 if (value === false) {
26136 return (0, import_i18n48.__)("False");
26137 }
26138 return "";
26139 }
26140 function isValidCustom4(item, field) {
26141 const value = field.getValue({ item });
26142 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
26143 return (0, import_i18n48.__)("Value must be true, false, or undefined");
26144 }
26145 return null;
26146 }
26147 var sort3 = (a2, b2, direction) => {
26148 const boolA = Boolean(a2);
26149 const boolB = Boolean(b2);
26150 if (boolA === boolB) {
26151 return 0;
26152 }
26153 if (direction === "asc") {
26154 return boolA ? 1 : -1;
26155 }
26156 return boolA ? -1 : 1;
26157 };
26158 var boolean_default = {
26159 type: "boolean",
26160 render,
26161 Edit: "checkbox",
26162 sort: sort3,
26163 validate: {
26164 required: isValidRequiredForBool,
26165 elements: isValidElements,
26166 custom: isValidCustom4
26167 },
26168 enableSorting: true,
26169 enableGlobalSearch: false,
26170 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
26171 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
26172 format: {},
26173 getValueFormatted: getValueFormatted6
26174 };
26175
26176 // packages/dataviews/build-module/field-types/media.mjs
26177 var media_default = {
26178 type: "media",
26179 render: () => null,
26180 Edit: null,
26181 sort: () => 0,
26182 enableSorting: false,
26183 enableGlobalSearch: false,
26184 defaultOperators: [],
26185 validOperators: [],
26186 format: {},
26187 getValueFormatted: get_value_formatted_default_default,
26188 // cannot validate any constraint, so
26189 // the only available validation for the field author
26190 // would be providing a custom validator.
26191 validate: {}
26192 };
26193
26194 // packages/dataviews/build-module/field-types/array.mjs
26195 var import_i18n49 = __toESM(require_i18n(), 1);
26196
26197 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
26198 function isValidRequiredForArray(item, field) {
26199 const value = field.getValue({ item });
26200 return Array.isArray(value) && value.length > 0 && value.every(
26201 (element) => ![void 0, "", null].includes(element)
26202 );
26203 }
26204
26205 // packages/dataviews/build-module/field-types/array.mjs
26206 function getValueFormatted7({
26207 item,
26208 field
26209 }) {
26210 const value = field.getValue({ item });
26211 const arr = Array.isArray(value) ? value : [];
26212 return arr.join(", ");
26213 }
26214 function render2({ item, field }) {
26215 return getValueFormatted7({ item, field });
26216 }
26217 function isValidCustom5(item, field) {
26218 const value = field.getValue({ item });
26219 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
26220 return (0, import_i18n49.__)("Value must be an array.");
26221 }
26222 if (!value.every((v2) => typeof v2 === "string")) {
26223 return (0, import_i18n49.__)("Every value must be a string.");
26224 }
26225 return null;
26226 }
26227 var sort4 = (a2, b2, direction) => {
26228 const arrA = Array.isArray(a2) ? a2 : [];
26229 const arrB = Array.isArray(b2) ? b2 : [];
26230 if (arrA.length !== arrB.length) {
26231 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
26232 }
26233 const joinedA = arrA.join(",");
26234 const joinedB = arrB.join(",");
26235 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
26236 };
26237 var array_default = {
26238 type: "array",
26239 render: render2,
26240 Edit: "array",
26241 sort: sort4,
26242 enableSorting: true,
26243 enableGlobalSearch: false,
26244 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
26245 validOperators: [
26246 OPERATOR_IS_ANY,
26247 OPERATOR_IS_NONE,
26248 OPERATOR_IS_ALL,
26249 OPERATOR_IS_NOT_ALL
26250 ],
26251 format: {},
26252 getValueFormatted: getValueFormatted7,
26253 validate: {
26254 required: isValidRequiredForArray,
26255 elements: isValidElements,
26256 custom: isValidCustom5
26257 }
26258 };
26259
26260 // packages/dataviews/build-module/field-types/password.mjs
26261 function getValueFormatted8({
26262 item,
26263 field
26264 }) {
26265 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
26266 }
26267 var password_default = {
26268 type: "password",
26269 render,
26270 Edit: "password",
26271 sort: () => 0,
26272 // Passwords should not be sortable for security reasons
26273 enableSorting: false,
26274 enableGlobalSearch: false,
26275 defaultOperators: [],
26276 validOperators: [],
26277 format: {},
26278 getValueFormatted: getValueFormatted8,
26279 validate: {
26280 required: isValidRequired,
26281 pattern: isValidPattern,
26282 minLength: isValidMinLength,
26283 maxLength: isValidMaxLength,
26284 elements: isValidElements
26285 }
26286 };
26287
26288 // packages/dataviews/build-module/field-types/telephone.mjs
26289 var telephone_default = {
26290 type: "telephone",
26291 render,
26292 Edit: "telephone",
26293 sort: sort_text_default,
26294 enableSorting: true,
26295 enableGlobalSearch: false,
26296 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
26297 validOperators: [
26298 OPERATOR_IS,
26299 OPERATOR_IS_NOT,
26300 OPERATOR_CONTAINS,
26301 OPERATOR_NOT_CONTAINS,
26302 OPERATOR_STARTS_WITH,
26303 // Multiple selection
26304 OPERATOR_IS_ANY,
26305 OPERATOR_IS_NONE,
26306 OPERATOR_IS_ALL,
26307 OPERATOR_IS_NOT_ALL
26308 ],
26309 format: {},
26310 getValueFormatted: get_value_formatted_default_default,
26311 validate: {
26312 required: isValidRequired,
26313 pattern: isValidPattern,
26314 minLength: isValidMinLength,
26315 maxLength: isValidMaxLength,
26316 elements: isValidElements
26317 }
26318 };
26319
26320 // packages/dataviews/build-module/field-types/color.mjs
26321 var import_i18n50 = __toESM(require_i18n(), 1);
26322 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1);
26323 function render3({ item, field }) {
26324 if (field.hasElements) {
26325 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(RenderFromElements, { item, field });
26326 }
26327 const value = get_value_formatted_default_default({ item, field });
26328 if (!value || !w(value).isValid()) {
26329 return value;
26330 }
26331 return /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
26332 /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
26333 "div",
26334 {
26335 style: {
26336 width: "16px",
26337 height: "16px",
26338 borderRadius: "50%",
26339 backgroundColor: value,
26340 border: "1px solid #ddd",
26341 flexShrink: 0
26342 }
26343 }
26344 ),
26345 /* @__PURE__ */ (0, import_jsx_runtime119.jsx)("span", { children: value })
26346 ] });
26347 }
26348 function isValidCustom6(item, field) {
26349 const value = field.getValue({ item });
26350 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
26351 return (0, import_i18n50.__)("Value must be a valid color.");
26352 }
26353 return null;
26354 }
26355 var sort5 = (a2, b2, direction) => {
26356 const colorA = w(a2);
26357 const colorB = w(b2);
26358 if (!colorA.isValid() && !colorB.isValid()) {
26359 return 0;
26360 }
26361 if (!colorA.isValid()) {
26362 return direction === "asc" ? 1 : -1;
26363 }
26364 if (!colorB.isValid()) {
26365 return direction === "asc" ? -1 : 1;
26366 }
26367 const hslA = colorA.toHsl();
26368 const hslB = colorB.toHsl();
26369 if (hslA.h !== hslB.h) {
26370 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
26371 }
26372 if (hslA.s !== hslB.s) {
26373 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
26374 }
26375 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
26376 };
26377 var color_default = {
26378 type: "color",
26379 render: render3,
26380 Edit: "color",
26381 sort: sort5,
26382 enableSorting: true,
26383 enableGlobalSearch: false,
26384 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
26385 validOperators: [
26386 OPERATOR_IS,
26387 OPERATOR_IS_NOT,
26388 OPERATOR_IS_ANY,
26389 OPERATOR_IS_NONE
26390 ],
26391 format: {},
26392 getValueFormatted: get_value_formatted_default_default,
26393 validate: {
26394 required: isValidRequired,
26395 elements: isValidElements,
26396 custom: isValidCustom6
26397 }
26398 };
26399
26400 // packages/dataviews/build-module/field-types/url.mjs
26401 var url_default = {
26402 type: "url",
26403 render,
26404 Edit: "url",
26405 sort: sort_text_default,
26406 enableSorting: true,
26407 enableGlobalSearch: false,
26408 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
26409 validOperators: [
26410 OPERATOR_IS,
26411 OPERATOR_IS_NOT,
26412 OPERATOR_CONTAINS,
26413 OPERATOR_NOT_CONTAINS,
26414 OPERATOR_STARTS_WITH,
26415 // Multiple selection
26416 OPERATOR_IS_ANY,
26417 OPERATOR_IS_NONE,
26418 OPERATOR_IS_ALL,
26419 OPERATOR_IS_NOT_ALL
26420 ],
26421 format: {},
26422 getValueFormatted: get_value_formatted_default_default,
26423 validate: {
26424 required: isValidRequired,
26425 pattern: isValidPattern,
26426 minLength: isValidMinLength,
26427 maxLength: isValidMaxLength,
26428 elements: isValidElements
26429 }
26430 };
26431
26432 // packages/dataviews/build-module/field-types/no-type.mjs
26433 var sort6 = (a2, b2, direction) => {
26434 if (typeof a2 === "number" && typeof b2 === "number") {
26435 return sort_number_default(a2, b2, direction);
26436 }
26437 return sort_text_default(a2, b2, direction);
26438 };
26439 var no_type_default = {
26440 // type: no type for this one
26441 render,
26442 Edit: null,
26443 sort: sort6,
26444 enableSorting: true,
26445 enableGlobalSearch: false,
26446 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
26447 validOperators: getAllOperatorNames(),
26448 format: {},
26449 getValueFormatted: get_value_formatted_default_default,
26450 validate: {
26451 required: isValidRequired,
26452 elements: isValidElements
26453 }
26454 };
26455
26456 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
26457 function supportsNumericRangeConstraint(type) {
26458 return type === "integer" || type === "number";
26459 }
26460 function supportsDateRangeConstraint(type) {
26461 return type === "date" || type === "datetime";
26462 }
26463 function normalizeRangeRule(value, fieldType, key) {
26464 const validator = fieldType.validate[key];
26465 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
26466 return { constraint: value, validate: validator };
26467 }
26468 return void 0;
26469 }
26470 function getIsValid(field, fieldType) {
26471 const rules = field.isValid;
26472 let required;
26473 if (rules?.required === true && fieldType.validate.required !== void 0) {
26474 required = {
26475 constraint: true,
26476 validate: fieldType.validate.required
26477 };
26478 }
26479 let elements;
26480 if ((rules?.elements === true || // elements is enabled unless the field opts-out
26481 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
26482 elements = {
26483 constraint: true,
26484 validate: fieldType.validate.elements
26485 };
26486 }
26487 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
26488 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
26489 const minLengthValue = rules?.minLength;
26490 let minLength;
26491 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
26492 minLength = {
26493 constraint: minLengthValue,
26494 validate: fieldType.validate.minLength
26495 };
26496 }
26497 const maxLengthValue = rules?.maxLength;
26498 let maxLength;
26499 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
26500 maxLength = {
26501 constraint: maxLengthValue,
26502 validate: fieldType.validate.maxLength
26503 };
26504 }
26505 const patternValue = rules?.pattern;
26506 let pattern;
26507 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
26508 pattern = {
26509 constraint: patternValue,
26510 validate: fieldType.validate.pattern
26511 };
26512 }
26513 const custom = rules?.custom ?? fieldType.validate.custom;
26514 return {
26515 required,
26516 elements,
26517 min: min2,
26518 max: max2,
26519 minLength,
26520 maxLength,
26521 pattern,
26522 custom
26523 };
26524 }
26525
26526 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
26527 function getFilter(fieldType) {
26528 return fieldType.validOperators.reduce((accumulator, operator) => {
26529 const operatorObj = getOperatorByName(operator);
26530 if (operatorObj?.filter) {
26531 accumulator[operator] = operatorObj.filter;
26532 }
26533 return accumulator;
26534 }, {});
26535 }
26536
26537 // packages/dataviews/build-module/field-types/utils/get-format.mjs
26538 function getFormat(field, fieldType) {
26539 return {
26540 ...fieldType.format,
26541 ...field.format
26542 };
26543 }
26544 var get_format_default = getFormat;
26545
26546 // packages/dataviews/build-module/field-types/index.mjs
26547 function getFieldTypeByName(type) {
26548 const found = [
26549 email_default,
26550 integer_default,
26551 number_default,
26552 text_default,
26553 datetime_default,
26554 date_default,
26555 boolean_default,
26556 media_default,
26557 array_default,
26558 password_default,
26559 telephone_default,
26560 color_default,
26561 url_default
26562 ].find((fieldType) => fieldType?.type === type);
26563 if (!!found) {
26564 return found;
26565 }
26566 return no_type_default;
26567 }
26568 function normalizeFields(fields) {
26569 return fields.map((field) => {
26570 const fieldType = getFieldTypeByName(field.type);
26571 const getValue = field.getValue || get_value_from_id_default(field.id);
26572 const sort7 = function(a2, b2, direction) {
26573 const aValue = getValue({ item: a2 });
26574 const bValue = getValue({ item: b2 });
26575 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
26576 };
26577 return {
26578 id: field.id,
26579 label: field.label || field.id,
26580 header: field.header || field.label || field.id,
26581 description: field.description,
26582 placeholder: field.placeholder,
26583 getValue,
26584 setValue: field.setValue || set_value_from_id_default(field.id),
26585 elements: field.elements,
26586 getElements: field.getElements,
26587 hasElements: hasElements(field),
26588 isVisible: field.isVisible,
26589 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
26590 enableHiding: field.enableHiding ?? true,
26591 readOnly: field.readOnly ?? false,
26592 // The type provides defaults for the following props
26593 type: fieldType.type,
26594 render: field.render ?? fieldType.render,
26595 Edit: getControl(field, fieldType.Edit),
26596 sort: sort7,
26597 enableSorting: field.enableSorting ?? fieldType.enableSorting,
26598 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
26599 isValid: getIsValid(field, fieldType),
26600 filterBy: get_filter_by_default(
26601 field,
26602 fieldType.defaultOperators,
26603 fieldType.validOperators
26604 ),
26605 filter: getFilter(fieldType),
26606 format: get_format_default(field, fieldType),
26607 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
26608 };
26609 });
26610 }
26611
26612 // packages/dataviews/build-module/hooks/use-data.mjs
26613 var import_element75 = __toESM(require_element(), 1);
26614 function useData({
26615 view,
26616 data: shownData,
26617 getItemId,
26618 isLoading,
26619 paginationInfo,
26620 selection
26621 }) {
26622 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
26623 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element75.useState)(
26624 !isLoading
26625 );
26626 (0, import_element75.useEffect)(() => {
26627 if (!isLoading) {
26628 setHasInitiallyLoaded(true);
26629 }
26630 }, [isLoading]);
26631 const previousDataRef = (0, import_element75.useRef)(shownData);
26632 const previousPaginationInfoRef = (0, import_element75.useRef)(paginationInfo);
26633 (0, import_element75.useEffect)(() => {
26634 if (!isLoading) {
26635 previousDataRef.current = shownData;
26636 previousPaginationInfoRef.current = paginationInfo;
26637 }
26638 }, [shownData, isLoading, paginationInfo]);
26639 const [visibleEntries, setVisibleEntries] = (0, import_element75.useState)([]);
26640 const positionMapRef = (0, import_element75.useRef)(/* @__PURE__ */ new Map());
26641 const allLoadedRecordsRef = (0, import_element75.useRef)([]);
26642 const prevViewParamsRef = (0, import_element75.useRef)({
26643 search: void 0,
26644 filters: void 0,
26645 perPage: void 0
26646 });
26647 const scrollDirectionRef = (0, import_element75.useRef)(void 0);
26648 const prevStartPositionRef = (0, import_element75.useRef)(void 0);
26649 const hasInitializedRef = (0, import_element75.useRef)(false);
26650 const allLoadedRecords = (0, import_element75.useMemo)(() => {
26651 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
26652 if (view.startPosition < prevStartPositionRef.current) {
26653 scrollDirectionRef.current = "up";
26654 } else if (view.startPosition > prevStartPositionRef.current) {
26655 scrollDirectionRef.current = "down";
26656 }
26657 }
26658 prevStartPositionRef.current = view.startPosition;
26659 const currentFiltersKey = JSON.stringify(view.filters ?? []);
26660 const prevFiltersKey = prevViewParamsRef.current.filters;
26661 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
26662 hasInitializedRef.current = true;
26663 prevViewParamsRef.current = {
26664 search: view.search,
26665 filters: currentFiltersKey,
26666 perPage: view.perPage
26667 };
26668 if (shouldReset) {
26669 positionMapRef.current.clear();
26670 scrollDirectionRef.current = void 0;
26671 const startPosition = view.search ? 1 : view.startPosition ?? 1;
26672 const records = shownData.map((record, index2) => {
26673 const position = startPosition + index2;
26674 positionMapRef.current.set(getItemId(record), position);
26675 return {
26676 ...record,
26677 position
26678 };
26679 });
26680 allLoadedRecordsRef.current = records;
26681 return records;
26682 }
26683 const prev = allLoadedRecordsRef.current;
26684 const shownDataIds = new Set(shownData.map(getItemId));
26685 const scrollDirection = scrollDirectionRef.current;
26686 const basePosition = view.search ? 1 : view.startPosition ?? 1;
26687 const newRecords = shownData.map((record, index2) => {
26688 const itemId = getItemId(record);
26689 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
26690 if (position !== void 0) {
26691 positionMapRef.current.set(itemId, position);
26692 }
26693 return {
26694 ...record,
26695 position
26696 };
26697 });
26698 if (newRecords.length === 0) {
26699 return prev;
26700 }
26701 const prevWithoutDuplicates = prev.filter(
26702 (record) => !shownDataIds.has(getItemId(record))
26703 );
26704 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
26705 allRecords.sort((a2, b2) => {
26706 const posA = a2.position;
26707 const posB = b2.position;
26708 return posA - posB;
26709 });
26710 let result = allRecords;
26711 if (visibleEntries.length > 0) {
26712 const visibleMin = Math.min(...visibleEntries);
26713 const visibleMax = Math.max(...visibleEntries);
26714 const buffer = 20;
26715 const recordPositions = allRecords.map(
26716 (r3) => r3.position
26717 );
26718 const minRecordPos = Math.min(...recordPositions);
26719 const maxRecordPos = Math.max(...recordPositions);
26720 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
26721 if (hasOverlap) {
26722 result = allRecords.filter((record) => {
26723 const itemId = getItemId(record);
26724 const isSelected2 = selection?.includes(itemId);
26725 if (isSelected2) {
26726 return true;
26727 }
26728 const itemPosition = record.position;
26729 if (scrollDirection === "up") {
26730 return itemPosition <= visibleMax + buffer;
26731 } else if (scrollDirection === "down") {
26732 return itemPosition >= visibleMin - buffer;
26733 }
26734 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
26735 });
26736 }
26737 }
26738 allLoadedRecordsRef.current = result;
26739 return result;
26740 }, [
26741 shownData,
26742 view.search,
26743 view.filters,
26744 view.perPage,
26745 view.startPosition,
26746 view.infiniteScrollEnabled,
26747 visibleEntries,
26748 selection,
26749 getItemId
26750 ]);
26751 if (!isInfiniteScrollEnabled) {
26752 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
26753 return {
26754 data: dataToReturn.map((item) => ({
26755 ...item,
26756 position: void 0
26757 })),
26758 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
26759 hasInitiallyLoaded,
26760 setVisibleEntries: void 0
26761 };
26762 }
26763 return {
26764 data: allLoadedRecords,
26765 paginationInfo,
26766 hasInitiallyLoaded,
26767 setVisibleEntries
26768 };
26769 }
26770
26771 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
26772 var import_element76 = __toESM(require_element(), 1);
26773 var import_compose13 = __toESM(require_compose(), 1);
26774 function captureAnchorElement(container, anchorElementRef, direction) {
26775 const containerRect = container.getBoundingClientRect();
26776 const centerY = containerRect.top + containerRect.height / 2;
26777 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
26778 if (items.length === 0) {
26779 return false;
26780 }
26781 const bestAnchor = items.reduce((best, item) => {
26782 const itemRect = item.getBoundingClientRect();
26783 const itemCenterY = itemRect.top + itemRect.height / 2;
26784 const distance = Math.abs(itemCenterY - centerY);
26785 const bestRect = best.getBoundingClientRect();
26786 const bestCenterY = bestRect.top + bestRect.height / 2;
26787 const bestDistance = Math.abs(bestCenterY - centerY);
26788 return distance < bestDistance ? item : best;
26789 });
26790 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
26791 const anchorRect = bestAnchor.getBoundingClientRect();
26792 anchorElementRef.current = {
26793 posinset,
26794 viewportOffset: anchorRect.top - containerRect.top,
26795 scrollTop: container.scrollTop,
26796 direction
26797 };
26798 return true;
26799 }
26800 function useInfiniteScroll({
26801 view,
26802 onChangeView,
26803 isLoading,
26804 paginationInfo,
26805 containerRef,
26806 setVisibleEntries
26807 }) {
26808 const anchorElementRef = (0, import_element76.useRef)(null);
26809 const viewRef = (0, import_element76.useRef)(view);
26810 const isLoadingRef = (0, import_element76.useRef)(isLoading);
26811 const onChangeViewRef = (0, import_element76.useRef)(onChangeView);
26812 const totalItemsRef = (0, import_element76.useRef)(paginationInfo.totalItems);
26813 (0, import_element76.useLayoutEffect)(() => {
26814 viewRef.current = view;
26815 isLoadingRef.current = isLoading;
26816 onChangeViewRef.current = onChangeView;
26817 totalItemsRef.current = paginationInfo.totalItems;
26818 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
26819 const intersectionObserverCallback = (0, import_element76.useCallback)(
26820 (entries) => {
26821 if (!setVisibleEntries) {
26822 return;
26823 }
26824 setVisibleEntries((prev) => {
26825 const newVisibleEntries = new Set(prev);
26826 let hasChanged = false;
26827 entries.forEach((entry) => {
26828 const posInSet = Number(
26829 entry.target?.attributes?.getNamedItem(
26830 "aria-posinset"
26831 )?.value
26832 );
26833 if (isNaN(posInSet)) {
26834 return;
26835 }
26836 if (entry.isIntersecting) {
26837 if (!newVisibleEntries.has(posInSet)) {
26838 newVisibleEntries.add(posInSet);
26839 hasChanged = true;
26840 }
26841 } else if (newVisibleEntries.has(posInSet)) {
26842 newVisibleEntries.delete(posInSet);
26843 hasChanged = true;
26844 }
26845 });
26846 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
26847 });
26848 },
26849 [setVisibleEntries]
26850 );
26851 (0, import_element76.useLayoutEffect)(() => {
26852 const container = containerRef.current;
26853 const anchor = anchorElementRef.current;
26854 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
26855 return;
26856 }
26857 const anchorElement = container.querySelector(
26858 `[aria-posinset="${anchor.posinset}"]`
26859 );
26860 if (anchorElement) {
26861 const containerRect = container.getBoundingClientRect();
26862 const anchorRect = anchorElement.getBoundingClientRect();
26863 const currentOffset = anchorRect.top - containerRect.top;
26864 const scrollAdjustment = currentOffset - anchor.viewportOffset + (container.scrollTop - anchor.scrollTop);
26865 if (Math.abs(scrollAdjustment) > 1) {
26866 container.scrollTop += scrollAdjustment;
26867 }
26868 }
26869 anchorElementRef.current = null;
26870 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
26871 const intersectionObserverRef = (0, import_element76.useRef)(
26872 null
26873 );
26874 (0, import_element76.useEffect)(() => {
26875 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
26876 if (intersectionObserverRef.current) {
26877 intersectionObserverRef.current.disconnect();
26878 intersectionObserverRef.current = null;
26879 }
26880 return;
26881 }
26882 intersectionObserverRef.current = new IntersectionObserver(
26883 intersectionObserverCallback,
26884 { root: null, rootMargin: "0px", threshold: 0.1 }
26885 );
26886 return () => {
26887 if (intersectionObserverRef.current) {
26888 intersectionObserverRef.current.disconnect();
26889 intersectionObserverRef.current = null;
26890 }
26891 };
26892 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
26893 (0, import_element76.useEffect)(() => {
26894 if (!view.infiniteScrollEnabled || !containerRef.current) {
26895 return;
26896 }
26897 let lastScrollTop = 0;
26898 const BOTTOM_THRESHOLD = 600;
26899 const TOP_THRESHOLD = 800;
26900 const handleScroll = (0, import_compose13.throttle)((event) => {
26901 const currentView = viewRef.current;
26902 const totalItems = totalItemsRef.current;
26903 const target = event.target;
26904 const scrollTop = target.scrollTop;
26905 const scrollHeight = target.scrollHeight;
26906 const clientHeight = target.clientHeight;
26907 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
26908 lastScrollTop = scrollTop;
26909 if (isLoadingRef.current) {
26910 return;
26911 }
26912 const currentStartPosition = currentView.startPosition || 1;
26913 const batchSize = currentView.perPage || 10;
26914 const currentEndPosition = Math.min(
26915 currentStartPosition + batchSize,
26916 totalItems
26917 );
26918 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
26919 if (currentEndPosition < totalItems) {
26920 const newStartPosition = currentEndPosition;
26921 captureAnchorElement(target, anchorElementRef, "down");
26922 onChangeViewRef.current({
26923 ...currentView,
26924 startPosition: newStartPosition
26925 });
26926 }
26927 }
26928 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
26929 if (currentStartPosition > 1) {
26930 const calculatedStartPosition = currentStartPosition - batchSize;
26931 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
26932 captureAnchorElement(target, anchorElementRef, "up");
26933 onChangeViewRef.current({
26934 ...currentView,
26935 startPosition: newStartPosition
26936 });
26937 }
26938 }
26939 }, 50);
26940 const container = containerRef.current;
26941 container.addEventListener("scroll", handleScroll);
26942 return () => {
26943 container.removeEventListener("scroll", handleScroll);
26944 handleScroll.cancel();
26945 };
26946 }, [containerRef, view.infiniteScrollEnabled]);
26947 return {
26948 intersectionObserver: intersectionObserverRef.current
26949 };
26950 }
26951
26952 // packages/dataviews/build-module/dataviews-picker/index.mjs
26953 var import_element77 = __toESM(require_element(), 1);
26954 var import_compose14 = __toESM(require_compose(), 1);
26955 var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1);
26956 var isItemClickable = () => false;
26957 var dataViewsPickerLayouts = VIEW_LAYOUTS.filter(
26958 (viewLayout) => viewLayout.isPicker
26959 );
26960 var defaultGetItemId = (item) => item.id;
26961 var EMPTY_ARRAY6 = [];
26962 var DEFAULT_PICKER_LAYOUTS = {
26963 pickerGrid: true,
26964 pickerTable: true
26965 };
26966 function DefaultUI({
26967 search = true,
26968 searchLabel = void 0
26969 }) {
26970 const { view } = (0, import_element77.useContext)(dataviews_context_default);
26971 const isInfiniteScroll = view.infiniteScrollEnabled;
26972 return /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(import_jsx_runtime120.Fragment, { children: [
26973 /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(
26974 Stack,
26975 {
26976 direction: "row",
26977 align: "top",
26978 justify: "space-between",
26979 className: clsx_default("dataviews__view-actions", {
26980 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
26981 }),
26982 gap: "xs",
26983 children: [
26984 /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(
26985 Stack,
26986 {
26987 direction: "row",
26988 gap: "sm",
26989 justify: "start",
26990 className: "dataviews__search",
26991 children: [
26992 search && /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(dataviews_search_default, { label: searchLabel }),
26993 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(toggle_default, {})
26994 ]
26995 }
26996 ),
26997 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(dataviews_view_config_default, {}) })
26998 ]
26999 }
27000 ),
27001 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
27002 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(DataViewsLayout, {}),
27003 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(DataViewsPickerFooter, {})
27004 ] });
27005 }
27006 function DataViewsPicker({
27007 view,
27008 onChangeView,
27009 fields,
27010 search = true,
27011 searchLabel = void 0,
27012 actions = EMPTY_ARRAY6,
27013 data,
27014 getItemId = defaultGetItemId,
27015 isLoading = false,
27016 paginationInfo,
27017 defaultLayouts: defaultLayoutsProperty = DEFAULT_PICKER_LAYOUTS,
27018 selection,
27019 onChangeSelection,
27020 children,
27021 config = { perPageSizes: [10, 20, 50, 100] },
27022 itemListLabel,
27023 empty,
27024 onReset
27025 }) {
27026 const { data: displayData, setVisibleEntries } = useData({
27027 view,
27028 data,
27029 getItemId,
27030 selection,
27031 paginationInfo
27032 });
27033 const containerRef = (0, import_element77.useRef)(null);
27034 const [containerWidth, setContainerWidth] = (0, import_element77.useState)(0);
27035 const resizeObserverRef = (0, import_compose14.useResizeObserver)(
27036 (resizeObserverEntries) => {
27037 setContainerWidth(
27038 resizeObserverEntries[0].borderBoxSize[0].inlineSize
27039 );
27040 },
27041 { box: "border-box" }
27042 );
27043 const [openedFilter, setOpenedFilter] = (0, import_element77.useState)(null);
27044 function setSelectionWithChange(value) {
27045 const newValue = typeof value === "function" ? value(selection) : value;
27046 if (onChangeSelection) {
27047 onChangeSelection(newValue);
27048 }
27049 }
27050 const _fields = (0, import_element77.useMemo)(() => normalizeFields(fields), [fields]);
27051 const filters = use_filters_default(_fields, view);
27052 const hasPrimaryOrLockedFilters = (0, import_element77.useMemo)(
27053 () => (filters || []).some(
27054 (filter) => filter.isPrimary || filter.isLocked
27055 ),
27056 [filters]
27057 );
27058 const [isShowingFilter, setIsShowingFilter] = (0, import_element77.useState)(
27059 hasPrimaryOrLockedFilters
27060 );
27061 const { intersectionObserver } = useInfiniteScroll({
27062 view,
27063 onChangeView,
27064 isLoading,
27065 paginationInfo,
27066 containerRef,
27067 setVisibleEntries
27068 });
27069 (0, import_element77.useEffect)(() => {
27070 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
27071 setIsShowingFilter(true);
27072 }
27073 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
27074 const defaultLayouts2 = (0, import_element77.useMemo)(
27075 () => Object.fromEntries(
27076 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
27077 return dataViewsPickerLayouts.some(
27078 (viewLayout) => viewLayout.type === layoutType
27079 );
27080 }).map(([key, value]) => [
27081 key,
27082 value === true ? {} : value
27083 ])
27084 ),
27085 [defaultLayoutsProperty]
27086 );
27087 if (!defaultLayouts2[view.type]) {
27088 return null;
27089 }
27090 return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
27091 dataviews_context_default.Provider,
27092 {
27093 value: {
27094 view,
27095 onChangeView,
27096 fields: _fields,
27097 actions,
27098 data: displayData,
27099 isLoading,
27100 paginationInfo,
27101 isItemClickable,
27102 selection,
27103 onChangeSelection: setSelectionWithChange,
27104 openedFilter,
27105 setOpenedFilter,
27106 getItemId,
27107 containerWidth,
27108 containerRef,
27109 resizeObserverRef,
27110 defaultLayouts: defaultLayouts2,
27111 filters,
27112 isShowingFilter,
27113 setIsShowingFilter,
27114 config,
27115 itemListLabel,
27116 empty,
27117 onReset,
27118 hasInitiallyLoaded: true,
27119 intersectionObserver
27120 },
27121 children: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)("div", { className: "dataviews-picker-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(DefaultUI, { search, searchLabel }) })
27122 }
27123 );
27124 }
27125 var DataViewsPickerSubComponents = DataViewsPicker;
27126 DataViewsPickerSubComponents.BulkActionToolbar = DataViewsPickerBulkActionToolbar;
27127 DataViewsPickerSubComponents.Footer = DataViewsPickerFooter;
27128 DataViewsPickerSubComponents.Filters = filters_default;
27129 DataViewsPickerSubComponents.FiltersToggled = filters_toggled_default;
27130 DataViewsPickerSubComponents.FiltersToggle = toggle_default;
27131 DataViewsPickerSubComponents.Layout = DataViewsLayout;
27132 DataViewsPickerSubComponents.LayoutSwitcher = ViewTypeMenu;
27133 DataViewsPickerSubComponents.Pagination = DataViewsPagination;
27134 DataViewsPickerSubComponents.Search = dataviews_search_default;
27135 DataViewsPickerSubComponents.ViewConfig = DataviewsViewConfigDropdown;
27136 var dataviews_picker_default = DataViewsPickerSubComponents;
27137
27138 // node_modules/dequal/dist/index.mjs
27139 var has = Object.prototype.hasOwnProperty;
27140 function find(iter, tar, key) {
27141 for (key of iter.keys()) {
27142 if (dequal(key, tar)) return key;
27143 }
27144 }
27145 function dequal(foo, bar) {
27146 var ctor, len, tmp;
27147 if (foo === bar) return true;
27148 if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
27149 if (ctor === Date) return foo.getTime() === bar.getTime();
27150 if (ctor === RegExp) return foo.toString() === bar.toString();
27151 if (ctor === Array) {
27152 if ((len = foo.length) === bar.length) {
27153 while (len-- && dequal(foo[len], bar[len])) ;
27154 }
27155 return len === -1;
27156 }
27157 if (ctor === Set) {
27158 if (foo.size !== bar.size) {
27159 return false;
27160 }
27161 for (len of foo) {
27162 tmp = len;
27163 if (tmp && typeof tmp === "object") {
27164 tmp = find(bar, tmp);
27165 if (!tmp) return false;
27166 }
27167 if (!bar.has(tmp)) return false;
27168 }
27169 return true;
27170 }
27171 if (ctor === Map) {
27172 if (foo.size !== bar.size) {
27173 return false;
27174 }
27175 for (len of foo) {
27176 tmp = len[0];
27177 if (tmp && typeof tmp === "object") {
27178 tmp = find(bar, tmp);
27179 if (!tmp) return false;
27180 }
27181 if (!dequal(len[1], bar.get(tmp))) {
27182 return false;
27183 }
27184 }
27185 return true;
27186 }
27187 if (ctor === ArrayBuffer) {
27188 foo = new Uint8Array(foo);
27189 bar = new Uint8Array(bar);
27190 } else if (ctor === DataView) {
27191 if ((len = foo.byteLength) === bar.byteLength) {
27192 while (len-- && foo.getInt8(len) === bar.getInt8(len)) ;
27193 }
27194 return len === -1;
27195 }
27196 if (ArrayBuffer.isView(foo)) {
27197 if ((len = foo.byteLength) === bar.byteLength) {
27198 while (len-- && foo[len] === bar[len]) ;
27199 }
27200 return len === -1;
27201 }
27202 if (!ctor || typeof foo === "object") {
27203 len = 0;
27204 for (ctor in foo) {
27205 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
27206 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
27207 }
27208 return Object.keys(bar).length === len;
27209 }
27210 }
27211 return foo !== foo && bar !== bar;
27212 }
27213
27214 // packages/views/build-module/use-view.mjs
27215 var import_element78 = __toESM(require_element(), 1);
27216 var import_data7 = __toESM(require_data(), 1);
27217 var import_preferences = __toESM(require_preferences(), 1);
27218
27219 // packages/views/build-module/preference-keys.mjs
27220 function generatePreferenceKey(kind, name, slug) {
27221 return `dataviews-${kind}-${name}-${slug}`;
27222 }
27223
27224 // packages/views/build-module/filter-utils.mjs
27225 var SCALAR_VALUES = [
27226 "titleField",
27227 "mediaField",
27228 "descriptionField",
27229 "showTitle",
27230 "showMedia",
27231 "showDescription",
27232 "showLevels",
27233 "infiniteScrollEnabled"
27234 ];
27235 function mergeActiveViewOverrides(view, activeViewOverrides, defaultView2) {
27236 if (!activeViewOverrides) {
27237 return view;
27238 }
27239 let result = view;
27240 for (const key of SCALAR_VALUES) {
27241 if (key in activeViewOverrides) {
27242 result = { ...result, [key]: activeViewOverrides[key] };
27243 }
27244 }
27245 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
27246 const activeFields = new Set(
27247 activeViewOverrides.filters.map((f2) => f2.field)
27248 );
27249 const preserved = (view.filters ?? []).filter(
27250 (f2) => !activeFields.has(f2.field)
27251 );
27252 result = {
27253 ...result,
27254 filters: [...preserved, ...activeViewOverrides.filters]
27255 };
27256 }
27257 if (activeViewOverrides.sort) {
27258 const isDefaultSort = defaultView2 && view.sort?.field === defaultView2.sort?.field && view.sort?.direction === defaultView2.sort?.direction;
27259 if (isDefaultSort) {
27260 result = {
27261 ...result,
27262 sort: activeViewOverrides.sort
27263 };
27264 }
27265 }
27266 if (activeViewOverrides.layout) {
27267 result = {
27268 ...result,
27269 layout: {
27270 ...result.layout,
27271 ...activeViewOverrides.layout
27272 }
27273 };
27274 }
27275 if (activeViewOverrides.groupBy) {
27276 result = {
27277 ...result,
27278 groupBy: activeViewOverrides.groupBy
27279 };
27280 }
27281 return result;
27282 }
27283 function stripActiveViewOverrides(view, activeViewOverrides, defaultView2) {
27284 if (!activeViewOverrides) {
27285 return view;
27286 }
27287 let result = view;
27288 for (const key of SCALAR_VALUES) {
27289 if (key in activeViewOverrides) {
27290 const { [key]: _, ...rest } = result;
27291 result = rest;
27292 }
27293 }
27294 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
27295 const activeFields = new Set(
27296 activeViewOverrides.filters.map((f2) => f2.field)
27297 );
27298 result = {
27299 ...result,
27300 filters: (view.filters ?? []).filter(
27301 (f2) => !activeFields.has(f2.field)
27302 )
27303 };
27304 }
27305 if (activeViewOverrides.sort && view.sort?.field === activeViewOverrides.sort.field && view.sort?.direction === activeViewOverrides.sort.direction) {
27306 result = {
27307 ...result,
27308 sort: defaultView2?.sort
27309 };
27310 }
27311 if (activeViewOverrides.layout && "layout" in result && result.layout) {
27312 const layout = { ...result.layout };
27313 for (const key of Object.keys(activeViewOverrides.layout)) {
27314 delete layout[key];
27315 }
27316 result = {
27317 ...result,
27318 layout: Object.keys(layout).length > 0 ? layout : void 0
27319 };
27320 }
27321 if (activeViewOverrides.groupBy && "groupBy" in result) {
27322 const { groupBy: _, ...rest } = result;
27323 result = rest;
27324 }
27325 return result;
27326 }
27327
27328 // packages/views/build-module/use-view.mjs
27329 function omit3(obj, keys) {
27330 const result = { ...obj };
27331 for (const key of keys) {
27332 delete result[key];
27333 }
27334 return result;
27335 }
27336 function useView(config) {
27337 const {
27338 kind,
27339 name,
27340 slug,
27341 defaultView: defaultView2,
27342 activeViewOverrides,
27343 queryParams,
27344 onChangeQueryParams
27345 } = config;
27346 const preferenceKey = generatePreferenceKey(kind, name, slug);
27347 const persistedView = (0, import_data7.useSelect)(
27348 (select3) => {
27349 return select3(import_preferences.store).get(
27350 "core/views",
27351 preferenceKey
27352 );
27353 },
27354 [preferenceKey]
27355 );
27356 const { set: set2 } = (0, import_data7.useDispatch)(import_preferences.store);
27357 const baseView = (0, import_element78.useMemo)(
27358 () => persistedView ?? defaultView2 ?? {},
27359 [persistedView, defaultView2]
27360 );
27361 const page = Number(queryParams?.page ?? baseView.page ?? 1);
27362 const search = queryParams?.search ?? baseView.search ?? "";
27363 const combinedOverrides = (0, import_element78.useMemo)(() => {
27364 const rawDefaults = config.defaultLayouts?.[baseView.type];
27365 const layoutTypeDefaults = !rawDefaults || rawDefaults === true ? {} : rawDefaults;
27366 return { ...layoutTypeDefaults, ...activeViewOverrides };
27367 }, [config.defaultLayouts, baseView.type, activeViewOverrides]);
27368 const view = (0, import_element78.useMemo)(() => {
27369 return mergeActiveViewOverrides(
27370 {
27371 ...baseView,
27372 page,
27373 search
27374 },
27375 combinedOverrides,
27376 defaultView2
27377 );
27378 }, [baseView, page, search, combinedOverrides, defaultView2]);
27379 const isModified = !!persistedView;
27380 const updateView = (0, import_element78.useCallback)(
27381 (newView) => {
27382 const urlParams = {
27383 page: newView?.page,
27384 search: newView?.search
27385 };
27386 const preferenceView = stripActiveViewOverrides(
27387 omit3(newView, ["page", "search"]),
27388 combinedOverrides,
27389 defaultView2
27390 );
27391 if (onChangeQueryParams && !dequal(urlParams, { page, search })) {
27392 onChangeQueryParams(urlParams);
27393 }
27394 const comparableBaseView = stripActiveViewOverrides(
27395 baseView,
27396 combinedOverrides,
27397 defaultView2
27398 );
27399 const comparableDefaultView = stripActiveViewOverrides(
27400 defaultView2,
27401 combinedOverrides,
27402 defaultView2
27403 );
27404 if (!dequal(comparableBaseView, preferenceView)) {
27405 if (dequal(preferenceView, comparableDefaultView)) {
27406 set2("core/views", preferenceKey, void 0);
27407 } else {
27408 set2("core/views", preferenceKey, preferenceView);
27409 }
27410 }
27411 },
27412 [
27413 onChangeQueryParams,
27414 page,
27415 search,
27416 baseView,
27417 defaultView2,
27418 combinedOverrides,
27419 set2,
27420 preferenceKey
27421 ]
27422 );
27423 const resetToDefault = (0, import_element78.useCallback)(() => {
27424 set2("core/views", preferenceKey, void 0);
27425 }, [preferenceKey, set2]);
27426 return {
27427 view,
27428 isModified,
27429 updateView,
27430 resetToDefault
27431 };
27432 }
27433
27434 // packages/views/build-module/load-view.mjs
27435 var import_data8 = __toESM(require_data(), 1);
27436 var import_preferences2 = __toESM(require_preferences(), 1);
27437
27438 // packages/views/build-module/use-view-config.mjs
27439 var import_data9 = __toESM(require_data(), 1);
27440 var import_core_data2 = __toESM(require_core_data(), 1);
27441
27442 // packages/views/build-module/lock-unlock.mjs
27443 var import_private_apis3 = __toESM(require_private_apis(), 1);
27444 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
27445 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
27446 "@wordpress/views"
27447 );
27448
27449 // packages/media-fields/build-module/alt_text/index.mjs
27450 var import_i18n51 = __toESM(require_i18n(), 1);
27451 var import_components47 = __toESM(require_components(), 1);
27452 var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1);
27453 var altTextField = {
27454 id: "alt_text",
27455 type: "text",
27456 label: (0, import_i18n51.__)("Alt text"),
27457 isVisible: (item) => item?.media_type === "image",
27458 render: ({ item }) => item?.alt_text || "-",
27459 Edit: ({ field, onChange, data }) => {
27460 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
27461 import_components47.TextareaControl,
27462 {
27463 label: field.label,
27464 value: data.alt_text || "",
27465 onChange: (value) => onChange({ alt_text: value }),
27466 help: /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(import_jsx_runtime121.Fragment, { children: [
27467 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
27468 Link,
27469 {
27470 href: (
27471 // translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
27472 (0, import_i18n51.__)(
27473 "https://www.w3.org/WAI/tutorials/images/decision-tree/"
27474 )
27475 ),
27476 openInNewTab: true,
27477 children: (0, import_i18n51.__)("Describe the purpose of the image.")
27478 }
27479 ),
27480 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)("br", {}),
27481 (0, import_i18n51.__)("Leave empty if decorative.")
27482 ] }),
27483 rows: 2
27484 }
27485 );
27486 },
27487 enableSorting: false,
27488 filterBy: false
27489 };
27490 var alt_text_default = altTextField;
27491
27492 // packages/media-fields/build-module/attached_to/index.mjs
27493 var import_i18n54 = __toESM(require_i18n(), 1);
27494
27495 // packages/media-fields/build-module/attached_to/view.mjs
27496 var import_element79 = __toESM(require_element(), 1);
27497 var import_i18n52 = __toESM(require_i18n(), 1);
27498
27499 // packages/media-fields/build-module/utils/get-rendered-content.mjs
27500 function getRenderedContent(content) {
27501 if (!content) {
27502 return "";
27503 }
27504 if (typeof content === "string") {
27505 return content;
27506 }
27507 if (typeof content === "object") {
27508 return content.rendered || content.raw || "";
27509 }
27510 return "";
27511 }
27512
27513 // packages/media-fields/build-module/attached_to/view.mjs
27514 var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1);
27515 function MediaAttachedToView({
27516 item
27517 }) {
27518 const [attachedPostTitle, setAttachedPostTitle] = (0, import_element79.useState)(null);
27519 const parentId = item.post;
27520 const embeddedPostId = item._embedded?.["wp:attached-to"]?.[0]?.id;
27521 const embeddedPostTitle = item._embedded?.["wp:attached-to"]?.[0]?.title;
27522 (0, import_element79.useEffect)(() => {
27523 if (!!parentId && parentId === embeddedPostId) {
27524 setAttachedPostTitle(
27525 getRenderedContent(embeddedPostTitle) || (0, import_i18n52.__)("(no title)")
27526 );
27527 }
27528 if (!parentId) {
27529 setAttachedPostTitle((0, import_i18n52.__)("(Unattached)"));
27530 }
27531 }, [parentId, embeddedPostId, embeddedPostTitle]);
27532 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_jsx_runtime122.Fragment, { children: attachedPostTitle });
27533 }
27534
27535 // packages/media-fields/build-module/attached_to/edit.mjs
27536 var import_core_data3 = __toESM(require_core_data(), 1);
27537 var import_components48 = __toESM(require_components(), 1);
27538 var import_i18n53 = __toESM(require_i18n(), 1);
27539 var import_element80 = __toESM(require_element(), 1);
27540 var import_compose15 = __toESM(require_compose(), 1);
27541 var import_data10 = __toESM(require_data(), 1);
27542 var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1);
27543 function MediaAttachedToEdit({
27544 data,
27545 onChange
27546 }) {
27547 const defaultPost = !!data.post && !!data?._embedded?.["wp:attached-to"]?.[0] ? [
27548 {
27549 label: getRenderedContent(
27550 data._embedded?.["wp:attached-to"]?.[0]?.title
27551 ),
27552 value: data.post.toString()
27553 }
27554 ] : [];
27555 const [options, setOptions] = (0, import_element80.useState)(defaultPost);
27556 const [searchResults, setSearchResults] = (0, import_element80.useState)(
27557 []
27558 );
27559 const [isLoading, setIsLoading] = (0, import_element80.useState)(false);
27560 const [value, setValue] = (0, import_element80.useState)(
27561 data?.post?.toString() ?? null
27562 );
27563 const postTypes = (0, import_data10.useSelect)(
27564 (select3) => select3(import_core_data3.store).getPostTypes(),
27565 []
27566 );
27567 const handleDetach = () => {
27568 onChange({
27569 post: 0,
27570 _embedded: { ...data?._embedded, "wp:attached-to": void 0 }
27571 });
27572 setValue(null);
27573 setOptions([]);
27574 };
27575 const onValueChange = async (filterValue) => {
27576 setIsLoading(true);
27577 const results = await (0, import_core_data3.__experimentalFetchLinkSuggestions)(
27578 filterValue,
27579 /*
27580 * @TODO `fetchLinkSuggestions()` should accept `perPage` as an option argument.
27581 * `isInitialSuggestions` limits the result to 3, otherwise it's hardcoded to 20.
27582 */
27583 { type: "post", isInitialSuggestions: true },
27584 {}
27585 );
27586 setSearchResults(results);
27587 const suggestions = results.map((result) => {
27588 return {
27589 label: result.title,
27590 value: result.id.toString()
27591 };
27592 });
27593 const includeCurrent = !filterValue && suggestions.findIndex((s2) => s2.value === value) === -1;
27594 setOptions(suggestions.concat(includeCurrent ? defaultPost : []));
27595 setIsLoading(false);
27596 };
27597 const handleSelectOption = (selectedPostId) => {
27598 if (!selectedPostId) {
27599 handleDetach();
27600 return;
27601 }
27602 setValue(selectedPostId);
27603 if (selectedPostId) {
27604 const selectedPost = searchResults.find(
27605 (result) => result.id === Number(selectedPostId)
27606 );
27607 if (selectedPost && postTypes) {
27608 const postType = postTypes.find(
27609 (_postType) => _postType.slug === selectedPost?.type
27610 );
27611 const attachedTo = {
27612 ...postType && { type: postType.slug },
27613 id: Number(selectedPostId),
27614 title: {
27615 raw: selectedPost.title,
27616 rendered: selectedPost.title
27617 }
27618 };
27619 onChange({
27620 post: Number(selectedPostId),
27621 _embedded: {
27622 ...data?._embedded,
27623 "wp:attached-to": [attachedTo]
27624 }
27625 });
27626 }
27627 }
27628 };
27629 const help = (0, import_element80.createInterpolateElement)(
27630 (0, import_i18n53.__)(
27631 "Search for a post or page to attach this media to or <button>detach current</button>."
27632 ),
27633 {
27634 button: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
27635 import_components48.Button,
27636 {
27637 __next40pxDefaultSize: true,
27638 onClick: handleDetach,
27639 variant: "link",
27640 accessibleWhenDisabled: true,
27641 disabled: !value
27642 }
27643 )
27644 }
27645 );
27646 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
27647 import_components48.ComboboxControl,
27648 {
27649 className: "dataviews-media-field__attached-to",
27650 isLoading,
27651 label: (0, import_i18n53.__)("Attached to"),
27652 help,
27653 value,
27654 options,
27655 onFilterValueChange: (0, import_compose15.debounce)(
27656 (filterValue) => onValueChange(filterValue),
27657 300
27658 ),
27659 onChange: handleSelectOption,
27660 hideLabelFromVision: true
27661 }
27662 );
27663 }
27664
27665 // packages/media-fields/build-module/attached_to/index.mjs
27666 var attachedToField = {
27667 id: "attached_to",
27668 type: "text",
27669 label: (0, import_i18n54.__)("Attached to"),
27670 Edit: MediaAttachedToEdit,
27671 render: MediaAttachedToView,
27672 enableSorting: false,
27673 filterBy: false
27674 };
27675 var attached_to_default = attachedToField;
27676
27677 // packages/media-fields/build-module/author/index.mjs
27678 var import_i18n56 = __toESM(require_i18n(), 1);
27679 var import_data11 = __toESM(require_data(), 1);
27680 var import_core_data4 = __toESM(require_core_data(), 1);
27681
27682 // packages/media-fields/build-module/author/view.mjs
27683 var import_i18n55 = __toESM(require_i18n(), 1);
27684 var import_element81 = __toESM(require_element(), 1);
27685 var import_components49 = __toESM(require_components(), 1);
27686 var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1);
27687 function AuthorView({
27688 item
27689 }) {
27690 const author = item?._embedded?.author?.[0];
27691 const text = author?.name;
27692 const imageUrl = author?.avatar_urls?.[48];
27693 const [loadingState, setLoadingState] = (0, import_element81.useState)("loading");
27694 (0, import_element81.useEffect)(() => {
27695 setLoadingState("loading");
27696 }, [imageUrl]);
27697 const imgRef = (0, import_element81.useCallback)((img) => {
27698 if (img?.complete) {
27699 setLoadingState("instant");
27700 }
27701 }, []);
27702 const handleLoad = () => {
27703 if (loadingState === "loading") {
27704 setLoadingState("loaded");
27705 }
27706 };
27707 return /* @__PURE__ */ (0, import_jsx_runtime124.jsxs)(import_components49.__experimentalHStack, { alignment: "left", spacing: 0, children: [
27708 !!imageUrl && /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
27709 "div",
27710 {
27711 className: clsx_default("media-author-field__avatar", {
27712 "is-loading": loadingState === "loading",
27713 "is-loaded": loadingState === "loaded"
27714 }),
27715 children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
27716 "img",
27717 {
27718 ref: imgRef,
27719 onLoad: handleLoad,
27720 alt: (0, import_i18n55.__)("Author avatar"),
27721 src: imageUrl
27722 }
27723 )
27724 }
27725 ),
27726 !imageUrl && /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("div", { className: "media-author-field__icon", children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(import_components49.Icon, { icon: comment_author_avatar_default }) }),
27727 /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("span", { className: "media-author-field__name", children: text })
27728 ] });
27729 }
27730
27731 // packages/media-fields/build-module/author/index.mjs
27732 var authorField = {
27733 label: (0, import_i18n56.__)("Author"),
27734 id: "author",
27735 type: "integer",
27736 getElements: async () => {
27737 const authors = await (0, import_data11.resolveSelect)(import_core_data4.store).getEntityRecords(
27738 "root",
27739 "user",
27740 {
27741 per_page: -1,
27742 who: "authors",
27743 _fields: "id,name",
27744 context: "view"
27745 }
27746 ) ?? [];
27747 return authors.map(({ id, name }) => ({
27748 value: id,
27749 label: name
27750 }));
27751 },
27752 render: AuthorView,
27753 sort: (a2, b2, direction) => {
27754 const nameA = a2._embedded?.author?.[0]?.name || "";
27755 const nameB = b2._embedded?.author?.[0]?.name || "";
27756 return direction === "asc" ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA);
27757 },
27758 filterBy: {
27759 operators: ["isAny", "isNone"]
27760 },
27761 readOnly: true
27762 };
27763 var author_default = authorField;
27764
27765 // packages/media-fields/build-module/caption/index.mjs
27766 var import_i18n57 = __toESM(require_i18n(), 1);
27767 var import_components50 = __toESM(require_components(), 1);
27768
27769 // packages/media-fields/build-module/utils/get-raw-content.mjs
27770 function getRawContent(content) {
27771 if (!content) {
27772 return "";
27773 }
27774 if (typeof content === "string") {
27775 return content;
27776 }
27777 if (typeof content === "object" && "raw" in content) {
27778 return content.raw || "";
27779 }
27780 return "";
27781 }
27782
27783 // packages/media-fields/build-module/caption/index.mjs
27784 var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1);
27785 var captionField = {
27786 id: "caption",
27787 type: "text",
27788 label: (0, import_i18n57.__)("Caption"),
27789 getValue: ({ item }) => getRawContent(item?.caption),
27790 render: ({ item }) => getRawContent(item?.caption) || "-",
27791 Edit: ({ field, onChange, data }) => {
27792 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
27793 import_components50.TextareaControl,
27794 {
27795 label: field.label,
27796 value: getRawContent(data.caption) || "",
27797 onChange: (value) => onChange({ caption: value }),
27798 rows: 2
27799 }
27800 );
27801 },
27802 enableSorting: false,
27803 filterBy: false
27804 };
27805 var caption_default = captionField;
27806
27807 // packages/media-fields/build-module/date_added/index.mjs
27808 var import_i18n58 = __toESM(require_i18n(), 1);
27809 var dateAddedField = {
27810 id: "date",
27811 type: "datetime",
27812 label: (0, import_i18n58.__)("Date added"),
27813 filterBy: {
27814 operators: ["before", "after"]
27815 },
27816 readOnly: true
27817 };
27818 var date_added_default = dateAddedField;
27819
27820 // packages/media-fields/build-module/date_modified/index.mjs
27821 var import_i18n59 = __toESM(require_i18n(), 1);
27822 var dateModifiedField = {
27823 id: "modified",
27824 type: "datetime",
27825 label: (0, import_i18n59.__)("Date modified"),
27826 filterBy: {
27827 operators: ["before", "after"]
27828 },
27829 readOnly: true
27830 };
27831 var date_modified_default = dateModifiedField;
27832
27833 // packages/media-fields/build-module/description/index.mjs
27834 var import_i18n60 = __toESM(require_i18n(), 1);
27835 var import_components51 = __toESM(require_components(), 1);
27836 var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1);
27837 var descriptionField = {
27838 id: "description",
27839 type: "text",
27840 label: (0, import_i18n60.__)("Description"),
27841 getValue: ({ item }) => getRawContent(item?.description),
27842 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime126.jsx)("div", { children: getRawContent(item?.description) || "-" }),
27843 Edit: ({ field, onChange, data }) => {
27844 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
27845 import_components51.TextareaControl,
27846 {
27847 label: field.label,
27848 value: getRawContent(data.description) || "",
27849 onChange: (value) => onChange({ description: value }),
27850 rows: 5
27851 }
27852 );
27853 },
27854 enableSorting: false,
27855 filterBy: false
27856 };
27857 var description_default = descriptionField;
27858
27859 // packages/media-fields/build-module/filename/index.mjs
27860 var import_i18n61 = __toESM(require_i18n(), 1);
27861 var import_url4 = __toESM(require_url(), 1);
27862
27863 // packages/media-fields/build-module/filename/view.mjs
27864 var import_element82 = __toESM(require_element(), 1);
27865 var import_url3 = __toESM(require_url(), 1);
27866 var import_jsx_runtime127 = __toESM(require_jsx_runtime(), 1);
27867 var TRUNCATE_LENGTH = 15;
27868 function FileNameView({
27869 item
27870 }) {
27871 const fileName = (0, import_element82.useMemo)(
27872 () => item?.source_url ? (0, import_url3.getFilename)(item.source_url) : null,
27873 [item?.source_url]
27874 );
27875 if (!fileName) {
27876 return "";
27877 }
27878 if (fileName.length <= TRUNCATE_LENGTH) {
27879 return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)("span", { className: "dataviews-media-field__filename", children: fileName });
27880 }
27881 return /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)(tooltip_exports.Root, { children: [
27882 /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
27883 tooltip_exports.Trigger,
27884 {
27885 render: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)("span", { className: "dataviews-media-field__filename", children: fileName })
27886 }
27887 ),
27888 /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(tooltip_exports.Popup, { children: fileName })
27889 ] });
27890 }
27891
27892 // packages/media-fields/build-module/filename/index.mjs
27893 var filenameField = {
27894 id: "filename",
27895 type: "text",
27896 label: (0, import_i18n61.__)("File name"),
27897 getValue: ({ item }) => (0, import_url4.getFilename)(item?.source_url || ""),
27898 render: FileNameView,
27899 enableSorting: false,
27900 filterBy: false,
27901 readOnly: true
27902 };
27903 var filename_default = filenameField;
27904
27905 // packages/media-fields/build-module/filesize/index.mjs
27906 var import_i18n62 = __toESM(require_i18n(), 1);
27907 var KB_IN_BYTES = 1024;
27908 var MB_IN_BYTES = 1024 * KB_IN_BYTES;
27909 var GB_IN_BYTES = 1024 * MB_IN_BYTES;
27910 var TB_IN_BYTES = 1024 * GB_IN_BYTES;
27911 var PB_IN_BYTES = 1024 * TB_IN_BYTES;
27912 var EB_IN_BYTES = 1024 * PB_IN_BYTES;
27913 var ZB_IN_BYTES = 1024 * EB_IN_BYTES;
27914 var YB_IN_BYTES = 1024 * ZB_IN_BYTES;
27915 function getBytesString(bytes, unitSymbol, decimals = 2) {
27916 return (0, import_i18n62.sprintf)(
27917 // translators: 1: Actual bytes of a file. 2: The unit symbol (e.g. MB).
27918 (0, import_i18n62._x)("%1$s %2$s", "file size"),
27919 bytes.toLocaleString(void 0, {
27920 minimumFractionDigits: 0,
27921 maximumFractionDigits: decimals
27922 }),
27923 unitSymbol
27924 );
27925 }
27926 function formatFileSize(bytes, decimals = 2) {
27927 if (bytes === 0) {
27928 return getBytesString(0, (0, import_i18n62._x)("B", "unit symbol"), decimals);
27929 }
27930 const quant = {
27931 /* translators: Unit symbol for yottabyte. */
27932 [(0, import_i18n62._x)("YB", "unit symbol")]: YB_IN_BYTES,
27933 /* translators: Unit symbol for zettabyte. */
27934 [(0, import_i18n62._x)("ZB", "unit symbol")]: ZB_IN_BYTES,
27935 /* translators: Unit symbol for exabyte. */
27936 [(0, import_i18n62._x)("EB", "unit symbol")]: EB_IN_BYTES,
27937 /* translators: Unit symbol for petabyte. */
27938 [(0, import_i18n62._x)("PB", "unit symbol")]: PB_IN_BYTES,
27939 /* translators: Unit symbol for terabyte. */
27940 [(0, import_i18n62._x)("TB", "unit symbol")]: TB_IN_BYTES,
27941 /* translators: Unit symbol for gigabyte. */
27942 [(0, import_i18n62._x)("GB", "unit symbol")]: GB_IN_BYTES,
27943 /* translators: Unit symbol for megabyte. */
27944 [(0, import_i18n62._x)("MB", "unit symbol")]: MB_IN_BYTES,
27945 /* translators: Unit symbol for kilobyte. */
27946 [(0, import_i18n62._x)("KB", "unit symbol")]: KB_IN_BYTES,
27947 /* translators: Unit symbol for byte. */
27948 [(0, import_i18n62._x)("B", "unit symbol")]: 1
27949 };
27950 for (const [unit, mag] of Object.entries(quant)) {
27951 if (bytes >= mag) {
27952 return getBytesString(bytes / mag, unit, decimals);
27953 }
27954 }
27955 return "";
27956 }
27957 var filesizeField = {
27958 id: "filesize",
27959 type: "text",
27960 label: (0, import_i18n62.__)("File size"),
27961 getValue: ({ item }) => item?.media_details?.filesize ? formatFileSize(item?.media_details?.filesize) : "",
27962 isVisible: (item) => {
27963 return !!item?.media_details?.filesize;
27964 },
27965 enableSorting: false,
27966 filterBy: false,
27967 readOnly: true
27968 };
27969 var filesize_default = filesizeField;
27970
27971 // packages/media-fields/build-module/media_dimensions/index.mjs
27972 var import_i18n63 = __toESM(require_i18n(), 1);
27973 var mediaDimensionsField = {
27974 id: "media_dimensions",
27975 type: "text",
27976 label: (0, import_i18n63.__)("Dimensions"),
27977 getValue: ({ item }) => item?.media_details?.width && item?.media_details?.height ? (0, import_i18n63.sprintf)(
27978 // translators: 1: Width. 2: Height.
27979 (0, import_i18n63._x)("%1$s \xD7 %2$s", "image dimensions"),
27980 item?.media_details?.width?.toString(),
27981 item?.media_details?.height?.toString()
27982 ) : "",
27983 isVisible: (item) => {
27984 return !!(item?.media_details?.width && item?.media_details?.height);
27985 },
27986 enableSorting: false,
27987 filterBy: false,
27988 readOnly: true
27989 };
27990 var media_dimensions_default = mediaDimensionsField;
27991
27992 // packages/media-fields/build-module/media_thumbnail/index.mjs
27993 var import_i18n65 = __toESM(require_i18n(), 1);
27994
27995 // packages/media-fields/build-module/media_thumbnail/view.mjs
27996 var import_data12 = __toESM(require_data(), 1);
27997 var import_core_data5 = __toESM(require_core_data(), 1);
27998 var import_components52 = __toESM(require_components(), 1);
27999 var import_element83 = __toESM(require_element(), 1);
28000 var import_url5 = __toESM(require_url(), 1);
28001
28002 // packages/media-fields/build-module/utils/get-media-type-from-mime-type.mjs
28003 var import_i18n64 = __toESM(require_i18n(), 1);
28004 function getMediaTypeFromMimeType(mimeType) {
28005 if (mimeType.startsWith("image/")) {
28006 return {
28007 type: "image",
28008 label: (0, import_i18n64.__)("Image"),
28009 icon: image_default
28010 };
28011 }
28012 if (mimeType.startsWith("video/")) {
28013 return {
28014 type: "video",
28015 label: (0, import_i18n64.__)("Video"),
28016 icon: video_default
28017 };
28018 }
28019 if (mimeType.startsWith("audio/")) {
28020 return {
28021 type: "audio",
28022 label: (0, import_i18n64.__)("Audio"),
28023 icon: audio_default
28024 };
28025 }
28026 return {
28027 type: "application",
28028 label: (0, import_i18n64.__)("Application"),
28029 icon: file_default
28030 };
28031 }
28032
28033 // packages/media-fields/build-module/media_thumbnail/view.mjs
28034 var import_jsx_runtime128 = __toESM(require_jsx_runtime(), 1);
28035 function getBestImageUrl(featuredMedia, configSizes) {
28036 const sizes = featuredMedia?.media_details?.sizes;
28037 if (!sizes) {
28038 return featuredMedia.source_url;
28039 }
28040 const sizeEntries = Object.values(sizes);
28041 if (!sizeEntries.length) {
28042 return featuredMedia.source_url;
28043 }
28044 const targetWidth = configSizes ? parseInt(configSizes, 10) : NaN;
28045 if (!Number.isNaN(targetWidth)) {
28046 const validEntries = sizeEntries.filter(
28047 (s2) => typeof s2.width === "number" && !Number.isNaN(s2.width)
28048 );
28049 if (!validEntries.length) {
28050 return featuredMedia.source_url;
28051 }
28052 const sorted = [...validEntries].sort(
28053 (a2, b2) => a2.width - b2.width
28054 );
28055 const match2 = sorted.find((s2) => s2.width >= targetWidth);
28056 if (match2) {
28057 return match2.source_url;
28058 }
28059 return sorted[sorted.length - 1].source_url;
28060 }
28061 return featuredMedia.source_url;
28062 }
28063 function FallbackView({
28064 item,
28065 filename
28066 }) {
28067 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)("div", { className: "dataviews-media-field__media-thumbnail", children: /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)(
28068 import_components52.__experimentalVStack,
28069 {
28070 justify: "center",
28071 alignment: "center",
28072 className: "dataviews-media-field__media-thumbnail__stack",
28073 spacing: 0,
28074 children: [
28075 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28076 import_components52.Icon,
28077 {
28078 className: "dataviews-media-field__media-thumbnail--icon",
28079 icon: getMediaTypeFromMimeType(item.mime_type).icon,
28080 size: 24
28081 }
28082 ),
28083 !!filename && /* @__PURE__ */ (0, import_jsx_runtime128.jsx)("div", { className: "dataviews-media-field__media-thumbnail__filename", children: /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(import_components52.__experimentalTruncate, { className: "dataviews-media-field__media-thumbnail__filename__truncate", children: filename }) })
28084 ]
28085 }
28086 ) });
28087 }
28088 function ImageView({
28089 item,
28090 configSizes,
28091 onError
28092 }) {
28093 const imageUrl = getBestImageUrl(item, configSizes);
28094 const imgRef = (0, import_element83.useRef)(null);
28095 const [loadingState, setLoadingState] = (0, import_element83.useState)("loading");
28096 (0, import_element83.useLayoutEffect)(() => {
28097 if (imgRef.current?.complete) {
28098 setLoadingState("instant");
28099 } else {
28100 setLoadingState("loading");
28101 }
28102 }, [imageUrl]);
28103 const handleLoad = () => {
28104 if (loadingState === "loading") {
28105 setLoadingState("loaded");
28106 }
28107 };
28108 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28109 "div",
28110 {
28111 className: clsx_default("dataviews-media-field__media-thumbnail", {
28112 "is-loading": loadingState === "loading",
28113 "is-loaded": loadingState === "loaded"
28114 }),
28115 children: /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28116 "img",
28117 {
28118 ref: imgRef,
28119 className: "dataviews-media-field__media-thumbnail--image",
28120 src: imageUrl,
28121 alt: item.alt_text || item.title.raw,
28122 onLoad: handleLoad,
28123 onError,
28124 loading: "lazy"
28125 }
28126 )
28127 }
28128 );
28129 }
28130 function MediaThumbnailView({
28131 item,
28132 config
28133 }) {
28134 const [imageError, setImageError] = (0, import_element83.useState)(false);
28135 const _featuredMedia = (0, import_data12.useSelect)(
28136 (select3) => {
28137 if (!item.featured_media) {
28138 return;
28139 }
28140 return select3(import_core_data5.store).getEntityRecord(
28141 "postType",
28142 "attachment",
28143 item.featured_media
28144 );
28145 },
28146 [item.featured_media]
28147 );
28148 const featuredMedia = item.featured_media ? _featuredMedia : item;
28149 if (!featuredMedia) {
28150 return null;
28151 }
28152 const filename = (0, import_url5.getFilename)(featuredMedia.source_url || "");
28153 if (imageError || getMediaTypeFromMimeType(featuredMedia.mime_type).type !== "image") {
28154 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(FallbackView, { item: featuredMedia, filename: filename || "" });
28155 }
28156 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28157 ImageView,
28158 {
28159 item: featuredMedia,
28160 configSizes: config?.sizes,
28161 onError: () => setImageError(true)
28162 }
28163 );
28164 }
28165
28166 // packages/media-fields/build-module/media_thumbnail/index.mjs
28167 var mediaThumbnailField = {
28168 id: "media_thumbnail",
28169 type: "media",
28170 label: (0, import_i18n65.__)("Thumbnail"),
28171 render: MediaThumbnailView,
28172 enableSorting: false,
28173 filterBy: false
28174 };
28175 var media_thumbnail_default = mediaThumbnailField;
28176
28177 // packages/media-fields/build-module/mime_type/index.mjs
28178 var import_i18n66 = __toESM(require_i18n(), 1);
28179 var mimeTypeField = {
28180 id: "mime_type",
28181 type: "text",
28182 label: (0, import_i18n66.__)("File type"),
28183 getValue: ({ item }) => item?.mime_type || "",
28184 render: ({ item }) => item?.mime_type || "-",
28185 // Disable sorting until REST API support for ordering my `mime_type` is added.
28186 // See: https://core.trac.wordpress.org/ticket/64073
28187 enableSorting: false,
28188 filterBy: false,
28189 readOnly: true
28190 };
28191 var mime_type_default = mimeTypeField;
28192
28193 // packages/media-utils/build-module/components/media-upload-modal/index.mjs
28194 var import_notices = __toESM(require_notices(), 1);
28195
28196 // packages/media-utils/build-module/lock-unlock.mjs
28197 var import_private_apis4 = __toESM(require_private_apis(), 1);
28198 var { lock: lock4, unlock: unlock4 } = (0, import_private_apis4.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
28199 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
28200 "@wordpress/media-utils"
28201 );
28202
28203 // packages/media-utils/build-module/components/media-upload-modal/upload-status-popover.mjs
28204 var import_element84 = __toESM(require_element(), 1);
28205 var import_i18n67 = __toESM(require_i18n(), 1);
28206 var import_components53 = __toESM(require_components(), 1);
28207 var import_jsx_runtime129 = __toESM(require_jsx_runtime(), 1);
28208 function UploadStatusPopover({
28209 uploadingFiles,
28210 onDismissError,
28211 onOpenChange
28212 }) {
28213 const [isOpen, setIsOpen] = (0, import_element84.useState)(false);
28214 const [prevHadErrors, setPrevHadErrors] = (0, import_element84.useState)(false);
28215 const triggerRef = (0, import_element84.useRef)(null);
28216 const updateIsOpen = (0, import_element84.useCallback)(
28217 (open) => {
28218 setIsOpen(open);
28219 onOpenChange?.(open);
28220 },
28221 [onOpenChange]
28222 );
28223 const activeFiles = uploadingFiles.filter(
28224 (file) => file.status === "uploading"
28225 );
28226 const errorFiles = uploadingFiles.filter(
28227 (file) => file.status === "error"
28228 );
28229 const hasErrors = errorFiles.length > 0;
28230 const isUploading = activeFiles.length > 0;
28231 (0, import_element84.useEffect)(() => {
28232 if (hasErrors && !prevHadErrors) {
28233 updateIsOpen(true);
28234 }
28235 setPrevHadErrors(hasErrors);
28236 }, [hasErrors, prevHadErrors, updateIsOpen]);
28237 if (uploadingFiles.length === 0) {
28238 return null;
28239 }
28240 let buttonLabel, popoverHeading;
28241 if (isUploading) {
28242 buttonLabel = (0, import_i18n67.sprintf)(
28243 // translators: %s: number of files being uploaded
28244 (0, import_i18n67._n)("Uploading %s file", "Uploading %s files", activeFiles.length),
28245 activeFiles.length.toLocaleString()
28246 );
28247 popoverHeading = (0, import_i18n67.__)("Uploading");
28248 } else if (hasErrors) {
28249 buttonLabel = (0, import_i18n67.sprintf)(
28250 // translators: %s: number of upload errors
28251 (0, import_i18n67._n)("%s upload error", "%s upload errors", errorFiles.length),
28252 errorFiles.length.toLocaleString()
28253 );
28254 popoverHeading = (0, import_i18n67.__)("Upload errors");
28255 } else {
28256 buttonLabel = (0, import_i18n67.__)("Upload complete");
28257 popoverHeading = (0, import_i18n67.__)("Upload complete");
28258 }
28259 return /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("div", { className: "media-upload-modal__upload-status", children: [
28260 isUploading && /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(import_components53.Spinner, {}),
28261 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28262 import_components53.Button,
28263 {
28264 className: "media-upload-modal__upload-status__trigger",
28265 size: "compact",
28266 icon: chevron_down_default,
28267 iconPosition: "right",
28268 onClick: () => updateIsOpen(!isOpen),
28269 "aria-expanded": isOpen,
28270 ref: triggerRef,
28271 children: buttonLabel
28272 }
28273 ),
28274 isOpen && /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(
28275 import_components53.Popover,
28276 {
28277 className: "media-upload-modal__upload-status__popover",
28278 placement: "top-start",
28279 offset: 8,
28280 anchor: triggerRef.current,
28281 focusOnMount: true,
28282 onClose: () => {
28283 if (triggerRef.current?.contains(
28284 triggerRef.current.ownerDocument.activeElement
28285 )) {
28286 return;
28287 }
28288 updateIsOpen(false);
28289 },
28290 children: [
28291 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("div", { className: "media-upload-modal__upload-status__header", children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("h3", { children: popoverHeading }) }),
28292 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("ul", { className: "media-upload-modal__upload-status__list", children: uploadingFiles.map((file) => /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(
28293 "li",
28294 {
28295 className: "media-upload-modal__upload-status__item",
28296 children: [
28297 file.status === "uploading" && /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(import_components53.Spinner, {}),
28298 file.status === "uploaded" && /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(import_components53.Icon, { icon: check_default, size: 16 }),
28299 (file.status === "uploading" || file.status === "uploaded") && /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28300 "span",
28301 {
28302 className: "media-upload-modal__upload-status__filename",
28303 title: file.name,
28304 children: file.name
28305 }
28306 ),
28307 file.status === "error" && /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(
28308 import_components53.Notice,
28309 {
28310 status: "error",
28311 isDismissible: !!onDismissError,
28312 onRemove: () => onDismissError?.(file.id),
28313 children: [
28314 file.name,
28315 ": ",
28316 file.error
28317 ]
28318 }
28319 )
28320 ]
28321 },
28322 file.id
28323 )) })
28324 ]
28325 }
28326 )
28327 ] });
28328 }
28329
28330 // packages/media-utils/build-module/components/media-upload-modal/use-invalidate-attachment-resolutions.mjs
28331 var import_element85 = __toESM(require_element(), 1);
28332 var import_data13 = __toESM(require_data(), 1);
28333 function useInvalidateAttachmentResolutions() {
28334 const registry = (0, import_data13.useRegistry)();
28335 return (0, import_element85.useCallback)(
28336 () => invalidateAttachmentResolutions(registry),
28337 [registry]
28338 );
28339 }
28340
28341 // packages/media-utils/build-module/components/media-upload-modal/use-upload-status.mjs
28342 var import_element86 = __toESM(require_element(), 1);
28343 var import_blob2 = __toESM(require_blob(), 1);
28344 var idCounter = 0;
28345 var batchIdCounter = 0;
28346 function useUploadStatus({
28347 onBatchComplete
28348 } = {}) {
28349 const [uploadingFiles, setUploadingFiles] = (0, import_element86.useState)(
28350 []
28351 );
28352 const clearCompleted = (0, import_element86.useCallback)(() => {
28353 setUploadingFiles(
28354 (prev) => prev.filter((item) => item.status !== "uploaded")
28355 );
28356 }, []);
28357 const dismissError = (0, import_element86.useCallback)((fileId) => {
28358 setUploadingFiles(
28359 (prev) => prev.filter((item) => item.id !== fileId)
28360 );
28361 }, []);
28362 const registerBatch = (0, import_element86.useCallback)(
28363 (files) => {
28364 const batchId = String(++batchIdCounter);
28365 const batchSize = files.length;
28366 const newEntries = files.map((file) => ({
28367 id: String(++idCounter),
28368 batchId,
28369 name: file.name,
28370 status: "uploading"
28371 }));
28372 setUploadingFiles((prev) => [...prev, ...newEntries]);
28373 let successCount = 0;
28374 let errorCount = 0;
28375 let batchDone = false;
28376 let successAttachments = [];
28377 const completeBatchIfDone = () => {
28378 if (batchDone || successCount + errorCount < batchSize) {
28379 return;
28380 }
28381 batchDone = true;
28382 setUploadingFiles(
28383 (prev) => prev.map(
28384 (item) => item.batchId === batchId && item.status === "uploading" ? {
28385 ...item,
28386 status: "uploaded"
28387 } : item
28388 )
28389 );
28390 onBatchComplete?.(successAttachments);
28391 };
28392 const onFileChange = (attachments) => {
28393 if (batchDone) {
28394 return;
28395 }
28396 const allReal = attachments.every(
28397 (attachment) => attachment.id && attachment.url && !(0, import_blob2.isBlobURL)(attachment.url)
28398 );
28399 if (!allReal) {
28400 return;
28401 }
28402 successCount = attachments.length;
28403 successAttachments = attachments;
28404 completeBatchIfDone();
28405 };
28406 const onError = (error) => {
28407 const fileName = error instanceof UploadError ? error.file.name : void 0;
28408 setUploadingFiles((prev) => {
28409 let matched = false;
28410 return prev.map((item) => {
28411 if (!matched && item.batchId === batchId && item.status === "uploading" && (!fileName || item.name === fileName)) {
28412 matched = true;
28413 return {
28414 ...item,
28415 status: "error",
28416 error: error.message
28417 };
28418 }
28419 return item;
28420 });
28421 });
28422 errorCount++;
28423 completeBatchIfDone();
28424 };
28425 return { onFileChange, onError };
28426 },
28427 [onBatchComplete]
28428 );
28429 const allComplete = uploadingFiles.length > 0 && uploadingFiles.every((item) => item.status !== "uploading");
28430 return {
28431 uploadingFiles,
28432 registerBatch,
28433 dismissError,
28434 clearCompleted,
28435 allComplete
28436 };
28437 }
28438
28439 // packages/media-utils/build-module/components/media-upload-modal/index.mjs
28440 var import_jsx_runtime130 = __toESM(require_jsx_runtime(), 1);
28441 var { useEntityRecordsWithPermissions } = unlock4(import_core_data6.privateApis);
28442 var LAYOUT_PICKER_GRID2 = "pickerGrid";
28443 var LAYOUT_PICKER_TABLE2 = "pickerTable";
28444 var NOTICES_CONTEXT = "media-modal";
28445 var NOTICE_ID_UPLOAD_PROGRESS = "media-modal-upload-progress";
28446 var defaultQueryParams = {
28447 page: 1,
28448 search: ""
28449 };
28450 function getSelectionFromValue(value) {
28451 if (!value) {
28452 return [];
28453 }
28454 return Array.isArray(value) ? value.map(String) : [String(value)];
28455 }
28456 var defaultView = {
28457 type: LAYOUT_PICKER_GRID2,
28458 fields: [],
28459 showTitle: false,
28460 titleField: "title",
28461 mediaField: "media_thumbnail",
28462 perPage: 50,
28463 filters: [],
28464 layout: {
28465 previewSize: 170,
28466 density: "compact"
28467 }
28468 };
28469 var defaultLayouts = {
28470 [LAYOUT_PICKER_GRID2]: {
28471 fields: [],
28472 showTitle: false,
28473 layout: {
28474 previewSize: 170,
28475 density: "compact"
28476 }
28477 },
28478 [LAYOUT_PICKER_TABLE2]: {
28479 fields: [
28480 "filename",
28481 "filesize",
28482 "media_dimensions",
28483 "author",
28484 "date"
28485 ],
28486 showTitle: true
28487 }
28488 };
28489 function MediaUploadModal({
28490 allowedTypes,
28491 multiple = false,
28492 value,
28493 onSelect,
28494 onClose,
28495 onUpload,
28496 title = (0, import_i18n68.__)("Select Media"),
28497 isOpen,
28498 isDismissible = true,
28499 modalClass,
28500 search = true,
28501 searchLabel = (0, import_i18n68.__)("Search media")
28502 }) {
28503 const [selection, setSelection] = (0, import_element87.useState)(
28504 () => getSelectionFromValue(value)
28505 );
28506 const { createSuccessNotice, removeAllNotices } = (0, import_data14.useDispatch)(import_notices.store);
28507 const invalidateAttachmentResolutions2 = useInvalidateAttachmentResolutions();
28508 const [queryParams, setQueryParams] = (0, import_element87.useState)(
28509 () => defaultQueryParams
28510 );
28511 const { view, updateView, isModified, resetToDefault } = useView({
28512 kind: "postType",
28513 name: "attachment",
28514 slug: "media-modal",
28515 defaultView,
28516 queryParams,
28517 onChangeQueryParams: setQueryParams
28518 });
28519 const handleChangeView = (0, import_element87.useCallback)(
28520 (nextView) => {
28521 const normalizedView = { ...nextView };
28522 if (normalizedView.startPosition === void 0) {
28523 delete normalizedView.startPosition;
28524 }
28525 updateView(normalizedView);
28526 },
28527 [updateView]
28528 );
28529 const queryArgs = (0, import_element87.useMemo)(() => {
28530 const filters = {};
28531 view.filters?.forEach((filter) => {
28532 if (filter.field === "media_type") {
28533 filters.media_type = filter.value;
28534 }
28535 if (filter.field === "author") {
28536 if (filter.operator === "isAny") {
28537 filters.author = filter.value;
28538 } else if (filter.operator === "isNone") {
28539 filters.author_exclude = filter.value;
28540 }
28541 }
28542 if (filter.field === "date" || filter.field === "modified") {
28543 if (filter.operator === "before") {
28544 filters.before = filter.value;
28545 } else if (filter.operator === "after") {
28546 filters.after = filter.value;
28547 }
28548 }
28549 if (filter.field === "mime_type") {
28550 filters.mime_type = filter.value;
28551 }
28552 });
28553 if (!filters.media_type && !filters.mime_type && allowedTypes && !allowedTypes.includes("*")) {
28554 const { mediaTypes, mimeTypes } = allowedTypes.reduce(
28555 (acc, type) => {
28556 if (type.endsWith("/*")) {
28557 acc.mediaTypes.push(type.replace("/*", ""));
28558 } else if (type.includes("/")) {
28559 acc.mimeTypes.push(type);
28560 } else {
28561 acc.mediaTypes.push(type);
28562 }
28563 return acc;
28564 },
28565 { mediaTypes: [], mimeTypes: [] }
28566 );
28567 if (mediaTypes.length) {
28568 filters.media_type = mediaTypes;
28569 }
28570 if (mimeTypes.length) {
28571 filters.mime_type = mimeTypes;
28572 }
28573 }
28574 return {
28575 per_page: view.perPage || 20,
28576 page: view.page || 1,
28577 status: "inherit",
28578 order: view.sort?.direction,
28579 orderby: view.sort?.field,
28580 search: view.search,
28581 _embed: "author,wp:attached-to",
28582 ...filters
28583 };
28584 }, [view, allowedTypes]);
28585 const handleBatchComplete = (0, import_element87.useCallback)(
28586 (attachments) => {
28587 const uploadedIds = attachments.map((attachment) => String(attachment.id)).filter(Boolean);
28588 if (multiple) {
28589 setSelection((prev) => {
28590 const existing = new Set(prev);
28591 const newIds = uploadedIds.filter(
28592 (id) => !existing.has(id)
28593 );
28594 return [...prev, ...newIds];
28595 });
28596 } else {
28597 setSelection(uploadedIds.slice(0, 1));
28598 }
28599 invalidateAttachmentResolutions2();
28600 },
28601 [multiple, invalidateAttachmentResolutions2]
28602 );
28603 const {
28604 uploadingFiles,
28605 registerBatch,
28606 dismissError,
28607 clearCompleted,
28608 allComplete
28609 } = useUploadStatus({ onBatchComplete: handleBatchComplete });
28610 const isPopoverOpenRef = (0, import_element87.useRef)(false);
28611 const handlePopoverOpenChange = (0, import_element87.useCallback)(
28612 (open) => {
28613 isPopoverOpenRef.current = open;
28614 if (!open) {
28615 clearCompleted();
28616 }
28617 },
28618 [clearCompleted]
28619 );
28620 const {
28621 records: mediaRecords,
28622 isResolving: isLoading,
28623 totalItems,
28624 totalPages
28625 } = useEntityRecordsWithPermissions("postType", "attachment", queryArgs);
28626 const fields = (0, import_element87.useMemo)(
28627 () => [
28628 // Media field definitions from @wordpress/media-fields
28629 // Cast is safe because RestAttachment has the same properties as Attachment
28630 {
28631 ...media_thumbnail_default,
28632 enableHiding: false
28633 // Within the modal, the thumbnail should always be shown.
28634 },
28635 {
28636 id: "title",
28637 type: "text",
28638 label: (0, import_i18n68.__)("Title"),
28639 getValue: ({ item }) => {
28640 const titleValue = item.title.raw || item.title.rendered;
28641 return titleValue || (0, import_i18n68.__)("(no title)");
28642 }
28643 },
28644 alt_text_default,
28645 caption_default,
28646 description_default,
28647 date_added_default,
28648 date_modified_default,
28649 author_default,
28650 filename_default,
28651 filesize_default,
28652 media_dimensions_default,
28653 mime_type_default,
28654 attached_to_default
28655 ],
28656 []
28657 );
28658 const actions = (0, import_element87.useMemo)(
28659 () => [
28660 {
28661 id: "select",
28662 label: (0, import_i18n68.__)("Select"),
28663 isPrimary: true,
28664 supportsBulk: multiple,
28665 async callback() {
28666 if (selection.length === 0) {
28667 return;
28668 }
28669 const selectedPostsQuery = {
28670 include: selection,
28671 per_page: -1
28672 };
28673 const selectedPosts = await (0, import_data14.resolveSelect)(
28674 import_core_data6.store
28675 ).getEntityRecords(
28676 "postType",
28677 "attachment",
28678 selectedPostsQuery
28679 );
28680 const transformedPosts = (selectedPosts ?? []).map(transformAttachment).filter(Boolean);
28681 const selectedItems = multiple ? transformedPosts : transformedPosts?.[0];
28682 removeAllNotices("snackbar", NOTICES_CONTEXT);
28683 onSelect(selectedItems);
28684 }
28685 }
28686 ],
28687 [multiple, onSelect, selection, removeAllNotices]
28688 );
28689 const handleModalClose = (0, import_element87.useCallback)(() => {
28690 removeAllNotices("snackbar", NOTICES_CONTEXT);
28691 onClose?.();
28692 }, [removeAllNotices, onClose]);
28693 const valueRef = (0, import_element87.useRef)(value);
28694 (0, import_element87.useEffect)(() => {
28695 valueRef.current = value;
28696 }, [value]);
28697 (0, import_element87.useEffect)(() => {
28698 if (isOpen) {
28699 setSelection(getSelectionFromValue(valueRef.current));
28700 } else {
28701 setQueryParams(defaultQueryParams);
28702 }
28703 }, [isOpen]);
28704 const handleUpload = onUpload || uploadMedia;
28705 const prevAllCompleteRef = (0, import_element87.useRef)(false);
28706 (0, import_element87.useEffect)(() => {
28707 if (allComplete && !prevAllCompleteRef.current) {
28708 const completeCount = uploadingFiles.filter(
28709 (file) => file.status === "uploaded"
28710 ).length;
28711 if (completeCount > 0) {
28712 createSuccessNotice(
28713 (0, import_i18n68.sprintf)(
28714 // translators: %s: number of files
28715 (0, import_i18n68._n)(
28716 "Uploaded %s file",
28717 "Uploaded %s files",
28718 completeCount
28719 ),
28720 completeCount.toLocaleString()
28721 ),
28722 {
28723 type: "snackbar",
28724 context: NOTICES_CONTEXT,
28725 id: NOTICE_ID_UPLOAD_PROGRESS
28726 }
28727 );
28728 }
28729 if (!isPopoverOpenRef.current) {
28730 clearCompleted();
28731 }
28732 }
28733 prevAllCompleteRef.current = allComplete;
28734 }, [allComplete, uploadingFiles, createSuccessNotice, clearCompleted]);
28735 const handleFileSelect = (0, import_element87.useCallback)(
28736 (event) => {
28737 const files = event.target.files;
28738 if (files && files.length > 0) {
28739 const filesArray = Array.from(files);
28740 const { onFileChange, onError } = registerBatch(filesArray);
28741 handleUpload({
28742 allowedTypes,
28743 filesList: filesArray,
28744 onFileChange,
28745 onError
28746 });
28747 }
28748 },
28749 [allowedTypes, handleUpload, registerBatch]
28750 );
28751 const paginationInfo = (0, import_element87.useMemo)(
28752 () => ({
28753 totalItems,
28754 totalPages
28755 }),
28756 [totalItems, totalPages]
28757 );
28758 const acceptTypes = (0, import_element87.useMemo)(() => {
28759 if (allowedTypes?.includes("*")) {
28760 return void 0;
28761 }
28762 return allowedTypes?.join(",");
28763 }, [allowedTypes]);
28764 if (!isOpen) {
28765 return null;
28766 }
28767 return /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
28768 import_components54.Modal,
28769 {
28770 title,
28771 onRequestClose: handleModalClose,
28772 isDismissible,
28773 className: modalClass,
28774 overlayClassName: "media-upload-modal",
28775 size: "fill",
28776 headerActions: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28777 import_components54.FormFileUpload,
28778 {
28779 accept: acceptTypes,
28780 multiple: true,
28781 onChange: handleFileSelect,
28782 render: ({ openFileDialog }) => /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28783 import_components54.Button,
28784 {
28785 onClick: openFileDialog,
28786 icon: upload_default,
28787 __next40pxDefaultSize: true,
28788 children: (0, import_i18n68.__)("Upload media")
28789 }
28790 )
28791 }
28792 ),
28793 children: [
28794 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28795 import_components54.DropZone,
28796 {
28797 onFilesDrop: (files) => {
28798 let filteredFiles = files;
28799 if (allowedTypes && !allowedTypes.includes("*")) {
28800 filteredFiles = files.filter(
28801 (file) => allowedTypes.some((allowedType) => {
28802 return file.type === allowedType || file.type.startsWith(
28803 allowedType.replace("*", "")
28804 );
28805 })
28806 );
28807 }
28808 if (filteredFiles.length > 0) {
28809 const { onFileChange, onError } = registerBatch(filteredFiles);
28810 handleUpload({
28811 allowedTypes,
28812 filesList: filteredFiles,
28813 onFileChange,
28814 onError
28815 });
28816 }
28817 },
28818 label: (0, import_i18n68.__)("Drop files to upload")
28819 }
28820 ),
28821 /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
28822 dataviews_picker_default,
28823 {
28824 data: mediaRecords || [],
28825 fields,
28826 view,
28827 onChangeView: handleChangeView,
28828 actions,
28829 selection,
28830 onChangeSelection: setSelection,
28831 isLoading,
28832 paginationInfo,
28833 defaultLayouts,
28834 getItemId: (item) => String(item.id),
28835 itemListLabel: (0, import_i18n68.__)("Media items"),
28836 onReset: isModified ? resetToDefault : false,
28837 children: [
28838 /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
28839 Stack,
28840 {
28841 direction: "row",
28842 align: "top",
28843 justify: "space-between",
28844 className: "dataviews__view-actions",
28845 gap: "xs",
28846 children: [
28847 /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
28848 Stack,
28849 {
28850 direction: "row",
28851 gap: "sm",
28852 justify: "start",
28853 className: "dataviews__search",
28854 children: [
28855 search && /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_picker_default.Search, { label: searchLabel }),
28856 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_picker_default.FiltersToggle, {})
28857 ]
28858 }
28859 ),
28860 /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
28861 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_picker_default.LayoutSwitcher, {}),
28862 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_picker_default.ViewConfig, {})
28863 ] })
28864 ]
28865 }
28866 ),
28867 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_picker_default.FiltersToggled, { className: "dataviews-filters__container" }),
28868 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_picker_default.Layout, {}),
28869 /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
28870 "div",
28871 {
28872 className: clsx_default("media-upload-modal__footer", {
28873 "is-uploading": uploadingFiles.length > 0
28874 }),
28875 children: [
28876 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28877 UploadStatusPopover,
28878 {
28879 uploadingFiles,
28880 onDismissError: dismissError,
28881 onOpenChange: handlePopoverOpenChange
28882 }
28883 ),
28884 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(dataviews_picker_default.Footer, {})
28885 ]
28886 }
28887 )
28888 ]
28889 }
28890 ),
28891 (0, import_element87.createPortal)(
28892 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
28893 import_notices.SnackbarNotices,
28894 {
28895 className: "media-upload-modal__snackbar",
28896 context: NOTICES_CONTEXT
28897 }
28898 ),
28899 document.body
28900 )
28901 ]
28902 }
28903 );
28904 }
28905
28906 // packages/media-utils/build-module/private-apis.mjs
28907 var privateApis12 = {};
28908 lock4(privateApis12, {
28909 sideloadMedia,
28910 MediaUploadModal
28911 });
28912 return __toCommonJS(index_exports);
28913 })();
28914 /*! Bundled license information:
28915
28916 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
28917 (**
28918 * @license React
28919 * use-sync-external-store-shim.development.js
28920 *
28921 * Copyright (c) Meta Platforms, Inc. and affiliates.
28922 *
28923 * This source code is licensed under the MIT license found in the
28924 * LICENSE file in the root directory of this source tree.
28925 *)
28926
28927 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
28928 (**
28929 * @license React
28930 * use-sync-external-store-shim/with-selector.development.js
28931 *
28932 * Copyright (c) Meta Platforms, Inc. and affiliates.
28933 *
28934 * This source code is licensed under the MIT license found in the
28935 * LICENSE file in the root directory of this source tree.
28936 *)
28937 */
28938 //# sourceMappingURL=index.js.map
28939