PluginProbe
Gutenberg / 23.3.0
Gutenberg v23.3.0
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.3.0, at build/scripts/media-utils/index.js

27,719 lines 984.3 KB
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/blob
50 var require_blob = __commonJS({
51 "package-external:@wordpress/blob"(exports, module) {
52 module.exports = window.wp.blob;
53 }
54 });
55
56 // package-external:@wordpress/api-fetch
57 var require_api_fetch = __commonJS({
58 "package-external:@wordpress/api-fetch"(exports, module) {
59 module.exports = window.wp.apiFetch;
60 }
61 });
62
63 // package-external:@wordpress/core-data
64 var require_core_data = __commonJS({
65 "package-external:@wordpress/core-data"(exports, module) {
66 module.exports = window.wp.coreData;
67 }
68 });
69
70 // package-external:@wordpress/data
71 var require_data = __commonJS({
72 "package-external:@wordpress/data"(exports, module) {
73 module.exports = window.wp.data;
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 === React51.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 = useState42({
139 inst: { value, getSnapshot }
140 });
141 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
142 useLayoutEffect7(
143 function() {
144 inst.value = value;
145 inst.getSnapshot = getSnapshot;
146 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
147 },
148 [subscribe2, value, getSnapshot]
149 );
150 useEffect35(
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 React51 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState42 = React51.useState, useEffect35 = React51.useEffect, useLayoutEffect7 = React51.useLayoutEffect, useDebugValue2 = React51.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
177 exports.useSyncExternalStore = void 0 !== React51.useSyncExternalStore ? React51.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 React51 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef47 = React51.useRef, useEffect35 = React51.useEffect, useMemo42 = React51.useMemo, useDebugValue2 = React51.useDebugValue;
205 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
206 var instRef = useRef47(null);
207 if (null === instRef.current) {
208 var inst = { hasValue: false, value: null };
209 instRef.current = inst;
210 } else inst = instRef.current;
211 instRef = useMemo42(
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 useEffect35(
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/theme
275 var require_theme = __commonJS({
276 "package-external:@wordpress/theme"(exports, module) {
277 module.exports = window.wp.theme;
278 }
279 });
280
281 // package-external:@wordpress/private-apis
282 var require_private_apis = __commonJS({
283 "package-external:@wordpress/private-apis"(exports, module) {
284 module.exports = window.wp.privateApis;
285 }
286 });
287
288 // package-external:@wordpress/keycodes
289 var require_keycodes = __commonJS({
290 "package-external:@wordpress/keycodes"(exports, module) {
291 module.exports = window.wp.keycodes;
292 }
293 });
294
295 // node_modules/remove-accents/index.js
296 var require_remove_accents = __commonJS({
297 "node_modules/remove-accents/index.js"(exports, module) {
298 var characterMap = {
299 "\xC0": "A",
300 "\xC1": "A",
301 "\xC2": "A",
302 "\xC3": "A",
303 "\xC4": "A",
304 "\xC5": "A",
305 "\u1EA4": "A",
306 "\u1EAE": "A",
307 "\u1EB2": "A",
308 "\u1EB4": "A",
309 "\u1EB6": "A",
310 "\xC6": "AE",
311 "\u1EA6": "A",
312 "\u1EB0": "A",
313 "\u0202": "A",
314 "\u1EA2": "A",
315 "\u1EA0": "A",
316 "\u1EA8": "A",
317 "\u1EAA": "A",
318 "\u1EAC": "A",
319 "\xC7": "C",
320 "\u1E08": "C",
321 "\xC8": "E",
322 "\xC9": "E",
323 "\xCA": "E",
324 "\xCB": "E",
325 "\u1EBE": "E",
326 "\u1E16": "E",
327 "\u1EC0": "E",
328 "\u1E14": "E",
329 "\u1E1C": "E",
330 "\u0206": "E",
331 "\u1EBA": "E",
332 "\u1EBC": "E",
333 "\u1EB8": "E",
334 "\u1EC2": "E",
335 "\u1EC4": "E",
336 "\u1EC6": "E",
337 "\xCC": "I",
338 "\xCD": "I",
339 "\xCE": "I",
340 "\xCF": "I",
341 "\u1E2E": "I",
342 "\u020A": "I",
343 "\u1EC8": "I",
344 "\u1ECA": "I",
345 "\xD0": "D",
346 "\xD1": "N",
347 "\xD2": "O",
348 "\xD3": "O",
349 "\xD4": "O",
350 "\xD5": "O",
351 "\xD6": "O",
352 "\xD8": "O",
353 "\u1ED0": "O",
354 "\u1E4C": "O",
355 "\u1E52": "O",
356 "\u020E": "O",
357 "\u1ECE": "O",
358 "\u1ECC": "O",
359 "\u1ED4": "O",
360 "\u1ED6": "O",
361 "\u1ED8": "O",
362 "\u1EDC": "O",
363 "\u1EDE": "O",
364 "\u1EE0": "O",
365 "\u1EDA": "O",
366 "\u1EE2": "O",
367 "\xD9": "U",
368 "\xDA": "U",
369 "\xDB": "U",
370 "\xDC": "U",
371 "\u1EE6": "U",
372 "\u1EE4": "U",
373 "\u1EEC": "U",
374 "\u1EEE": "U",
375 "\u1EF0": "U",
376 "\xDD": "Y",
377 "\xE0": "a",
378 "\xE1": "a",
379 "\xE2": "a",
380 "\xE3": "a",
381 "\xE4": "a",
382 "\xE5": "a",
383 "\u1EA5": "a",
384 "\u1EAF": "a",
385 "\u1EB3": "a",
386 "\u1EB5": "a",
387 "\u1EB7": "a",
388 "\xE6": "ae",
389 "\u1EA7": "a",
390 "\u1EB1": "a",
391 "\u0203": "a",
392 "\u1EA3": "a",
393 "\u1EA1": "a",
394 "\u1EA9": "a",
395 "\u1EAB": "a",
396 "\u1EAD": "a",
397 "\xE7": "c",
398 "\u1E09": "c",
399 "\xE8": "e",
400 "\xE9": "e",
401 "\xEA": "e",
402 "\xEB": "e",
403 "\u1EBF": "e",
404 "\u1E17": "e",
405 "\u1EC1": "e",
406 "\u1E15": "e",
407 "\u1E1D": "e",
408 "\u0207": "e",
409 "\u1EBB": "e",
410 "\u1EBD": "e",
411 "\u1EB9": "e",
412 "\u1EC3": "e",
413 "\u1EC5": "e",
414 "\u1EC7": "e",
415 "\xEC": "i",
416 "\xED": "i",
417 "\xEE": "i",
418 "\xEF": "i",
419 "\u1E2F": "i",
420 "\u020B": "i",
421 "\u1EC9": "i",
422 "\u1ECB": "i",
423 "\xF0": "d",
424 "\xF1": "n",
425 "\xF2": "o",
426 "\xF3": "o",
427 "\xF4": "o",
428 "\xF5": "o",
429 "\xF6": "o",
430 "\xF8": "o",
431 "\u1ED1": "o",
432 "\u1E4D": "o",
433 "\u1E53": "o",
434 "\u020F": "o",
435 "\u1ECF": "o",
436 "\u1ECD": "o",
437 "\u1ED5": "o",
438 "\u1ED7": "o",
439 "\u1ED9": "o",
440 "\u1EDD": "o",
441 "\u1EDF": "o",
442 "\u1EE1": "o",
443 "\u1EDB": "o",
444 "\u1EE3": "o",
445 "\xF9": "u",
446 "\xFA": "u",
447 "\xFB": "u",
448 "\xFC": "u",
449 "\u1EE7": "u",
450 "\u1EE5": "u",
451 "\u1EED": "u",
452 "\u1EEF": "u",
453 "\u1EF1": "u",
454 "\xFD": "y",
455 "\xFF": "y",
456 "\u0100": "A",
457 "\u0101": "a",
458 "\u0102": "A",
459 "\u0103": "a",
460 "\u0104": "A",
461 "\u0105": "a",
462 "\u0106": "C",
463 "\u0107": "c",
464 "\u0108": "C",
465 "\u0109": "c",
466 "\u010A": "C",
467 "\u010B": "c",
468 "\u010C": "C",
469 "\u010D": "c",
470 "C\u0306": "C",
471 "c\u0306": "c",
472 "\u010E": "D",
473 "\u010F": "d",
474 "\u0110": "D",
475 "\u0111": "d",
476 "\u0112": "E",
477 "\u0113": "e",
478 "\u0114": "E",
479 "\u0115": "e",
480 "\u0116": "E",
481 "\u0117": "e",
482 "\u0118": "E",
483 "\u0119": "e",
484 "\u011A": "E",
485 "\u011B": "e",
486 "\u011C": "G",
487 "\u01F4": "G",
488 "\u011D": "g",
489 "\u01F5": "g",
490 "\u011E": "G",
491 "\u011F": "g",
492 "\u0120": "G",
493 "\u0121": "g",
494 "\u0122": "G",
495 "\u0123": "g",
496 "\u0124": "H",
497 "\u0125": "h",
498 "\u0126": "H",
499 "\u0127": "h",
500 "\u1E2A": "H",
501 "\u1E2B": "h",
502 "\u0128": "I",
503 "\u0129": "i",
504 "\u012A": "I",
505 "\u012B": "i",
506 "\u012C": "I",
507 "\u012D": "i",
508 "\u012E": "I",
509 "\u012F": "i",
510 "\u0130": "I",
511 "\u0131": "i",
512 "\u0132": "IJ",
513 "\u0133": "ij",
514 "\u0134": "J",
515 "\u0135": "j",
516 "\u0136": "K",
517 "\u0137": "k",
518 "\u1E30": "K",
519 "\u1E31": "k",
520 "K\u0306": "K",
521 "k\u0306": "k",
522 "\u0139": "L",
523 "\u013A": "l",
524 "\u013B": "L",
525 "\u013C": "l",
526 "\u013D": "L",
527 "\u013E": "l",
528 "\u013F": "L",
529 "\u0140": "l",
530 "\u0141": "l",
531 "\u0142": "l",
532 "\u1E3E": "M",
533 "\u1E3F": "m",
534 "M\u0306": "M",
535 "m\u0306": "m",
536 "\u0143": "N",
537 "\u0144": "n",
538 "\u0145": "N",
539 "\u0146": "n",
540 "\u0147": "N",
541 "\u0148": "n",
542 "\u0149": "n",
543 "N\u0306": "N",
544 "n\u0306": "n",
545 "\u014C": "O",
546 "\u014D": "o",
547 "\u014E": "O",
548 "\u014F": "o",
549 "\u0150": "O",
550 "\u0151": "o",
551 "\u0152": "OE",
552 "\u0153": "oe",
553 "P\u0306": "P",
554 "p\u0306": "p",
555 "\u0154": "R",
556 "\u0155": "r",
557 "\u0156": "R",
558 "\u0157": "r",
559 "\u0158": "R",
560 "\u0159": "r",
561 "R\u0306": "R",
562 "r\u0306": "r",
563 "\u0212": "R",
564 "\u0213": "r",
565 "\u015A": "S",
566 "\u015B": "s",
567 "\u015C": "S",
568 "\u015D": "s",
569 "\u015E": "S",
570 "\u0218": "S",
571 "\u0219": "s",
572 "\u015F": "s",
573 "\u0160": "S",
574 "\u0161": "s",
575 "\u0162": "T",
576 "\u0163": "t",
577 "\u021B": "t",
578 "\u021A": "T",
579 "\u0164": "T",
580 "\u0165": "t",
581 "\u0166": "T",
582 "\u0167": "t",
583 "T\u0306": "T",
584 "t\u0306": "t",
585 "\u0168": "U",
586 "\u0169": "u",
587 "\u016A": "U",
588 "\u016B": "u",
589 "\u016C": "U",
590 "\u016D": "u",
591 "\u016E": "U",
592 "\u016F": "u",
593 "\u0170": "U",
594 "\u0171": "u",
595 "\u0172": "U",
596 "\u0173": "u",
597 "\u0216": "U",
598 "\u0217": "u",
599 "V\u0306": "V",
600 "v\u0306": "v",
601 "\u0174": "W",
602 "\u0175": "w",
603 "\u1E82": "W",
604 "\u1E83": "w",
605 "X\u0306": "X",
606 "x\u0306": "x",
607 "\u0176": "Y",
608 "\u0177": "y",
609 "\u0178": "Y",
610 "Y\u0306": "Y",
611 "y\u0306": "y",
612 "\u0179": "Z",
613 "\u017A": "z",
614 "\u017B": "Z",
615 "\u017C": "z",
616 "\u017D": "Z",
617 "\u017E": "z",
618 "\u017F": "s",
619 "\u0192": "f",
620 "\u01A0": "O",
621 "\u01A1": "o",
622 "\u01AF": "U",
623 "\u01B0": "u",
624 "\u01CD": "A",
625 "\u01CE": "a",
626 "\u01CF": "I",
627 "\u01D0": "i",
628 "\u01D1": "O",
629 "\u01D2": "o",
630 "\u01D3": "U",
631 "\u01D4": "u",
632 "\u01D5": "U",
633 "\u01D6": "u",
634 "\u01D7": "U",
635 "\u01D8": "u",
636 "\u01D9": "U",
637 "\u01DA": "u",
638 "\u01DB": "U",
639 "\u01DC": "u",
640 "\u1EE8": "U",
641 "\u1EE9": "u",
642 "\u1E78": "U",
643 "\u1E79": "u",
644 "\u01FA": "A",
645 "\u01FB": "a",
646 "\u01FC": "AE",
647 "\u01FD": "ae",
648 "\u01FE": "O",
649 "\u01FF": "o",
650 "\xDE": "TH",
651 "\xFE": "th",
652 "\u1E54": "P",
653 "\u1E55": "p",
654 "\u1E64": "S",
655 "\u1E65": "s",
656 "X\u0301": "X",
657 "x\u0301": "x",
658 "\u0403": "\u0413",
659 "\u0453": "\u0433",
660 "\u040C": "\u041A",
661 "\u045C": "\u043A",
662 "A\u030B": "A",
663 "a\u030B": "a",
664 "E\u030B": "E",
665 "e\u030B": "e",
666 "I\u030B": "I",
667 "i\u030B": "i",
668 "\u01F8": "N",
669 "\u01F9": "n",
670 "\u1ED2": "O",
671 "\u1ED3": "o",
672 "\u1E50": "O",
673 "\u1E51": "o",
674 "\u1EEA": "U",
675 "\u1EEB": "u",
676 "\u1E80": "W",
677 "\u1E81": "w",
678 "\u1EF2": "Y",
679 "\u1EF3": "y",
680 "\u0200": "A",
681 "\u0201": "a",
682 "\u0204": "E",
683 "\u0205": "e",
684 "\u0208": "I",
685 "\u0209": "i",
686 "\u020C": "O",
687 "\u020D": "o",
688 "\u0210": "R",
689 "\u0211": "r",
690 "\u0214": "U",
691 "\u0215": "u",
692 "B\u030C": "B",
693 "b\u030C": "b",
694 "\u010C\u0323": "C",
695 "\u010D\u0323": "c",
696 "\xCA\u030C": "E",
697 "\xEA\u030C": "e",
698 "F\u030C": "F",
699 "f\u030C": "f",
700 "\u01E6": "G",
701 "\u01E7": "g",
702 "\u021E": "H",
703 "\u021F": "h",
704 "J\u030C": "J",
705 "\u01F0": "j",
706 "\u01E8": "K",
707 "\u01E9": "k",
708 "M\u030C": "M",
709 "m\u030C": "m",
710 "P\u030C": "P",
711 "p\u030C": "p",
712 "Q\u030C": "Q",
713 "q\u030C": "q",
714 "\u0158\u0329": "R",
715 "\u0159\u0329": "r",
716 "\u1E66": "S",
717 "\u1E67": "s",
718 "V\u030C": "V",
719 "v\u030C": "v",
720 "W\u030C": "W",
721 "w\u030C": "w",
722 "X\u030C": "X",
723 "x\u030C": "x",
724 "Y\u030C": "Y",
725 "y\u030C": "y",
726 "A\u0327": "A",
727 "a\u0327": "a",
728 "B\u0327": "B",
729 "b\u0327": "b",
730 "\u1E10": "D",
731 "\u1E11": "d",
732 "\u0228": "E",
733 "\u0229": "e",
734 "\u0190\u0327": "E",
735 "\u025B\u0327": "e",
736 "\u1E28": "H",
737 "\u1E29": "h",
738 "I\u0327": "I",
739 "i\u0327": "i",
740 "\u0197\u0327": "I",
741 "\u0268\u0327": "i",
742 "M\u0327": "M",
743 "m\u0327": "m",
744 "O\u0327": "O",
745 "o\u0327": "o",
746 "Q\u0327": "Q",
747 "q\u0327": "q",
748 "U\u0327": "U",
749 "u\u0327": "u",
750 "X\u0327": "X",
751 "x\u0327": "x",
752 "Z\u0327": "Z",
753 "z\u0327": "z",
754 "\u0439": "\u0438",
755 "\u0419": "\u0418",
756 "\u0451": "\u0435",
757 "\u0401": "\u0415"
758 };
759 var chars = Object.keys(characterMap).join("|");
760 var allAccents = new RegExp(chars, "g");
761 var firstAccent = new RegExp(chars, "");
762 function matcher(match2) {
763 return characterMap[match2];
764 }
765 var removeAccents2 = function(string) {
766 return string.replace(allAccents, matcher);
767 };
768 var hasAccents = function(string) {
769 return !!string.match(firstAccent);
770 };
771 module.exports = removeAccents2;
772 module.exports.has = hasAccents;
773 module.exports.remove = removeAccents2;
774 }
775 });
776
777 // node_modules/fast-deep-equal/es6/index.js
778 var require_es6 = __commonJS({
779 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
780 "use strict";
781 module.exports = function equal(a2, b2) {
782 if (a2 === b2) return true;
783 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
784 if (a2.constructor !== b2.constructor) return false;
785 var length, i2, keys;
786 if (Array.isArray(a2)) {
787 length = a2.length;
788 if (length != b2.length) return false;
789 for (i2 = length; i2-- !== 0; )
790 if (!equal(a2[i2], b2[i2])) return false;
791 return true;
792 }
793 if (a2 instanceof Map && b2 instanceof Map) {
794 if (a2.size !== b2.size) return false;
795 for (i2 of a2.entries())
796 if (!b2.has(i2[0])) return false;
797 for (i2 of a2.entries())
798 if (!equal(i2[1], b2.get(i2[0]))) return false;
799 return true;
800 }
801 if (a2 instanceof Set && b2 instanceof Set) {
802 if (a2.size !== b2.size) return false;
803 for (i2 of a2.entries())
804 if (!b2.has(i2[0])) return false;
805 return true;
806 }
807 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
808 length = a2.length;
809 if (length != b2.length) return false;
810 for (i2 = length; i2-- !== 0; )
811 if (a2[i2] !== b2[i2]) return false;
812 return true;
813 }
814 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
815 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
816 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
817 keys = Object.keys(a2);
818 length = keys.length;
819 if (length !== Object.keys(b2).length) return false;
820 for (i2 = length; i2-- !== 0; )
821 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
822 for (i2 = length; i2-- !== 0; ) {
823 var key = keys[i2];
824 if (!equal(a2[key], b2[key])) return false;
825 }
826 return true;
827 }
828 return a2 !== a2 && b2 !== b2;
829 };
830 }
831 });
832
833 // package-external:@wordpress/date
834 var require_date = __commonJS({
835 "package-external:@wordpress/date"(exports, module) {
836 module.exports = window.wp.date;
837 }
838 });
839
840 // package-external:@wordpress/warning
841 var require_warning = __commonJS({
842 "package-external:@wordpress/warning"(exports, module) {
843 module.exports = window.wp.warning;
844 }
845 });
846
847 // package-external:@wordpress/preferences
848 var require_preferences = __commonJS({
849 "package-external:@wordpress/preferences"(exports, module) {
850 module.exports = window.wp.preferences;
851 }
852 });
853
854 // package-external:@wordpress/url
855 var require_url = __commonJS({
856 "package-external:@wordpress/url"(exports, module) {
857 module.exports = window.wp.url;
858 }
859 });
860
861 // package-external:@wordpress/notices
862 var require_notices = __commonJS({
863 "package-external:@wordpress/notices"(exports, module) {
864 module.exports = window.wp.notices;
865 }
866 });
867
868 // packages/media-utils/build-module/index.mjs
869 var index_exports = {};
870 __export(index_exports, {
871 MediaUpload: () => media_upload_default,
872 privateApis: () => privateApis12,
873 transformAttachment: () => transformAttachment,
874 uploadMedia: () => uploadMedia,
875 validateFileSize: () => validateFileSize,
876 validateMimeType: () => validateMimeType,
877 validateMimeTypeForUser: () => validateMimeTypeForUser
878 });
879
880 // packages/media-utils/build-module/components/media-upload/index.mjs
881 var import_element = __toESM(require_element(), 1);
882 var import_i18n = __toESM(require_i18n(), 1);
883 var DEFAULT_EMPTY_GALLERY = [];
884 var getFeaturedImageMediaFrame = () => {
885 const { wp } = window;
886 return wp.media.view.MediaFrame.Select.extend({
887 /**
888 * Enables the Set Featured Image Button.
889 *
890 * @param {Object} toolbar toolbar for featured image state
891 * @return {void}
892 */
893 featuredImageToolbar(toolbar) {
894 this.createSelectToolbar(toolbar, {
895 text: wp.media.view.l10n.setFeaturedImage,
896 state: this.options.state
897 });
898 },
899 /**
900 * Handle the edit state requirements of selected media item.
901 *
902 * @return {void}
903 */
904 editState() {
905 const selection = this.state("featured-image").get("selection");
906 const view = new wp.media.view.EditImage({
907 model: selection.single(),
908 controller: this
909 }).render();
910 this.content.set(view);
911 view.loadEditor();
912 },
913 /**
914 * Create the default states.
915 *
916 * @return {void}
917 */
918 createStates: function createStates() {
919 this.on(
920 "toolbar:create:featured-image",
921 this.featuredImageToolbar,
922 this
923 );
924 this.on("content:render:edit-image", this.editState, this);
925 this.states.add([
926 new wp.media.controller.FeaturedImage(),
927 new wp.media.controller.EditImage({
928 model: this.options.editImage
929 })
930 ]);
931 }
932 });
933 };
934 var getSingleMediaFrame = () => {
935 const { wp } = window;
936 return wp.media.view.MediaFrame.Select.extend({
937 /**
938 * Create the default states on the frame.
939 */
940 createStates() {
941 const options = this.options;
942 if (this.options.states) {
943 return;
944 }
945 this.states.add([
946 // Main states.
947 new wp.media.controller.Library({
948 library: wp.media.query(options.library),
949 multiple: options.multiple,
950 title: options.title,
951 priority: 20,
952 filterable: "uploaded"
953 // Allow filtering by uploaded images.
954 }),
955 new wp.media.controller.EditImage({
956 model: options.editImage
957 })
958 ]);
959 }
960 });
961 };
962 var getGalleryDetailsMediaFrame = () => {
963 const { wp } = window;
964 return wp.media.view.MediaFrame.Post.extend({
965 /**
966 * Set up gallery toolbar.
967 *
968 * @return {void}
969 */
970 galleryToolbar() {
971 const editing = this.state().get("editing");
972 this.toolbar.set(
973 new wp.media.view.Toolbar({
974 controller: this,
975 items: {
976 insert: {
977 style: "primary",
978 text: editing ? wp.media.view.l10n.updateGallery : wp.media.view.l10n.insertGallery,
979 priority: 80,
980 requires: { library: true },
981 /**
982 * @fires wp.media.controller.State#update
983 */
984 click() {
985 const controller = this.controller, state = controller.state();
986 controller.close();
987 state.trigger(
988 "update",
989 state.get("library")
990 );
991 controller.setState(controller.options.state);
992 controller.reset();
993 }
994 }
995 }
996 })
997 );
998 },
999 /**
1000 * Handle the edit state requirements of selected media item.
1001 *
1002 * @return {void}
1003 */
1004 editState() {
1005 const selection = this.state("gallery").get("selection");
1006 const view = new wp.media.view.EditImage({
1007 model: selection.single(),
1008 controller: this
1009 }).render();
1010 this.content.set(view);
1011 view.loadEditor();
1012 },
1013 /**
1014 * Create the default states.
1015 *
1016 * @return {void}
1017 */
1018 createStates: function createStates() {
1019 this.on("toolbar:create:main-gallery", this.galleryToolbar, this);
1020 this.on("content:render:edit-image", this.editState, this);
1021 this.states.add([
1022 new wp.media.controller.Library({
1023 id: "gallery",
1024 title: wp.media.view.l10n.createGalleryTitle,
1025 priority: 40,
1026 toolbar: "main-gallery",
1027 filterable: "uploaded",
1028 multiple: "add",
1029 editable: false,
1030 library: wp.media.query({
1031 type: "image",
1032 ...this.options.library
1033 })
1034 }),
1035 new wp.media.controller.EditImage({
1036 model: this.options.editImage
1037 }),
1038 new wp.media.controller.GalleryEdit({
1039 library: this.options.selection,
1040 editing: this.options.editing,
1041 menu: "gallery",
1042 displaySettings: false,
1043 multiple: true
1044 }),
1045 new wp.media.controller.GalleryAdd()
1046 ]);
1047 }
1048 });
1049 };
1050 var slimImageObject = (img) => {
1051 const attrSet = [
1052 "sizes",
1053 "mime",
1054 "type",
1055 "subtype",
1056 "id",
1057 "url",
1058 "alt",
1059 "link",
1060 "caption"
1061 ];
1062 return attrSet.reduce((result, key) => {
1063 if (img?.hasOwnProperty(key)) {
1064 result[key] = img[key];
1065 }
1066 return result;
1067 }, {});
1068 };
1069 var getAttachmentsCollection = (ids) => {
1070 const { wp } = window;
1071 return wp.media.query({
1072 order: "ASC",
1073 orderby: "post__in",
1074 post__in: ids,
1075 posts_per_page: -1,
1076 query: true,
1077 type: "image"
1078 });
1079 };
1080 var MediaUpload = class extends import_element.Component {
1081 constructor() {
1082 super(...arguments);
1083 this.openModal = this.openModal.bind(this);
1084 this.onOpen = this.onOpen.bind(this);
1085 this.onSelect = this.onSelect.bind(this);
1086 this.onUpdate = this.onUpdate.bind(this);
1087 this.onClose = this.onClose.bind(this);
1088 }
1089 initializeListeners() {
1090 this.frame.on("select", this.onSelect);
1091 this.frame.on("update", this.onUpdate);
1092 this.frame.on("open", this.onOpen);
1093 this.frame.on("close", this.onClose);
1094 }
1095 /**
1096 * Sets the Gallery frame and initializes listeners.
1097 *
1098 * @return {void}
1099 */
1100 buildAndSetGalleryFrame() {
1101 const {
1102 addToGallery = false,
1103 allowedTypes,
1104 multiple = false,
1105 value = DEFAULT_EMPTY_GALLERY
1106 } = this.props;
1107 if (value === this.lastGalleryValue) {
1108 return;
1109 }
1110 const { wp } = window;
1111 this.lastGalleryValue = value;
1112 if (this.frame) {
1113 this.frame.remove();
1114 }
1115 let currentState;
1116 if (addToGallery) {
1117 currentState = "gallery-library";
1118 } else {
1119 currentState = value && value.length ? "gallery-edit" : "gallery";
1120 }
1121 if (!this.GalleryDetailsMediaFrame) {
1122 this.GalleryDetailsMediaFrame = getGalleryDetailsMediaFrame();
1123 }
1124 const attachments = getAttachmentsCollection(value);
1125 const selection = new wp.media.model.Selection(attachments.models, {
1126 props: attachments.props.toJSON(),
1127 multiple
1128 });
1129 this.frame = new this.GalleryDetailsMediaFrame({
1130 mimeType: allowedTypes,
1131 state: currentState,
1132 multiple,
1133 selection,
1134 editing: !!value?.length
1135 });
1136 wp.media.frame = this.frame;
1137 this.initializeListeners();
1138 }
1139 /**
1140 * Initializes the Media Library requirements for the featured image flow.
1141 *
1142 * @return {void}
1143 */
1144 buildAndSetFeatureImageFrame() {
1145 const { wp } = window;
1146 const { value: featuredImageId, multiple, allowedTypes } = this.props;
1147 const featuredImageFrame = getFeaturedImageMediaFrame();
1148 const attachments = getAttachmentsCollection(featuredImageId);
1149 const selection = new wp.media.model.Selection(attachments.models, {
1150 props: attachments.props.toJSON()
1151 });
1152 this.frame = new featuredImageFrame({
1153 mimeType: allowedTypes,
1154 state: "featured-image",
1155 multiple,
1156 selection,
1157 editing: featuredImageId
1158 });
1159 wp.media.frame = this.frame;
1160 wp.media.view.settings.post = {
1161 ...wp.media.view.settings.post,
1162 featuredImageId: featuredImageId || -1
1163 };
1164 }
1165 /**
1166 * Initializes the Media Library requirements for the single image flow.
1167 *
1168 * @return {void}
1169 */
1170 buildAndSetSingleMediaFrame() {
1171 const { wp } = window;
1172 const {
1173 allowedTypes,
1174 multiple = false,
1175 title = (0, import_i18n.__)("Select or Upload Media"),
1176 value
1177 } = this.props;
1178 const frameConfig = {
1179 title,
1180 multiple
1181 };
1182 if (!!allowedTypes) {
1183 frameConfig.library = { type: allowedTypes };
1184 }
1185 if (this.frame) {
1186 this.frame.remove();
1187 }
1188 const singleImageFrame = getSingleMediaFrame();
1189 const attachments = getAttachmentsCollection(value);
1190 const selection = new wp.media.model.Selection(attachments.models, {
1191 props: attachments.props.toJSON()
1192 });
1193 this.frame = new singleImageFrame({
1194 mimeType: allowedTypes,
1195 multiple,
1196 selection,
1197 ...frameConfig
1198 });
1199 wp.media.frame = this.frame;
1200 }
1201 componentWillUnmount() {
1202 this.frame?.remove();
1203 }
1204 onUpdate(selections) {
1205 const { onSelect, multiple = false } = this.props;
1206 const state = this.frame.state();
1207 const selectedImages = selections || state.get("selection");
1208 if (!selectedImages || !selectedImages.models.length) {
1209 return;
1210 }
1211 if (multiple) {
1212 onSelect(
1213 selectedImages.models.map(
1214 (model) => slimImageObject(model.toJSON())
1215 )
1216 );
1217 } else {
1218 onSelect(slimImageObject(selectedImages.models[0].toJSON()));
1219 }
1220 }
1221 onSelect() {
1222 const { onSelect, multiple = false } = this.props;
1223 const attachment = this.frame.state().get("selection").toJSON();
1224 onSelect(multiple ? attachment : attachment[0]);
1225 }
1226 onOpen() {
1227 const { wp } = window;
1228 const { value } = this.props;
1229 this.updateCollection();
1230 if (this.props.mode) {
1231 this.frame.content.mode(this.props.mode);
1232 }
1233 const hasMedia = Array.isArray(value) ? !!value?.length : !!value;
1234 if (!hasMedia) {
1235 return;
1236 }
1237 const isGallery = this.props.gallery;
1238 const selection = this.frame.state().get("selection");
1239 const valueArray = Array.isArray(value) ? value : [value];
1240 if (!isGallery) {
1241 valueArray.forEach((id) => {
1242 selection.add(wp.media.attachment(id));
1243 });
1244 }
1245 const attachments = getAttachmentsCollection(valueArray);
1246 attachments.more().done(function() {
1247 if (isGallery && attachments?.models?.length) {
1248 selection.add(attachments.models);
1249 }
1250 });
1251 }
1252 onClose() {
1253 const { onClose } = this.props;
1254 if (onClose) {
1255 onClose();
1256 }
1257 this.frame.detach();
1258 }
1259 updateCollection() {
1260 const frameContent = this.frame.content.get();
1261 if (frameContent && frameContent.collection) {
1262 const collection = frameContent.collection;
1263 collection.toArray().forEach((model) => model.trigger("destroy", model));
1264 collection.mirroring._hasMore = true;
1265 collection.more();
1266 }
1267 }
1268 openModal() {
1269 const {
1270 gallery = false,
1271 unstableFeaturedImageFlow = false,
1272 modalClass
1273 } = this.props;
1274 if (gallery) {
1275 this.buildAndSetGalleryFrame();
1276 } else {
1277 this.buildAndSetSingleMediaFrame();
1278 }
1279 if (modalClass) {
1280 this.frame.$el.addClass(modalClass);
1281 }
1282 if (unstableFeaturedImageFlow) {
1283 this.buildAndSetFeatureImageFrame();
1284 }
1285 this.initializeListeners();
1286 this.frame.open();
1287 }
1288 render() {
1289 return this.props.render({ open: this.openModal });
1290 }
1291 };
1292 var media_upload_default = MediaUpload;
1293
1294 // packages/media-utils/build-module/utils/upload-media.mjs
1295 var import_i18n5 = __toESM(require_i18n(), 1);
1296 var import_blob = __toESM(require_blob(), 1);
1297
1298 // packages/media-utils/build-module/utils/upload-to-server.mjs
1299 var import_api_fetch = __toESM(require_api_fetch(), 1);
1300
1301 // packages/media-utils/build-module/utils/flatten-form-data.mjs
1302 function isPlainObject(data) {
1303 return data !== null && typeof data === "object" && Object.getPrototypeOf(data) === Object.prototype;
1304 }
1305 function flattenFormData(formData, key, data) {
1306 if (isPlainObject(data)) {
1307 for (const [name, value] of Object.entries(data)) {
1308 flattenFormData(formData, `${key}[${name}]`, value);
1309 }
1310 } else if (data !== void 0) {
1311 formData.append(key, String(data));
1312 }
1313 }
1314
1315 // packages/media-utils/build-module/utils/transform-attachment.mjs
1316 function transformAttachment(attachment) {
1317 const { alt_text, source_url, ...savedMediaProps } = attachment;
1318 return {
1319 ...savedMediaProps,
1320 alt: attachment.alt_text,
1321 caption: attachment.caption?.raw ?? "",
1322 title: attachment.title.raw,
1323 url: attachment.source_url,
1324 poster: attachment._embedded?.["wp:featuredmedia"]?.[0]?.source_url || void 0
1325 };
1326 }
1327
1328 // packages/media-utils/build-module/utils/upload-to-server.mjs
1329 async function uploadToServer(file, additionalData = {}, signal) {
1330 const data = new FormData();
1331 data.append("file", file, file.name || file.type.replace("/", "."));
1332 for (const [key, value] of Object.entries(additionalData)) {
1333 flattenFormData(
1334 data,
1335 key,
1336 value
1337 );
1338 }
1339 return transformAttachment(
1340 await (0, import_api_fetch.default)({
1341 // This allows the video block to directly get a video's poster image.
1342 path: "/wp/v2/media?_embed=wp:featuredmedia",
1343 body: data,
1344 method: "POST",
1345 signal
1346 })
1347 );
1348 }
1349
1350 // packages/media-utils/build-module/utils/validate-mime-type.mjs
1351 var import_i18n2 = __toESM(require_i18n(), 1);
1352
1353 // packages/media-utils/build-module/utils/upload-error.mjs
1354 var UploadError = class extends Error {
1355 code;
1356 file;
1357 constructor({ code, message: message2, file, cause }) {
1358 super(message2, { cause });
1359 Object.setPrototypeOf(this, new.target.prototype);
1360 this.code = code;
1361 this.file = file;
1362 }
1363 };
1364
1365 // packages/media-utils/build-module/utils/validate-mime-type.mjs
1366 function validateMimeType(file, allowedTypes) {
1367 if (!allowedTypes || allowedTypes.includes("*")) {
1368 return;
1369 }
1370 const isAllowedType = allowedTypes.some((allowedType) => {
1371 if (allowedType.includes("/")) {
1372 return allowedType === file.type;
1373 }
1374 return file.type.startsWith(`${allowedType}/`);
1375 });
1376 if (file.type && !isAllowedType) {
1377 throw new UploadError({
1378 code: "MIME_TYPE_NOT_SUPPORTED",
1379 message: (0, import_i18n2.sprintf)(
1380 // translators: %s: file name.
1381 (0, import_i18n2.__)("%s: Sorry, this file type is not supported here."),
1382 file.name
1383 ),
1384 file
1385 });
1386 }
1387 }
1388
1389 // packages/media-utils/build-module/utils/validate-mime-type-for-user.mjs
1390 var import_i18n3 = __toESM(require_i18n(), 1);
1391
1392 // packages/media-utils/build-module/utils/get-mime-types-array.mjs
1393 function getMimeTypesArray(wpMimeTypesObject) {
1394 if (!wpMimeTypesObject) {
1395 return null;
1396 }
1397 return Object.entries(wpMimeTypesObject).flatMap(
1398 ([extensionsString, mime]) => {
1399 const [type] = mime.split("/");
1400 const extensions = extensionsString.split("|");
1401 return [
1402 mime,
1403 ...extensions.map(
1404 (extension) => `${type}/${extension}`
1405 )
1406 ];
1407 }
1408 );
1409 }
1410
1411 // packages/media-utils/build-module/utils/validate-mime-type-for-user.mjs
1412 function validateMimeTypeForUser(file, wpAllowedMimeTypes) {
1413 const allowedMimeTypesForUser = getMimeTypesArray(wpAllowedMimeTypes);
1414 if (!allowedMimeTypesForUser) {
1415 return;
1416 }
1417 const isAllowedMimeTypeForUser = allowedMimeTypesForUser.includes(
1418 file.type
1419 );
1420 if (file.type && !isAllowedMimeTypeForUser) {
1421 throw new UploadError({
1422 code: "MIME_TYPE_NOT_ALLOWED_FOR_USER",
1423 message: (0, import_i18n3.sprintf)(
1424 // translators: %s: file name.
1425 (0, import_i18n3.__)(
1426 "%s: Sorry, you are not allowed to upload this file type."
1427 ),
1428 file.name
1429 ),
1430 file
1431 });
1432 }
1433 }
1434
1435 // packages/media-utils/build-module/utils/validate-file-size.mjs
1436 var import_i18n4 = __toESM(require_i18n(), 1);
1437 function validateFileSize(file, maxUploadFileSize) {
1438 if (file.size <= 0) {
1439 throw new UploadError({
1440 code: "EMPTY_FILE",
1441 message: (0, import_i18n4.sprintf)(
1442 // translators: %s: file name.
1443 (0, import_i18n4.__)("%s: This file is empty."),
1444 file.name
1445 ),
1446 file
1447 });
1448 }
1449 if (maxUploadFileSize && file.size > maxUploadFileSize) {
1450 throw new UploadError({
1451 code: "SIZE_ABOVE_LIMIT",
1452 message: (0, import_i18n4.sprintf)(
1453 // translators: %s: file name.
1454 (0, import_i18n4.__)(
1455 "%s: This file exceeds the maximum upload size for this site."
1456 ),
1457 file.name
1458 ),
1459 file
1460 });
1461 }
1462 }
1463
1464 // packages/media-utils/build-module/utils/upload-media.mjs
1465 function uploadMedia({
1466 wpAllowedMimeTypes,
1467 allowedTypes,
1468 additionalData = {},
1469 filesList,
1470 maxUploadFileSize,
1471 onError,
1472 onFileChange,
1473 signal,
1474 multiple = true
1475 }) {
1476 if (!multiple && filesList.length > 1) {
1477 onError?.(new Error((0, import_i18n5.__)("Only one file can be used here.")));
1478 return;
1479 }
1480 const validFiles = [];
1481 const filesSet = [];
1482 const setAndUpdateFiles = (index2, value) => {
1483 if (!window.__clientSideMediaProcessing) {
1484 if (filesSet[index2]?.url) {
1485 (0, import_blob.revokeBlobURL)(filesSet[index2].url);
1486 }
1487 }
1488 filesSet[index2] = value;
1489 onFileChange?.(
1490 filesSet.filter((attachment) => attachment !== null)
1491 );
1492 };
1493 for (const mediaFile of filesList) {
1494 try {
1495 validateMimeTypeForUser(mediaFile, wpAllowedMimeTypes);
1496 } catch (error) {
1497 onError?.(error);
1498 continue;
1499 }
1500 try {
1501 validateMimeType(mediaFile, allowedTypes);
1502 } catch (error) {
1503 onError?.(error);
1504 continue;
1505 }
1506 try {
1507 validateFileSize(mediaFile, maxUploadFileSize);
1508 } catch (error) {
1509 onError?.(error);
1510 continue;
1511 }
1512 validFiles.push(mediaFile);
1513 if (!window.__clientSideMediaProcessing) {
1514 filesSet.push({ url: (0, import_blob.createBlobURL)(mediaFile) });
1515 onFileChange?.(filesSet);
1516 }
1517 }
1518 validFiles.map(async (file, index2) => {
1519 try {
1520 const attachment = await uploadToServer(
1521 file,
1522 additionalData,
1523 signal
1524 );
1525 setAndUpdateFiles(index2, attachment);
1526 } catch (error) {
1527 setAndUpdateFiles(index2, null);
1528 let message2;
1529 if (typeof error === "object" && error !== null && "message" in error) {
1530 message2 = typeof error.message === "string" ? error.message : String(error.message);
1531 } else {
1532 message2 = (0, import_i18n5.sprintf)(
1533 // translators: %s: file name
1534 (0, import_i18n5.__)("Error while uploading file %s to the media library."),
1535 file.name
1536 );
1537 }
1538 onError?.(
1539 new UploadError({
1540 code: "GENERAL",
1541 message: message2,
1542 file,
1543 cause: error instanceof Error ? error : void 0
1544 })
1545 );
1546 }
1547 });
1548 }
1549
1550 // packages/media-utils/build-module/utils/sideload-media.mjs
1551 var import_i18n6 = __toESM(require_i18n(), 1);
1552
1553 // packages/media-utils/build-module/utils/sideload-to-server.mjs
1554 var import_api_fetch2 = __toESM(require_api_fetch(), 1);
1555 async function sideloadToServer(file, attachmentId, additionalData = {}, signal) {
1556 const data = new FormData();
1557 data.append("file", file, file.name || file.type.replace("/", "."));
1558 for (const [key, value] of Object.entries(additionalData)) {
1559 flattenFormData(
1560 data,
1561 key,
1562 value
1563 );
1564 }
1565 return (0, import_api_fetch2.default)({
1566 path: `/wp/v2/media/${attachmentId}/sideload`,
1567 body: data,
1568 method: "POST",
1569 signal
1570 });
1571 }
1572
1573 // packages/media-utils/build-module/utils/sideload-media.mjs
1574 var noop = () => {
1575 };
1576 async function sideloadMedia({
1577 file,
1578 attachmentId,
1579 additionalData = {},
1580 signal,
1581 onSuccess,
1582 onError = noop
1583 }) {
1584 try {
1585 const subSizeData = await sideloadToServer(
1586 file,
1587 attachmentId,
1588 additionalData,
1589 signal
1590 );
1591 onSuccess?.(subSizeData);
1592 } catch (error) {
1593 let message2;
1594 if (error instanceof Error) {
1595 message2 = error.message;
1596 } else {
1597 message2 = (0, import_i18n6.sprintf)(
1598 // translators: %s: file name
1599 (0, import_i18n6.__)("Error while sideloading file %s to the server."),
1600 file.name
1601 );
1602 }
1603 onError(
1604 new UploadError({
1605 code: "GENERAL",
1606 message: message2,
1607 file,
1608 cause: error instanceof Error ? error : void 0
1609 })
1610 );
1611 }
1612 }
1613
1614 // node_modules/clsx/dist/clsx.mjs
1615 function r(e2) {
1616 var t2, f2, n2 = "";
1617 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
1618 else if ("object" == typeof e2) if (Array.isArray(e2)) {
1619 var o2 = e2.length;
1620 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
1621 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
1622 return n2;
1623 }
1624 function clsx() {
1625 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
1626 return n2;
1627 }
1628 var clsx_default = clsx;
1629
1630 // packages/media-utils/build-module/components/media-upload-modal/index.mjs
1631 var import_element80 = __toESM(require_element(), 1);
1632 var import_i18n66 = __toESM(require_i18n(), 1);
1633 var import_core_data6 = __toESM(require_core_data(), 1);
1634 var import_data13 = __toESM(require_data(), 1);
1635 var import_components53 = __toESM(require_components(), 1);
1636
1637 // packages/icons/build-module/library/arrow-down.mjs
1638 var import_primitives = __toESM(require_primitives(), 1);
1639 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
1640 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", 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" }) });
1641
1642 // packages/icons/build-module/library/arrow-left.mjs
1643 var import_primitives2 = __toESM(require_primitives(), 1);
1644 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
1645 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", 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" }) });
1646
1647 // packages/icons/build-module/library/arrow-right.mjs
1648 var import_primitives3 = __toESM(require_primitives(), 1);
1649 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
1650 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", 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" }) });
1651
1652 // packages/icons/build-module/library/arrow-up.mjs
1653 var import_primitives4 = __toESM(require_primitives(), 1);
1654 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
1655 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", 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" }) });
1656
1657 // packages/icons/build-module/library/audio.mjs
1658 var import_primitives5 = __toESM(require_primitives(), 1);
1659 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
1660 var audio_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", 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" }) });
1661
1662 // packages/icons/build-module/library/block-table.mjs
1663 var import_primitives6 = __toESM(require_primitives(), 1);
1664 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
1665 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", 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" }) });
1666
1667 // packages/icons/build-module/library/category.mjs
1668 var import_primitives7 = __toESM(require_primitives(), 1);
1669 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
1670 var category_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", 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" }) });
1671
1672 // packages/icons/build-module/library/check.mjs
1673 var import_primitives8 = __toESM(require_primitives(), 1);
1674 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
1675 var check_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", 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" }) });
1676
1677 // packages/icons/build-module/library/chevron-down.mjs
1678 var import_primitives9 = __toESM(require_primitives(), 1);
1679 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
1680 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", 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" }) });
1681
1682 // packages/icons/build-module/library/close-small.mjs
1683 var import_primitives10 = __toESM(require_primitives(), 1);
1684 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
1685 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", 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" }) });
1686
1687 // packages/icons/build-module/library/cog.mjs
1688 var import_primitives11 = __toESM(require_primitives(), 1);
1689 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
1690 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", 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" }) });
1691
1692 // packages/icons/build-module/library/comment-author-avatar.mjs
1693 var import_primitives12 = __toESM(require_primitives(), 1);
1694 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
1695 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", 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" }) });
1696
1697 // packages/icons/build-module/library/envelope.mjs
1698 var import_primitives13 = __toESM(require_primitives(), 1);
1699 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
1700 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", 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" }) });
1701
1702 // packages/icons/build-module/library/error.mjs
1703 var import_primitives14 = __toESM(require_primitives(), 1);
1704 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
1705 var error_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", 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" }) });
1706
1707 // packages/icons/build-module/library/file.mjs
1708 var import_primitives15 = __toESM(require_primitives(), 1);
1709 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
1710 var file_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", 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" }) });
1711
1712 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
1713 var import_primitives16 = __toESM(require_primitives(), 1);
1714 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
1715 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", 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" }) });
1716
1717 // packages/icons/build-module/library/format-list-bullets.mjs
1718 var import_primitives17 = __toESM(require_primitives(), 1);
1719 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
1720 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", 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" }) });
1721
1722 // packages/icons/build-module/library/funnel.mjs
1723 var import_primitives18 = __toESM(require_primitives(), 1);
1724 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
1725 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
1726
1727 // packages/icons/build-module/library/image.mjs
1728 var import_primitives19 = __toESM(require_primitives(), 1);
1729 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
1730 var image_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", 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" }) });
1731
1732 // packages/icons/build-module/library/link.mjs
1733 var import_primitives20 = __toESM(require_primitives(), 1);
1734 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
1735 var link_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", 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" }) });
1736
1737 // packages/icons/build-module/library/mobile.mjs
1738 var import_primitives21 = __toESM(require_primitives(), 1);
1739 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
1740 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", 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" }) });
1741
1742 // packages/icons/build-module/library/more-vertical.mjs
1743 var import_primitives22 = __toESM(require_primitives(), 1);
1744 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
1745 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", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
1746
1747 // packages/icons/build-module/library/next.mjs
1748 var import_primitives23 = __toESM(require_primitives(), 1);
1749 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
1750 var next_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", 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" }) });
1751
1752 // packages/icons/build-module/library/previous.mjs
1753 var import_primitives24 = __toESM(require_primitives(), 1);
1754 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
1755 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", 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" }) });
1756
1757 // packages/icons/build-module/library/scheduled.mjs
1758 var import_primitives25 = __toESM(require_primitives(), 1);
1759 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
1760 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", 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" }) });
1761
1762 // packages/icons/build-module/library/search.mjs
1763 var import_primitives26 = __toESM(require_primitives(), 1);
1764 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
1765 var search_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", 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" }) });
1766
1767 // packages/icons/build-module/library/seen.mjs
1768 var import_primitives27 = __toESM(require_primitives(), 1);
1769 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
1770 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", 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" }) });
1771
1772 // packages/icons/build-module/library/unseen.mjs
1773 var import_primitives28 = __toESM(require_primitives(), 1);
1774 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
1775 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", 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" }) });
1776
1777 // packages/icons/build-module/library/upload.mjs
1778 var import_primitives29 = __toESM(require_primitives(), 1);
1779 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
1780 var upload_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", 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" }) });
1781
1782 // packages/icons/build-module/library/video.mjs
1783 var import_primitives30 = __toESM(require_primitives(), 1);
1784 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
1785 var video_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives30.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", 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" }) });
1786
1787 // node_modules/@base-ui/utils/esm/useStableCallback.js
1788 var React2 = __toESM(require_react(), 1);
1789
1790 // node_modules/@base-ui/utils/esm/useRefWithInit.js
1791 var React = __toESM(require_react(), 1);
1792 var UNINITIALIZED = {};
1793 function useRefWithInit(init2, initArg) {
1794 const ref = React.useRef(UNINITIALIZED);
1795 if (ref.current === UNINITIALIZED) {
1796 ref.current = init2(initArg);
1797 }
1798 return ref;
1799 }
1800
1801 // node_modules/@base-ui/utils/esm/useStableCallback.js
1802 var useInsertionEffect = React2[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0, -3)];
1803 var useSafeInsertionEffect = (
1804 // React 17 doesn't have useInsertionEffect.
1805 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
1806 useInsertionEffect !== React2.useLayoutEffect ? useInsertionEffect : (fn) => fn()
1807 );
1808 function useStableCallback(callback) {
1809 const stable = useRefWithInit(createStableCallback).current;
1810 stable.next = callback;
1811 useSafeInsertionEffect(stable.effect);
1812 return stable.trampoline;
1813 }
1814 function createStableCallback() {
1815 const stable = {
1816 next: void 0,
1817 callback: assertNotCalled,
1818 trampoline: (...args) => stable.callback?.(...args),
1819 effect: () => {
1820 stable.callback = stable.next;
1821 }
1822 };
1823 return stable;
1824 }
1825 function assertNotCalled() {
1826 if (true) {
1827 throw (
1828 /* minify-error-disabled */
1829 new Error("Base UI: Cannot call an event handler while rendering.")
1830 );
1831 }
1832 }
1833
1834 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
1835 var React3 = __toESM(require_react(), 1);
1836 var noop2 = () => {
1837 };
1838 var useIsoLayoutEffect = typeof document !== "undefined" ? React3.useLayoutEffect : noop2;
1839
1840 // node_modules/@base-ui/utils/esm/warn.js
1841 var set;
1842 if (true) {
1843 set = /* @__PURE__ */ new Set();
1844 }
1845 function warn(...messages) {
1846 if (true) {
1847 const messageKey = messages.join(" ");
1848 if (!set.has(messageKey)) {
1849 set.add(messageKey);
1850 console.warn(`Base UI: ${messageKey}`);
1851 }
1852 }
1853 }
1854
1855 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js
1856 var React4 = __toESM(require_react(), 1);
1857 var DirectionContext = /* @__PURE__ */ React4.createContext(void 0);
1858 if (true) DirectionContext.displayName = "DirectionContext";
1859 function useDirection() {
1860 const context = React4.useContext(DirectionContext);
1861 return context?.direction ?? "ltr";
1862 }
1863
1864 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1865 var React7 = __toESM(require_react(), 1);
1866
1867 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1868 function useMergedRefs(a2, b2, c2, d2) {
1869 const forkRef = useRefWithInit(createForkRef).current;
1870 if (didChange(forkRef, a2, b2, c2, d2)) {
1871 update(forkRef, [a2, b2, c2, d2]);
1872 }
1873 return forkRef.callback;
1874 }
1875 function useMergedRefsN(refs) {
1876 const forkRef = useRefWithInit(createForkRef).current;
1877 if (didChangeN(forkRef, refs)) {
1878 update(forkRef, refs);
1879 }
1880 return forkRef.callback;
1881 }
1882 function createForkRef() {
1883 return {
1884 callback: null,
1885 cleanup: null,
1886 refs: []
1887 };
1888 }
1889 function didChange(forkRef, a2, b2, c2, d2) {
1890 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1891 }
1892 function didChangeN(forkRef, newRefs) {
1893 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
1894 }
1895 function update(forkRef, refs) {
1896 forkRef.refs = refs;
1897 if (refs.every((ref) => ref == null)) {
1898 forkRef.callback = null;
1899 return;
1900 }
1901 forkRef.callback = (instance) => {
1902 if (forkRef.cleanup) {
1903 forkRef.cleanup();
1904 forkRef.cleanup = null;
1905 }
1906 if (instance != null) {
1907 const cleanupCallbacks = Array(refs.length).fill(null);
1908 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1909 const ref = refs[i2];
1910 if (ref == null) {
1911 continue;
1912 }
1913 switch (typeof ref) {
1914 case "function": {
1915 const refCleanup = ref(instance);
1916 if (typeof refCleanup === "function") {
1917 cleanupCallbacks[i2] = refCleanup;
1918 }
1919 break;
1920 }
1921 case "object": {
1922 ref.current = instance;
1923 break;
1924 }
1925 default:
1926 }
1927 }
1928 forkRef.cleanup = () => {
1929 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1930 const ref = refs[i2];
1931 if (ref == null) {
1932 continue;
1933 }
1934 switch (typeof ref) {
1935 case "function": {
1936 const cleanupCallback = cleanupCallbacks[i2];
1937 if (typeof cleanupCallback === "function") {
1938 cleanupCallback();
1939 } else {
1940 ref(null);
1941 }
1942 break;
1943 }
1944 case "object": {
1945 ref.current = null;
1946 break;
1947 }
1948 default:
1949 }
1950 }
1951 };
1952 }
1953 };
1954 }
1955
1956 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1957 var React6 = __toESM(require_react(), 1);
1958
1959 // node_modules/@base-ui/utils/esm/reactVersion.js
1960 var React5 = __toESM(require_react(), 1);
1961 var majorVersion = parseInt(React5.version, 10);
1962 function isReactVersionAtLeast(reactVersionToCheck) {
1963 return majorVersion >= reactVersionToCheck;
1964 }
1965
1966 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1967 function getReactElementRef(element) {
1968 if (!/* @__PURE__ */ React6.isValidElement(element)) {
1969 return null;
1970 }
1971 const reactElement = element;
1972 const propsWithRef = reactElement.props;
1973 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1974 }
1975
1976 // node_modules/@base-ui/utils/esm/mergeObjects.js
1977 function mergeObjects(a2, b2) {
1978 if (a2 && !b2) {
1979 return a2;
1980 }
1981 if (!a2 && b2) {
1982 return b2;
1983 }
1984 if (a2 || b2) {
1985 return {
1986 ...a2,
1987 ...b2
1988 };
1989 }
1990 return void 0;
1991 }
1992
1993 // node_modules/@base-ui/utils/esm/empty.js
1994 function NOOP() {
1995 }
1996 var EMPTY_ARRAY = Object.freeze([]);
1997 var EMPTY_OBJECT = Object.freeze({});
1998
1999 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
2000 function getStateAttributesProps(state, customMapping) {
2001 const props = {};
2002 for (const key in state) {
2003 const value = state[key];
2004 if (customMapping?.hasOwnProperty(key)) {
2005 const customProps = customMapping[key](value);
2006 if (customProps != null) {
2007 Object.assign(props, customProps);
2008 }
2009 continue;
2010 }
2011 if (value === true) {
2012 props[`data-${key.toLowerCase()}`] = "";
2013 } else if (value) {
2014 props[`data-${key.toLowerCase()}`] = value.toString();
2015 }
2016 }
2017 return props;
2018 }
2019
2020 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
2021 function resolveClassName(className, state) {
2022 return typeof className === "function" ? className(state) : className;
2023 }
2024
2025 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
2026 function resolveStyle(style, state) {
2027 return typeof style === "function" ? style(state) : style;
2028 }
2029
2030 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
2031 var EMPTY_PROPS = {};
2032 function mergeProps(a2, b2, c2, d2, e2) {
2033 if (!c2 && !d2 && !e2 && !a2) {
2034 return createInitialMergedProps(b2);
2035 }
2036 let merged = createInitialMergedProps(a2);
2037 if (b2) {
2038 merged = mergeInto(merged, b2);
2039 }
2040 if (c2) {
2041 merged = mergeInto(merged, c2);
2042 }
2043 if (d2) {
2044 merged = mergeInto(merged, d2);
2045 }
2046 if (e2) {
2047 merged = mergeInto(merged, e2);
2048 }
2049 return merged;
2050 }
2051 function mergePropsN(props) {
2052 if (props.length === 0) {
2053 return EMPTY_PROPS;
2054 }
2055 if (props.length === 1) {
2056 return createInitialMergedProps(props[0]);
2057 }
2058 let merged = createInitialMergedProps(props[0]);
2059 for (let i2 = 1; i2 < props.length; i2 += 1) {
2060 merged = mergeInto(merged, props[i2]);
2061 }
2062 return merged;
2063 }
2064 function createInitialMergedProps(inputProps) {
2065 if (isPropsGetter(inputProps)) {
2066 return {
2067 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
2068 };
2069 }
2070 return copyInitialProps(inputProps);
2071 }
2072 function mergeInto(merged, inputProps) {
2073 if (isPropsGetter(inputProps)) {
2074 return resolvePropsGetter(inputProps, merged);
2075 }
2076 return mutablyMergeInto(merged, inputProps);
2077 }
2078 function copyInitialProps(inputProps) {
2079 const copiedProps = {
2080 ...inputProps
2081 };
2082 for (const propName in copiedProps) {
2083 const propValue = copiedProps[propName];
2084 if (isEventHandler(propName, propValue)) {
2085 copiedProps[propName] = wrapEventHandler(propValue);
2086 }
2087 }
2088 return copiedProps;
2089 }
2090 function mutablyMergeInto(mergedProps, externalProps) {
2091 if (!externalProps) {
2092 return mergedProps;
2093 }
2094 for (const propName in externalProps) {
2095 const externalPropValue = externalProps[propName];
2096 switch (propName) {
2097 case "style": {
2098 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
2099 break;
2100 }
2101 case "className": {
2102 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
2103 break;
2104 }
2105 default: {
2106 if (isEventHandler(propName, externalPropValue)) {
2107 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
2108 } else {
2109 mergedProps[propName] = externalPropValue;
2110 }
2111 }
2112 }
2113 }
2114 return mergedProps;
2115 }
2116 function isEventHandler(key, value) {
2117 const code0 = key.charCodeAt(0);
2118 const code1 = key.charCodeAt(1);
2119 const code2 = key.charCodeAt(2);
2120 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
2121 }
2122 function isPropsGetter(inputProps) {
2123 return typeof inputProps === "function";
2124 }
2125 function resolvePropsGetter(inputProps, previousProps) {
2126 if (isPropsGetter(inputProps)) {
2127 return inputProps(previousProps);
2128 }
2129 return inputProps ?? EMPTY_PROPS;
2130 }
2131 function mergeEventHandlers(ourHandler, theirHandler) {
2132 if (!theirHandler) {
2133 return ourHandler;
2134 }
2135 if (!ourHandler) {
2136 return wrapEventHandler(theirHandler);
2137 }
2138 return (...args) => {
2139 const event = args[0];
2140 if (isSyntheticEvent(event)) {
2141 const baseUIEvent = event;
2142 makeEventPreventable(baseUIEvent);
2143 const result2 = theirHandler(...args);
2144 if (!baseUIEvent.baseUIHandlerPrevented) {
2145 ourHandler?.(...args);
2146 }
2147 return result2;
2148 }
2149 const result = theirHandler(...args);
2150 ourHandler?.(...args);
2151 return result;
2152 };
2153 }
2154 function wrapEventHandler(handler) {
2155 if (!handler) {
2156 return handler;
2157 }
2158 return (...args) => {
2159 const event = args[0];
2160 if (isSyntheticEvent(event)) {
2161 makeEventPreventable(event);
2162 }
2163 return handler(...args);
2164 };
2165 }
2166 function makeEventPreventable(event) {
2167 event.preventBaseUIHandler = () => {
2168 event.baseUIHandlerPrevented = true;
2169 };
2170 return event;
2171 }
2172 function mergeClassNames(ourClassName, theirClassName) {
2173 if (theirClassName) {
2174 if (ourClassName) {
2175 return theirClassName + " " + ourClassName;
2176 }
2177 return theirClassName;
2178 }
2179 return ourClassName;
2180 }
2181 function isSyntheticEvent(event) {
2182 return event != null && typeof event === "object" && "nativeEvent" in event;
2183 }
2184
2185 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
2186 var import_react = __toESM(require_react(), 1);
2187 function useRenderElement(element, componentProps, params = {}) {
2188 const renderProp = componentProps.render;
2189 const outProps = useRenderElementProps(componentProps, params);
2190 if (params.enabled === false) {
2191 return null;
2192 }
2193 const state = params.state ?? EMPTY_OBJECT;
2194 return evaluateRenderProp(element, renderProp, outProps, state);
2195 }
2196 function useRenderElementProps(componentProps, params = {}) {
2197 const {
2198 className: classNameProp,
2199 style: styleProp,
2200 render: renderProp
2201 } = componentProps;
2202 const {
2203 state = EMPTY_OBJECT,
2204 ref,
2205 props,
2206 stateAttributesMapping: stateAttributesMapping3,
2207 enabled = true
2208 } = params;
2209 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
2210 const style = enabled ? resolveStyle(styleProp, state) : void 0;
2211 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
2212 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
2213 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
2214 if (typeof document !== "undefined") {
2215 if (!enabled) {
2216 useMergedRefs(null, null);
2217 } else if (Array.isArray(ref)) {
2218 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
2219 } else {
2220 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
2221 }
2222 }
2223 if (!enabled) {
2224 return EMPTY_OBJECT;
2225 }
2226 if (className !== void 0) {
2227 outProps.className = mergeClassNames(outProps.className, className);
2228 }
2229 if (style !== void 0) {
2230 outProps.style = mergeObjects(outProps.style, style);
2231 }
2232 return outProps;
2233 }
2234 function resolveRenderFunctionProps(props) {
2235 if (Array.isArray(props)) {
2236 return mergePropsN(props);
2237 }
2238 return mergeProps(void 0, props);
2239 }
2240 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
2241 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
2242 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
2243 function evaluateRenderProp(element, render4, props, state) {
2244 if (render4) {
2245 if (typeof render4 === "function") {
2246 if (true) {
2247 warnIfRenderPropLooksLikeComponent(render4);
2248 }
2249 return render4(props, state);
2250 }
2251 const mergedProps = mergeProps(props, render4.props);
2252 mergedProps.ref = props.ref;
2253 let newElement = render4;
2254 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
2255 const children = React7.Children.toArray(render4);
2256 newElement = children[0];
2257 }
2258 if (true) {
2259 if (!/* @__PURE__ */ React7.isValidElement(newElement)) {
2260 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"));
2261 }
2262 }
2263 return /* @__PURE__ */ React7.cloneElement(newElement, mergedProps);
2264 }
2265 if (element) {
2266 if (typeof element === "string") {
2267 return renderTag(element, props);
2268 }
2269 }
2270 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
2271 }
2272 function warnIfRenderPropLooksLikeComponent(renderFn) {
2273 const functionName = renderFn.name;
2274 if (functionName.length === 0) {
2275 return;
2276 }
2277 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
2278 return;
2279 }
2280 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
2281 return;
2282 }
2283 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");
2284 }
2285 function renderTag(Tag, props) {
2286 if (Tag === "button") {
2287 return /* @__PURE__ */ (0, import_react.createElement)("button", {
2288 type: "button",
2289 ...props,
2290 key: props.key
2291 });
2292 }
2293 if (Tag === "img") {
2294 return /* @__PURE__ */ (0, import_react.createElement)("img", {
2295 alt: "",
2296 ...props,
2297 key: props.key
2298 });
2299 }
2300 return /* @__PURE__ */ React7.createElement(Tag, props);
2301 }
2302
2303 // node_modules/@base-ui/react/esm/internals/reason-parts.js
2304 var reason_parts_exports = {};
2305 __export(reason_parts_exports, {
2306 cancelOpen: () => cancelOpen,
2307 chipRemovePress: () => chipRemovePress,
2308 clearPress: () => clearPress,
2309 closePress: () => closePress,
2310 closeWatcher: () => closeWatcher,
2311 decrementPress: () => decrementPress,
2312 disabled: () => disabled,
2313 drag: () => drag,
2314 escapeKey: () => escapeKey,
2315 focusOut: () => focusOut,
2316 imperativeAction: () => imperativeAction,
2317 incrementPress: () => incrementPress,
2318 inputBlur: () => inputBlur,
2319 inputChange: () => inputChange,
2320 inputClear: () => inputClear,
2321 inputPaste: () => inputPaste,
2322 inputPress: () => inputPress,
2323 itemPress: () => itemPress,
2324 keyboard: () => keyboard,
2325 linkPress: () => linkPress,
2326 listNavigation: () => listNavigation,
2327 none: () => none,
2328 outsidePress: () => outsidePress,
2329 pointer: () => pointer,
2330 scrub: () => scrub,
2331 siblingOpen: () => siblingOpen,
2332 swipe: () => swipe,
2333 trackPress: () => trackPress,
2334 triggerFocus: () => triggerFocus,
2335 triggerHover: () => triggerHover,
2336 triggerPress: () => triggerPress,
2337 wheel: () => wheel,
2338 windowResize: () => windowResize
2339 });
2340 var none = "none";
2341 var triggerPress = "trigger-press";
2342 var triggerHover = "trigger-hover";
2343 var triggerFocus = "trigger-focus";
2344 var outsidePress = "outside-press";
2345 var itemPress = "item-press";
2346 var closePress = "close-press";
2347 var linkPress = "link-press";
2348 var clearPress = "clear-press";
2349 var chipRemovePress = "chip-remove-press";
2350 var trackPress = "track-press";
2351 var incrementPress = "increment-press";
2352 var decrementPress = "decrement-press";
2353 var inputChange = "input-change";
2354 var inputClear = "input-clear";
2355 var inputBlur = "input-blur";
2356 var inputPaste = "input-paste";
2357 var inputPress = "input-press";
2358 var focusOut = "focus-out";
2359 var escapeKey = "escape-key";
2360 var closeWatcher = "close-watcher";
2361 var listNavigation = "list-navigation";
2362 var keyboard = "keyboard";
2363 var pointer = "pointer";
2364 var drag = "drag";
2365 var wheel = "wheel";
2366 var scrub = "scrub";
2367 var cancelOpen = "cancel-open";
2368 var siblingOpen = "sibling-open";
2369 var disabled = "disabled";
2370 var imperativeAction = "imperative-action";
2371 var swipe = "swipe";
2372 var windowResize = "window-resize";
2373
2374 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
2375 function createChangeEventDetails(reason, event, trigger, customProperties) {
2376 let canceled = false;
2377 let allowPropagation = false;
2378 const custom = customProperties ?? EMPTY_OBJECT;
2379 const details = {
2380 reason,
2381 event: event ?? new Event("base-ui"),
2382 cancel() {
2383 canceled = true;
2384 },
2385 allowPropagation() {
2386 allowPropagation = true;
2387 },
2388 get isCanceled() {
2389 return canceled;
2390 },
2391 get isPropagationAllowed() {
2392 return allowPropagation;
2393 },
2394 trigger,
2395 ...custom
2396 };
2397 return details;
2398 }
2399
2400 // node_modules/@base-ui/utils/esm/useId.js
2401 var React9 = __toESM(require_react(), 1);
2402
2403 // node_modules/@base-ui/utils/esm/safeReact.js
2404 var React8 = __toESM(require_react(), 1);
2405 var SafeReact = {
2406 ...React8
2407 };
2408
2409 // node_modules/@base-ui/utils/esm/useId.js
2410 var globalId = 0;
2411 function useGlobalId(idOverride, prefix = "mui") {
2412 const [defaultId, setDefaultId] = React9.useState(idOverride);
2413 const id = idOverride || defaultId;
2414 React9.useEffect(() => {
2415 if (defaultId == null) {
2416 globalId += 1;
2417 setDefaultId(`${prefix}-${globalId}`);
2418 }
2419 }, [defaultId, prefix]);
2420 return id;
2421 }
2422 var maybeReactUseId = SafeReact.useId;
2423 function useId(idOverride, prefix) {
2424 if (maybeReactUseId !== void 0) {
2425 const reactId = maybeReactUseId();
2426 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
2427 }
2428 return useGlobalId(idOverride, prefix);
2429 }
2430
2431 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
2432 function useBaseUiId(idOverride) {
2433 return useId(idOverride, "base-ui");
2434 }
2435
2436 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2437 var ReactDOM = __toESM(require_react_dom(), 1);
2438
2439 // node_modules/@base-ui/utils/esm/useOnMount.js
2440 var React10 = __toESM(require_react(), 1);
2441 var EMPTY = [];
2442 function useOnMount(fn) {
2443 React10.useEffect(fn, EMPTY);
2444 }
2445
2446 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
2447 var EMPTY2 = null;
2448 var LAST_RAF = globalThis.requestAnimationFrame;
2449 var Scheduler = class {
2450 /* This implementation uses an array as a backing data-structure for frame callbacks.
2451 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
2452 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
2453 * be much more efficient if there is a call pattern that alterns as
2454 * "request-cancel-request-cancel-…".
2455 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
2456 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
2457 callbacks = [];
2458 callbacksCount = 0;
2459 nextId = 1;
2460 startId = 1;
2461 isScheduled = false;
2462 tick = (timestamp) => {
2463 this.isScheduled = false;
2464 const currentCallbacks = this.callbacks;
2465 const currentCallbacksCount = this.callbacksCount;
2466 this.callbacks = [];
2467 this.callbacksCount = 0;
2468 this.startId = this.nextId;
2469 if (currentCallbacksCount > 0) {
2470 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
2471 currentCallbacks[i2]?.(timestamp);
2472 }
2473 }
2474 };
2475 request(fn) {
2476 const id = this.nextId;
2477 this.nextId += 1;
2478 this.callbacks.push(fn);
2479 this.callbacksCount += 1;
2480 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
2481 if (!this.isScheduled || didRAFChange) {
2482 requestAnimationFrame(this.tick);
2483 this.isScheduled = true;
2484 }
2485 return id;
2486 }
2487 cancel(id) {
2488 const index2 = id - this.startId;
2489 if (index2 < 0 || index2 >= this.callbacks.length) {
2490 return;
2491 }
2492 this.callbacks[index2] = null;
2493 this.callbacksCount -= 1;
2494 }
2495 };
2496 var scheduler = new Scheduler();
2497 var AnimationFrame = class _AnimationFrame {
2498 static create() {
2499 return new _AnimationFrame();
2500 }
2501 static request(fn) {
2502 return scheduler.request(fn);
2503 }
2504 static cancel(id) {
2505 return scheduler.cancel(id);
2506 }
2507 currentId = EMPTY2;
2508 /**
2509 * Executes `fn` after `delay`, clearing any previously scheduled call.
2510 */
2511 request(fn) {
2512 this.cancel();
2513 this.currentId = scheduler.request(() => {
2514 this.currentId = EMPTY2;
2515 fn();
2516 });
2517 }
2518 cancel = () => {
2519 if (this.currentId !== EMPTY2) {
2520 scheduler.cancel(this.currentId);
2521 this.currentId = EMPTY2;
2522 }
2523 };
2524 disposeEffect = () => {
2525 return this.cancel;
2526 };
2527 };
2528 function useAnimationFrame() {
2529 const timeout = useRefWithInit(AnimationFrame.create).current;
2530 useOnMount(timeout.disposeEffect);
2531 return timeout;
2532 }
2533
2534 // node_modules/@base-ui/react/esm/utils/resolveRef.js
2535 function resolveRef(maybeRef) {
2536 if (maybeRef == null) {
2537 return maybeRef;
2538 }
2539 return "current" in maybeRef ? maybeRef.current : maybeRef;
2540 }
2541
2542 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
2543 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
2544 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
2545 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
2546 return TransitionStatusDataAttributes2;
2547 })({});
2548 var STARTING_HOOK = {
2549 [TransitionStatusDataAttributes.startingStyle]: ""
2550 };
2551 var ENDING_HOOK = {
2552 [TransitionStatusDataAttributes.endingStyle]: ""
2553 };
2554 var transitionStatusMapping = {
2555 transitionStatus(value) {
2556 if (value === "starting") {
2557 return STARTING_HOOK;
2558 }
2559 if (value === "ending") {
2560 return ENDING_HOOK;
2561 }
2562 return null;
2563 }
2564 };
2565
2566 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2567 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
2568 const frame = useAnimationFrame();
2569 return useStableCallback((fnToExecute, signal = null) => {
2570 frame.cancel();
2571 const element = resolveRef(elementOrRef);
2572 if (element == null) {
2573 return;
2574 }
2575 const resolvedElement = element;
2576 const done = () => {
2577 ReactDOM.flushSync(fnToExecute);
2578 };
2579 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
2580 fnToExecute();
2581 return;
2582 }
2583 function exec() {
2584 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
2585 if (!signal?.aborted) {
2586 done();
2587 }
2588 }).catch(() => {
2589 if (treatAbortedAsFinished) {
2590 if (!signal?.aborted) {
2591 done();
2592 }
2593 return;
2594 }
2595 const currentAnimations = resolvedElement.getAnimations();
2596 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
2597 exec();
2598 }
2599 });
2600 }
2601 if (waitForStartingStyleRemoved) {
2602 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
2603 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2604 frame.request(exec);
2605 return;
2606 }
2607 const attributeObserver = new MutationObserver(() => {
2608 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2609 attributeObserver.disconnect();
2610 exec();
2611 }
2612 });
2613 attributeObserver.observe(resolvedElement, {
2614 attributes: true,
2615 attributeFilter: [startingStyleAttribute]
2616 });
2617 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
2618 once: true
2619 });
2620 return;
2621 }
2622 frame.request(exec);
2623 });
2624 }
2625
2626 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
2627 var React11 = __toESM(require_react(), 1);
2628 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
2629 const [transitionStatus, setTransitionStatus] = React11.useState(open && enableIdleState ? "idle" : void 0);
2630 const [mounted, setMounted] = React11.useState(open);
2631 if (open && !mounted) {
2632 setMounted(true);
2633 setTransitionStatus("starting");
2634 }
2635 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
2636 setTransitionStatus("ending");
2637 }
2638 if (!open && !mounted && transitionStatus === "ending") {
2639 setTransitionStatus(void 0);
2640 }
2641 useIsoLayoutEffect(() => {
2642 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
2643 const frame = AnimationFrame.request(() => {
2644 setTransitionStatus("ending");
2645 });
2646 return () => {
2647 AnimationFrame.cancel(frame);
2648 };
2649 }
2650 return void 0;
2651 }, [open, mounted, transitionStatus, deferEndingState]);
2652 useIsoLayoutEffect(() => {
2653 if (!open || enableIdleState) {
2654 return void 0;
2655 }
2656 const frame = AnimationFrame.request(() => {
2657 setTransitionStatus(void 0);
2658 });
2659 return () => {
2660 AnimationFrame.cancel(frame);
2661 };
2662 }, [enableIdleState, open]);
2663 useIsoLayoutEffect(() => {
2664 if (!open || !enableIdleState) {
2665 return void 0;
2666 }
2667 if (open && mounted && transitionStatus !== "idle") {
2668 setTransitionStatus("starting");
2669 }
2670 const frame = AnimationFrame.request(() => {
2671 setTransitionStatus("idle");
2672 });
2673 return () => {
2674 AnimationFrame.cancel(frame);
2675 };
2676 }, [enableIdleState, open, mounted, transitionStatus]);
2677 return {
2678 mounted,
2679 setMounted,
2680 transitionStatus
2681 };
2682 }
2683
2684 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
2685 function hasWindow() {
2686 return typeof window !== "undefined";
2687 }
2688 function getNodeName(node) {
2689 if (isNode(node)) {
2690 return (node.nodeName || "").toLowerCase();
2691 }
2692 return "#document";
2693 }
2694 function getWindow(node) {
2695 var _node$ownerDocument;
2696 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2697 }
2698 function getDocumentElement(node) {
2699 var _ref;
2700 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2701 }
2702 function isNode(value) {
2703 if (!hasWindow()) {
2704 return false;
2705 }
2706 return value instanceof Node || value instanceof getWindow(value).Node;
2707 }
2708 function isElement(value) {
2709 if (!hasWindow()) {
2710 return false;
2711 }
2712 return value instanceof Element || value instanceof getWindow(value).Element;
2713 }
2714 function isHTMLElement(value) {
2715 if (!hasWindow()) {
2716 return false;
2717 }
2718 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2719 }
2720 function isShadowRoot(value) {
2721 if (!hasWindow() || typeof ShadowRoot === "undefined") {
2722 return false;
2723 }
2724 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2725 }
2726 function isOverflowElement(element) {
2727 const {
2728 overflow,
2729 overflowX,
2730 overflowY,
2731 display
2732 } = getComputedStyle2(element);
2733 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
2734 }
2735 function isTableElement(element) {
2736 return /^(table|td|th)$/.test(getNodeName(element));
2737 }
2738 function isTopLayer(element) {
2739 try {
2740 if (element.matches(":popover-open")) {
2741 return true;
2742 }
2743 } catch (_e) {
2744 }
2745 try {
2746 return element.matches(":modal");
2747 } catch (_e) {
2748 return false;
2749 }
2750 }
2751 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
2752 var containRe = /paint|layout|strict|content/;
2753 var isNotNone = (value) => !!value && value !== "none";
2754 var isWebKitValue;
2755 function isContainingBlock(elementOrCss) {
2756 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
2757 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 || "");
2758 }
2759 function getContainingBlock(element) {
2760 let currentNode = getParentNode(element);
2761 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2762 if (isContainingBlock(currentNode)) {
2763 return currentNode;
2764 } else if (isTopLayer(currentNode)) {
2765 return null;
2766 }
2767 currentNode = getParentNode(currentNode);
2768 }
2769 return null;
2770 }
2771 function isWebKit() {
2772 if (isWebKitValue == null) {
2773 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
2774 }
2775 return isWebKitValue;
2776 }
2777 function isLastTraversableNode(node) {
2778 return /^(html|body|#document)$/.test(getNodeName(node));
2779 }
2780 function getComputedStyle2(element) {
2781 return getWindow(element).getComputedStyle(element);
2782 }
2783 function getNodeScroll(element) {
2784 if (isElement(element)) {
2785 return {
2786 scrollLeft: element.scrollLeft,
2787 scrollTop: element.scrollTop
2788 };
2789 }
2790 return {
2791 scrollLeft: element.scrollX,
2792 scrollTop: element.scrollY
2793 };
2794 }
2795 function getParentNode(node) {
2796 if (getNodeName(node) === "html") {
2797 return node;
2798 }
2799 const result = (
2800 // Step into the shadow DOM of the parent of a slotted node.
2801 node.assignedSlot || // DOM Element detected.
2802 node.parentNode || // ShadowRoot detected.
2803 isShadowRoot(node) && node.host || // Fallback.
2804 getDocumentElement(node)
2805 );
2806 return isShadowRoot(result) ? result.host : result;
2807 }
2808 function getNearestOverflowAncestor(node) {
2809 const parentNode = getParentNode(node);
2810 if (isLastTraversableNode(parentNode)) {
2811 return node.ownerDocument ? node.ownerDocument.body : node.body;
2812 }
2813 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2814 return parentNode;
2815 }
2816 return getNearestOverflowAncestor(parentNode);
2817 }
2818 function getOverflowAncestors(node, list, traverseIframes) {
2819 var _node$ownerDocument2;
2820 if (list === void 0) {
2821 list = [];
2822 }
2823 if (traverseIframes === void 0) {
2824 traverseIframes = true;
2825 }
2826 const scrollableAncestor = getNearestOverflowAncestor(node);
2827 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2828 const win = getWindow(scrollableAncestor);
2829 if (isBody) {
2830 const frameElement = getFrameElement(win);
2831 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2832 } else {
2833 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2834 }
2835 }
2836 function getFrameElement(win) {
2837 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2838 }
2839
2840 // node_modules/@base-ui/utils/esm/detectBrowser.js
2841 var hasNavigator = typeof navigator !== "undefined";
2842 var nav = getNavigatorData();
2843 var platform = getPlatform();
2844 var userAgent = getUserAgent();
2845 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
2846 var isIOS = (
2847 // iPads can claim to be MacIntel
2848 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
2849 );
2850 var isFirefox = hasNavigator && /firefox/i.test(userAgent);
2851 var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
2852 var isEdge = hasNavigator && /Edg/i.test(userAgent);
2853 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
2854 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
2855 var isJSDOM = userAgent.includes("jsdom/");
2856 function getNavigatorData() {
2857 if (!hasNavigator) {
2858 return {
2859 platform: "",
2860 maxTouchPoints: -1
2861 };
2862 }
2863 const uaData = navigator.userAgentData;
2864 if (uaData?.platform) {
2865 return {
2866 platform: uaData.platform,
2867 maxTouchPoints: navigator.maxTouchPoints
2868 };
2869 }
2870 return {
2871 platform: navigator.platform ?? "",
2872 maxTouchPoints: navigator.maxTouchPoints ?? -1
2873 };
2874 }
2875 function getUserAgent() {
2876 if (!hasNavigator) {
2877 return "";
2878 }
2879 const uaData = navigator.userAgentData;
2880 if (uaData && Array.isArray(uaData.brands)) {
2881 return uaData.brands.map(({
2882 brand,
2883 version: version2
2884 }) => `${brand}/${version2}`).join(" ");
2885 }
2886 return navigator.userAgent;
2887 }
2888 function getPlatform() {
2889 if (!hasNavigator) {
2890 return "";
2891 }
2892 const uaData = navigator.userAgentData;
2893 if (uaData?.platform) {
2894 return uaData.platform;
2895 }
2896 return navigator.platform ?? "";
2897 }
2898
2899 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js
2900 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
2901 var ACTIVE_KEY = "active";
2902 var SELECTED_KEY = "selected";
2903 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
2904
2905 // node_modules/@base-ui/react/esm/internals/shadowDom.js
2906 function activeElement(doc) {
2907 let element = doc.activeElement;
2908 while (element?.shadowRoot?.activeElement != null) {
2909 element = element.shadowRoot.activeElement;
2910 }
2911 return element;
2912 }
2913 function contains(parent, child) {
2914 if (!parent || !child) {
2915 return false;
2916 }
2917 const rootNode = child.getRootNode?.();
2918 if (parent.contains(child)) {
2919 return true;
2920 }
2921 if (rootNode && isShadowRoot(rootNode)) {
2922 let next = child;
2923 while (next) {
2924 if (parent === next) {
2925 return true;
2926 }
2927 next = next.parentNode || next.host;
2928 }
2929 }
2930 return false;
2931 }
2932 function getTarget(event) {
2933 if ("composedPath" in event) {
2934 return event.composedPath()[0];
2935 }
2936 return event.target;
2937 }
2938
2939 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js
2940 function isTargetInsideEnabledTrigger(target, triggerElements) {
2941 if (!isElement(target)) {
2942 return false;
2943 }
2944 const targetElement = target;
2945 if (triggerElements.hasElement(targetElement)) {
2946 return !targetElement.hasAttribute("data-trigger-disabled");
2947 }
2948 for (const [, trigger] of triggerElements.entries()) {
2949 if (contains(trigger, targetElement)) {
2950 return !trigger.hasAttribute("data-trigger-disabled");
2951 }
2952 }
2953 return false;
2954 }
2955 function isEventTargetWithin(event, node) {
2956 if (node == null) {
2957 return false;
2958 }
2959 if ("composedPath" in event) {
2960 return event.composedPath().includes(node);
2961 }
2962 const eventAgain = event;
2963 return eventAgain.target != null && node.contains(eventAgain.target);
2964 }
2965 function isRootElement(element) {
2966 return element.matches("html,body");
2967 }
2968 function isTypeableElement(element) {
2969 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
2970 }
2971 function isInteractiveElement(element) {
2972 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
2973 }
2974 function matchesFocusVisible(element) {
2975 if (!element || isJSDOM) {
2976 return true;
2977 }
2978 try {
2979 return element.matches(":focus-visible");
2980 } catch (_e) {
2981 return true;
2982 }
2983 }
2984
2985 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js
2986 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
2987 const directChildren = nodes.filter((node) => node.parentId === id);
2988 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
2989 }
2990
2991 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js
2992 function isReactEvent(event) {
2993 return "nativeEvent" in event;
2994 }
2995 function isMouseLikePointerType(pointerType, strict) {
2996 const values = ["mouse", "pen"];
2997 if (!strict) {
2998 values.push("", void 0);
2999 }
3000 return values.includes(pointerType);
3001 }
3002 function isClickLikeEvent(event) {
3003 const type = event.type;
3004 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
3005 }
3006
3007 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
3008 var sides = ["top", "right", "bottom", "left"];
3009 var min = Math.min;
3010 var max = Math.max;
3011 var round = Math.round;
3012 var floor = Math.floor;
3013 var createCoords = (v2) => ({
3014 x: v2,
3015 y: v2
3016 });
3017 var oppositeSideMap = {
3018 left: "right",
3019 right: "left",
3020 bottom: "top",
3021 top: "bottom"
3022 };
3023 function clamp(start, value, end) {
3024 return max(start, min(value, end));
3025 }
3026 function evaluate(value, param) {
3027 return typeof value === "function" ? value(param) : value;
3028 }
3029 function getSide(placement) {
3030 return placement.split("-")[0];
3031 }
3032 function getAlignment(placement) {
3033 return placement.split("-")[1];
3034 }
3035 function getOppositeAxis(axis) {
3036 return axis === "x" ? "y" : "x";
3037 }
3038 function getAxisLength(axis) {
3039 return axis === "y" ? "height" : "width";
3040 }
3041 function getSideAxis(placement) {
3042 const firstChar = placement[0];
3043 return firstChar === "t" || firstChar === "b" ? "y" : "x";
3044 }
3045 function getAlignmentAxis(placement) {
3046 return getOppositeAxis(getSideAxis(placement));
3047 }
3048 function getAlignmentSides(placement, rects, rtl) {
3049 if (rtl === void 0) {
3050 rtl = false;
3051 }
3052 const alignment = getAlignment(placement);
3053 const alignmentAxis = getAlignmentAxis(placement);
3054 const length = getAxisLength(alignmentAxis);
3055 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
3056 if (rects.reference[length] > rects.floating[length]) {
3057 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
3058 }
3059 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
3060 }
3061 function getExpandedPlacements(placement) {
3062 const oppositePlacement = getOppositePlacement(placement);
3063 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
3064 }
3065 function getOppositeAlignmentPlacement(placement) {
3066 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
3067 }
3068 var lrPlacement = ["left", "right"];
3069 var rlPlacement = ["right", "left"];
3070 var tbPlacement = ["top", "bottom"];
3071 var btPlacement = ["bottom", "top"];
3072 function getSideList(side, isStart, rtl) {
3073 switch (side) {
3074 case "top":
3075 case "bottom":
3076 if (rtl) return isStart ? rlPlacement : lrPlacement;
3077 return isStart ? lrPlacement : rlPlacement;
3078 case "left":
3079 case "right":
3080 return isStart ? tbPlacement : btPlacement;
3081 default:
3082 return [];
3083 }
3084 }
3085 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
3086 const alignment = getAlignment(placement);
3087 let list = getSideList(getSide(placement), direction === "start", rtl);
3088 if (alignment) {
3089 list = list.map((side) => side + "-" + alignment);
3090 if (flipAlignment) {
3091 list = list.concat(list.map(getOppositeAlignmentPlacement));
3092 }
3093 }
3094 return list;
3095 }
3096 function getOppositePlacement(placement) {
3097 const side = getSide(placement);
3098 return oppositeSideMap[side] + placement.slice(side.length);
3099 }
3100 function expandPaddingObject(padding) {
3101 return {
3102 top: 0,
3103 right: 0,
3104 bottom: 0,
3105 left: 0,
3106 ...padding
3107 };
3108 }
3109 function getPaddingObject(padding) {
3110 return typeof padding !== "number" ? expandPaddingObject(padding) : {
3111 top: padding,
3112 right: padding,
3113 bottom: padding,
3114 left: padding
3115 };
3116 }
3117 function rectToClientRect(rect) {
3118 const {
3119 x: x2,
3120 y: y2,
3121 width,
3122 height
3123 } = rect;
3124 return {
3125 width,
3126 height,
3127 top: y2,
3128 left: x2,
3129 right: x2 + width,
3130 bottom: y2 + height,
3131 x: x2,
3132 y: y2
3133 };
3134 }
3135
3136 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
3137 function isHiddenByStyles(styles) {
3138 return styles.visibility === "hidden" || styles.visibility === "collapse";
3139 }
3140 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
3141 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
3142 return false;
3143 }
3144 if (typeof element.checkVisibility === "function") {
3145 return element.checkVisibility();
3146 }
3147 return styles.display !== "none" && styles.display !== "contents";
3148 }
3149
3150 // node_modules/@base-ui/utils/esm/owner.js
3151 function ownerDocument(node) {
3152 return node?.ownerDocument || document;
3153 }
3154
3155 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js
3156 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
3157 function getParentElement(element) {
3158 const assignedSlot = element.assignedSlot;
3159 if (assignedSlot) {
3160 return assignedSlot;
3161 }
3162 if (element.parentElement) {
3163 return element.parentElement;
3164 }
3165 const rootNode = element.getRootNode();
3166 return isShadowRoot(rootNode) ? rootNode.host : null;
3167 }
3168 function getDetailsSummary(details) {
3169 for (const child of Array.from(details.children)) {
3170 if (getNodeName(child) === "summary") {
3171 return child;
3172 }
3173 }
3174 return null;
3175 }
3176 function isWithinOpenDetailsSummary(element, details) {
3177 const summary = getDetailsSummary(details);
3178 return !!summary && (element === summary || contains(summary, element));
3179 }
3180 function isFocusableCandidate(element) {
3181 const nodeName = element ? getNodeName(element) : "";
3182 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");
3183 }
3184 function isFocusableElement(element) {
3185 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
3186 return false;
3187 }
3188 for (let current = element; current; current = getParentElement(current)) {
3189 const isAncestor = current !== element;
3190 const isSlot = getNodeName(current) === "slot";
3191 if (current.hasAttribute("inert")) {
3192 return false;
3193 }
3194 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
3195 return false;
3196 }
3197 }
3198 return true;
3199 }
3200 function isVisibleInTabbableTree(element, isAncestor) {
3201 const styles = getComputedStyle2(element);
3202 if (!isAncestor) {
3203 return isElementVisible(element, styles);
3204 }
3205 return styles.display !== "none";
3206 }
3207 function getTabIndex(element) {
3208 const tabIndex = element.tabIndex;
3209 if (tabIndex < 0) {
3210 const nodeName = getNodeName(element);
3211 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
3212 return 0;
3213 }
3214 }
3215 return tabIndex;
3216 }
3217 function getNamedRadioInput(element) {
3218 if (getNodeName(element) !== "input") {
3219 return null;
3220 }
3221 const input = element;
3222 return input.type === "radio" && input.name !== "" ? input : null;
3223 }
3224 function isTabbableRadio(element, candidates) {
3225 const input = getNamedRadioInput(element);
3226 if (!input) {
3227 return true;
3228 }
3229 const checkedRadio = candidates.find((candidate) => {
3230 const radio = getNamedRadioInput(candidate);
3231 return radio?.name === input.name && radio.form === input.form && radio.checked;
3232 });
3233 if (checkedRadio) {
3234 return checkedRadio === input;
3235 }
3236 return candidates.find((candidate) => {
3237 const radio = getNamedRadioInput(candidate);
3238 return radio?.name === input.name && radio.form === input.form;
3239 }) === input;
3240 }
3241 function getComposedChildren(container) {
3242 if (isHTMLElement(container) && getNodeName(container) === "slot") {
3243 const assignedElements = container.assignedElements({
3244 flatten: true
3245 });
3246 if (assignedElements.length > 0) {
3247 return assignedElements;
3248 }
3249 }
3250 if (isHTMLElement(container) && container.shadowRoot) {
3251 return Array.from(container.shadowRoot.children);
3252 }
3253 return Array.from(container.children);
3254 }
3255 function appendCandidates(container, list) {
3256 getComposedChildren(container).forEach((child) => {
3257 if (isFocusableCandidate(child)) {
3258 list.push(child);
3259 }
3260 appendCandidates(child, list);
3261 });
3262 }
3263 function appendMatchingElements(container, selector2, list) {
3264 getComposedChildren(container).forEach((child) => {
3265 if (isHTMLElement(child) && child.matches(selector2)) {
3266 list.push(child);
3267 }
3268 appendMatchingElements(child, selector2, list);
3269 });
3270 }
3271 function focusable(container) {
3272 const candidates = [];
3273 appendCandidates(container, candidates);
3274 return candidates.filter(isFocusableElement);
3275 }
3276 function tabbable(container) {
3277 const candidates = focusable(container);
3278 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
3279 }
3280 function getTabbableIn(container, dir) {
3281 const list = tabbable(container);
3282 const len = list.length;
3283 if (len === 0) {
3284 return void 0;
3285 }
3286 const active = activeElement(ownerDocument(container));
3287 const index2 = list.indexOf(active);
3288 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
3289 return list[nextIndex];
3290 }
3291 function getNextTabbable(referenceElement) {
3292 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
3293 }
3294 function getPreviousTabbable(referenceElement) {
3295 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
3296 }
3297 function isOutsideEvent(event, container) {
3298 const containerElement = container || event.currentTarget;
3299 const relatedTarget = event.relatedTarget;
3300 return !relatedTarget || !contains(containerElement, relatedTarget);
3301 }
3302 function disableFocusInside(container) {
3303 const tabbableElements = tabbable(container);
3304 tabbableElements.forEach((element) => {
3305 element.dataset.tabindex = element.getAttribute("tabindex") || "";
3306 element.setAttribute("tabindex", "-1");
3307 });
3308 }
3309 function enableFocusInside(container) {
3310 const elements = [];
3311 appendMatchingElements(container, "[data-tabindex]", elements);
3312 elements.forEach((element) => {
3313 const tabindex = element.dataset.tabindex;
3314 delete element.dataset.tabindex;
3315 if (tabindex) {
3316 element.setAttribute("tabindex", tabindex);
3317 } else {
3318 element.removeAttribute("tabindex");
3319 }
3320 });
3321 }
3322
3323 // node_modules/@base-ui/utils/esm/addEventListener.js
3324 function addEventListener(target, type, listener, options) {
3325 target.addEventListener(type, listener, options);
3326 return () => {
3327 target.removeEventListener(type, listener, options);
3328 };
3329 }
3330
3331 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
3332 var React12 = __toESM(require_react(), 1);
3333 function useOpenChangeComplete(parameters) {
3334 const {
3335 enabled = true,
3336 open,
3337 ref,
3338 onComplete: onCompleteParam
3339 } = parameters;
3340 const onComplete = useStableCallback(onCompleteParam);
3341 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
3342 React12.useEffect(() => {
3343 if (!enabled) {
3344 return void 0;
3345 }
3346 const abortController = new AbortController();
3347 runOnceAnimationsFinish(onComplete, abortController.signal);
3348 return () => {
3349 abortController.abort();
3350 };
3351 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
3352 }
3353
3354 // node_modules/@base-ui/utils/esm/useOnFirstRender.js
3355 var React13 = __toESM(require_react(), 1);
3356 function useOnFirstRender(fn) {
3357 const ref = React13.useRef(true);
3358 if (ref.current) {
3359 ref.current = false;
3360 fn();
3361 }
3362 }
3363
3364 // node_modules/@base-ui/utils/esm/useTimeout.js
3365 var EMPTY3 = 0;
3366 var Timeout = class _Timeout {
3367 static create() {
3368 return new _Timeout();
3369 }
3370 currentId = EMPTY3;
3371 /**
3372 * Executes `fn` after `delay`, clearing any previously scheduled call.
3373 */
3374 start(delay, fn) {
3375 this.clear();
3376 this.currentId = setTimeout(() => {
3377 this.currentId = EMPTY3;
3378 fn();
3379 }, delay);
3380 }
3381 isStarted() {
3382 return this.currentId !== EMPTY3;
3383 }
3384 clear = () => {
3385 if (this.currentId !== EMPTY3) {
3386 clearTimeout(this.currentId);
3387 this.currentId = EMPTY3;
3388 }
3389 };
3390 disposeEffect = () => {
3391 return this.clear;
3392 };
3393 };
3394 function useTimeout() {
3395 const timeout = useRefWithInit(Timeout.create).current;
3396 useOnMount(timeout.disposeEffect);
3397 return timeout;
3398 }
3399
3400 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
3401 var React14 = __toESM(require_react(), 1);
3402
3403 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js
3404 function resolveValue(value, pointerType) {
3405 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
3406 return 0;
3407 }
3408 if (typeof value === "function") {
3409 return value();
3410 }
3411 return value;
3412 }
3413 function getDelay(value, prop, pointerType) {
3414 const result = resolveValue(value, pointerType);
3415 if (typeof result === "number") {
3416 return result;
3417 }
3418 return result?.[prop];
3419 }
3420 function getRestMs(value) {
3421 if (typeof value === "function") {
3422 return value();
3423 }
3424 return value;
3425 }
3426 function isClickLikeOpenEvent(openEventType, interactedInside) {
3427 return interactedInside || openEventType === "click" || openEventType === "mousedown";
3428 }
3429
3430 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
3431 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
3432 var FloatingDelayGroupContext = /* @__PURE__ */ React14.createContext({
3433 hasProvider: false,
3434 timeoutMs: 0,
3435 delayRef: {
3436 current: 0
3437 },
3438 initialDelayRef: {
3439 current: 0
3440 },
3441 timeout: new Timeout(),
3442 currentIdRef: {
3443 current: null
3444 },
3445 currentContextRef: {
3446 current: null
3447 }
3448 });
3449 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
3450 function FloatingDelayGroup(props) {
3451 const {
3452 children,
3453 delay,
3454 timeoutMs = 0
3455 } = props;
3456 const delayRef = React14.useRef(delay);
3457 const initialDelayRef = React14.useRef(delay);
3458 const currentIdRef = React14.useRef(null);
3459 const currentContextRef = React14.useRef(null);
3460 const timeout = useTimeout();
3461 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(FloatingDelayGroupContext.Provider, {
3462 value: React14.useMemo(() => ({
3463 hasProvider: true,
3464 delayRef,
3465 initialDelayRef,
3466 currentIdRef,
3467 timeoutMs,
3468 currentContextRef,
3469 timeout
3470 }), [timeoutMs, timeout]),
3471 children
3472 });
3473 }
3474 function useDelayGroup(context, options = {
3475 open: false
3476 }) {
3477 const store = "rootStore" in context ? context.rootStore : context;
3478 const floatingId = store.useState("floatingId");
3479 const {
3480 open
3481 } = options;
3482 const groupContext = React14.useContext(FloatingDelayGroupContext);
3483 const {
3484 currentIdRef,
3485 delayRef,
3486 timeoutMs,
3487 initialDelayRef,
3488 currentContextRef,
3489 hasProvider,
3490 timeout
3491 } = groupContext;
3492 const [isInstantPhase, setIsInstantPhase] = React14.useState(false);
3493 useIsoLayoutEffect(() => {
3494 function unset() {
3495 setIsInstantPhase(false);
3496 currentContextRef.current?.setIsInstantPhase(false);
3497 currentIdRef.current = null;
3498 currentContextRef.current = null;
3499 delayRef.current = initialDelayRef.current;
3500 }
3501 if (!currentIdRef.current) {
3502 return void 0;
3503 }
3504 if (!open && currentIdRef.current === floatingId) {
3505 setIsInstantPhase(false);
3506 if (timeoutMs) {
3507 const closingId = floatingId;
3508 timeout.start(timeoutMs, () => {
3509 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
3510 return;
3511 }
3512 unset();
3513 });
3514 return () => {
3515 timeout.clear();
3516 };
3517 }
3518 unset();
3519 }
3520 return void 0;
3521 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
3522 useIsoLayoutEffect(() => {
3523 if (!open) {
3524 return;
3525 }
3526 const prevContext = currentContextRef.current;
3527 const prevId = currentIdRef.current;
3528 timeout.clear();
3529 currentContextRef.current = {
3530 onOpenChange: store.setOpen,
3531 setIsInstantPhase
3532 };
3533 currentIdRef.current = floatingId;
3534 delayRef.current = {
3535 open: 0,
3536 close: getDelay(initialDelayRef.current, "close")
3537 };
3538 if (prevId !== null && prevId !== floatingId) {
3539 setIsInstantPhase(true);
3540 prevContext?.setIsInstantPhase(true);
3541 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
3542 } else {
3543 setIsInstantPhase(false);
3544 prevContext?.setIsInstantPhase(false);
3545 }
3546 }, [open, floatingId, store, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout]);
3547 useIsoLayoutEffect(() => {
3548 return () => {
3549 currentContextRef.current = null;
3550 };
3551 }, [currentContextRef]);
3552 return React14.useMemo(() => ({
3553 hasProvider,
3554 delayRef,
3555 isInstantPhase
3556 }), [hasProvider, delayRef, isInstantPhase]);
3557 }
3558
3559 // node_modules/@base-ui/utils/esm/mergeCleanups.js
3560 function mergeCleanups(...cleanups) {
3561 return () => {
3562 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
3563 const cleanup = cleanups[i2];
3564 if (cleanup) {
3565 cleanup();
3566 }
3567 }
3568 };
3569 }
3570
3571 // node_modules/@base-ui/utils/esm/useValueAsRef.js
3572 function useValueAsRef(value) {
3573 const latest = useRefWithInit(createLatestRef, value).current;
3574 latest.next = value;
3575 useIsoLayoutEffect(latest.effect);
3576 return latest;
3577 }
3578 function createLatestRef(value) {
3579 const latest = {
3580 current: value,
3581 next: value,
3582 effect: () => {
3583 latest.current = latest.next;
3584 }
3585 };
3586 return latest;
3587 }
3588
3589 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
3590 var React15 = __toESM(require_react(), 1);
3591
3592 // node_modules/@base-ui/utils/esm/visuallyHidden.js
3593 var visuallyHiddenBase = {
3594 clipPath: "inset(50%)",
3595 overflow: "hidden",
3596 whiteSpace: "nowrap",
3597 border: 0,
3598 padding: 0,
3599 width: 1,
3600 height: 1,
3601 margin: -1
3602 };
3603 var visuallyHidden = {
3604 ...visuallyHiddenBase,
3605 position: "fixed",
3606 top: 0,
3607 left: 0
3608 };
3609 var visuallyHiddenInput = {
3610 ...visuallyHiddenBase,
3611 position: "absolute"
3612 };
3613
3614 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
3615 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
3616 var FocusGuard = /* @__PURE__ */ React15.forwardRef(function FocusGuard2(props, ref) {
3617 const [role, setRole] = React15.useState();
3618 useIsoLayoutEffect(() => {
3619 if (isSafari) {
3620 setRole("button");
3621 }
3622 }, []);
3623 const restProps = {
3624 tabIndex: 0,
3625 // Role is only for VoiceOver
3626 role
3627 };
3628 return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", {
3629 ...props,
3630 ref,
3631 style: visuallyHidden,
3632 "aria-hidden": role ? void 0 : true,
3633 ...restProps,
3634 "data-base-ui-focus-guard": ""
3635 });
3636 });
3637 if (true) FocusGuard.displayName = "FocusGuard";
3638
3639 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js
3640 function createAttribute(name) {
3641 return `data-base-ui-${name}`;
3642 }
3643
3644 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
3645 var React16 = __toESM(require_react(), 1);
3646 var ReactDOM2 = __toESM(require_react_dom(), 1);
3647
3648 // node_modules/@base-ui/react/esm/internals/constants.js
3649 var DISABLED_TRANSITIONS_STYLE = {
3650 style: {
3651 transition: "none"
3652 }
3653 };
3654 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
3655 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
3656 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
3657 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
3658 var POPUP_COLLISION_AVOIDANCE = {
3659 fallbackAxisSide: "end"
3660 };
3661 var ownerVisuallyHidden = {
3662 clipPath: "inset(50%)",
3663 position: "fixed",
3664 top: 0,
3665 left: 0
3666 };
3667
3668 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
3669 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
3670 var PortalContext = /* @__PURE__ */ React16.createContext(null);
3671 if (true) PortalContext.displayName = "PortalContext";
3672 var usePortalContext = () => React16.useContext(PortalContext);
3673 var attr = createAttribute("portal");
3674 function useFloatingPortalNode(props = {}) {
3675 const {
3676 ref,
3677 container: containerProp,
3678 componentProps = EMPTY_OBJECT,
3679 elementProps
3680 } = props;
3681 const uniqueId = useId();
3682 const portalContext = usePortalContext();
3683 const parentPortalNode = portalContext?.portalNode;
3684 const [containerElement, setContainerElement] = React16.useState(null);
3685 const [portalNode, setPortalNode] = React16.useState(null);
3686 const setPortalNodeRef = useStableCallback((node) => {
3687 if (node !== null) {
3688 setPortalNode(node);
3689 }
3690 });
3691 const containerRef = React16.useRef(null);
3692 useIsoLayoutEffect(() => {
3693 if (containerProp === null) {
3694 if (containerRef.current) {
3695 containerRef.current = null;
3696 setPortalNode(null);
3697 setContainerElement(null);
3698 }
3699 return;
3700 }
3701 if (uniqueId == null) {
3702 return;
3703 }
3704 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
3705 if (resolvedContainer == null) {
3706 if (containerRef.current) {
3707 containerRef.current = null;
3708 setPortalNode(null);
3709 setContainerElement(null);
3710 }
3711 return;
3712 }
3713 if (containerRef.current !== resolvedContainer) {
3714 containerRef.current = resolvedContainer;
3715 setPortalNode(null);
3716 setContainerElement(resolvedContainer);
3717 }
3718 }, [containerProp, parentPortalNode, uniqueId]);
3719 const portalElement = useRenderElement("div", componentProps, {
3720 ref: [ref, setPortalNodeRef],
3721 props: [{
3722 id: uniqueId,
3723 [attr]: ""
3724 }, elementProps]
3725 });
3726 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
3727 return {
3728 portalNode,
3729 portalSubtree
3730 };
3731 }
3732 var FloatingPortal = /* @__PURE__ */ React16.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
3733 const {
3734 children,
3735 container,
3736 className,
3737 render: render4,
3738 renderGuards,
3739 style,
3740 ...elementProps
3741 } = componentProps;
3742 const {
3743 portalNode,
3744 portalSubtree
3745 } = useFloatingPortalNode({
3746 container,
3747 ref: forwardedRef,
3748 componentProps,
3749 elementProps
3750 });
3751 const beforeOutsideRef = React16.useRef(null);
3752 const afterOutsideRef = React16.useRef(null);
3753 const beforeInsideRef = React16.useRef(null);
3754 const afterInsideRef = React16.useRef(null);
3755 const [focusManagerState, setFocusManagerState] = React16.useState(null);
3756 const focusInsideDisabledRef = React16.useRef(false);
3757 const modal = focusManagerState?.modal;
3758 const open = focusManagerState?.open;
3759 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
3760 React16.useEffect(() => {
3761 if (!portalNode || modal) {
3762 return void 0;
3763 }
3764 function onFocus(event) {
3765 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
3766 if (event.type === "focusin") {
3767 if (focusInsideDisabledRef.current) {
3768 enableFocusInside(portalNode);
3769 focusInsideDisabledRef.current = false;
3770 }
3771 } else {
3772 disableFocusInside(portalNode);
3773 focusInsideDisabledRef.current = true;
3774 }
3775 }
3776 }
3777 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
3778 }, [portalNode, modal]);
3779 React16.useEffect(() => {
3780 if (!portalNode || open !== false) {
3781 return;
3782 }
3783 enableFocusInside(portalNode);
3784 focusInsideDisabledRef.current = false;
3785 }, [open, portalNode]);
3786 const portalContextValue = React16.useMemo(() => ({
3787 beforeOutsideRef,
3788 afterOutsideRef,
3789 beforeInsideRef,
3790 afterInsideRef,
3791 portalNode,
3792 setFocusManagerState
3793 }), [portalNode]);
3794 return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(React16.Fragment, {
3795 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(PortalContext.Provider, {
3796 value: portalContextValue,
3797 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FocusGuard, {
3798 "data-type": "outside",
3799 ref: beforeOutsideRef,
3800 onFocus: (event) => {
3801 if (isOutsideEvent(event, portalNode)) {
3802 beforeInsideRef.current?.focus();
3803 } else {
3804 const domReference = focusManagerState ? focusManagerState.domReference : null;
3805 const prevTabbable = getPreviousTabbable(domReference);
3806 prevTabbable?.focus();
3807 }
3808 }
3809 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", {
3810 "aria-owns": portalNode.id,
3811 style: ownerVisuallyHidden
3812 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FocusGuard, {
3813 "data-type": "outside",
3814 ref: afterOutsideRef,
3815 onFocus: (event) => {
3816 if (isOutsideEvent(event, portalNode)) {
3817 afterInsideRef.current?.focus();
3818 } else {
3819 const domReference = focusManagerState ? focusManagerState.domReference : null;
3820 const nextTabbable = getNextTabbable(domReference);
3821 nextTabbable?.focus();
3822 if (focusManagerState?.closeOnFocusOut) {
3823 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
3824 }
3825 }
3826 }
3827 })]
3828 })]
3829 });
3830 });
3831 if (true) FloatingPortal.displayName = "FloatingPortal";
3832
3833 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3834 var React17 = __toESM(require_react(), 1);
3835
3836 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js
3837 function createEventEmitter() {
3838 const map = /* @__PURE__ */ new Map();
3839 return {
3840 emit(event, data) {
3841 map.get(event)?.forEach((listener) => listener(data));
3842 },
3843 on(event, listener) {
3844 if (!map.has(event)) {
3845 map.set(event, /* @__PURE__ */ new Set());
3846 }
3847 map.get(event).add(listener);
3848 },
3849 off(event, listener) {
3850 map.get(event)?.delete(listener);
3851 }
3852 };
3853 }
3854
3855 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3856 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
3857 var FloatingNodeContext = /* @__PURE__ */ React17.createContext(null);
3858 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
3859 var FloatingTreeContext = /* @__PURE__ */ React17.createContext(null);
3860 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3861 var useFloatingParentNodeId = () => React17.useContext(FloatingNodeContext)?.id || null;
3862 var useFloatingTree = (externalTree) => {
3863 const contextTree = React17.useContext(FloatingTreeContext);
3864 return externalTree ?? contextTree;
3865 };
3866
3867 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js
3868 var React18 = __toESM(require_react(), 1);
3869 function createVirtualElement(domElement, data) {
3870 let offsetX = null;
3871 let offsetY = null;
3872 let isAutoUpdateEvent = false;
3873 return {
3874 contextElement: domElement || void 0,
3875 getBoundingClientRect() {
3876 const domRect = domElement?.getBoundingClientRect() || {
3877 width: 0,
3878 height: 0,
3879 x: 0,
3880 y: 0
3881 };
3882 const isXAxis = data.axis === "x" || data.axis === "both";
3883 const isYAxis = data.axis === "y" || data.axis === "both";
3884 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
3885 let width = domRect.width;
3886 let height = domRect.height;
3887 let x2 = domRect.x;
3888 let y2 = domRect.y;
3889 if (offsetX == null && data.x && isXAxis) {
3890 offsetX = domRect.x - data.x;
3891 }
3892 if (offsetY == null && data.y && isYAxis) {
3893 offsetY = domRect.y - data.y;
3894 }
3895 x2 -= offsetX || 0;
3896 y2 -= offsetY || 0;
3897 width = 0;
3898 height = 0;
3899 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
3900 width = data.axis === "y" ? domRect.width : 0;
3901 height = data.axis === "x" ? domRect.height : 0;
3902 x2 = isXAxis && data.x != null ? data.x : x2;
3903 y2 = isYAxis && data.y != null ? data.y : y2;
3904 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
3905 height = data.axis === "x" ? domRect.height : height;
3906 width = data.axis === "y" ? domRect.width : width;
3907 }
3908 isAutoUpdateEvent = true;
3909 return {
3910 width,
3911 height,
3912 x: x2,
3913 y: y2,
3914 top: y2,
3915 right: x2 + width,
3916 bottom: y2 + height,
3917 left: x2
3918 };
3919 }
3920 };
3921 }
3922 function isMouseBasedEvent(event) {
3923 return event != null && event.clientX != null;
3924 }
3925 function useClientPoint(context, props = {}) {
3926 const store = "rootStore" in context ? context.rootStore : context;
3927 const open = store.useState("open");
3928 const floating = store.useState("floatingElement");
3929 const domReference = store.useState("domReferenceElement");
3930 const dataRef = store.context.dataRef;
3931 const {
3932 enabled = true,
3933 axis = "both"
3934 } = props;
3935 const initialRef = React18.useRef(false);
3936 const cleanupListenerRef = React18.useRef(null);
3937 const [pointerType, setPointerType] = React18.useState();
3938 const [reactive, setReactive] = React18.useState([]);
3939 const setReference = useStableCallback((newX, newY, referenceElement) => {
3940 if (initialRef.current) {
3941 return;
3942 }
3943 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3944 return;
3945 }
3946 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3947 x: newX,
3948 y: newY,
3949 axis,
3950 dataRef,
3951 pointerType
3952 }));
3953 });
3954 const handleReferenceEnterOrMove = useStableCallback((event) => {
3955 if (!open) {
3956 setReference(event.clientX, event.clientY, event.currentTarget);
3957 } else if (!cleanupListenerRef.current) {
3958 setReactive([]);
3959 }
3960 });
3961 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
3962 const addListener = React18.useCallback(() => {
3963 if (!openCheck || !enabled) {
3964 return void 0;
3965 }
3966 const win = getWindow(floating);
3967 function handleMouseMove(event) {
3968 const target = getTarget(event);
3969 if (!contains(floating, target)) {
3970 setReference(event.clientX, event.clientY);
3971 } else {
3972 cleanupListenerRef.current?.();
3973 cleanupListenerRef.current = null;
3974 }
3975 }
3976 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3977 const cleanup = () => {
3978 cleanupListenerRef.current?.();
3979 cleanupListenerRef.current = null;
3980 };
3981 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3982 return cleanup;
3983 }
3984 store.set("positionReference", domReference);
3985 return void 0;
3986 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference]);
3987 React18.useEffect(() => {
3988 return addListener();
3989 }, [addListener, reactive]);
3990 React18.useEffect(() => {
3991 if (enabled && !floating) {
3992 initialRef.current = false;
3993 }
3994 }, [enabled, floating]);
3995 React18.useEffect(() => {
3996 if (!enabled && open) {
3997 initialRef.current = true;
3998 }
3999 }, [enabled, open]);
4000 const reference = React18.useMemo(() => {
4001 function setPointerTypeRef(event) {
4002 setPointerType(event.pointerType);
4003 }
4004 return {
4005 onPointerDown: setPointerTypeRef,
4006 onPointerEnter: setPointerTypeRef,
4007 onMouseMove: handleReferenceEnterOrMove,
4008 onMouseEnter: handleReferenceEnterOrMove
4009 };
4010 }, [handleReferenceEnterOrMove]);
4011 return React18.useMemo(() => enabled ? {
4012 reference,
4013 trigger: reference
4014 } : {}, [enabled, reference]);
4015 }
4016
4017 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js
4018 var React19 = __toESM(require_react(), 1);
4019 var bubbleHandlerKeys = {
4020 intentional: "onClick",
4021 sloppy: "onPointerDown"
4022 };
4023 function alwaysFalse() {
4024 return false;
4025 }
4026 function normalizeProp(normalizable) {
4027 return {
4028 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
4029 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
4030 };
4031 }
4032 function useDismiss(context, props = {}) {
4033 const store = "rootStore" in context ? context.rootStore : context;
4034 const open = store.useState("open");
4035 const floatingElement = store.useState("floatingElement");
4036 const {
4037 dataRef
4038 } = store.context;
4039 const {
4040 enabled = true,
4041 escapeKey: escapeKey2 = true,
4042 outsidePress: outsidePressProp = true,
4043 outsidePressEvent = "sloppy",
4044 referencePress = alwaysFalse,
4045 referencePressEvent = "sloppy",
4046 bubbles,
4047 externalTree
4048 } = props;
4049 const tree = useFloatingTree(externalTree);
4050 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
4051 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
4052 const outsidePressEnabled = outsidePress2 !== false;
4053 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
4054 const pressStartedInsideRef = React19.useRef(false);
4055 const pressStartPreventedRef = React19.useRef(false);
4056 const suppressNextOutsideClickRef = React19.useRef(false);
4057 const {
4058 escapeKey: escapeKeyBubbles,
4059 outsidePress: outsidePressBubbles
4060 } = normalizeProp(bubbles);
4061 const touchStateRef = React19.useRef(null);
4062 const cancelDismissOnEndTimeout = useTimeout();
4063 const clearInsideReactTreeTimeout = useTimeout();
4064 const clearInsideReactTree = useStableCallback(() => {
4065 clearInsideReactTreeTimeout.clear();
4066 dataRef.current.insideReactTree = false;
4067 });
4068 const isComposingRef = React19.useRef(false);
4069 const currentPointerTypeRef = React19.useRef("");
4070 const isReferencePressEnabled = useStableCallback(referencePress);
4071 const closeOnEscapeKeyDown = useStableCallback((event) => {
4072 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
4073 return;
4074 }
4075 if (isComposingRef.current) {
4076 return;
4077 }
4078 const nodeId = dataRef.current.floatingContext?.nodeId;
4079 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
4080 if (!escapeKeyBubbles) {
4081 if (children.length > 0) {
4082 let shouldDismiss = true;
4083 children.forEach((child) => {
4084 if (child.context?.open && !child.context.dataRef.current.__escapeKeyBubbles) {
4085 shouldDismiss = false;
4086 }
4087 });
4088 if (!shouldDismiss) {
4089 return;
4090 }
4091 }
4092 }
4093 const native = isReactEvent(event) ? event.nativeEvent : event;
4094 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
4095 store.setOpen(false, eventDetails);
4096 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
4097 event.stopPropagation();
4098 }
4099 });
4100 const markInsideReactTree = useStableCallback(() => {
4101 dataRef.current.insideReactTree = true;
4102 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
4103 });
4104 React19.useEffect(() => {
4105 if (!open || !enabled) {
4106 return void 0;
4107 }
4108 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
4109 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
4110 const compositionTimeout = new Timeout();
4111 const preventedPressSuppressionTimeout = new Timeout();
4112 function handleCompositionStart() {
4113 compositionTimeout.clear();
4114 isComposingRef.current = true;
4115 }
4116 function handleCompositionEnd() {
4117 compositionTimeout.start(
4118 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
4119 // Only apply to WebKit for the test to remain 0ms.
4120 isWebKit() ? 5 : 0,
4121 () => {
4122 isComposingRef.current = false;
4123 }
4124 );
4125 }
4126 function suppressImmediateOutsideClickAfterPreventedStart() {
4127 suppressNextOutsideClickRef.current = true;
4128 preventedPressSuppressionTimeout.start(0, () => {
4129 suppressNextOutsideClickRef.current = false;
4130 });
4131 }
4132 function resetPressStartState() {
4133 pressStartedInsideRef.current = false;
4134 pressStartPreventedRef.current = false;
4135 }
4136 function getOutsidePressEvent() {
4137 const type = currentPointerTypeRef.current;
4138 const computedType = type === "pen" || !type ? "mouse" : type;
4139 const outsidePressEventValue = getOutsidePressEventProp();
4140 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
4141 if (typeof resolved === "string") {
4142 return resolved;
4143 }
4144 return resolved[computedType];
4145 }
4146 function shouldIgnoreEvent(event) {
4147 const computedOutsidePressEvent = getOutsidePressEvent();
4148 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
4149 }
4150 function isEventWithinFloatingTree(event) {
4151 const nodeId = dataRef.current.floatingContext?.nodeId;
4152 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
4153 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement")) || targetIsInsideChildren;
4154 }
4155 function closeOnPressOutside(event) {
4156 if (shouldIgnoreEvent(event)) {
4157 clearInsideReactTree();
4158 return;
4159 }
4160 if (dataRef.current.insideReactTree) {
4161 clearInsideReactTree();
4162 return;
4163 }
4164 const target = getTarget(event);
4165 const inertSelector = `[${createAttribute("inert")}]`;
4166 const targetRoot = isElement(target) ? target.getRootNode() : null;
4167 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
4168 const triggers = store.context.triggerElements;
4169 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
4170 return;
4171 }
4172 let targetRootAncestor = isElement(target) ? target : null;
4173 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
4174 const nextParent = getParentNode(targetRootAncestor);
4175 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
4176 break;
4177 }
4178 targetRootAncestor = nextParent;
4179 }
4180 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
4181 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
4182 // element was injected after the floating element rendered.
4183 markers.every((marker) => !contains(targetRootAncestor, marker))) {
4184 return;
4185 }
4186 if (isHTMLElement(target) && !("touches" in event)) {
4187 const lastTraversableNode = isLastTraversableNode(target);
4188 const style = getComputedStyle2(target);
4189 const scrollRe = /auto|scroll/;
4190 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
4191 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
4192 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
4193 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
4194 const isRTL7 = style.direction === "rtl";
4195 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
4196 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
4197 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
4198 return;
4199 }
4200 }
4201 if (isEventWithinFloatingTree(event)) {
4202 return;
4203 }
4204 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
4205 preventedPressSuppressionTimeout.clear();
4206 suppressNextOutsideClickRef.current = false;
4207 return;
4208 }
4209 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
4210 return;
4211 }
4212 const nodeId = dataRef.current.floatingContext?.nodeId;
4213 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
4214 if (children.length > 0) {
4215 let shouldDismiss = true;
4216 children.forEach((child) => {
4217 if (child.context?.open && !child.context.dataRef.current.__outsidePressBubbles) {
4218 shouldDismiss = false;
4219 }
4220 });
4221 if (!shouldDismiss) {
4222 return;
4223 }
4224 }
4225 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
4226 clearInsideReactTree();
4227 }
4228 function handlePointerDown(event) {
4229 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
4230 return;
4231 }
4232 closeOnPressOutside(event);
4233 }
4234 function handleTouchStart(event) {
4235 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
4236 return;
4237 }
4238 const touch = event.touches[0];
4239 if (touch) {
4240 touchStateRef.current = {
4241 startTime: Date.now(),
4242 startX: touch.clientX,
4243 startY: touch.clientY,
4244 dismissOnTouchEnd: false,
4245 dismissOnMouseDown: true
4246 };
4247 cancelDismissOnEndTimeout.start(1e3, () => {
4248 if (touchStateRef.current) {
4249 touchStateRef.current.dismissOnTouchEnd = false;
4250 touchStateRef.current.dismissOnMouseDown = false;
4251 }
4252 });
4253 }
4254 }
4255 function addTargetEventListenerOnce(event, listener) {
4256 const target = getTarget(event);
4257 if (!target) {
4258 return;
4259 }
4260 const unsubscribe2 = addEventListener(target, event.type, () => {
4261 listener(event);
4262 unsubscribe2();
4263 });
4264 }
4265 function handleTouchStartCapture(event) {
4266 currentPointerTypeRef.current = "touch";
4267 addTargetEventListenerOnce(event, handleTouchStart);
4268 }
4269 function closeOnPressOutsideCapture(event) {
4270 cancelDismissOnEndTimeout.clear();
4271 if (event.type === "pointerdown") {
4272 currentPointerTypeRef.current = event.pointerType;
4273 }
4274 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
4275 return;
4276 }
4277 addTargetEventListenerOnce(event, (targetEvent) => {
4278 if (targetEvent.type === "pointerdown") {
4279 handlePointerDown(targetEvent);
4280 } else {
4281 closeOnPressOutside(targetEvent);
4282 }
4283 });
4284 }
4285 function handlePressEndCapture(event) {
4286 if (!pressStartedInsideRef.current) {
4287 return;
4288 }
4289 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
4290 resetPressStartState();
4291 if (getOutsidePressEvent() !== "intentional") {
4292 return;
4293 }
4294 if (event.type === "pointercancel") {
4295 if (pressStartedInsideDefaultPrevented) {
4296 suppressImmediateOutsideClickAfterPreventedStart();
4297 }
4298 return;
4299 }
4300 if (isEventWithinFloatingTree(event)) {
4301 return;
4302 }
4303 if (pressStartedInsideDefaultPrevented) {
4304 suppressImmediateOutsideClickAfterPreventedStart();
4305 return;
4306 }
4307 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
4308 return;
4309 }
4310 preventedPressSuppressionTimeout.clear();
4311 suppressNextOutsideClickRef.current = true;
4312 clearInsideReactTree();
4313 }
4314 function handleTouchMove(event) {
4315 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
4316 return;
4317 }
4318 const touch = event.touches[0];
4319 if (!touch) {
4320 return;
4321 }
4322 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
4323 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
4324 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
4325 if (distance > 5) {
4326 touchStateRef.current.dismissOnTouchEnd = true;
4327 }
4328 if (distance > 10) {
4329 closeOnPressOutside(event);
4330 cancelDismissOnEndTimeout.clear();
4331 touchStateRef.current = null;
4332 }
4333 }
4334 function handleTouchMoveCapture(event) {
4335 addTargetEventListenerOnce(event, handleTouchMove);
4336 }
4337 function handleTouchEnd(event) {
4338 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
4339 return;
4340 }
4341 if (touchStateRef.current.dismissOnTouchEnd) {
4342 closeOnPressOutside(event);
4343 }
4344 cancelDismissOnEndTimeout.clear();
4345 touchStateRef.current = null;
4346 }
4347 function handleTouchEndCapture(event) {
4348 addTargetEventListenerOnce(event, handleTouchEnd);
4349 }
4350 const doc = ownerDocument(floatingElement);
4351 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)));
4352 return () => {
4353 unsubscribe();
4354 compositionTimeout.clear();
4355 preventedPressSuppressionTimeout.clear();
4356 resetPressStartState();
4357 suppressNextOutsideClickRef.current = false;
4358 };
4359 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, tree, store, cancelDismissOnEndTimeout]);
4360 React19.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
4361 const reference = React19.useMemo(() => ({
4362 onKeyDown: closeOnEscapeKeyDown,
4363 [bubbleHandlerKeys[referencePressEvent]]: (event) => {
4364 if (!isReferencePressEnabled()) {
4365 return;
4366 }
4367 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
4368 },
4369 ...referencePressEvent !== "intentional" && {
4370 onClick(event) {
4371 if (!isReferencePressEnabled()) {
4372 return;
4373 }
4374 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
4375 }
4376 }
4377 }), [closeOnEscapeKeyDown, store, referencePressEvent, isReferencePressEnabled]);
4378 const markPressStartedInsideReactTree = useStableCallback((event) => {
4379 if (!open || !enabled || event.button !== 0) {
4380 return;
4381 }
4382 const target = getTarget(event.nativeEvent);
4383 if (!contains(store.select("floatingElement"), target)) {
4384 return;
4385 }
4386 if (!pressStartedInsideRef.current) {
4387 pressStartedInsideRef.current = true;
4388 pressStartPreventedRef.current = false;
4389 }
4390 });
4391 const markInsidePressStartPrevented = useStableCallback((event) => {
4392 if (!open || !enabled) {
4393 return;
4394 }
4395 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
4396 return;
4397 }
4398 if (pressStartedInsideRef.current) {
4399 pressStartPreventedRef.current = true;
4400 }
4401 });
4402 const floating = React19.useMemo(() => ({
4403 onKeyDown: closeOnEscapeKeyDown,
4404 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
4405 // `onPointerDown`, such as with <NumberField.ScrubArea>.
4406 // See https://github.com/mui/base-ui/pull/3379
4407 onPointerDown: markInsidePressStartPrevented,
4408 onMouseDown: markInsidePressStartPrevented,
4409 onClickCapture: markInsideReactTree,
4410 onMouseDownCapture(event) {
4411 markInsideReactTree();
4412 markPressStartedInsideReactTree(event);
4413 },
4414 onPointerDownCapture(event) {
4415 markInsideReactTree();
4416 markPressStartedInsideReactTree(event);
4417 },
4418 onMouseUpCapture: markInsideReactTree,
4419 onTouchEndCapture: markInsideReactTree,
4420 onTouchMoveCapture: markInsideReactTree
4421 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
4422 return React19.useMemo(() => enabled ? {
4423 reference,
4424 floating,
4425 trigger: reference
4426 } : {}, [enabled, reference, floating]);
4427 }
4428
4429 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
4430 var React25 = __toESM(require_react(), 1);
4431
4432 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
4433 function computeCoordsFromPlacement(_ref, placement, rtl) {
4434 let {
4435 reference,
4436 floating
4437 } = _ref;
4438 const sideAxis = getSideAxis(placement);
4439 const alignmentAxis = getAlignmentAxis(placement);
4440 const alignLength = getAxisLength(alignmentAxis);
4441 const side = getSide(placement);
4442 const isVertical = sideAxis === "y";
4443 const commonX = reference.x + reference.width / 2 - floating.width / 2;
4444 const commonY = reference.y + reference.height / 2 - floating.height / 2;
4445 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
4446 let coords;
4447 switch (side) {
4448 case "top":
4449 coords = {
4450 x: commonX,
4451 y: reference.y - floating.height
4452 };
4453 break;
4454 case "bottom":
4455 coords = {
4456 x: commonX,
4457 y: reference.y + reference.height
4458 };
4459 break;
4460 case "right":
4461 coords = {
4462 x: reference.x + reference.width,
4463 y: commonY
4464 };
4465 break;
4466 case "left":
4467 coords = {
4468 x: reference.x - floating.width,
4469 y: commonY
4470 };
4471 break;
4472 default:
4473 coords = {
4474 x: reference.x,
4475 y: reference.y
4476 };
4477 }
4478 switch (getAlignment(placement)) {
4479 case "start":
4480 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
4481 break;
4482 case "end":
4483 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
4484 break;
4485 }
4486 return coords;
4487 }
4488 async function detectOverflow(state, options) {
4489 var _await$platform$isEle;
4490 if (options === void 0) {
4491 options = {};
4492 }
4493 const {
4494 x: x2,
4495 y: y2,
4496 platform: platform3,
4497 rects,
4498 elements,
4499 strategy
4500 } = state;
4501 const {
4502 boundary = "clippingAncestors",
4503 rootBoundary = "viewport",
4504 elementContext = "floating",
4505 altBoundary = false,
4506 padding = 0
4507 } = evaluate(options, state);
4508 const paddingObject = getPaddingObject(padding);
4509 const altContext = elementContext === "floating" ? "reference" : "floating";
4510 const element = elements[altBoundary ? altContext : elementContext];
4511 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
4512 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)),
4513 boundary,
4514 rootBoundary,
4515 strategy
4516 }));
4517 const rect = elementContext === "floating" ? {
4518 x: x2,
4519 y: y2,
4520 width: rects.floating.width,
4521 height: rects.floating.height
4522 } : rects.reference;
4523 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
4524 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
4525 x: 1,
4526 y: 1
4527 } : {
4528 x: 1,
4529 y: 1
4530 };
4531 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
4532 elements,
4533 rect,
4534 offsetParent,
4535 strategy
4536 }) : rect);
4537 return {
4538 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
4539 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
4540 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
4541 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
4542 };
4543 }
4544 var MAX_RESET_COUNT = 50;
4545 var computePosition = async (reference, floating, config) => {
4546 const {
4547 placement = "bottom",
4548 strategy = "absolute",
4549 middleware = [],
4550 platform: platform3
4551 } = config;
4552 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
4553 ...platform3,
4554 detectOverflow
4555 };
4556 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
4557 let rects = await platform3.getElementRects({
4558 reference,
4559 floating,
4560 strategy
4561 });
4562 let {
4563 x: x2,
4564 y: y2
4565 } = computeCoordsFromPlacement(rects, placement, rtl);
4566 let statefulPlacement = placement;
4567 let resetCount = 0;
4568 const middlewareData = {};
4569 for (let i2 = 0; i2 < middleware.length; i2++) {
4570 const currentMiddleware = middleware[i2];
4571 if (!currentMiddleware) {
4572 continue;
4573 }
4574 const {
4575 name,
4576 fn
4577 } = currentMiddleware;
4578 const {
4579 x: nextX,
4580 y: nextY,
4581 data,
4582 reset
4583 } = await fn({
4584 x: x2,
4585 y: y2,
4586 initialPlacement: placement,
4587 placement: statefulPlacement,
4588 strategy,
4589 middlewareData,
4590 rects,
4591 platform: platformWithDetectOverflow,
4592 elements: {
4593 reference,
4594 floating
4595 }
4596 });
4597 x2 = nextX != null ? nextX : x2;
4598 y2 = nextY != null ? nextY : y2;
4599 middlewareData[name] = {
4600 ...middlewareData[name],
4601 ...data
4602 };
4603 if (reset && resetCount < MAX_RESET_COUNT) {
4604 resetCount++;
4605 if (typeof reset === "object") {
4606 if (reset.placement) {
4607 statefulPlacement = reset.placement;
4608 }
4609 if (reset.rects) {
4610 rects = reset.rects === true ? await platform3.getElementRects({
4611 reference,
4612 floating,
4613 strategy
4614 }) : reset.rects;
4615 }
4616 ({
4617 x: x2,
4618 y: y2
4619 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
4620 }
4621 i2 = -1;
4622 }
4623 }
4624 return {
4625 x: x2,
4626 y: y2,
4627 placement: statefulPlacement,
4628 strategy,
4629 middlewareData
4630 };
4631 };
4632 var flip = function(options) {
4633 if (options === void 0) {
4634 options = {};
4635 }
4636 return {
4637 name: "flip",
4638 options,
4639 async fn(state) {
4640 var _middlewareData$arrow, _middlewareData$flip;
4641 const {
4642 placement,
4643 middlewareData,
4644 rects,
4645 initialPlacement,
4646 platform: platform3,
4647 elements
4648 } = state;
4649 const {
4650 mainAxis: checkMainAxis = true,
4651 crossAxis: checkCrossAxis = true,
4652 fallbackPlacements: specifiedFallbackPlacements,
4653 fallbackStrategy = "bestFit",
4654 fallbackAxisSideDirection = "none",
4655 flipAlignment = true,
4656 ...detectOverflowOptions
4657 } = evaluate(options, state);
4658 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4659 return {};
4660 }
4661 const side = getSide(placement);
4662 const initialSideAxis = getSideAxis(initialPlacement);
4663 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
4664 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4665 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
4666 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
4667 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
4668 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
4669 }
4670 const placements2 = [initialPlacement, ...fallbackPlacements];
4671 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4672 const overflows = [];
4673 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
4674 if (checkMainAxis) {
4675 overflows.push(overflow[side]);
4676 }
4677 if (checkCrossAxis) {
4678 const sides2 = getAlignmentSides(placement, rects, rtl);
4679 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
4680 }
4681 overflowsData = [...overflowsData, {
4682 placement,
4683 overflows
4684 }];
4685 if (!overflows.every((side2) => side2 <= 0)) {
4686 var _middlewareData$flip2, _overflowsData$filter;
4687 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
4688 const nextPlacement = placements2[nextIndex];
4689 if (nextPlacement) {
4690 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
4691 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
4692 // overflows the main axis.
4693 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
4694 return {
4695 data: {
4696 index: nextIndex,
4697 overflows: overflowsData
4698 },
4699 reset: {
4700 placement: nextPlacement
4701 }
4702 };
4703 }
4704 }
4705 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;
4706 if (!resetPlacement) {
4707 switch (fallbackStrategy) {
4708 case "bestFit": {
4709 var _overflowsData$filter2;
4710 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
4711 if (hasFallbackAxisSideDirection) {
4712 const currentSideAxis = getSideAxis(d2.placement);
4713 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
4714 // reading directions favoring greater width.
4715 currentSideAxis === "y";
4716 }
4717 return true;
4718 }).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];
4719 if (placement2) {
4720 resetPlacement = placement2;
4721 }
4722 break;
4723 }
4724 case "initialPlacement":
4725 resetPlacement = initialPlacement;
4726 break;
4727 }
4728 }
4729 if (placement !== resetPlacement) {
4730 return {
4731 reset: {
4732 placement: resetPlacement
4733 }
4734 };
4735 }
4736 }
4737 return {};
4738 }
4739 };
4740 };
4741 function getSideOffsets(overflow, rect) {
4742 return {
4743 top: overflow.top - rect.height,
4744 right: overflow.right - rect.width,
4745 bottom: overflow.bottom - rect.height,
4746 left: overflow.left - rect.width
4747 };
4748 }
4749 function isAnySideFullyClipped(overflow) {
4750 return sides.some((side) => overflow[side] >= 0);
4751 }
4752 var hide = function(options) {
4753 if (options === void 0) {
4754 options = {};
4755 }
4756 return {
4757 name: "hide",
4758 options,
4759 async fn(state) {
4760 const {
4761 rects,
4762 platform: platform3
4763 } = state;
4764 const {
4765 strategy = "referenceHidden",
4766 ...detectOverflowOptions
4767 } = evaluate(options, state);
4768 switch (strategy) {
4769 case "referenceHidden": {
4770 const overflow = await platform3.detectOverflow(state, {
4771 ...detectOverflowOptions,
4772 elementContext: "reference"
4773 });
4774 const offsets = getSideOffsets(overflow, rects.reference);
4775 return {
4776 data: {
4777 referenceHiddenOffsets: offsets,
4778 referenceHidden: isAnySideFullyClipped(offsets)
4779 }
4780 };
4781 }
4782 case "escaped": {
4783 const overflow = await platform3.detectOverflow(state, {
4784 ...detectOverflowOptions,
4785 altBoundary: true
4786 });
4787 const offsets = getSideOffsets(overflow, rects.floating);
4788 return {
4789 data: {
4790 escapedOffsets: offsets,
4791 escaped: isAnySideFullyClipped(offsets)
4792 }
4793 };
4794 }
4795 default: {
4796 return {};
4797 }
4798 }
4799 }
4800 };
4801 };
4802 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
4803 async function convertValueToCoords(state, options) {
4804 const {
4805 placement,
4806 platform: platform3,
4807 elements
4808 } = state;
4809 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4810 const side = getSide(placement);
4811 const alignment = getAlignment(placement);
4812 const isVertical = getSideAxis(placement) === "y";
4813 const mainAxisMulti = originSides.has(side) ? -1 : 1;
4814 const crossAxisMulti = rtl && isVertical ? -1 : 1;
4815 const rawValue = evaluate(options, state);
4816 let {
4817 mainAxis,
4818 crossAxis,
4819 alignmentAxis
4820 } = typeof rawValue === "number" ? {
4821 mainAxis: rawValue,
4822 crossAxis: 0,
4823 alignmentAxis: null
4824 } : {
4825 mainAxis: rawValue.mainAxis || 0,
4826 crossAxis: rawValue.crossAxis || 0,
4827 alignmentAxis: rawValue.alignmentAxis
4828 };
4829 if (alignment && typeof alignmentAxis === "number") {
4830 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
4831 }
4832 return isVertical ? {
4833 x: crossAxis * crossAxisMulti,
4834 y: mainAxis * mainAxisMulti
4835 } : {
4836 x: mainAxis * mainAxisMulti,
4837 y: crossAxis * crossAxisMulti
4838 };
4839 }
4840 var offset = function(options) {
4841 if (options === void 0) {
4842 options = 0;
4843 }
4844 return {
4845 name: "offset",
4846 options,
4847 async fn(state) {
4848 var _middlewareData$offse, _middlewareData$arrow;
4849 const {
4850 x: x2,
4851 y: y2,
4852 placement,
4853 middlewareData
4854 } = state;
4855 const diffCoords = await convertValueToCoords(state, options);
4856 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4857 return {};
4858 }
4859 return {
4860 x: x2 + diffCoords.x,
4861 y: y2 + diffCoords.y,
4862 data: {
4863 ...diffCoords,
4864 placement
4865 }
4866 };
4867 }
4868 };
4869 };
4870 var shift = function(options) {
4871 if (options === void 0) {
4872 options = {};
4873 }
4874 return {
4875 name: "shift",
4876 options,
4877 async fn(state) {
4878 const {
4879 x: x2,
4880 y: y2,
4881 placement,
4882 platform: platform3
4883 } = state;
4884 const {
4885 mainAxis: checkMainAxis = true,
4886 crossAxis: checkCrossAxis = false,
4887 limiter = {
4888 fn: (_ref) => {
4889 let {
4890 x: x3,
4891 y: y3
4892 } = _ref;
4893 return {
4894 x: x3,
4895 y: y3
4896 };
4897 }
4898 },
4899 ...detectOverflowOptions
4900 } = evaluate(options, state);
4901 const coords = {
4902 x: x2,
4903 y: y2
4904 };
4905 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4906 const crossAxis = getSideAxis(getSide(placement));
4907 const mainAxis = getOppositeAxis(crossAxis);
4908 let mainAxisCoord = coords[mainAxis];
4909 let crossAxisCoord = coords[crossAxis];
4910 if (checkMainAxis) {
4911 const minSide = mainAxis === "y" ? "top" : "left";
4912 const maxSide = mainAxis === "y" ? "bottom" : "right";
4913 const min2 = mainAxisCoord + overflow[minSide];
4914 const max2 = mainAxisCoord - overflow[maxSide];
4915 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
4916 }
4917 if (checkCrossAxis) {
4918 const minSide = crossAxis === "y" ? "top" : "left";
4919 const maxSide = crossAxis === "y" ? "bottom" : "right";
4920 const min2 = crossAxisCoord + overflow[minSide];
4921 const max2 = crossAxisCoord - overflow[maxSide];
4922 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
4923 }
4924 const limitedCoords = limiter.fn({
4925 ...state,
4926 [mainAxis]: mainAxisCoord,
4927 [crossAxis]: crossAxisCoord
4928 });
4929 return {
4930 ...limitedCoords,
4931 data: {
4932 x: limitedCoords.x - x2,
4933 y: limitedCoords.y - y2,
4934 enabled: {
4935 [mainAxis]: checkMainAxis,
4936 [crossAxis]: checkCrossAxis
4937 }
4938 }
4939 };
4940 }
4941 };
4942 };
4943 var limitShift = function(options) {
4944 if (options === void 0) {
4945 options = {};
4946 }
4947 return {
4948 options,
4949 fn(state) {
4950 const {
4951 x: x2,
4952 y: y2,
4953 placement,
4954 rects,
4955 middlewareData
4956 } = state;
4957 const {
4958 offset: offset4 = 0,
4959 mainAxis: checkMainAxis = true,
4960 crossAxis: checkCrossAxis = true
4961 } = evaluate(options, state);
4962 const coords = {
4963 x: x2,
4964 y: y2
4965 };
4966 const crossAxis = getSideAxis(placement);
4967 const mainAxis = getOppositeAxis(crossAxis);
4968 let mainAxisCoord = coords[mainAxis];
4969 let crossAxisCoord = coords[crossAxis];
4970 const rawOffset = evaluate(offset4, state);
4971 const computedOffset = typeof rawOffset === "number" ? {
4972 mainAxis: rawOffset,
4973 crossAxis: 0
4974 } : {
4975 mainAxis: 0,
4976 crossAxis: 0,
4977 ...rawOffset
4978 };
4979 if (checkMainAxis) {
4980 const len = mainAxis === "y" ? "height" : "width";
4981 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
4982 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
4983 if (mainAxisCoord < limitMin) {
4984 mainAxisCoord = limitMin;
4985 } else if (mainAxisCoord > limitMax) {
4986 mainAxisCoord = limitMax;
4987 }
4988 }
4989 if (checkCrossAxis) {
4990 var _middlewareData$offse, _middlewareData$offse2;
4991 const len = mainAxis === "y" ? "width" : "height";
4992 const isOriginSide = originSides.has(getSide(placement));
4993 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);
4994 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);
4995 if (crossAxisCoord < limitMin) {
4996 crossAxisCoord = limitMin;
4997 } else if (crossAxisCoord > limitMax) {
4998 crossAxisCoord = limitMax;
4999 }
5000 }
5001 return {
5002 [mainAxis]: mainAxisCoord,
5003 [crossAxis]: crossAxisCoord
5004 };
5005 }
5006 };
5007 };
5008 var size = function(options) {
5009 if (options === void 0) {
5010 options = {};
5011 }
5012 return {
5013 name: "size",
5014 options,
5015 async fn(state) {
5016 var _state$middlewareData, _state$middlewareData2;
5017 const {
5018 placement,
5019 rects,
5020 platform: platform3,
5021 elements
5022 } = state;
5023 const {
5024 apply = () => {
5025 },
5026 ...detectOverflowOptions
5027 } = evaluate(options, state);
5028 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
5029 const side = getSide(placement);
5030 const alignment = getAlignment(placement);
5031 const isYAxis = getSideAxis(placement) === "y";
5032 const {
5033 width,
5034 height
5035 } = rects.floating;
5036 let heightSide;
5037 let widthSide;
5038 if (side === "top" || side === "bottom") {
5039 heightSide = side;
5040 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
5041 } else {
5042 widthSide = side;
5043 heightSide = alignment === "end" ? "top" : "bottom";
5044 }
5045 const maximumClippingHeight = height - overflow.top - overflow.bottom;
5046 const maximumClippingWidth = width - overflow.left - overflow.right;
5047 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
5048 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
5049 const noShift = !state.middlewareData.shift;
5050 let availableHeight = overflowAvailableHeight;
5051 let availableWidth = overflowAvailableWidth;
5052 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
5053 availableWidth = maximumClippingWidth;
5054 }
5055 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
5056 availableHeight = maximumClippingHeight;
5057 }
5058 if (noShift && !alignment) {
5059 const xMin = max(overflow.left, 0);
5060 const xMax = max(overflow.right, 0);
5061 const yMin = max(overflow.top, 0);
5062 const yMax = max(overflow.bottom, 0);
5063 if (isYAxis) {
5064 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
5065 } else {
5066 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
5067 }
5068 }
5069 await apply({
5070 ...state,
5071 availableWidth,
5072 availableHeight
5073 });
5074 const nextDimensions = await platform3.getDimensions(elements.floating);
5075 if (width !== nextDimensions.width || height !== nextDimensions.height) {
5076 return {
5077 reset: {
5078 rects: true
5079 }
5080 };
5081 }
5082 return {};
5083 }
5084 };
5085 };
5086
5087 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
5088 function getCssDimensions(element) {
5089 const css = getComputedStyle2(element);
5090 let width = parseFloat(css.width) || 0;
5091 let height = parseFloat(css.height) || 0;
5092 const hasOffset = isHTMLElement(element);
5093 const offsetWidth = hasOffset ? element.offsetWidth : width;
5094 const offsetHeight = hasOffset ? element.offsetHeight : height;
5095 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
5096 if (shouldFallback) {
5097 width = offsetWidth;
5098 height = offsetHeight;
5099 }
5100 return {
5101 width,
5102 height,
5103 $: shouldFallback
5104 };
5105 }
5106 function unwrapElement(element) {
5107 return !isElement(element) ? element.contextElement : element;
5108 }
5109 function getScale(element) {
5110 const domElement = unwrapElement(element);
5111 if (!isHTMLElement(domElement)) {
5112 return createCoords(1);
5113 }
5114 const rect = domElement.getBoundingClientRect();
5115 const {
5116 width,
5117 height,
5118 $: $2
5119 } = getCssDimensions(domElement);
5120 let x2 = ($2 ? round(rect.width) : rect.width) / width;
5121 let y2 = ($2 ? round(rect.height) : rect.height) / height;
5122 if (!x2 || !Number.isFinite(x2)) {
5123 x2 = 1;
5124 }
5125 if (!y2 || !Number.isFinite(y2)) {
5126 y2 = 1;
5127 }
5128 return {
5129 x: x2,
5130 y: y2
5131 };
5132 }
5133 var noOffsets = /* @__PURE__ */ createCoords(0);
5134 function getVisualOffsets(element) {
5135 const win = getWindow(element);
5136 if (!isWebKit() || !win.visualViewport) {
5137 return noOffsets;
5138 }
5139 return {
5140 x: win.visualViewport.offsetLeft,
5141 y: win.visualViewport.offsetTop
5142 };
5143 }
5144 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
5145 if (isFixed === void 0) {
5146 isFixed = false;
5147 }
5148 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
5149 return false;
5150 }
5151 return isFixed;
5152 }
5153 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
5154 if (includeScale === void 0) {
5155 includeScale = false;
5156 }
5157 if (isFixedStrategy === void 0) {
5158 isFixedStrategy = false;
5159 }
5160 const clientRect = element.getBoundingClientRect();
5161 const domElement = unwrapElement(element);
5162 let scale = createCoords(1);
5163 if (includeScale) {
5164 if (offsetParent) {
5165 if (isElement(offsetParent)) {
5166 scale = getScale(offsetParent);
5167 }
5168 } else {
5169 scale = getScale(element);
5170 }
5171 }
5172 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
5173 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
5174 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
5175 let width = clientRect.width / scale.x;
5176 let height = clientRect.height / scale.y;
5177 if (domElement) {
5178 const win = getWindow(domElement);
5179 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
5180 let currentWin = win;
5181 let currentIFrame = getFrameElement(currentWin);
5182 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
5183 const iframeScale = getScale(currentIFrame);
5184 const iframeRect = currentIFrame.getBoundingClientRect();
5185 const css = getComputedStyle2(currentIFrame);
5186 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
5187 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
5188 x2 *= iframeScale.x;
5189 y2 *= iframeScale.y;
5190 width *= iframeScale.x;
5191 height *= iframeScale.y;
5192 x2 += left;
5193 y2 += top;
5194 currentWin = getWindow(currentIFrame);
5195 currentIFrame = getFrameElement(currentWin);
5196 }
5197 }
5198 return rectToClientRect({
5199 width,
5200 height,
5201 x: x2,
5202 y: y2
5203 });
5204 }
5205 function getWindowScrollBarX(element, rect) {
5206 const leftScroll = getNodeScroll(element).scrollLeft;
5207 if (!rect) {
5208 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
5209 }
5210 return rect.left + leftScroll;
5211 }
5212 function getHTMLOffset(documentElement, scroll) {
5213 const htmlRect = documentElement.getBoundingClientRect();
5214 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
5215 const y2 = htmlRect.top + scroll.scrollTop;
5216 return {
5217 x: x2,
5218 y: y2
5219 };
5220 }
5221 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
5222 let {
5223 elements,
5224 rect,
5225 offsetParent,
5226 strategy
5227 } = _ref;
5228 const isFixed = strategy === "fixed";
5229 const documentElement = getDocumentElement(offsetParent);
5230 const topLayer = elements ? isTopLayer(elements.floating) : false;
5231 if (offsetParent === documentElement || topLayer && isFixed) {
5232 return rect;
5233 }
5234 let scroll = {
5235 scrollLeft: 0,
5236 scrollTop: 0
5237 };
5238 let scale = createCoords(1);
5239 const offsets = createCoords(0);
5240 const isOffsetParentAnElement = isHTMLElement(offsetParent);
5241 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5242 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5243 scroll = getNodeScroll(offsetParent);
5244 }
5245 if (isOffsetParentAnElement) {
5246 const offsetRect = getBoundingClientRect(offsetParent);
5247 scale = getScale(offsetParent);
5248 offsets.x = offsetRect.x + offsetParent.clientLeft;
5249 offsets.y = offsetRect.y + offsetParent.clientTop;
5250 }
5251 }
5252 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5253 return {
5254 width: rect.width * scale.x,
5255 height: rect.height * scale.y,
5256 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
5257 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
5258 };
5259 }
5260 function getClientRects(element) {
5261 return Array.from(element.getClientRects());
5262 }
5263 function getDocumentRect(element) {
5264 const html = getDocumentElement(element);
5265 const scroll = getNodeScroll(element);
5266 const body = element.ownerDocument.body;
5267 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
5268 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
5269 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
5270 const y2 = -scroll.scrollTop;
5271 if (getComputedStyle2(body).direction === "rtl") {
5272 x2 += max(html.clientWidth, body.clientWidth) - width;
5273 }
5274 return {
5275 width,
5276 height,
5277 x: x2,
5278 y: y2
5279 };
5280 }
5281 var SCROLLBAR_MAX = 25;
5282 function getViewportRect(element, strategy) {
5283 const win = getWindow(element);
5284 const html = getDocumentElement(element);
5285 const visualViewport = win.visualViewport;
5286 let width = html.clientWidth;
5287 let height = html.clientHeight;
5288 let x2 = 0;
5289 let y2 = 0;
5290 if (visualViewport) {
5291 width = visualViewport.width;
5292 height = visualViewport.height;
5293 const visualViewportBased = isWebKit();
5294 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
5295 x2 = visualViewport.offsetLeft;
5296 y2 = visualViewport.offsetTop;
5297 }
5298 }
5299 const windowScrollbarX = getWindowScrollBarX(html);
5300 if (windowScrollbarX <= 0) {
5301 const doc = html.ownerDocument;
5302 const body = doc.body;
5303 const bodyStyles = getComputedStyle(body);
5304 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
5305 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
5306 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
5307 width -= clippingStableScrollbarWidth;
5308 }
5309 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
5310 width += windowScrollbarX;
5311 }
5312 return {
5313 width,
5314 height,
5315 x: x2,
5316 y: y2
5317 };
5318 }
5319 function getInnerBoundingClientRect(element, strategy) {
5320 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
5321 const top = clientRect.top + element.clientTop;
5322 const left = clientRect.left + element.clientLeft;
5323 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
5324 const width = element.clientWidth * scale.x;
5325 const height = element.clientHeight * scale.y;
5326 const x2 = left * scale.x;
5327 const y2 = top * scale.y;
5328 return {
5329 width,
5330 height,
5331 x: x2,
5332 y: y2
5333 };
5334 }
5335 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
5336 let rect;
5337 if (clippingAncestor === "viewport") {
5338 rect = getViewportRect(element, strategy);
5339 } else if (clippingAncestor === "document") {
5340 rect = getDocumentRect(getDocumentElement(element));
5341 } else if (isElement(clippingAncestor)) {
5342 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
5343 } else {
5344 const visualOffsets = getVisualOffsets(element);
5345 rect = {
5346 x: clippingAncestor.x - visualOffsets.x,
5347 y: clippingAncestor.y - visualOffsets.y,
5348 width: clippingAncestor.width,
5349 height: clippingAncestor.height
5350 };
5351 }
5352 return rectToClientRect(rect);
5353 }
5354 function hasFixedPositionAncestor(element, stopNode) {
5355 const parentNode = getParentNode(element);
5356 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
5357 return false;
5358 }
5359 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
5360 }
5361 function getClippingElementAncestors(element, cache) {
5362 const cachedResult = cache.get(element);
5363 if (cachedResult) {
5364 return cachedResult;
5365 }
5366 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
5367 let currentContainingBlockComputedStyle = null;
5368 const elementIsFixed = getComputedStyle2(element).position === "fixed";
5369 let currentNode = elementIsFixed ? getParentNode(element) : element;
5370 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
5371 const computedStyle = getComputedStyle2(currentNode);
5372 const currentNodeIsContaining = isContainingBlock(currentNode);
5373 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
5374 currentContainingBlockComputedStyle = null;
5375 }
5376 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
5377 if (shouldDropCurrentNode) {
5378 result = result.filter((ancestor) => ancestor !== currentNode);
5379 } else {
5380 currentContainingBlockComputedStyle = computedStyle;
5381 }
5382 currentNode = getParentNode(currentNode);
5383 }
5384 cache.set(element, result);
5385 return result;
5386 }
5387 function getClippingRect(_ref) {
5388 let {
5389 element,
5390 boundary,
5391 rootBoundary,
5392 strategy
5393 } = _ref;
5394 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
5395 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
5396 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
5397 let top = firstRect.top;
5398 let right = firstRect.right;
5399 let bottom = firstRect.bottom;
5400 let left = firstRect.left;
5401 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
5402 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
5403 top = max(rect.top, top);
5404 right = min(rect.right, right);
5405 bottom = min(rect.bottom, bottom);
5406 left = max(rect.left, left);
5407 }
5408 return {
5409 width: right - left,
5410 height: bottom - top,
5411 x: left,
5412 y: top
5413 };
5414 }
5415 function getDimensions(element) {
5416 const {
5417 width,
5418 height
5419 } = getCssDimensions(element);
5420 return {
5421 width,
5422 height
5423 };
5424 }
5425 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
5426 const isOffsetParentAnElement = isHTMLElement(offsetParent);
5427 const documentElement = getDocumentElement(offsetParent);
5428 const isFixed = strategy === "fixed";
5429 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
5430 let scroll = {
5431 scrollLeft: 0,
5432 scrollTop: 0
5433 };
5434 const offsets = createCoords(0);
5435 function setLeftRTLScrollbarOffset() {
5436 offsets.x = getWindowScrollBarX(documentElement);
5437 }
5438 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5439 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5440 scroll = getNodeScroll(offsetParent);
5441 }
5442 if (isOffsetParentAnElement) {
5443 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
5444 offsets.x = offsetRect.x + offsetParent.clientLeft;
5445 offsets.y = offsetRect.y + offsetParent.clientTop;
5446 } else if (documentElement) {
5447 setLeftRTLScrollbarOffset();
5448 }
5449 }
5450 if (isFixed && !isOffsetParentAnElement && documentElement) {
5451 setLeftRTLScrollbarOffset();
5452 }
5453 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5454 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
5455 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
5456 return {
5457 x: x2,
5458 y: y2,
5459 width: rect.width,
5460 height: rect.height
5461 };
5462 }
5463 function isStaticPositioned(element) {
5464 return getComputedStyle2(element).position === "static";
5465 }
5466 function getTrueOffsetParent(element, polyfill) {
5467 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
5468 return null;
5469 }
5470 if (polyfill) {
5471 return polyfill(element);
5472 }
5473 let rawOffsetParent = element.offsetParent;
5474 if (getDocumentElement(element) === rawOffsetParent) {
5475 rawOffsetParent = rawOffsetParent.ownerDocument.body;
5476 }
5477 return rawOffsetParent;
5478 }
5479 function getOffsetParent(element, polyfill) {
5480 const win = getWindow(element);
5481 if (isTopLayer(element)) {
5482 return win;
5483 }
5484 if (!isHTMLElement(element)) {
5485 let svgOffsetParent = getParentNode(element);
5486 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
5487 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
5488 return svgOffsetParent;
5489 }
5490 svgOffsetParent = getParentNode(svgOffsetParent);
5491 }
5492 return win;
5493 }
5494 let offsetParent = getTrueOffsetParent(element, polyfill);
5495 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
5496 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
5497 }
5498 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
5499 return win;
5500 }
5501 return offsetParent || getContainingBlock(element) || win;
5502 }
5503 var getElementRects = async function(data) {
5504 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
5505 const getDimensionsFn = this.getDimensions;
5506 const floatingDimensions = await getDimensionsFn(data.floating);
5507 return {
5508 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
5509 floating: {
5510 x: 0,
5511 y: 0,
5512 width: floatingDimensions.width,
5513 height: floatingDimensions.height
5514 }
5515 };
5516 };
5517 function isRTL(element) {
5518 return getComputedStyle2(element).direction === "rtl";
5519 }
5520 var platform2 = {
5521 convertOffsetParentRelativeRectToViewportRelativeRect,
5522 getDocumentElement,
5523 getClippingRect,
5524 getOffsetParent,
5525 getElementRects,
5526 getClientRects,
5527 getDimensions,
5528 getScale,
5529 isElement,
5530 isRTL
5531 };
5532 function rectsAreEqual(a2, b2) {
5533 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
5534 }
5535 function observeMove(element, onMove) {
5536 let io = null;
5537 let timeoutId;
5538 const root = getDocumentElement(element);
5539 function cleanup() {
5540 var _io;
5541 clearTimeout(timeoutId);
5542 (_io = io) == null || _io.disconnect();
5543 io = null;
5544 }
5545 function refresh(skip, threshold) {
5546 if (skip === void 0) {
5547 skip = false;
5548 }
5549 if (threshold === void 0) {
5550 threshold = 1;
5551 }
5552 cleanup();
5553 const elementRectForRootMargin = element.getBoundingClientRect();
5554 const {
5555 left,
5556 top,
5557 width,
5558 height
5559 } = elementRectForRootMargin;
5560 if (!skip) {
5561 onMove();
5562 }
5563 if (!width || !height) {
5564 return;
5565 }
5566 const insetTop = floor(top);
5567 const insetRight = floor(root.clientWidth - (left + width));
5568 const insetBottom = floor(root.clientHeight - (top + height));
5569 const insetLeft = floor(left);
5570 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
5571 const options = {
5572 rootMargin,
5573 threshold: max(0, min(1, threshold)) || 1
5574 };
5575 let isFirstUpdate = true;
5576 function handleObserve(entries) {
5577 const ratio = entries[0].intersectionRatio;
5578 if (ratio !== threshold) {
5579 if (!isFirstUpdate) {
5580 return refresh();
5581 }
5582 if (!ratio) {
5583 timeoutId = setTimeout(() => {
5584 refresh(false, 1e-7);
5585 }, 1e3);
5586 } else {
5587 refresh(false, ratio);
5588 }
5589 }
5590 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
5591 refresh();
5592 }
5593 isFirstUpdate = false;
5594 }
5595 try {
5596 io = new IntersectionObserver(handleObserve, {
5597 ...options,
5598 // Handle <iframe>s
5599 root: root.ownerDocument
5600 });
5601 } catch (_e) {
5602 io = new IntersectionObserver(handleObserve, options);
5603 }
5604 io.observe(element);
5605 }
5606 refresh(true);
5607 return cleanup;
5608 }
5609 function autoUpdate(reference, floating, update2, options) {
5610 if (options === void 0) {
5611 options = {};
5612 }
5613 const {
5614 ancestorScroll = true,
5615 ancestorResize = true,
5616 elementResize = typeof ResizeObserver === "function",
5617 layoutShift = typeof IntersectionObserver === "function",
5618 animationFrame = false
5619 } = options;
5620 const referenceEl = unwrapElement(reference);
5621 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
5622 ancestors.forEach((ancestor) => {
5623 ancestorScroll && ancestor.addEventListener("scroll", update2, {
5624 passive: true
5625 });
5626 ancestorResize && ancestor.addEventListener("resize", update2);
5627 });
5628 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
5629 let reobserveFrame = -1;
5630 let resizeObserver = null;
5631 if (elementResize) {
5632 resizeObserver = new ResizeObserver((_ref) => {
5633 let [firstEntry] = _ref;
5634 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
5635 resizeObserver.unobserve(floating);
5636 cancelAnimationFrame(reobserveFrame);
5637 reobserveFrame = requestAnimationFrame(() => {
5638 var _resizeObserver;
5639 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
5640 });
5641 }
5642 update2();
5643 });
5644 if (referenceEl && !animationFrame) {
5645 resizeObserver.observe(referenceEl);
5646 }
5647 if (floating) {
5648 resizeObserver.observe(floating);
5649 }
5650 }
5651 let frameId;
5652 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
5653 if (animationFrame) {
5654 frameLoop();
5655 }
5656 function frameLoop() {
5657 const nextRefRect = getBoundingClientRect(reference);
5658 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
5659 update2();
5660 }
5661 prevRefRect = nextRefRect;
5662 frameId = requestAnimationFrame(frameLoop);
5663 }
5664 update2();
5665 return () => {
5666 var _resizeObserver2;
5667 ancestors.forEach((ancestor) => {
5668 ancestorScroll && ancestor.removeEventListener("scroll", update2);
5669 ancestorResize && ancestor.removeEventListener("resize", update2);
5670 });
5671 cleanupIo == null || cleanupIo();
5672 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
5673 resizeObserver = null;
5674 if (animationFrame) {
5675 cancelAnimationFrame(frameId);
5676 }
5677 };
5678 }
5679 var offset2 = offset;
5680 var shift2 = shift;
5681 var flip2 = flip;
5682 var size2 = size;
5683 var hide2 = hide;
5684 var limitShift2 = limitShift;
5685 var computePosition2 = (reference, floating, options) => {
5686 const cache = /* @__PURE__ */ new Map();
5687 const mergedOptions = {
5688 platform: platform2,
5689 ...options
5690 };
5691 const platformWithCache = {
5692 ...mergedOptions.platform,
5693 _c: cache
5694 };
5695 return computePosition(reference, floating, {
5696 ...mergedOptions,
5697 platform: platformWithCache
5698 });
5699 };
5700
5701 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
5702 var React20 = __toESM(require_react(), 1);
5703 var import_react2 = __toESM(require_react(), 1);
5704 var ReactDOM3 = __toESM(require_react_dom(), 1);
5705 var isClient = typeof document !== "undefined";
5706 var noop3 = function noop4() {
5707 };
5708 var index = isClient ? import_react2.useLayoutEffect : noop3;
5709 function deepEqual(a2, b2) {
5710 if (a2 === b2) {
5711 return true;
5712 }
5713 if (typeof a2 !== typeof b2) {
5714 return false;
5715 }
5716 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
5717 return true;
5718 }
5719 let length;
5720 let i2;
5721 let keys;
5722 if (a2 && b2 && typeof a2 === "object") {
5723 if (Array.isArray(a2)) {
5724 length = a2.length;
5725 if (length !== b2.length) return false;
5726 for (i2 = length; i2-- !== 0; ) {
5727 if (!deepEqual(a2[i2], b2[i2])) {
5728 return false;
5729 }
5730 }
5731 return true;
5732 }
5733 keys = Object.keys(a2);
5734 length = keys.length;
5735 if (length !== Object.keys(b2).length) {
5736 return false;
5737 }
5738 for (i2 = length; i2-- !== 0; ) {
5739 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
5740 return false;
5741 }
5742 }
5743 for (i2 = length; i2-- !== 0; ) {
5744 const key = keys[i2];
5745 if (key === "_owner" && a2.$$typeof) {
5746 continue;
5747 }
5748 if (!deepEqual(a2[key], b2[key])) {
5749 return false;
5750 }
5751 }
5752 return true;
5753 }
5754 return a2 !== a2 && b2 !== b2;
5755 }
5756 function getDPR(element) {
5757 if (typeof window === "undefined") {
5758 return 1;
5759 }
5760 const win = element.ownerDocument.defaultView || window;
5761 return win.devicePixelRatio || 1;
5762 }
5763 function roundByDPR(element, value) {
5764 const dpr = getDPR(element);
5765 return Math.round(value * dpr) / dpr;
5766 }
5767 function useLatestRef(value) {
5768 const ref = React20.useRef(value);
5769 index(() => {
5770 ref.current = value;
5771 });
5772 return ref;
5773 }
5774 function useFloating(options) {
5775 if (options === void 0) {
5776 options = {};
5777 }
5778 const {
5779 placement = "bottom",
5780 strategy = "absolute",
5781 middleware = [],
5782 platform: platform3,
5783 elements: {
5784 reference: externalReference,
5785 floating: externalFloating
5786 } = {},
5787 transform = true,
5788 whileElementsMounted,
5789 open
5790 } = options;
5791 const [data, setData] = React20.useState({
5792 x: 0,
5793 y: 0,
5794 strategy,
5795 placement,
5796 middlewareData: {},
5797 isPositioned: false
5798 });
5799 const [latestMiddleware, setLatestMiddleware] = React20.useState(middleware);
5800 if (!deepEqual(latestMiddleware, middleware)) {
5801 setLatestMiddleware(middleware);
5802 }
5803 const [_reference, _setReference] = React20.useState(null);
5804 const [_floating, _setFloating] = React20.useState(null);
5805 const setReference = React20.useCallback((node) => {
5806 if (node !== referenceRef.current) {
5807 referenceRef.current = node;
5808 _setReference(node);
5809 }
5810 }, []);
5811 const setFloating = React20.useCallback((node) => {
5812 if (node !== floatingRef.current) {
5813 floatingRef.current = node;
5814 _setFloating(node);
5815 }
5816 }, []);
5817 const referenceEl = externalReference || _reference;
5818 const floatingEl = externalFloating || _floating;
5819 const referenceRef = React20.useRef(null);
5820 const floatingRef = React20.useRef(null);
5821 const dataRef = React20.useRef(data);
5822 const hasWhileElementsMounted = whileElementsMounted != null;
5823 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5824 const platformRef = useLatestRef(platform3);
5825 const openRef = useLatestRef(open);
5826 const update2 = React20.useCallback(() => {
5827 if (!referenceRef.current || !floatingRef.current) {
5828 return;
5829 }
5830 const config = {
5831 placement,
5832 strategy,
5833 middleware: latestMiddleware
5834 };
5835 if (platformRef.current) {
5836 config.platform = platformRef.current;
5837 }
5838 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
5839 const fullData = {
5840 ...data2,
5841 // The floating element's position may be recomputed while it's closed
5842 // but still mounted (such as when transitioning out). To ensure
5843 // `isPositioned` will be `false` initially on the next open, avoid
5844 // setting it to `true` when `open === false` (must be specified).
5845 isPositioned: openRef.current !== false
5846 };
5847 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5848 dataRef.current = fullData;
5849 ReactDOM3.flushSync(() => {
5850 setData(fullData);
5851 });
5852 }
5853 });
5854 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
5855 index(() => {
5856 if (open === false && dataRef.current.isPositioned) {
5857 dataRef.current.isPositioned = false;
5858 setData((data2) => ({
5859 ...data2,
5860 isPositioned: false
5861 }));
5862 }
5863 }, [open]);
5864 const isMountedRef = React20.useRef(false);
5865 index(() => {
5866 isMountedRef.current = true;
5867 return () => {
5868 isMountedRef.current = false;
5869 };
5870 }, []);
5871 index(() => {
5872 if (referenceEl) referenceRef.current = referenceEl;
5873 if (floatingEl) floatingRef.current = floatingEl;
5874 if (referenceEl && floatingEl) {
5875 if (whileElementsMountedRef.current) {
5876 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
5877 }
5878 update2();
5879 }
5880 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
5881 const refs = React20.useMemo(() => ({
5882 reference: referenceRef,
5883 floating: floatingRef,
5884 setReference,
5885 setFloating
5886 }), [setReference, setFloating]);
5887 const elements = React20.useMemo(() => ({
5888 reference: referenceEl,
5889 floating: floatingEl
5890 }), [referenceEl, floatingEl]);
5891 const floatingStyles = React20.useMemo(() => {
5892 const initialStyles = {
5893 position: strategy,
5894 left: 0,
5895 top: 0
5896 };
5897 if (!elements.floating) {
5898 return initialStyles;
5899 }
5900 const x2 = roundByDPR(elements.floating, data.x);
5901 const y2 = roundByDPR(elements.floating, data.y);
5902 if (transform) {
5903 return {
5904 ...initialStyles,
5905 transform: "translate(" + x2 + "px, " + y2 + "px)",
5906 ...getDPR(elements.floating) >= 1.5 && {
5907 willChange: "transform"
5908 }
5909 };
5910 }
5911 return {
5912 position: strategy,
5913 left: x2,
5914 top: y2
5915 };
5916 }, [strategy, transform, elements.floating, data.x, data.y]);
5917 return React20.useMemo(() => ({
5918 ...data,
5919 update: update2,
5920 refs,
5921 elements,
5922 floatingStyles
5923 }), [data, update2, refs, elements, floatingStyles]);
5924 }
5925 var offset3 = (options, deps) => {
5926 const result = offset2(options);
5927 return {
5928 name: result.name,
5929 fn: result.fn,
5930 options: [options, deps]
5931 };
5932 };
5933 var shift3 = (options, deps) => {
5934 const result = shift2(options);
5935 return {
5936 name: result.name,
5937 fn: result.fn,
5938 options: [options, deps]
5939 };
5940 };
5941 var limitShift3 = (options, deps) => {
5942 const result = limitShift2(options);
5943 return {
5944 fn: result.fn,
5945 options: [options, deps]
5946 };
5947 };
5948 var flip3 = (options, deps) => {
5949 const result = flip2(options);
5950 return {
5951 name: result.name,
5952 fn: result.fn,
5953 options: [options, deps]
5954 };
5955 };
5956 var size3 = (options, deps) => {
5957 const result = size2(options);
5958 return {
5959 name: result.name,
5960 fn: result.fn,
5961 options: [options, deps]
5962 };
5963 };
5964 var hide3 = (options, deps) => {
5965 const result = hide2(options);
5966 return {
5967 name: result.name,
5968 fn: result.fn,
5969 options: [options, deps]
5970 };
5971 };
5972
5973 // node_modules/@base-ui/utils/esm/store/createSelector.js
5974 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
5975 if (other.length > 0) {
5976 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
5977 }
5978 let selector2;
5979 if (a2 && b2 && c2 && d2 && e2 && f2) {
5980 selector2 = (state, a1, a22, a3) => {
5981 const va = a2(state, a1, a22, a3);
5982 const vb = b2(state, a1, a22, a3);
5983 const vc = c2(state, a1, a22, a3);
5984 const vd = d2(state, a1, a22, a3);
5985 const ve = e2(state, a1, a22, a3);
5986 return f2(va, vb, vc, vd, ve, a1, a22, a3);
5987 };
5988 } else if (a2 && b2 && c2 && d2 && e2) {
5989 selector2 = (state, a1, a22, a3) => {
5990 const va = a2(state, a1, a22, a3);
5991 const vb = b2(state, a1, a22, a3);
5992 const vc = c2(state, a1, a22, a3);
5993 const vd = d2(state, a1, a22, a3);
5994 return e2(va, vb, vc, vd, a1, a22, a3);
5995 };
5996 } else if (a2 && b2 && c2 && d2) {
5997 selector2 = (state, a1, a22, a3) => {
5998 const va = a2(state, a1, a22, a3);
5999 const vb = b2(state, a1, a22, a3);
6000 const vc = c2(state, a1, a22, a3);
6001 return d2(va, vb, vc, a1, a22, a3);
6002 };
6003 } else if (a2 && b2 && c2) {
6004 selector2 = (state, a1, a22, a3) => {
6005 const va = a2(state, a1, a22, a3);
6006 const vb = b2(state, a1, a22, a3);
6007 return c2(va, vb, a1, a22, a3);
6008 };
6009 } else if (a2 && b2) {
6010 selector2 = (state, a1, a22, a3) => {
6011 const va = a2(state, a1, a22, a3);
6012 return b2(va, a1, a22, a3);
6013 };
6014 } else if (a2) {
6015 selector2 = a2;
6016 } else {
6017 throw (
6018 /* minify-error-disabled */
6019 new Error("Missing arguments")
6020 );
6021 }
6022 return selector2;
6023 };
6024
6025 // node_modules/@base-ui/utils/esm/store/useStore.js
6026 var React22 = __toESM(require_react(), 1);
6027 var import_shim = __toESM(require_shim(), 1);
6028 var import_with_selector = __toESM(require_with_selector(), 1);
6029
6030 // node_modules/@base-ui/utils/esm/fastHooks.js
6031 var React21 = __toESM(require_react(), 1);
6032 var hooks = [];
6033 var currentInstance = void 0;
6034 function getInstance() {
6035 return currentInstance;
6036 }
6037 function register(hook) {
6038 hooks.push(hook);
6039 }
6040 function fastComponent(fn) {
6041 const FastComponent = (props, forwardedRef) => {
6042 const instance = useRefWithInit(createInstance).current;
6043 let result;
6044 try {
6045 currentInstance = instance;
6046 for (const hook of hooks) {
6047 hook.before(instance);
6048 }
6049 result = fn(props, forwardedRef);
6050 for (const hook of hooks) {
6051 hook.after(instance);
6052 }
6053 instance.didInitialize = true;
6054 } finally {
6055 currentInstance = void 0;
6056 }
6057 return result;
6058 };
6059 FastComponent.displayName = fn.displayName || fn.name;
6060 return FastComponent;
6061 }
6062 function fastComponentRef(fn) {
6063 return /* @__PURE__ */ React21.forwardRef(fastComponent(fn));
6064 }
6065 function createInstance() {
6066 return {
6067 didInitialize: false
6068 };
6069 }
6070
6071 // node_modules/@base-ui/utils/esm/store/useStore.js
6072 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
6073 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
6074 function useStore(store, selector2, a1, a2, a3) {
6075 return useStoreImplementation(store, selector2, a1, a2, a3);
6076 }
6077 function useStoreR19(store, selector2, a1, a2, a3) {
6078 const getSelection = React22.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
6079 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
6080 }
6081 register({
6082 before(instance) {
6083 instance.syncIndex = 0;
6084 if (!instance.didInitialize) {
6085 instance.syncTick = 1;
6086 instance.syncHooks = [];
6087 instance.didChangeStore = true;
6088 instance.getSnapshot = () => {
6089 let didChange2 = false;
6090 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
6091 const hook = instance.syncHooks[i2];
6092 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
6093 if (hook.didChange || !Object.is(hook.value, value)) {
6094 didChange2 = true;
6095 hook.value = value;
6096 hook.didChange = false;
6097 }
6098 }
6099 if (didChange2) {
6100 instance.syncTick += 1;
6101 }
6102 return instance.syncTick;
6103 };
6104 }
6105 },
6106 after(instance) {
6107 if (instance.syncHooks.length > 0) {
6108 if (instance.didChangeStore) {
6109 instance.didChangeStore = false;
6110 instance.subscribe = (onStoreChange) => {
6111 const stores = /* @__PURE__ */ new Set();
6112 for (const hook of instance.syncHooks) {
6113 stores.add(hook.store);
6114 }
6115 const unsubscribes = [];
6116 for (const store of stores) {
6117 unsubscribes.push(store.subscribe(onStoreChange));
6118 }
6119 return () => {
6120 for (const unsubscribe of unsubscribes) {
6121 unsubscribe();
6122 }
6123 };
6124 };
6125 }
6126 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
6127 }
6128 }
6129 });
6130 function useStoreFast(store, selector2, a1, a2, a3) {
6131 const instance = getInstance();
6132 if (!instance) {
6133 return useStoreR19(store, selector2, a1, a2, a3);
6134 }
6135 const index2 = instance.syncIndex;
6136 instance.syncIndex += 1;
6137 let hook;
6138 if (!instance.didInitialize) {
6139 hook = {
6140 store,
6141 selector: selector2,
6142 a1,
6143 a2,
6144 a3,
6145 value: selector2(store.getSnapshot(), a1, a2, a3),
6146 didChange: false
6147 };
6148 instance.syncHooks.push(hook);
6149 } else {
6150 hook = instance.syncHooks[index2];
6151 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
6152 if (hook.store !== store) {
6153 instance.didChangeStore = true;
6154 }
6155 hook.store = store;
6156 hook.selector = selector2;
6157 hook.a1 = a1;
6158 hook.a2 = a2;
6159 hook.a3 = a3;
6160 hook.didChange = true;
6161 }
6162 }
6163 return hook.value;
6164 }
6165 function useStoreLegacy(store, selector2, a1, a2, a3) {
6166 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
6167 }
6168
6169 // node_modules/@base-ui/utils/esm/store/Store.js
6170 var Store = class {
6171 /**
6172 * The current state of the store.
6173 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
6174 * 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).
6175 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
6176 *
6177 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
6178 */
6179 // Internal state to handle recursive `setState()` calls
6180 constructor(state) {
6181 this.state = state;
6182 this.listeners = /* @__PURE__ */ new Set();
6183 this.updateTick = 0;
6184 }
6185 /**
6186 * Registers a listener that will be called whenever the store's state changes.
6187 *
6188 * @param fn The listener function to be called on state changes.
6189 * @returns A function to unsubscribe the listener.
6190 */
6191 subscribe = (fn) => {
6192 this.listeners.add(fn);
6193 return () => {
6194 this.listeners.delete(fn);
6195 };
6196 };
6197 /**
6198 * Returns the current state of the store.
6199 */
6200 getSnapshot = () => {
6201 return this.state;
6202 };
6203 /**
6204 * Updates the entire store's state and notifies all registered listeners.
6205 *
6206 * @param newState The new state to set for the store.
6207 */
6208 setState(newState) {
6209 if (this.state === newState) {
6210 return;
6211 }
6212 this.state = newState;
6213 this.updateTick += 1;
6214 const currentTick = this.updateTick;
6215 for (const listener of this.listeners) {
6216 if (currentTick !== this.updateTick) {
6217 return;
6218 }
6219 listener(newState);
6220 }
6221 }
6222 /**
6223 * Merges the provided changes into the current state and notifies listeners if there are changes.
6224 *
6225 * @param changes An object containing the changes to apply to the current state.
6226 */
6227 update(changes) {
6228 for (const key in changes) {
6229 if (!Object.is(this.state[key], changes[key])) {
6230 this.setState({
6231 ...this.state,
6232 ...changes
6233 });
6234 return;
6235 }
6236 }
6237 }
6238 /**
6239 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
6240 *
6241 * @param key The key in the store's state to update.
6242 * @param value The new value to set for the specified key.
6243 */
6244 set(key, value) {
6245 if (!Object.is(this.state[key], value)) {
6246 this.setState({
6247 ...this.state,
6248 [key]: value
6249 });
6250 }
6251 }
6252 /**
6253 * Gives the state a new reference and updates all registered listeners.
6254 */
6255 notifyAll() {
6256 const newState = {
6257 ...this.state
6258 };
6259 this.setState(newState);
6260 }
6261 use(selector2, a1, a2, a3) {
6262 return useStore(this, selector2, a1, a2, a3);
6263 }
6264 };
6265
6266 // node_modules/@base-ui/utils/esm/store/ReactStore.js
6267 var React23 = __toESM(require_react(), 1);
6268 var ReactStore = class extends Store {
6269 /**
6270 * Creates a new ReactStore instance.
6271 *
6272 * @param state Initial state of the store.
6273 * @param context Non-reactive context values.
6274 * @param selectors Optional selectors for use with `useState`.
6275 */
6276 constructor(state, context = {}, selectors3) {
6277 super(state);
6278 this.context = context;
6279 this.selectors = selectors3;
6280 }
6281 /**
6282 * Non-reactive values such as refs, callbacks, etc.
6283 */
6284 /**
6285 * Synchronizes a single external value into the store.
6286 *
6287 * Note that the while the value in `state` is updated immediately, the value returned
6288 * by `useState` is updated before the next render (similarly to React's `useState`).
6289 */
6290 useSyncedValue(key, value) {
6291 React23.useDebugValue(key);
6292 useIsoLayoutEffect(() => {
6293 if (this.state[key] !== value) {
6294 this.set(key, value);
6295 }
6296 }, [key, value]);
6297 }
6298 /**
6299 * Synchronizes a single external value into the store and
6300 * cleans it up (sets to `undefined`) on unmount.
6301 *
6302 * Note that the while the value in `state` is updated immediately, the value returned
6303 * by `useState` is updated before the next render (similarly to React's `useState`).
6304 */
6305 useSyncedValueWithCleanup(key, value) {
6306 const store = this;
6307 useIsoLayoutEffect(() => {
6308 if (store.state[key] !== value) {
6309 store.set(key, value);
6310 }
6311 return () => {
6312 store.set(key, void 0);
6313 };
6314 }, [store, key, value]);
6315 }
6316 /**
6317 * Synchronizes multiple external values into the store.
6318 *
6319 * Note that the while the values in `state` are updated immediately, the values returned
6320 * by `useState` are updated before the next render (similarly to React's `useState`).
6321 */
6322 useSyncedValues(statePart) {
6323 const store = this;
6324 if (true) {
6325 React23.useDebugValue(statePart, (p2) => Object.keys(p2));
6326 const keys = React23.useRef(Object.keys(statePart)).current;
6327 const nextKeys = Object.keys(statePart);
6328 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
6329 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
6330 }
6331 }
6332 const dependencies = Object.values(statePart);
6333 useIsoLayoutEffect(() => {
6334 store.update(statePart);
6335 }, [store, ...dependencies]);
6336 }
6337 /**
6338 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
6339 * is non-undefined, the store's state at `key` is updated to match `controlled`.
6340 */
6341 useControlledProp(key, controlled) {
6342 React23.useDebugValue(key);
6343 const isControlled = controlled !== void 0;
6344 useIsoLayoutEffect(() => {
6345 if (isControlled && !Object.is(this.state[key], controlled)) {
6346 super.setState({
6347 ...this.state,
6348 [key]: controlled
6349 });
6350 }
6351 }, [key, controlled, isControlled]);
6352 if (true) {
6353 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
6354 if (!cache.has(key)) {
6355 cache.set(key, isControlled);
6356 }
6357 const previouslyControlled = cache.get(key);
6358 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
6359 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).`);
6360 }
6361 }
6362 }
6363 /** Gets the current value from the store using a selector with the provided key.
6364 *
6365 * @param key Key of the selector to use.
6366 */
6367 select(key, a1, a2, a3) {
6368 const selector2 = this.selectors[key];
6369 return selector2(this.state, a1, a2, a3);
6370 }
6371 /**
6372 * Returns a value from the store's state using a selector function.
6373 * Used to subscribe to specific parts of the state.
6374 * This methods causes a rerender whenever the selected state changes.
6375 *
6376 * @param key Key of the selector to use.
6377 */
6378 useState(key, a1, a2, a3) {
6379 React23.useDebugValue(key);
6380 return useStore(this, this.selectors[key], a1, a2, a3);
6381 }
6382 /**
6383 * Wraps a function with `useStableCallback` to ensure it has a stable reference
6384 * and assigns it to the context.
6385 *
6386 * @param key Key of the event callback. Must be a function in the context.
6387 * @param fn Function to assign.
6388 */
6389 useContextCallback(key, fn) {
6390 React23.useDebugValue(key);
6391 const stableFunction = useStableCallback(fn ?? NOOP);
6392 this.context[key] = stableFunction;
6393 }
6394 /**
6395 * Returns a stable setter function for a specific key in the store's state.
6396 * It's commonly used to pass as a ref callback to React elements.
6397 *
6398 * @param key Key of the state to set.
6399 */
6400 useStateSetter(key) {
6401 const ref = React23.useRef(void 0);
6402 if (ref.current === void 0) {
6403 ref.current = (value) => {
6404 this.set(key, value);
6405 };
6406 }
6407 return ref.current;
6408 }
6409 /**
6410 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
6411 *
6412 * @param key Key of the selector to observe.
6413 * @param listener Listener function called when the selector result changes.
6414 */
6415 observe(selector2, listener) {
6416 let selectFn;
6417 if (typeof selector2 === "function") {
6418 selectFn = selector2;
6419 } else {
6420 selectFn = this.selectors[selector2];
6421 }
6422 let prevValue = selectFn(this.state);
6423 listener(prevValue, prevValue, this);
6424 return this.subscribe((nextState) => {
6425 const nextValue = selectFn(nextState);
6426 if (!Object.is(prevValue, nextValue)) {
6427 const oldValue = prevValue;
6428 prevValue = nextValue;
6429 listener(nextValue, oldValue, this);
6430 }
6431 });
6432 }
6433 };
6434
6435 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js
6436 var selectors = {
6437 open: createSelector((state) => state.open),
6438 transitionStatus: createSelector((state) => state.transitionStatus),
6439 domReferenceElement: createSelector((state) => state.domReferenceElement),
6440 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
6441 floatingElement: createSelector((state) => state.floatingElement),
6442 floatingId: createSelector((state) => state.floatingId)
6443 };
6444 var FloatingRootStore = class extends ReactStore {
6445 constructor(options) {
6446 const {
6447 syncOnly,
6448 nested,
6449 onOpenChange,
6450 triggerElements,
6451 ...initialState
6452 } = options;
6453 super({
6454 ...initialState,
6455 positionReference: initialState.referenceElement,
6456 domReferenceElement: initialState.referenceElement
6457 }, {
6458 onOpenChange,
6459 dataRef: {
6460 current: {}
6461 },
6462 events: createEventEmitter(),
6463 nested,
6464 triggerElements
6465 }, selectors);
6466 this.syncOnly = syncOnly;
6467 }
6468 /**
6469 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
6470 */
6471 syncOpenEvent = (newOpen, event) => {
6472 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
6473 // click events to upgrade a hover-open.
6474 event != null && isClickLikeEvent(event)) {
6475 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
6476 }
6477 };
6478 /**
6479 * Runs the root-owned side effects for an open state change.
6480 */
6481 dispatchOpenChange = (newOpen, eventDetails) => {
6482 this.syncOpenEvent(newOpen, eventDetails.event);
6483 const details = {
6484 open: newOpen,
6485 reason: eventDetails.reason,
6486 nativeEvent: eventDetails.event,
6487 nested: this.context.nested,
6488 triggerElement: eventDetails.trigger
6489 };
6490 this.context.events.emit("openchange", details);
6491 };
6492 /**
6493 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
6494 *
6495 * @param newOpen The new open state.
6496 * @param eventDetails Details about the event that triggered the open state change.
6497 */
6498 setOpen = (newOpen, eventDetails) => {
6499 if (this.syncOnly) {
6500 this.context.onOpenChange?.(newOpen, eventDetails);
6501 return;
6502 }
6503 this.dispatchOpenChange(newOpen, eventDetails);
6504 this.context.onOpenChange?.(newOpen, eventDetails);
6505 };
6506 };
6507
6508 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
6509 var React24 = __toESM(require_react(), 1);
6510 function useTriggerRegistration(id, store) {
6511 const registeredElementIdRef = React24.useRef(null);
6512 const registeredElementRef = React24.useRef(null);
6513 return React24.useCallback((element) => {
6514 if (id === void 0) {
6515 return;
6516 }
6517 if (registeredElementIdRef.current !== null) {
6518 const registeredId = registeredElementIdRef.current;
6519 const registeredElement = registeredElementRef.current;
6520 const currentElement = store.context.triggerElements.getById(registeredId);
6521 if (registeredElement && currentElement === registeredElement) {
6522 store.context.triggerElements.delete(registeredId);
6523 }
6524 registeredElementIdRef.current = null;
6525 registeredElementRef.current = null;
6526 }
6527 if (element !== null) {
6528 registeredElementIdRef.current = id;
6529 registeredElementRef.current = element;
6530 store.context.triggerElements.add(id, element);
6531 }
6532 }, [store, id]);
6533 }
6534 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
6535 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
6536 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
6537 const registerTrigger = useStableCallback((element) => {
6538 baseRegisterTrigger(element);
6539 if (!element || !store.select("open")) {
6540 return;
6541 }
6542 const activeTriggerId = store.select("activeTriggerId");
6543 if (activeTriggerId === triggerId) {
6544 store.update({
6545 activeTriggerElement: element,
6546 ...stateUpdates
6547 });
6548 return;
6549 }
6550 if (activeTriggerId == null) {
6551 store.update({
6552 activeTriggerId: triggerId,
6553 activeTriggerElement: element,
6554 ...stateUpdates
6555 });
6556 }
6557 });
6558 useIsoLayoutEffect(() => {
6559 if (isMountedByThisTrigger) {
6560 store.update({
6561 activeTriggerElement: triggerElementRef.current,
6562 ...stateUpdates
6563 });
6564 }
6565 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
6566 return {
6567 registerTrigger,
6568 isMountedByThisTrigger
6569 };
6570 }
6571 function useImplicitActiveTrigger(store) {
6572 const open = store.useState("open");
6573 useIsoLayoutEffect(() => {
6574 if (open && !store.select("activeTriggerId") && store.context.triggerElements.size === 1) {
6575 const iteratorResult = store.context.triggerElements.entries().next();
6576 if (!iteratorResult.done) {
6577 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
6578 store.update({
6579 activeTriggerId: implicitTriggerId,
6580 activeTriggerElement: implicitTriggerElement
6581 });
6582 }
6583 }
6584 }, [open, store]);
6585 }
6586 function useOpenStateTransitions(open, store, onUnmount) {
6587 const {
6588 mounted,
6589 setMounted,
6590 transitionStatus
6591 } = useTransitionStatus(open);
6592 store.useSyncedValues({
6593 mounted,
6594 transitionStatus
6595 });
6596 const forceUnmount = useStableCallback(() => {
6597 setMounted(false);
6598 store.update({
6599 activeTriggerId: null,
6600 activeTriggerElement: null,
6601 mounted: false
6602 });
6603 onUnmount?.();
6604 store.context.onOpenChangeComplete?.(false);
6605 });
6606 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
6607 useOpenChangeComplete({
6608 enabled: !preventUnmountingOnClose,
6609 open,
6610 ref: store.context.popupRef,
6611 onComplete() {
6612 if (!open) {
6613 forceUnmount();
6614 }
6615 }
6616 });
6617 return {
6618 forceUnmount,
6619 transitionStatus
6620 };
6621 }
6622
6623 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js
6624 var PopupTriggerMap = class {
6625 constructor() {
6626 this.elementsSet = /* @__PURE__ */ new Set();
6627 this.idMap = /* @__PURE__ */ new Map();
6628 }
6629 /**
6630 * Adds a trigger element with the given ID.
6631 *
6632 * Note: The provided element is assumed to not be registered under multiple IDs.
6633 */
6634 add(id, element) {
6635 const existingElement = this.idMap.get(id);
6636 if (existingElement === element) {
6637 return;
6638 }
6639 if (existingElement !== void 0) {
6640 this.elementsSet.delete(existingElement);
6641 }
6642 this.elementsSet.add(element);
6643 this.idMap.set(id, element);
6644 if (true) {
6645 if (this.elementsSet.size !== this.idMap.size) {
6646 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
6647 }
6648 }
6649 }
6650 /**
6651 * Removes the trigger element with the given ID.
6652 */
6653 delete(id) {
6654 const element = this.idMap.get(id);
6655 if (element) {
6656 this.elementsSet.delete(element);
6657 this.idMap.delete(id);
6658 }
6659 }
6660 /**
6661 * Whether the given element is registered as a trigger.
6662 */
6663 hasElement(element) {
6664 return this.elementsSet.has(element);
6665 }
6666 /**
6667 * Whether there is a registered trigger element matching the given predicate.
6668 */
6669 hasMatchingElement(predicate) {
6670 for (const element of this.elementsSet) {
6671 if (predicate(element)) {
6672 return true;
6673 }
6674 }
6675 return false;
6676 }
6677 /**
6678 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
6679 */
6680 getById(id) {
6681 return this.idMap.get(id);
6682 }
6683 /**
6684 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
6685 */
6686 entries() {
6687 return this.idMap.entries();
6688 }
6689 /**
6690 * Returns an iterable of all registered trigger elements.
6691 */
6692 elements() {
6693 return this.elementsSet.values();
6694 }
6695 /**
6696 * Returns the number of registered trigger elements.
6697 */
6698 get size() {
6699 return this.idMap.size;
6700 }
6701 };
6702
6703 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js
6704 function getEmptyRootContext() {
6705 return new FloatingRootStore({
6706 open: false,
6707 transitionStatus: void 0,
6708 floatingElement: null,
6709 referenceElement: null,
6710 triggerElements: new PopupTriggerMap(),
6711 floatingId: "",
6712 syncOnly: false,
6713 nested: false,
6714 onOpenChange: void 0
6715 });
6716 }
6717
6718 // node_modules/@base-ui/react/esm/utils/popups/store.js
6719 function createInitialPopupStoreState() {
6720 return {
6721 open: false,
6722 openProp: void 0,
6723 mounted: false,
6724 transitionStatus: void 0,
6725 floatingRootContext: getEmptyRootContext(),
6726 preventUnmountingOnClose: false,
6727 payload: void 0,
6728 activeTriggerId: null,
6729 activeTriggerElement: null,
6730 triggerIdProp: void 0,
6731 popupElement: null,
6732 positionerElement: null,
6733 activeTriggerProps: EMPTY_OBJECT,
6734 inactiveTriggerProps: EMPTY_OBJECT,
6735 popupProps: EMPTY_OBJECT
6736 };
6737 }
6738 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
6739 var popupStoreSelectors = {
6740 open: createSelector((state) => state.openProp ?? state.open),
6741 mounted: createSelector((state) => state.mounted),
6742 transitionStatus: createSelector((state) => state.transitionStatus),
6743 floatingRootContext: createSelector((state) => state.floatingRootContext),
6744 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
6745 payload: createSelector((state) => state.payload),
6746 activeTriggerId: activeTriggerIdSelector,
6747 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
6748 /**
6749 * Whether the trigger with the given ID was used to open the popup.
6750 */
6751 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
6752 /**
6753 * Whether the popup is open and was activated by a trigger with the given ID.
6754 */
6755 isOpenedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.open),
6756 /**
6757 * Whether the popup is mounted and was activated by a trigger with the given ID.
6758 */
6759 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
6760 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
6761 popupProps: createSelector((state) => state.popupProps),
6762 popupElement: createSelector((state) => state.popupElement),
6763 positionerElement: createSelector((state) => state.positionerElement)
6764 };
6765
6766 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js
6767 function useFloatingRootContext(options) {
6768 const {
6769 open = false,
6770 onOpenChange,
6771 elements = {}
6772 } = options;
6773 const floatingId = useId();
6774 const nested = useFloatingParentNodeId() != null;
6775 if (true) {
6776 const optionDomReference = elements.reference;
6777 if (optionDomReference && !isElement(optionDomReference)) {
6778 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
6779 }
6780 }
6781 const store = useRefWithInit(() => new FloatingRootStore({
6782 open,
6783 transitionStatus: void 0,
6784 onOpenChange,
6785 referenceElement: elements.reference ?? null,
6786 floatingElement: elements.floating ?? null,
6787 triggerElements: new PopupTriggerMap(),
6788 floatingId,
6789 syncOnly: false,
6790 nested
6791 })).current;
6792 useIsoLayoutEffect(() => {
6793 const valuesToSync = {
6794 open,
6795 floatingId
6796 };
6797 if (elements.reference !== void 0) {
6798 valuesToSync.referenceElement = elements.reference;
6799 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
6800 }
6801 if (elements.floating !== void 0) {
6802 valuesToSync.floatingElement = elements.floating;
6803 }
6804 store.update(valuesToSync);
6805 }, [open, floatingId, elements.reference, elements.floating, store]);
6806 store.context.onOpenChange = onOpenChange;
6807 store.context.nested = nested;
6808 return store;
6809 }
6810
6811 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
6812 function useFloating2(options = {}) {
6813 const {
6814 nodeId,
6815 externalTree
6816 } = options;
6817 const internalRootStore = useFloatingRootContext(options);
6818 const rootContext = options.rootContext || internalRootStore;
6819 const rootContextElements = {
6820 reference: rootContext.useState("referenceElement"),
6821 floating: rootContext.useState("floatingElement"),
6822 domReference: rootContext.useState("domReferenceElement")
6823 };
6824 const [positionReference, setPositionReferenceRaw] = React25.useState(null);
6825 const domReferenceRef = React25.useRef(null);
6826 const tree = useFloatingTree(externalTree);
6827 useIsoLayoutEffect(() => {
6828 if (rootContextElements.domReference) {
6829 domReferenceRef.current = rootContextElements.domReference;
6830 }
6831 }, [rootContextElements.domReference]);
6832 const position = useFloating({
6833 ...options,
6834 elements: {
6835 ...rootContextElements,
6836 ...positionReference && {
6837 reference: positionReference
6838 }
6839 }
6840 });
6841 const setPositionReference = React25.useCallback((node) => {
6842 const computedPositionReference = isElement(node) ? {
6843 getBoundingClientRect: () => node.getBoundingClientRect(),
6844 getClientRects: () => node.getClientRects(),
6845 contextElement: node
6846 } : node;
6847 setPositionReferenceRaw(computedPositionReference);
6848 position.refs.setReference(computedPositionReference);
6849 }, [position.refs]);
6850 const [localDomReference, setLocalDomReference] = React25.useState(void 0);
6851 const [localFloatingElement, setLocalFloatingElement] = React25.useState(null);
6852 rootContext.useSyncedValue("referenceElement", localDomReference ?? null);
6853 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
6854 rootContext.useSyncedValue("domReferenceElement", localDomReference === void 0 ? rootContextElements.domReference : localDomReferenceElement);
6855 rootContext.useSyncedValue("floatingElement", localFloatingElement);
6856 const setReference = React25.useCallback((node) => {
6857 if (isElement(node) || node === null) {
6858 domReferenceRef.current = node;
6859 setLocalDomReference(node);
6860 }
6861 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
6862 // `null` to support `positionReference` + an unstable `reference`
6863 // callback ref.
6864 node !== null && !isElement(node)) {
6865 position.refs.setReference(node);
6866 }
6867 }, [position.refs, setLocalDomReference]);
6868 const setFloating = React25.useCallback((node) => {
6869 setLocalFloatingElement(node);
6870 position.refs.setFloating(node);
6871 }, [position.refs]);
6872 const refs = React25.useMemo(() => ({
6873 ...position.refs,
6874 setReference,
6875 setFloating,
6876 setPositionReference,
6877 domReference: domReferenceRef
6878 }), [position.refs, setReference, setFloating, setPositionReference]);
6879 const elements = React25.useMemo(() => ({
6880 ...position.elements,
6881 domReference: rootContextElements.domReference
6882 }), [position.elements, rootContextElements.domReference]);
6883 const open = rootContext.useState("open");
6884 const floatingId = rootContext.useState("floatingId");
6885 const context = React25.useMemo(() => ({
6886 ...position,
6887 dataRef: rootContext.context.dataRef,
6888 open,
6889 onOpenChange: rootContext.setOpen,
6890 events: rootContext.context.events,
6891 floatingId,
6892 refs,
6893 elements,
6894 nodeId,
6895 rootStore: rootContext
6896 }), [position, refs, elements, nodeId, rootContext, open, floatingId]);
6897 useIsoLayoutEffect(() => {
6898 rootContext.context.dataRef.current.floatingContext = context;
6899 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
6900 if (node) {
6901 node.context = context;
6902 }
6903 });
6904 return React25.useMemo(() => ({
6905 ...position,
6906 context,
6907 refs,
6908 elements,
6909 rootStore: rootContext
6910 }), [position, refs, elements, context, rootContext]);
6911 }
6912
6913 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
6914 function useSyncedFloatingRootContext(options) {
6915 const {
6916 popupStore,
6917 treatPopupAsFloatingElement = false,
6918 onOpenChange
6919 } = options;
6920 const floatingId = useId();
6921 const nested = useFloatingParentNodeId() != null;
6922 const open = popupStore.useState("open");
6923 const referenceElement = popupStore.useState("activeTriggerElement");
6924 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
6925 const triggerElements = popupStore.context.triggerElements;
6926 const store = useRefWithInit(() => new FloatingRootStore({
6927 open,
6928 transitionStatus: void 0,
6929 referenceElement,
6930 floatingElement,
6931 triggerElements,
6932 onOpenChange,
6933 floatingId,
6934 syncOnly: true,
6935 nested
6936 })).current;
6937 useIsoLayoutEffect(() => {
6938 const valuesToSync = {
6939 open,
6940 floatingId,
6941 referenceElement,
6942 floatingElement
6943 };
6944 if (isElement(referenceElement)) {
6945 valuesToSync.domReferenceElement = referenceElement;
6946 }
6947 if (store.state.positionReference === store.state.referenceElement) {
6948 valuesToSync.positionReference = referenceElement;
6949 }
6950 store.update(valuesToSync);
6951 }, [open, floatingId, referenceElement, floatingElement, store]);
6952 store.context.onOpenChange = onOpenChange;
6953 store.context.nested = nested;
6954 return store;
6955 }
6956
6957 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js
6958 var React26 = __toESM(require_react(), 1);
6959 var isMacSafari = isMac && isSafari;
6960 function useFocus(context, props = {}) {
6961 const store = "rootStore" in context ? context.rootStore : context;
6962 const {
6963 events,
6964 dataRef
6965 } = store.context;
6966 const {
6967 enabled = true,
6968 delay
6969 } = props;
6970 const blockFocusRef = React26.useRef(false);
6971 const blockedReferenceRef = React26.useRef(null);
6972 const timeout = useTimeout();
6973 const keyboardModalityRef = React26.useRef(true);
6974 React26.useEffect(() => {
6975 const domReference = store.select("domReferenceElement");
6976 if (!enabled) {
6977 return void 0;
6978 }
6979 const win = getWindow(domReference);
6980 function onBlur() {
6981 const currentDomReference = store.select("domReferenceElement");
6982 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
6983 blockFocusRef.current = true;
6984 }
6985 }
6986 function onKeyDown() {
6987 keyboardModalityRef.current = true;
6988 }
6989 function onPointerDown() {
6990 keyboardModalityRef.current = false;
6991 }
6992 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
6993 }, [store, enabled]);
6994 React26.useEffect(() => {
6995 if (!enabled) {
6996 return void 0;
6997 }
6998 function onOpenChangeLocal(details) {
6999 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
7000 const referenceElement = store.select("domReferenceElement");
7001 if (isElement(referenceElement)) {
7002 blockedReferenceRef.current = referenceElement;
7003 blockFocusRef.current = true;
7004 }
7005 }
7006 }
7007 events.on("openchange", onOpenChangeLocal);
7008 return () => {
7009 events.off("openchange", onOpenChangeLocal);
7010 };
7011 }, [events, enabled, store]);
7012 const reference = React26.useMemo(() => ({
7013 onMouseLeave() {
7014 blockFocusRef.current = false;
7015 blockedReferenceRef.current = null;
7016 },
7017 onFocus(event) {
7018 const focusTarget = event.currentTarget;
7019 if (blockFocusRef.current) {
7020 if (blockedReferenceRef.current === focusTarget) {
7021 return;
7022 }
7023 blockFocusRef.current = false;
7024 blockedReferenceRef.current = null;
7025 }
7026 const target = getTarget(event.nativeEvent);
7027 if (isElement(target)) {
7028 if (isMacSafari && !event.relatedTarget) {
7029 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
7030 return;
7031 }
7032 } else if (!matchesFocusVisible(target)) {
7033 return;
7034 }
7035 }
7036 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
7037 const {
7038 nativeEvent,
7039 currentTarget
7040 } = event;
7041 const delayValue = typeof delay === "function" ? delay() : delay;
7042 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
7043 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
7044 return;
7045 }
7046 timeout.start(delayValue, () => {
7047 if (blockFocusRef.current) {
7048 return;
7049 }
7050 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
7051 });
7052 },
7053 onBlur(event) {
7054 blockFocusRef.current = false;
7055 blockedReferenceRef.current = null;
7056 const relatedTarget = event.relatedTarget;
7057 const nativeEvent = event.nativeEvent;
7058 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
7059 timeout.start(0, () => {
7060 const domReference = store.select("domReferenceElement");
7061 const activeEl = activeElement(ownerDocument(domReference));
7062 if (!relatedTarget && activeEl === domReference) {
7063 return;
7064 }
7065 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
7066 return;
7067 }
7068 const nextFocusedElement = relatedTarget ?? activeEl;
7069 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
7070 return;
7071 }
7072 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
7073 });
7074 }
7075 }), [dataRef, store, timeout, delay]);
7076 return React26.useMemo(() => enabled ? {
7077 reference,
7078 trigger: reference
7079 } : {}, [enabled, reference]);
7080 }
7081
7082 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
7083 var React27 = __toESM(require_react(), 1);
7084
7085 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js
7086 var HoverInteraction = class _HoverInteraction {
7087 constructor() {
7088 this.pointerType = void 0;
7089 this.interactedInside = false;
7090 this.handler = void 0;
7091 this.blockMouseMove = true;
7092 this.performedPointerEventsMutation = false;
7093 this.pointerEventsScopeElement = null;
7094 this.pointerEventsReferenceElement = null;
7095 this.pointerEventsFloatingElement = null;
7096 this.restTimeoutPending = false;
7097 this.openChangeTimeout = new Timeout();
7098 this.restTimeout = new Timeout();
7099 this.handleCloseOptions = void 0;
7100 }
7101 static create() {
7102 return new _HoverInteraction();
7103 }
7104 dispose = () => {
7105 this.openChangeTimeout.clear();
7106 this.restTimeout.clear();
7107 };
7108 disposeEffect = () => {
7109 return this.dispose;
7110 };
7111 };
7112 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
7113 function clearSafePolygonPointerEventsMutation(instance) {
7114 if (!instance.performedPointerEventsMutation) {
7115 return;
7116 }
7117 const scopeElement = instance.pointerEventsScopeElement;
7118 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
7119 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
7120 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
7121 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
7122 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
7123 }
7124 instance.performedPointerEventsMutation = false;
7125 instance.pointerEventsScopeElement = null;
7126 instance.pointerEventsReferenceElement = null;
7127 instance.pointerEventsFloatingElement = null;
7128 }
7129 function applySafePolygonPointerEventsMutation(instance, options) {
7130 const {
7131 scopeElement,
7132 referenceElement,
7133 floatingElement
7134 } = options;
7135 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
7136 if (existingOwner && existingOwner !== instance) {
7137 clearSafePolygonPointerEventsMutation(existingOwner);
7138 }
7139 clearSafePolygonPointerEventsMutation(instance);
7140 instance.performedPointerEventsMutation = true;
7141 instance.pointerEventsScopeElement = scopeElement;
7142 instance.pointerEventsReferenceElement = referenceElement;
7143 instance.pointerEventsFloatingElement = floatingElement;
7144 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
7145 scopeElement.style.pointerEvents = "none";
7146 referenceElement.style.pointerEvents = "auto";
7147 floatingElement.style.pointerEvents = "auto";
7148 }
7149 function useHoverInteractionSharedState(store) {
7150 const instance = useRefWithInit(HoverInteraction.create).current;
7151 const data = store.context.dataRef.current;
7152 if (!data.hoverInteractionState) {
7153 data.hoverInteractionState = instance;
7154 }
7155 useOnMount(data.hoverInteractionState.disposeEffect);
7156 return data.hoverInteractionState;
7157 }
7158
7159 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
7160 function useHoverFloatingInteraction(context, parameters = {}) {
7161 const store = "rootStore" in context ? context.rootStore : context;
7162 const open = store.useState("open");
7163 const floatingElement = store.useState("floatingElement");
7164 const domReferenceElement = store.useState("domReferenceElement");
7165 const {
7166 dataRef
7167 } = store.context;
7168 const {
7169 enabled = true,
7170 closeDelay: closeDelayProp = 0,
7171 nodeId: nodeIdProp
7172 } = parameters;
7173 const instance = useHoverInteractionSharedState(store);
7174 const tree = useFloatingTree();
7175 const parentId = useFloatingParentNodeId();
7176 const isClickLikeOpenEvent2 = useStableCallback(() => {
7177 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7178 });
7179 const isHoverOpen = useStableCallback(() => {
7180 const type = dataRef.current.openEvent?.type;
7181 return type?.includes("mouse") && type !== "mousedown";
7182 });
7183 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => {
7184 return isTargetInsideEnabledTrigger(target, store.context.triggerElements);
7185 });
7186 const closeWithDelay = React27.useCallback((event) => {
7187 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
7188 const close = () => {
7189 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7190 tree?.events.emit("floating.closed", event);
7191 };
7192 if (closeDelay) {
7193 instance.openChangeTimeout.start(closeDelay, close);
7194 } else {
7195 instance.openChangeTimeout.clear();
7196 close();
7197 }
7198 }, [closeDelayProp, store, instance, tree]);
7199 const clearPointerEvents = useStableCallback(() => {
7200 clearSafePolygonPointerEventsMutation(instance);
7201 });
7202 const handleInteractInside = useStableCallback((event) => {
7203 const target = getTarget(event);
7204 if (!isInteractiveElement(target)) {
7205 instance.interactedInside = false;
7206 return;
7207 }
7208 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
7209 });
7210 useIsoLayoutEffect(() => {
7211 if (!open) {
7212 instance.pointerType = void 0;
7213 instance.restTimeoutPending = false;
7214 instance.interactedInside = false;
7215 clearPointerEvents();
7216 }
7217 }, [open, instance, clearPointerEvents]);
7218 React27.useEffect(() => {
7219 return clearPointerEvents;
7220 }, [clearPointerEvents]);
7221 useIsoLayoutEffect(() => {
7222 if (!enabled) {
7223 return void 0;
7224 }
7225 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
7226 const ref = domReferenceElement;
7227 const floatingEl = floatingElement;
7228 const doc = ownerDocument(floatingElement);
7229 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
7230 if (parentFloating) {
7231 parentFloating.style.pointerEvents = "";
7232 }
7233 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? instance.pointerEventsScopeElement ?? parentFloating ?? ref.closest("[data-rootownerid]") ?? doc.body;
7234 applySafePolygonPointerEventsMutation(instance, {
7235 scopeElement,
7236 referenceElement: ref,
7237 floatingElement: floatingEl
7238 });
7239 return () => {
7240 clearPointerEvents();
7241 };
7242 }
7243 return void 0;
7244 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
7245 const childClosedTimeout = useTimeout();
7246 React27.useEffect(() => {
7247 if (!enabled) {
7248 return void 0;
7249 }
7250 function onFloatingMouseEnter() {
7251 instance.openChangeTimeout.clear();
7252 childClosedTimeout.clear();
7253 tree?.events.off("floating.closed", onNodeClosed);
7254 clearPointerEvents();
7255 }
7256 function onFloatingMouseLeave(event) {
7257 if (tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
7258 tree.events.on("floating.closed", onNodeClosed);
7259 return;
7260 }
7261 if (isRelatedTargetInsideEnabledTrigger(event.relatedTarget)) {
7262 return;
7263 }
7264 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
7265 const relatedTarget = event.relatedTarget;
7266 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
7267 if (isMovingIntoDescendantFloating) {
7268 return;
7269 }
7270 if (instance.handler) {
7271 instance.handler(event);
7272 return;
7273 }
7274 clearPointerEvents();
7275 if (!isClickLikeOpenEvent2()) {
7276 closeWithDelay(event);
7277 }
7278 }
7279 function onNodeClosed(event) {
7280 if (!tree || !parentId || getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
7281 return;
7282 }
7283 childClosedTimeout.start(0, () => {
7284 tree.events.off("floating.closed", onNodeClosed);
7285 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7286 tree.events.emit("floating.closed", event);
7287 });
7288 }
7289 const floating = floatingElement;
7290 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
7291 tree?.events.off("floating.closed", onNodeClosed);
7292 });
7293 }, [enabled, floatingElement, store, dataRef, nodeIdProp, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, closeWithDelay, clearPointerEvents, handleInteractInside, instance, tree, parentId, childClosedTimeout]);
7294 }
7295
7296 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js
7297 var React28 = __toESM(require_react(), 1);
7298 var ReactDOM4 = __toESM(require_react_dom(), 1);
7299 var EMPTY_REF = {
7300 current: null
7301 };
7302 function useHoverReferenceInteraction(context, props = {}) {
7303 const store = "rootStore" in context ? context.rootStore : context;
7304 const {
7305 dataRef,
7306 events
7307 } = store.context;
7308 const {
7309 enabled = true,
7310 delay = 0,
7311 handleClose = null,
7312 mouseOnly = false,
7313 restMs = 0,
7314 move = true,
7315 triggerElementRef = EMPTY_REF,
7316 externalTree,
7317 isActiveTrigger = true,
7318 getHandleCloseContext,
7319 isClosing
7320 } = props;
7321 const tree = useFloatingTree(externalTree);
7322 const instance = useHoverInteractionSharedState(store);
7323 const isHoverCloseActiveRef = React28.useRef(false);
7324 const handleCloseRef = useValueAsRef(handleClose);
7325 const delayRef = useValueAsRef(delay);
7326 const restMsRef = useValueAsRef(restMs);
7327 const enabledRef = useValueAsRef(enabled);
7328 const isClosingRef = useValueAsRef(isClosing);
7329 if (isActiveTrigger) {
7330 instance.handleCloseOptions = handleCloseRef.current?.__options;
7331 }
7332 const isClickLikeOpenEvent2 = useStableCallback(() => {
7333 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7334 });
7335 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => {
7336 return isTargetInsideEnabledTrigger(target, store.context.triggerElements);
7337 });
7338 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
7339 const allTriggers = store.context.triggerElements;
7340 if (allTriggers.hasElement(currentTarget)) {
7341 return !currentDomReference || !contains(currentDomReference, currentTarget);
7342 }
7343 if (!isElement(target)) {
7344 return false;
7345 }
7346 const targetElement = target;
7347 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
7348 });
7349 const closeWithDelay = useStableCallback((event, runElseBranch = true) => {
7350 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
7351 if (closeDelay) {
7352 instance.openChangeTimeout.start(closeDelay, () => {
7353 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7354 tree?.events.emit("floating.closed", event);
7355 });
7356 } else if (runElseBranch) {
7357 instance.openChangeTimeout.clear();
7358 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7359 tree?.events.emit("floating.closed", event);
7360 }
7361 });
7362 const cleanupMouseMoveHandler = useStableCallback(() => {
7363 if (!instance.handler) {
7364 return;
7365 }
7366 const doc = ownerDocument(store.select("domReferenceElement"));
7367 doc.removeEventListener("mousemove", instance.handler);
7368 instance.handler = void 0;
7369 });
7370 const clearPointerEvents = useStableCallback(() => {
7371 clearSafePolygonPointerEventsMutation(instance);
7372 });
7373 React28.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
7374 React28.useEffect(() => {
7375 if (!enabled) {
7376 return void 0;
7377 }
7378 function onOpenChangeLocal(details) {
7379 if (!details.open) {
7380 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
7381 cleanupMouseMoveHandler();
7382 instance.openChangeTimeout.clear();
7383 instance.restTimeout.clear();
7384 instance.blockMouseMove = true;
7385 instance.restTimeoutPending = false;
7386 } else {
7387 isHoverCloseActiveRef.current = false;
7388 }
7389 }
7390 events.on("openchange", onOpenChangeLocal);
7391 return () => {
7392 events.off("openchange", onOpenChangeLocal);
7393 };
7394 }, [enabled, events, instance, cleanupMouseMoveHandler]);
7395 React28.useEffect(() => {
7396 if (!enabled) {
7397 return void 0;
7398 }
7399 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
7400 if (!isElement(trigger)) {
7401 return void 0;
7402 }
7403 function onMouseEnter(event) {
7404 instance.openChangeTimeout.clear();
7405 instance.blockMouseMove = false;
7406 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7407 return;
7408 }
7409 const restMsValue = getRestMs(restMsRef.current);
7410 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
7411 const eventTarget = getTarget(event);
7412 const currentTarget = event.currentTarget ?? null;
7413 const currentDomReference = store.select("domReferenceElement");
7414 let triggerNode = currentTarget;
7415 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
7416 for (const triggerElement of store.context.triggerElements.elements()) {
7417 if (contains(triggerElement, eventTarget)) {
7418 triggerNode = triggerElement;
7419 break;
7420 }
7421 }
7422 }
7423 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
7424 triggerNode = currentDomReference;
7425 }
7426 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
7427 const isOpen = store.select("open");
7428 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
7429 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
7430 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
7431 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
7432 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
7433 const shouldOpen = !isOpen || isOverInactive;
7434 if (shouldOpenImmediately) {
7435 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7436 return;
7437 }
7438 if (isRestOnlyDelay) {
7439 return;
7440 }
7441 if (openDelay) {
7442 instance.openChangeTimeout.start(openDelay, () => {
7443 if (shouldOpen) {
7444 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7445 }
7446 });
7447 } else if (shouldOpen) {
7448 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7449 }
7450 }
7451 function onMouseLeave(event) {
7452 if (isClickLikeOpenEvent2()) {
7453 clearPointerEvents();
7454 return;
7455 }
7456 cleanupMouseMoveHandler();
7457 const domReferenceElement = store.select("domReferenceElement");
7458 const doc = ownerDocument(domReferenceElement);
7459 instance.restTimeout.clear();
7460 instance.restTimeoutPending = false;
7461 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
7462 const ignoreRelatedTargetTrigger = isRelatedTargetInsideEnabledTrigger(event.relatedTarget);
7463 if (ignoreRelatedTargetTrigger) {
7464 return;
7465 }
7466 if (handleCloseRef.current && handleCloseContextBase) {
7467 if (!store.select("open")) {
7468 instance.openChangeTimeout.clear();
7469 }
7470 const currentTrigger = triggerElementRef.current;
7471 instance.handler = handleCloseRef.current({
7472 ...handleCloseContextBase,
7473 tree,
7474 x: event.clientX,
7475 y: event.clientY,
7476 onClose() {
7477 clearPointerEvents();
7478 cleanupMouseMoveHandler();
7479 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
7480 closeWithDelay(event, true);
7481 }
7482 }
7483 });
7484 doc.addEventListener("mousemove", instance.handler);
7485 instance.handler(event);
7486 return;
7487 }
7488 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
7489 if (shouldClose) {
7490 closeWithDelay(event);
7491 }
7492 }
7493 if (move) {
7494 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
7495 once: true
7496 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7497 }
7498 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7499 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, closeWithDelay, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef]);
7500 return React28.useMemo(() => {
7501 if (!enabled) {
7502 return void 0;
7503 }
7504 function setPointerRef(event) {
7505 instance.pointerType = event.pointerType;
7506 }
7507 return {
7508 onPointerDown: setPointerRef,
7509 onPointerEnter: setPointerRef,
7510 onMouseMove(event) {
7511 const {
7512 nativeEvent
7513 } = event;
7514 const trigger = event.currentTarget;
7515 const currentDomReference = store.select("domReferenceElement");
7516 const currentOpen = store.select("open");
7517 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
7518 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7519 return;
7520 }
7521 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
7522 const floatingElement = store.select("floatingElement");
7523 if (floatingElement) {
7524 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
7525 applySafePolygonPointerEventsMutation(instance, {
7526 scopeElement,
7527 referenceElement: trigger,
7528 floatingElement
7529 });
7530 }
7531 }
7532 const restMsValue = getRestMs(restMsRef.current);
7533 if (currentOpen && !isOverInactive || restMsValue === 0) {
7534 return;
7535 }
7536 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
7537 return;
7538 }
7539 instance.restTimeout.clear();
7540 function handleMouseMove() {
7541 instance.restTimeoutPending = false;
7542 if (isClickLikeOpenEvent2()) {
7543 return;
7544 }
7545 const latestOpen = store.select("open");
7546 if (!instance.blockMouseMove && (!latestOpen || isOverInactive)) {
7547 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
7548 }
7549 }
7550 if (instance.pointerType === "touch") {
7551 ReactDOM4.flushSync(() => {
7552 handleMouseMove();
7553 });
7554 } else if (isOverInactive && currentOpen) {
7555 handleMouseMove();
7556 } else {
7557 instance.restTimeoutPending = true;
7558 instance.restTimeout.start(restMsValue, handleMouseMove);
7559 }
7560 }
7561 };
7562 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef]);
7563 }
7564
7565 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useInteractions.js
7566 var React29 = __toESM(require_react(), 1);
7567 function useInteractions(propsList = []) {
7568 const referenceDeps = propsList.map((key) => key?.reference);
7569 const floatingDeps = propsList.map((key) => key?.floating);
7570 const itemDeps = propsList.map((key) => key?.item);
7571 const triggerDeps = propsList.map((key) => key?.trigger);
7572 const getReferenceProps = React29.useCallback(
7573 (userProps) => mergeProps2(userProps, propsList, "reference"),
7574 // eslint-disable-next-line react-hooks/exhaustive-deps
7575 referenceDeps
7576 );
7577 const getFloatingProps = React29.useCallback(
7578 (userProps) => mergeProps2(userProps, propsList, "floating"),
7579 // eslint-disable-next-line react-hooks/exhaustive-deps
7580 floatingDeps
7581 );
7582 const getItemProps = React29.useCallback(
7583 (userProps) => mergeProps2(userProps, propsList, "item"),
7584 // eslint-disable-next-line react-hooks/exhaustive-deps
7585 itemDeps
7586 );
7587 const getTriggerProps = React29.useCallback(
7588 (userProps) => mergeProps2(userProps, propsList, "trigger"),
7589 // eslint-disable-next-line react-hooks/exhaustive-deps
7590 triggerDeps
7591 );
7592 return React29.useMemo(() => ({
7593 getReferenceProps,
7594 getFloatingProps,
7595 getItemProps,
7596 getTriggerProps
7597 }), [getReferenceProps, getFloatingProps, getItemProps, getTriggerProps]);
7598 }
7599 function mergeProps2(userProps, propsList, elementKey) {
7600 const eventHandlers = /* @__PURE__ */ new Map();
7601 const isItem2 = elementKey === "item";
7602 const outputProps = {};
7603 if (elementKey === "floating") {
7604 outputProps.tabIndex = -1;
7605 outputProps[FOCUSABLE_ATTRIBUTE] = "";
7606 }
7607 for (const key in userProps) {
7608 if (isItem2 && userProps) {
7609 if (key === ACTIVE_KEY || key === SELECTED_KEY) {
7610 continue;
7611 }
7612 }
7613 outputProps[key] = userProps[key];
7614 }
7615 for (let i2 = 0; i2 < propsList.length; i2 += 1) {
7616 let props;
7617 const propsOrGetProps = propsList[i2]?.[elementKey];
7618 if (typeof propsOrGetProps === "function") {
7619 props = userProps ? propsOrGetProps(userProps) : null;
7620 } else {
7621 props = propsOrGetProps;
7622 }
7623 if (!props) {
7624 continue;
7625 }
7626 mutablyMergeProps(outputProps, props, isItem2, eventHandlers);
7627 }
7628 mutablyMergeProps(outputProps, userProps, isItem2, eventHandlers);
7629 return outputProps;
7630 }
7631 function mutablyMergeProps(outputProps, props, isItem2, eventHandlers) {
7632 for (const key in props) {
7633 const value = props[key];
7634 if (isItem2 && (key === ACTIVE_KEY || key === SELECTED_KEY)) {
7635 continue;
7636 }
7637 if (!key.startsWith("on")) {
7638 outputProps[key] = value;
7639 } else {
7640 if (!eventHandlers.has(key)) {
7641 eventHandlers.set(key, []);
7642 }
7643 if (typeof value === "function") {
7644 eventHandlers.get(key)?.push(value);
7645 outputProps[key] = (...args) => {
7646 return eventHandlers.get(key)?.map((fn) => fn(...args)).find((val) => val !== void 0);
7647 };
7648 }
7649 }
7650 }
7651 }
7652
7653 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js
7654 var CURSOR_SPEED_THRESHOLD = 0.1;
7655 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
7656 var POLYGON_BUFFER = 0.5;
7657 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
7658 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
7659 }
7660 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
7661 let isInsideValue = false;
7662 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
7663 isInsideValue = !isInsideValue;
7664 }
7665 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
7666 isInsideValue = !isInsideValue;
7667 }
7668 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
7669 isInsideValue = !isInsideValue;
7670 }
7671 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
7672 isInsideValue = !isInsideValue;
7673 }
7674 return isInsideValue;
7675 }
7676 function isInsideRect(pointX, pointY, rect) {
7677 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
7678 }
7679 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
7680 const minX = Math.min(x1, x2);
7681 const maxX = Math.max(x1, x2);
7682 const minY = Math.min(y1, y2);
7683 const maxY = Math.max(y1, y2);
7684 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
7685 }
7686 function safePolygon(options = {}) {
7687 const {
7688 blockPointerEvents = false
7689 } = options;
7690 const timeout = new Timeout();
7691 const fn = ({
7692 x: x2,
7693 y: y2,
7694 placement,
7695 elements,
7696 onClose,
7697 nodeId,
7698 tree
7699 }) => {
7700 const side = placement?.split("-")[0];
7701 let hasLanded = false;
7702 let lastX = null;
7703 let lastY = null;
7704 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
7705 function isCursorMovingSlowly(nextX, nextY) {
7706 const currentTime = performance.now();
7707 const elapsedTime = currentTime - lastCursorTime;
7708 if (lastX === null || lastY === null || elapsedTime === 0) {
7709 lastX = nextX;
7710 lastY = nextY;
7711 lastCursorTime = currentTime;
7712 return false;
7713 }
7714 const deltaX = nextX - lastX;
7715 const deltaY = nextY - lastY;
7716 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
7717 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
7718 lastX = nextX;
7719 lastY = nextY;
7720 lastCursorTime = currentTime;
7721 return distanceSquared < thresholdSquared;
7722 }
7723 function close() {
7724 timeout.clear();
7725 onClose();
7726 }
7727 return function onMouseMove(event) {
7728 timeout.clear();
7729 const domReference = elements.domReference;
7730 const floating = elements.floating;
7731 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
7732 return void 0;
7733 }
7734 const {
7735 clientX,
7736 clientY
7737 } = event;
7738 const target = getTarget(event);
7739 const isLeave = event.type === "mouseleave";
7740 const isOverFloatingEl = contains(floating, target);
7741 const isOverReferenceEl = contains(domReference, target);
7742 if (isOverFloatingEl) {
7743 hasLanded = true;
7744 if (!isLeave) {
7745 return void 0;
7746 }
7747 }
7748 if (isOverReferenceEl) {
7749 hasLanded = false;
7750 if (!isLeave) {
7751 hasLanded = true;
7752 return void 0;
7753 }
7754 }
7755 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
7756 return void 0;
7757 }
7758 function hasOpenChildNode() {
7759 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
7760 }
7761 function closeIfNoOpenChild() {
7762 if (!hasOpenChildNode()) {
7763 close();
7764 }
7765 }
7766 if (hasOpenChildNode()) {
7767 return void 0;
7768 }
7769 const refRect = domReference.getBoundingClientRect();
7770 const rect = floating.getBoundingClientRect();
7771 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
7772 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
7773 const isFloatingWider = rect.width > refRect.width;
7774 const isFloatingTaller = rect.height > refRect.height;
7775 const left = (isFloatingWider ? refRect : rect).left;
7776 const right = (isFloatingWider ? refRect : rect).right;
7777 const top = (isFloatingTaller ? refRect : rect).top;
7778 const bottom = (isFloatingTaller ? refRect : rect).bottom;
7779 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) {
7780 closeIfNoOpenChild();
7781 return void 0;
7782 }
7783 let isInsideTroughRect = false;
7784 switch (side) {
7785 case "top":
7786 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
7787 break;
7788 case "bottom":
7789 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
7790 break;
7791 case "left":
7792 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
7793 break;
7794 case "right":
7795 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
7796 break;
7797 default:
7798 }
7799 if (isInsideTroughRect) {
7800 return void 0;
7801 }
7802 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
7803 closeIfNoOpenChild();
7804 return void 0;
7805 }
7806 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
7807 closeIfNoOpenChild();
7808 return void 0;
7809 }
7810 let isInsidePolygon = false;
7811 switch (side) {
7812 case "top": {
7813 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7814 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7815 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7816 const cursorPointY = y2 + POLYGON_BUFFER + 1;
7817 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
7818 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
7819 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7820 break;
7821 }
7822 case "bottom": {
7823 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7824 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7825 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7826 const cursorPointY = y2 - POLYGON_BUFFER;
7827 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
7828 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
7829 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7830 break;
7831 }
7832 case "left": {
7833 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7834 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7835 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7836 const cursorPointX = x2 + POLYGON_BUFFER + 1;
7837 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
7838 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
7839 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
7840 break;
7841 }
7842 case "right": {
7843 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7844 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7845 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7846 const cursorPointX = x2 - POLYGON_BUFFER;
7847 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
7848 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
7849 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
7850 break;
7851 }
7852 default:
7853 }
7854 if (!isInsidePolygon) {
7855 closeIfNoOpenChild();
7856 } else if (!hasLanded) {
7857 timeout.start(40, closeIfNoOpenChild);
7858 }
7859 return void 0;
7860 };
7861 };
7862 fn.__options = {
7863 ...options,
7864 blockPointerEvents
7865 };
7866 return fn;
7867 }
7868
7869 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js
7870 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
7871 CommonPopupDataAttributes2["open"] = "data-open";
7872 CommonPopupDataAttributes2["closed"] = "data-closed";
7873 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
7874 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
7875 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
7876 CommonPopupDataAttributes2["side"] = "data-side";
7877 CommonPopupDataAttributes2["align"] = "data-align";
7878 return CommonPopupDataAttributes2;
7879 })({});
7880 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
7881 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
7882 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
7883 return CommonTriggerDataAttributes2;
7884 })({});
7885 var TRIGGER_HOOK = {
7886 [CommonTriggerDataAttributes.popupOpen]: ""
7887 };
7888 var PRESSABLE_TRIGGER_HOOK = {
7889 [CommonTriggerDataAttributes.popupOpen]: "",
7890 [CommonTriggerDataAttributes.pressed]: ""
7891 };
7892 var POPUP_OPEN_HOOK = {
7893 [CommonPopupDataAttributes.open]: ""
7894 };
7895 var POPUP_CLOSED_HOOK = {
7896 [CommonPopupDataAttributes.closed]: ""
7897 };
7898 var ANCHOR_HIDDEN_HOOK = {
7899 [CommonPopupDataAttributes.anchorHidden]: ""
7900 };
7901 var triggerOpenStateMapping = {
7902 open(value) {
7903 if (value) {
7904 return TRIGGER_HOOK;
7905 }
7906 return null;
7907 }
7908 };
7909 var popupStateMapping = {
7910 open(value) {
7911 if (value) {
7912 return POPUP_OPEN_HOOK;
7913 }
7914 return POPUP_CLOSED_HOOK;
7915 },
7916 anchorHidden(value) {
7917 if (value) {
7918 return ANCHOR_HIDDEN_HOOK;
7919 }
7920 return null;
7921 }
7922 };
7923
7924 // node_modules/@base-ui/utils/esm/inertValue.js
7925 function inertValue(value) {
7926 if (isReactVersionAtLeast(19)) {
7927 return value;
7928 }
7929 return value ? "true" : void 0;
7930 }
7931
7932 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7933 var React30 = __toESM(require_react(), 1);
7934
7935 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js
7936 var baseArrow = (options) => ({
7937 name: "arrow",
7938 options,
7939 async fn(state) {
7940 const {
7941 x: x2,
7942 y: y2,
7943 placement,
7944 rects,
7945 platform: platform3,
7946 elements,
7947 middlewareData
7948 } = state;
7949 const {
7950 element,
7951 padding = 0,
7952 offsetParent = "real"
7953 } = evaluate(options, state) || {};
7954 if (element == null) {
7955 return {};
7956 }
7957 const paddingObject = getPaddingObject(padding);
7958 const coords = {
7959 x: x2,
7960 y: y2
7961 };
7962 const axis = getAlignmentAxis(placement);
7963 const length = getAxisLength(axis);
7964 const arrowDimensions = await platform3.getDimensions(element);
7965 const isYAxis = axis === "y";
7966 const minProp = isYAxis ? "top" : "left";
7967 const maxProp = isYAxis ? "bottom" : "right";
7968 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
7969 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
7970 const startDiff = coords[axis] - rects.reference[axis];
7971 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
7972 let clientSize = elements.floating[clientProp] || rects.floating[length];
7973 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
7974 clientSize = elements.floating[clientProp] || rects.floating[length];
7975 }
7976 const centerToReference = endDiff / 2 - startDiff / 2;
7977 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
7978 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
7979 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
7980 const min2 = minPadding;
7981 const max2 = clientSize - arrowDimensions[length] - maxPadding;
7982 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
7983 const offset4 = clamp(min2, center, max2);
7984 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
7985 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
7986 return {
7987 [axis]: coords[axis] + alignmentOffset,
7988 data: {
7989 [axis]: offset4,
7990 centerOffset: center - offset4 - alignmentOffset,
7991 ...shouldAddOffset && {
7992 alignmentOffset
7993 }
7994 },
7995 reset: shouldAddOffset
7996 };
7997 }
7998 });
7999 var arrow4 = (options, deps) => ({
8000 ...baseArrow(options),
8001 options: [options, deps]
8002 });
8003
8004 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js
8005 var hide4 = {
8006 name: "hide",
8007 async fn(state) {
8008 const {
8009 width,
8010 height,
8011 x: x2,
8012 y: y2
8013 } = state.rects.reference;
8014 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
8015 const nativeHideResult = await hide3().fn(state);
8016 return {
8017 data: {
8018 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
8019 }
8020 };
8021 }
8022 };
8023
8024 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js
8025 var DEFAULT_SIDES = {
8026 sideX: "left",
8027 sideY: "top"
8028 };
8029 var adaptiveOrigin = {
8030 name: "adaptiveOrigin",
8031 async fn(state) {
8032 const {
8033 x: rawX,
8034 y: rawY,
8035 rects: {
8036 floating: floatRect
8037 },
8038 elements: {
8039 floating
8040 },
8041 platform: platform3,
8042 strategy,
8043 placement
8044 } = state;
8045 const win = getWindow(floating);
8046 const styles = win.getComputedStyle(floating);
8047 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
8048 if (!hasTransition) {
8049 return {
8050 x: rawX,
8051 y: rawY,
8052 data: DEFAULT_SIDES
8053 };
8054 }
8055 const offsetParent = await platform3.getOffsetParent?.(floating);
8056 let offsetDimensions = {
8057 width: 0,
8058 height: 0
8059 };
8060 if (strategy === "fixed" && win?.visualViewport) {
8061 offsetDimensions = {
8062 width: win.visualViewport.width,
8063 height: win.visualViewport.height
8064 };
8065 } else if (offsetParent === win) {
8066 const doc = ownerDocument(floating);
8067 offsetDimensions = {
8068 width: doc.documentElement.clientWidth,
8069 height: doc.documentElement.clientHeight
8070 };
8071 } else if (await platform3.isElement?.(offsetParent)) {
8072 offsetDimensions = await platform3.getDimensions(offsetParent);
8073 }
8074 const currentSide = getSide(placement);
8075 let x2 = rawX;
8076 let y2 = rawY;
8077 if (currentSide === "left") {
8078 x2 = offsetDimensions.width - (rawX + floatRect.width);
8079 }
8080 if (currentSide === "top") {
8081 y2 = offsetDimensions.height - (rawY + floatRect.height);
8082 }
8083 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
8084 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
8085 return {
8086 x: x2,
8087 y: y2,
8088 data: {
8089 sideX,
8090 sideY
8091 }
8092 };
8093 }
8094 };
8095
8096 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
8097 function getLogicalSide(sideParam, renderedSide, isRtl) {
8098 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
8099 const logicalRight = isRtl ? "inline-start" : "inline-end";
8100 const logicalLeft = isRtl ? "inline-end" : "inline-start";
8101 return {
8102 top: "top",
8103 right: isLogicalSideParam ? logicalRight : "right",
8104 bottom: "bottom",
8105 left: isLogicalSideParam ? logicalLeft : "left"
8106 }[renderedSide];
8107 }
8108 function getOffsetData(state, sideParam, isRtl) {
8109 const {
8110 rects,
8111 placement
8112 } = state;
8113 const data = {
8114 side: getLogicalSide(sideParam, getSide(placement), isRtl),
8115 align: getAlignment(placement) || "center",
8116 anchor: {
8117 width: rects.reference.width,
8118 height: rects.reference.height
8119 },
8120 positioner: {
8121 width: rects.floating.width,
8122 height: rects.floating.height
8123 }
8124 };
8125 return data;
8126 }
8127 function useAnchorPositioning(params) {
8128 const {
8129 // Public parameters
8130 anchor,
8131 positionMethod = "absolute",
8132 side: sideParam = "bottom",
8133 sideOffset = 0,
8134 align = "center",
8135 alignOffset = 0,
8136 collisionBoundary,
8137 collisionPadding: collisionPaddingParam = 5,
8138 sticky = false,
8139 arrowPadding = 5,
8140 disableAnchorTracking = false,
8141 // Private parameters
8142 keepMounted = false,
8143 floatingRootContext,
8144 mounted,
8145 collisionAvoidance,
8146 shiftCrossAxis = false,
8147 nodeId,
8148 adaptiveOrigin: adaptiveOrigin2,
8149 lazyFlip = false,
8150 externalTree
8151 } = params;
8152 const [mountSide, setMountSide] = React30.useState(null);
8153 if (!mounted && mountSide !== null) {
8154 setMountSide(null);
8155 }
8156 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
8157 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
8158 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
8159 const anchorFn = typeof anchor === "function" ? anchor : void 0;
8160 const anchorFnCallback = useStableCallback(anchorFn);
8161 const anchorDep = anchorFn ? anchorFnCallback : anchor;
8162 const anchorValueRef = useValueAsRef(anchor);
8163 const mountedRef = useValueAsRef(mounted);
8164 const direction = useDirection();
8165 const isRtl = direction === "rtl";
8166 const side = mountSide || {
8167 top: "top",
8168 right: "right",
8169 bottom: "bottom",
8170 left: "left",
8171 "inline-end": isRtl ? "left" : "right",
8172 "inline-start": isRtl ? "right" : "left"
8173 }[sideParam];
8174 const placement = align === "center" ? side : `${side}-${align}`;
8175 let collisionPadding = collisionPaddingParam;
8176 const bias = 1;
8177 const biasTop = sideParam === "bottom" ? bias : 0;
8178 const biasBottom = sideParam === "top" ? bias : 0;
8179 const biasLeft = sideParam === "right" ? bias : 0;
8180 const biasRight = sideParam === "left" ? bias : 0;
8181 if (typeof collisionPadding === "number") {
8182 collisionPadding = {
8183 top: collisionPadding + biasTop,
8184 right: collisionPadding + biasRight,
8185 bottom: collisionPadding + biasBottom,
8186 left: collisionPadding + biasLeft
8187 };
8188 } else if (collisionPadding) {
8189 collisionPadding = {
8190 top: (collisionPadding.top || 0) + biasTop,
8191 right: (collisionPadding.right || 0) + biasRight,
8192 bottom: (collisionPadding.bottom || 0) + biasBottom,
8193 left: (collisionPadding.left || 0) + biasLeft
8194 };
8195 }
8196 const commonCollisionProps = {
8197 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
8198 padding: collisionPadding
8199 };
8200 const arrowRef = React30.useRef(null);
8201 const sideOffsetRef = useValueAsRef(sideOffset);
8202 const alignOffsetRef = useValueAsRef(alignOffset);
8203 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
8204 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
8205 const middleware = [offset3((state) => {
8206 const data = getOffsetData(state, sideParam, isRtl);
8207 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
8208 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
8209 return {
8210 mainAxis: sideAxis,
8211 crossAxis: alignAxis,
8212 alignmentAxis: alignAxis
8213 };
8214 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam])];
8215 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
8216 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
8217 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
8218 ...commonCollisionProps,
8219 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
8220 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
8221 padding: {
8222 top: collisionPadding.top + bias,
8223 right: collisionPadding.right + bias,
8224 bottom: collisionPadding.bottom + bias,
8225 left: collisionPadding.left + bias
8226 },
8227 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
8228 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
8229 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
8230 });
8231 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
8232 const html = ownerDocument(data.elements.floating).documentElement;
8233 return {
8234 ...commonCollisionProps,
8235 // Use the Layout Viewport to avoid shifting around when pinch-zooming
8236 // for context menus.
8237 rootBoundary: shiftCrossAxis ? {
8238 x: 0,
8239 y: 0,
8240 width: html.clientWidth,
8241 height: html.clientHeight
8242 } : void 0,
8243 mainAxis: collisionAvoidanceAlign !== "none",
8244 crossAxis: crossAxisShiftEnabled,
8245 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
8246 if (!arrowRef.current) {
8247 return {};
8248 }
8249 const {
8250 width,
8251 height
8252 } = arrowRef.current.getBoundingClientRect();
8253 const sideAxis = getSideAxis(getSide(limitData.placement));
8254 const arrowSize = sideAxis === "y" ? width : height;
8255 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
8256 return {
8257 offset: arrowSize / 2 + offsetAmount / 2
8258 };
8259 })
8260 };
8261 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
8262 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
8263 middleware.push(shiftMiddleware, flipMiddleware);
8264 } else {
8265 middleware.push(flipMiddleware, shiftMiddleware);
8266 }
8267 middleware.push(size3({
8268 ...commonCollisionProps,
8269 apply({
8270 elements: {
8271 floating
8272 },
8273 availableWidth,
8274 availableHeight,
8275 rects
8276 }) {
8277 if (!mountedRef.current) {
8278 return;
8279 }
8280 const floatingStyle = floating.style;
8281 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
8282 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
8283 const dpr = getWindow(floating).devicePixelRatio || 1;
8284 const {
8285 x: x3,
8286 y: y3,
8287 width,
8288 height
8289 } = rects.reference;
8290 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
8291 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
8292 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
8293 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
8294 }
8295 }), arrow4(() => ({
8296 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
8297 // we'll create a fake element.
8298 element: arrowRef.current || ownerDocument(arrowRef.current).createElement("div"),
8299 padding: arrowPadding,
8300 offsetParent: "floating"
8301 }), [arrowPadding]), {
8302 name: "transformOrigin",
8303 fn(state) {
8304 const {
8305 elements: elements2,
8306 middlewareData: middlewareData2,
8307 placement: renderedPlacement2,
8308 rects,
8309 y: y3
8310 } = state;
8311 const currentRenderedSide = getSide(renderedPlacement2);
8312 const currentRenderedAxis = getSideAxis(currentRenderedSide);
8313 const arrowEl = arrowRef.current;
8314 const arrowX = middlewareData2.arrow?.x || 0;
8315 const arrowY = middlewareData2.arrow?.y || 0;
8316 const arrowWidth = arrowEl?.clientWidth || 0;
8317 const arrowHeight = arrowEl?.clientHeight || 0;
8318 const transformX = arrowX + arrowWidth / 2;
8319 const transformY = arrowY + arrowHeight / 2;
8320 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
8321 const halfAnchorHeight = rects.reference.height / 2;
8322 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
8323 const isOverlappingAnchor = shiftY > sideOffsetValue;
8324 const adjacentTransformOrigin = {
8325 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
8326 bottom: `${transformX}px ${-sideOffsetValue}px`,
8327 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
8328 right: `${-sideOffsetValue}px ${transformY}px`
8329 }[currentRenderedSide];
8330 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
8331 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
8332 return {};
8333 }
8334 }, hide4, adaptiveOrigin2);
8335 useIsoLayoutEffect(() => {
8336 if (!mounted && floatingRootContext) {
8337 floatingRootContext.update({
8338 referenceElement: null,
8339 floatingElement: null,
8340 domReferenceElement: null,
8341 positionReference: null
8342 });
8343 }
8344 }, [mounted, floatingRootContext]);
8345 const autoUpdateOptions = React30.useMemo(() => ({
8346 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
8347 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
8348 }), [disableAnchorTracking]);
8349 const {
8350 refs,
8351 elements,
8352 x: x2,
8353 y: y2,
8354 middlewareData,
8355 update: update2,
8356 placement: renderedPlacement,
8357 context,
8358 isPositioned,
8359 floatingStyles: originalFloatingStyles
8360 } = useFloating2({
8361 rootContext: floatingRootContext,
8362 open: keepMounted ? mounted : void 0,
8363 placement,
8364 middleware,
8365 strategy: positionMethod,
8366 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
8367 nodeId,
8368 externalTree
8369 });
8370 const {
8371 sideX,
8372 sideY
8373 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
8374 const resolvedPosition = isPositioned ? positionMethod : "fixed";
8375 const floatingStyles = React30.useMemo(() => {
8376 const base = adaptiveOrigin2 ? {
8377 position: resolvedPosition,
8378 [sideX]: x2,
8379 [sideY]: y2
8380 } : {
8381 position: resolvedPosition,
8382 ...originalFloatingStyles
8383 };
8384 if (!isPositioned) {
8385 base.opacity = 0;
8386 }
8387 return base;
8388 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
8389 const registeredPositionReferenceRef = React30.useRef(null);
8390 useIsoLayoutEffect(() => {
8391 if (!mounted) {
8392 return;
8393 }
8394 const anchorValue = anchorValueRef.current;
8395 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
8396 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
8397 const finalAnchor = unwrappedElement || null;
8398 if (finalAnchor !== registeredPositionReferenceRef.current) {
8399 refs.setPositionReference(finalAnchor);
8400 registeredPositionReferenceRef.current = finalAnchor;
8401 }
8402 }, [mounted, refs, anchorDep, anchorValueRef]);
8403 React30.useEffect(() => {
8404 if (!mounted) {
8405 return;
8406 }
8407 const anchorValue = anchorValueRef.current;
8408 if (typeof anchorValue === "function") {
8409 return;
8410 }
8411 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
8412 refs.setPositionReference(anchorValue.current);
8413 registeredPositionReferenceRef.current = anchorValue.current;
8414 }
8415 }, [mounted, refs, anchorDep, anchorValueRef]);
8416 React30.useEffect(() => {
8417 if (keepMounted && mounted && elements.domReference && elements.floating) {
8418 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions);
8419 }
8420 return void 0;
8421 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
8422 const renderedSide = getSide(renderedPlacement);
8423 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
8424 const renderedAlign = getAlignment(renderedPlacement) || "center";
8425 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
8426 useIsoLayoutEffect(() => {
8427 if (lazyFlip && mounted && isPositioned) {
8428 setMountSide(renderedSide);
8429 }
8430 }, [lazyFlip, mounted, isPositioned, renderedSide]);
8431 const arrowStyles = React30.useMemo(() => ({
8432 position: "absolute",
8433 top: middlewareData.arrow?.y,
8434 left: middlewareData.arrow?.x
8435 }), [middlewareData.arrow]);
8436 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
8437 return React30.useMemo(() => ({
8438 positionerStyles: floatingStyles,
8439 arrowStyles,
8440 arrowRef,
8441 arrowUncentered,
8442 side: logicalRenderedSide,
8443 align: renderedAlign,
8444 physicalSide: renderedSide,
8445 anchorHidden,
8446 refs,
8447 context,
8448 isPositioned,
8449 update: update2
8450 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
8451 }
8452 function isRef(param) {
8453 return param != null && "current" in param;
8454 }
8455
8456 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js
8457 function getDisabledMountTransitionStyles(transitionStatus) {
8458 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
8459 }
8460
8461 // node_modules/@base-ui/react/esm/utils/usePositioner.js
8462 function usePositioner(componentProps, state, {
8463 styles,
8464 transitionStatus,
8465 props,
8466 refs,
8467 hidden,
8468 inert = false
8469 }) {
8470 const style = {
8471 ...styles
8472 };
8473 if (inert) {
8474 style.pointerEvents = "none";
8475 }
8476 return useRenderElement("div", componentProps, {
8477 state,
8478 ref: refs,
8479 props: [{
8480 role: "presentation",
8481 hidden,
8482 style
8483 }, getDisabledMountTransitionStyles(transitionStatus), props],
8484 stateAttributesMapping: popupStateMapping
8485 });
8486 }
8487
8488 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
8489 var React33 = __toESM(require_react(), 1);
8490 var ReactDOM5 = __toESM(require_react_dom(), 1);
8491
8492 // node_modules/@base-ui/utils/esm/usePreviousValue.js
8493 var React31 = __toESM(require_react(), 1);
8494 function usePreviousValue(value) {
8495 const [state, setState] = React31.useState({
8496 current: value,
8497 previous: null
8498 });
8499 if (value !== state.current) {
8500 setState({
8501 current: value,
8502 previous: state.current
8503 });
8504 }
8505 return state.previous;
8506 }
8507
8508 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
8509 var React32 = __toESM(require_react(), 1);
8510
8511 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js
8512 function getCssDimensions2(element) {
8513 const css = getComputedStyle2(element);
8514 let width = parseFloat(css.width) || 0;
8515 let height = parseFloat(css.height) || 0;
8516 const hasOffset = isHTMLElement(element);
8517 const offsetWidth = hasOffset ? element.offsetWidth : width;
8518 const offsetHeight = hasOffset ? element.offsetHeight : height;
8519 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
8520 if (shouldFallback) {
8521 width = offsetWidth;
8522 height = offsetHeight;
8523 }
8524 return {
8525 width,
8526 height
8527 };
8528 }
8529
8530 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
8531 var DEFAULT_ENABLED = () => true;
8532 function usePopupAutoResize(parameters) {
8533 const {
8534 popupElement,
8535 positionerElement,
8536 content,
8537 mounted,
8538 enabled = DEFAULT_ENABLED,
8539 onMeasureLayout: onMeasureLayoutParam,
8540 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
8541 side,
8542 direction
8543 } = parameters;
8544 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
8545 const animationFrame = useAnimationFrame();
8546 const committedDimensionsRef = React32.useRef(null);
8547 const liveDimensionsRef = React32.useRef(null);
8548 const isInitialRenderRef = React32.useRef(true);
8549 const restoreAnchoringStylesRef = React32.useRef(NOOP);
8550 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
8551 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
8552 const anchoringStyles = React32.useMemo(() => {
8553 let isOriginSide = side === "top";
8554 let isPhysicalLeft = side === "left";
8555 if (direction === "rtl") {
8556 isOriginSide = isOriginSide || side === "inline-end";
8557 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
8558 } else {
8559 isOriginSide = isOriginSide || side === "inline-start";
8560 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
8561 }
8562 return isOriginSide ? {
8563 position: "absolute",
8564 [side === "top" ? "bottom" : "top"]: "0",
8565 [isPhysicalLeft ? "right" : "left"]: "0"
8566 } : EMPTY_OBJECT;
8567 }, [side, direction]);
8568 useIsoLayoutEffect(() => {
8569 if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
8570 restoreAnchoringStylesRef.current = NOOP;
8571 isInitialRenderRef.current = true;
8572 committedDimensionsRef.current = null;
8573 liveDimensionsRef.current = null;
8574 return void 0;
8575 }
8576 if (!popupElement || !positionerElement) {
8577 return void 0;
8578 }
8579 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
8580 const observer = new ResizeObserver((entries) => {
8581 const entry = entries[0];
8582 if (entry) {
8583 liveDimensionsRef.current = {
8584 width: Math.ceil(entry.borderBoxSize[0].inlineSize),
8585 height: Math.ceil(entry.borderBoxSize[0].blockSize)
8586 };
8587 }
8588 });
8589 observer.observe(popupElement);
8590 setPopupCssSize(popupElement, "auto");
8591 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
8592 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
8593 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
8594 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
8595 "--available-width": "max-content",
8596 "--available-height": "max-content"
8597 });
8598 function restoreMeasurementOverrides() {
8599 restorePopupPosition();
8600 restorePopupTransform();
8601 restorePositionerAvailableSize();
8602 }
8603 function restoreMeasurementOverridesIncludingScale() {
8604 restoreMeasurementOverrides();
8605 restorePopupScale();
8606 }
8607 onMeasureLayout?.();
8608 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
8609 setPositionerCssSize(positionerElement, "max-content");
8610 const dimensions = getCssDimensions2(popupElement);
8611 committedDimensionsRef.current = dimensions;
8612 setPositionerCssSize(positionerElement, dimensions);
8613 restoreMeasurementOverridesIncludingScale();
8614 onMeasureLayoutComplete?.(null, dimensions);
8615 isInitialRenderRef.current = false;
8616 return () => {
8617 observer.disconnect();
8618 restoreAnchoringStylesRef.current();
8619 restoreAnchoringStylesRef.current = NOOP;
8620 };
8621 }
8622 setPopupCssSize(popupElement, "auto");
8623 setPositionerCssSize(positionerElement, "max-content");
8624 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
8625 const newDimensions = getCssDimensions2(popupElement);
8626 committedDimensionsRef.current = newDimensions;
8627 if (!previousDimensions) {
8628 setPositionerCssSize(positionerElement, newDimensions);
8629 restoreMeasurementOverridesIncludingScale();
8630 onMeasureLayoutComplete?.(null, newDimensions);
8631 return () => {
8632 observer.disconnect();
8633 animationFrame.cancel();
8634 restoreAnchoringStylesRef.current();
8635 restoreAnchoringStylesRef.current = NOOP;
8636 };
8637 }
8638 setPopupCssSize(popupElement, previousDimensions);
8639 restoreMeasurementOverridesIncludingScale();
8640 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
8641 setPositionerCssSize(positionerElement, newDimensions);
8642 const abortController = new AbortController();
8643 animationFrame.request(() => {
8644 setPopupCssSize(popupElement, newDimensions);
8645 runOnceAnimationsFinish(() => {
8646 popupElement.style.setProperty("--popup-width", "auto");
8647 popupElement.style.setProperty("--popup-height", "auto");
8648 }, abortController.signal);
8649 });
8650 return () => {
8651 observer.disconnect();
8652 abortController.abort();
8653 animationFrame.cancel();
8654 restoreAnchoringStylesRef.current();
8655 restoreAnchoringStylesRef.current = NOOP;
8656 };
8657 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
8658 }
8659 function overrideElementStyle(element, property, value) {
8660 const originalValue = element.style.getPropertyValue(property);
8661 element.style.setProperty(property, value);
8662 return () => {
8663 element.style.setProperty(property, originalValue);
8664 };
8665 }
8666 function applyElementStyles(element, styles) {
8667 const restorers = [];
8668 for (const [key, value] of Object.entries(styles)) {
8669 restorers.push(overrideElementStyle(element, key, value));
8670 }
8671 return restorers.length ? () => {
8672 restorers.forEach((restore) => restore());
8673 } : NOOP;
8674 }
8675 function setPopupCssSize(popupElement, size4) {
8676 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
8677 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
8678 popupElement.style.setProperty("--popup-width", width);
8679 popupElement.style.setProperty("--popup-height", height);
8680 }
8681 function setPositionerCssSize(positionerElement, size4) {
8682 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
8683 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
8684 positionerElement.style.setProperty("--positioner-width", width);
8685 positionerElement.style.setProperty("--positioner-height", height);
8686 }
8687
8688 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
8689 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
8690 function usePopupViewport(parameters) {
8691 const {
8692 store,
8693 side,
8694 cssVars,
8695 children
8696 } = parameters;
8697 const direction = useDirection();
8698 const activeTrigger = store.useState("activeTriggerElement");
8699 const activeTriggerId = store.useState("activeTriggerId");
8700 const open = store.useState("open");
8701 const payload = store.useState("payload");
8702 const mounted = store.useState("mounted");
8703 const popupElement = store.useState("popupElement");
8704 const positionerElement = store.useState("positionerElement");
8705 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
8706 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
8707 const capturedNodeRef = React33.useRef(null);
8708 const [previousContentNode, setPreviousContentNode] = React33.useState(null);
8709 const [newTriggerOffset, setNewTriggerOffset] = React33.useState(null);
8710 const currentContainerRef = React33.useRef(null);
8711 const previousContainerRef = React33.useRef(null);
8712 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
8713 const cleanupFrame = useAnimationFrame();
8714 const [previousContentDimensions, setPreviousContentDimensions] = React33.useState(null);
8715 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React33.useState(false);
8716 useIsoLayoutEffect(() => {
8717 store.set("hasViewport", true);
8718 return () => {
8719 store.set("hasViewport", false);
8720 };
8721 }, [store]);
8722 const handleMeasureLayout = useStableCallback(() => {
8723 currentContainerRef.current?.style.setProperty("animation", "none");
8724 currentContainerRef.current?.style.setProperty("transition", "none");
8725 previousContainerRef.current?.style.setProperty("display", "none");
8726 });
8727 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
8728 currentContainerRef.current?.style.removeProperty("animation");
8729 currentContainerRef.current?.style.removeProperty("transition");
8730 previousContainerRef.current?.style.removeProperty("display");
8731 if (previousDimensions) {
8732 setPreviousContentDimensions(previousDimensions);
8733 }
8734 });
8735 const lastHandledTriggerRef = React33.useRef(null);
8736 useIsoLayoutEffect(() => {
8737 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
8738 setPreviousContentNode(capturedNodeRef.current);
8739 setShowStartingStyleAttribute(true);
8740 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
8741 setNewTriggerOffset(offset4);
8742 cleanupFrame.request(() => {
8743 ReactDOM5.flushSync(() => {
8744 setShowStartingStyleAttribute(false);
8745 });
8746 onAnimationsFinished(() => {
8747 setPreviousContentNode(null);
8748 setPreviousContentDimensions(null);
8749 capturedNodeRef.current = null;
8750 });
8751 });
8752 lastHandledTriggerRef.current = activeTrigger;
8753 }
8754 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
8755 useIsoLayoutEffect(() => {
8756 const source = currentContainerRef.current;
8757 if (!source) {
8758 return;
8759 }
8760 const wrapper = ownerDocument(source).createElement("div");
8761 for (const child of Array.from(source.childNodes)) {
8762 wrapper.appendChild(child.cloneNode(true));
8763 }
8764 capturedNodeRef.current = wrapper;
8765 });
8766 const isTransitioning = previousContentNode != null;
8767 let childrenToRender;
8768 if (!isTransitioning) {
8769 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", {
8770 "data-current": true,
8771 ref: currentContainerRef,
8772 children
8773 }, currentContentKey);
8774 } else {
8775 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(React33.Fragment, {
8776 children: [/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", {
8777 "data-previous": true,
8778 inert: inertValue(true),
8779 ref: previousContainerRef,
8780 style: {
8781 ...previousContentDimensions ? {
8782 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
8783 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
8784 } : null,
8785 position: "absolute"
8786 },
8787 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
8788 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", {
8789 "data-current": true,
8790 ref: currentContainerRef,
8791 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
8792 children
8793 }, currentContentKey)]
8794 });
8795 }
8796 useIsoLayoutEffect(() => {
8797 const container = previousContainerRef.current;
8798 if (!container || !previousContentNode) {
8799 return;
8800 }
8801 container.replaceChildren(...Array.from(previousContentNode.childNodes));
8802 }, [previousContentNode]);
8803 usePopupAutoResize({
8804 popupElement,
8805 positionerElement,
8806 mounted,
8807 content: payload,
8808 onMeasureLayout: handleMeasureLayout,
8809 onMeasureLayoutComplete: handleMeasureLayoutComplete,
8810 side,
8811 direction
8812 });
8813 const state = {
8814 activationDirection: getActivationDirection(newTriggerOffset),
8815 transitioning: isTransitioning
8816 };
8817 return {
8818 children: childrenToRender,
8819 state
8820 };
8821 }
8822 function getActivationDirection(offset4) {
8823 if (!offset4) {
8824 return void 0;
8825 }
8826 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
8827 }
8828 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
8829 if (value > tolerance) {
8830 return positiveLabel;
8831 }
8832 if (value < -tolerance) {
8833 return negativeLabel;
8834 }
8835 return "";
8836 }
8837 function calculateRelativePosition(from, to) {
8838 const fromRect = from.getBoundingClientRect();
8839 const toRect = to.getBoundingClientRect();
8840 const fromCenter = {
8841 x: fromRect.left + fromRect.width / 2,
8842 y: fromRect.top + fromRect.height / 2
8843 };
8844 const toCenter = {
8845 x: toRect.left + toRect.width / 2,
8846 y: toRect.top + toRect.height / 2
8847 };
8848 return {
8849 horizontal: toCenter.x - fromCenter.x,
8850 vertical: toCenter.y - fromCenter.y
8851 };
8852 }
8853 function usePopupContentKey(activeTriggerId, payload) {
8854 const [contentKey, setContentKey] = React33.useState(0);
8855 const previousActiveTriggerIdRef = React33.useRef(activeTriggerId);
8856 const previousPayloadRef = React33.useRef(payload);
8857 const pendingPayloadUpdateRef = React33.useRef(false);
8858 useIsoLayoutEffect(() => {
8859 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
8860 const previousPayload = previousPayloadRef.current;
8861 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
8862 const payloadChanged = payload !== previousPayload;
8863 if (triggerIdChanged) {
8864 setContentKey((value) => value + 1);
8865 pendingPayloadUpdateRef.current = !payloadChanged;
8866 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
8867 setContentKey((value) => value + 1);
8868 pendingPayloadUpdateRef.current = false;
8869 }
8870 previousActiveTriggerIdRef.current = activeTriggerId;
8871 previousPayloadRef.current = payload;
8872 }, [activeTriggerId, payload]);
8873 return `${activeTriggerId ?? "current"}-${contentKey}`;
8874 }
8875
8876 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js
8877 var React34 = __toESM(require_react(), 1);
8878 var ReactDOM6 = __toESM(require_react_dom(), 1);
8879 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
8880 var FloatingPortalLite = /* @__PURE__ */ React34.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
8881 const {
8882 children,
8883 container,
8884 className,
8885 render: render4,
8886 style,
8887 ...elementProps
8888 } = componentProps;
8889 const {
8890 portalNode,
8891 portalSubtree
8892 } = useFloatingPortalNode({
8893 container,
8894 ref: forwardedRef,
8895 componentProps,
8896 elementProps
8897 });
8898 if (!portalSubtree && !portalNode) {
8899 return null;
8900 }
8901 return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(React34.Fragment, {
8902 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)]
8903 });
8904 });
8905 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
8906
8907 // node_modules/@base-ui/react/esm/tooltip/index.parts.js
8908 var index_parts_exports = {};
8909 __export(index_parts_exports, {
8910 Arrow: () => TooltipArrow,
8911 Handle: () => TooltipHandle,
8912 Popup: () => TooltipPopup,
8913 Portal: () => TooltipPortal,
8914 Positioner: () => TooltipPositioner,
8915 Provider: () => TooltipProvider,
8916 Root: () => TooltipRoot,
8917 Trigger: () => TooltipTrigger,
8918 Viewport: () => TooltipViewport,
8919 createHandle: () => createTooltipHandle
8920 });
8921
8922 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8923 var React37 = __toESM(require_react(), 1);
8924
8925 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js
8926 var React35 = __toESM(require_react(), 1);
8927 var TooltipRootContext = /* @__PURE__ */ React35.createContext(void 0);
8928 if (true) TooltipRootContext.displayName = "TooltipRootContext";
8929 function useTooltipRootContext(optional) {
8930 const context = React35.useContext(TooltipRootContext);
8931 if (context === void 0 && !optional) {
8932 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
8933 }
8934 return context;
8935 }
8936
8937 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js
8938 var React36 = __toESM(require_react(), 1);
8939 var ReactDOM7 = __toESM(require_react_dom(), 1);
8940 var selectors2 = {
8941 ...popupStoreSelectors,
8942 disabled: createSelector((state) => state.disabled),
8943 instantType: createSelector((state) => state.instantType),
8944 isInstantPhase: createSelector((state) => state.isInstantPhase),
8945 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
8946 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
8947 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
8948 closeOnClick: createSelector((state) => state.closeOnClick),
8949 closeDelay: createSelector((state) => state.closeDelay),
8950 hasViewport: createSelector((state) => state.hasViewport)
8951 };
8952 var TooltipStore = class _TooltipStore extends ReactStore {
8953 constructor(initialState) {
8954 super({
8955 ...createInitialState(),
8956 ...initialState
8957 }, {
8958 popupRef: /* @__PURE__ */ React36.createRef(),
8959 onOpenChange: void 0,
8960 onOpenChangeComplete: void 0,
8961 triggerElements: new PopupTriggerMap()
8962 }, selectors2);
8963 }
8964 setOpen = (nextOpen, eventDetails) => {
8965 const reason = eventDetails.reason;
8966 const isHover = reason === reason_parts_exports.triggerHover;
8967 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
8968 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
8969 eventDetails.preventUnmountOnClose = () => {
8970 this.set("preventUnmountingOnClose", true);
8971 };
8972 this.context.onOpenChange?.(nextOpen, eventDetails);
8973 if (eventDetails.isCanceled) {
8974 return;
8975 }
8976 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
8977 const changeState = () => {
8978 const updatedState = {
8979 open: nextOpen,
8980 openChangeReason: reason
8981 };
8982 if (isFocusOpen) {
8983 updatedState.instantType = "focus";
8984 } else if (isDismissClose) {
8985 updatedState.instantType = "dismiss";
8986 } else if (reason === reason_parts_exports.triggerHover) {
8987 updatedState.instantType = void 0;
8988 }
8989 const newTriggerId = eventDetails.trigger?.id ?? null;
8990 if (newTriggerId || nextOpen) {
8991 updatedState.activeTriggerId = newTriggerId;
8992 updatedState.activeTriggerElement = eventDetails.trigger ?? null;
8993 }
8994 this.update(updatedState);
8995 };
8996 if (isHover) {
8997 ReactDOM7.flushSync(changeState);
8998 } else {
8999 changeState();
9000 }
9001 };
9002 static useStore(externalStore, initialState) {
9003 const internalStore = useRefWithInit(() => {
9004 return new _TooltipStore(initialState);
9005 }).current;
9006 const store = externalStore ?? internalStore;
9007 const floatingRootContext = useSyncedFloatingRootContext({
9008 popupStore: store,
9009 onOpenChange: store.setOpen
9010 });
9011 store.state.floatingRootContext = floatingRootContext;
9012 return store;
9013 }
9014 };
9015 function createInitialState() {
9016 return {
9017 ...createInitialPopupStoreState(),
9018 disabled: false,
9019 instantType: void 0,
9020 isInstantPhase: false,
9021 trackCursorAxis: "none",
9022 disableHoverablePopup: false,
9023 openChangeReason: null,
9024 closeOnClick: true,
9025 closeDelay: 0,
9026 hasViewport: false
9027 };
9028 }
9029
9030 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
9031 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
9032 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
9033 const {
9034 disabled: disabled2 = false,
9035 defaultOpen = false,
9036 open: openProp,
9037 disableHoverablePopup = false,
9038 trackCursorAxis = "none",
9039 actionsRef,
9040 onOpenChange,
9041 onOpenChangeComplete,
9042 handle,
9043 triggerId: triggerIdProp,
9044 defaultTriggerId: defaultTriggerIdProp = null,
9045 children
9046 } = props;
9047 const store = TooltipStore.useStore(handle?.store, {
9048 open: defaultOpen,
9049 openProp,
9050 activeTriggerId: defaultTriggerIdProp,
9051 triggerIdProp
9052 });
9053 useOnFirstRender(() => {
9054 if (openProp === void 0 && store.state.open === false && defaultOpen === true) {
9055 store.update({
9056 open: true,
9057 activeTriggerId: defaultTriggerIdProp
9058 });
9059 }
9060 });
9061 store.useControlledProp("openProp", openProp);
9062 store.useControlledProp("triggerIdProp", triggerIdProp);
9063 store.useContextCallback("onOpenChange", onOpenChange);
9064 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
9065 const openState = store.useState("open");
9066 const open = !disabled2 && openState;
9067 const activeTriggerId = store.useState("activeTriggerId");
9068 const payload = store.useState("payload");
9069 store.useSyncedValues({
9070 trackCursorAxis,
9071 disableHoverablePopup
9072 });
9073 useIsoLayoutEffect(() => {
9074 if (openState && disabled2) {
9075 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
9076 }
9077 }, [openState, disabled2, store]);
9078 store.useSyncedValue("disabled", disabled2);
9079 useImplicitActiveTrigger(store);
9080 const {
9081 forceUnmount,
9082 transitionStatus
9083 } = useOpenStateTransitions(open, store);
9084 const floatingRootContext = store.select("floatingRootContext");
9085 const isInstantPhase = store.useState("isInstantPhase");
9086 const instantType = store.useState("instantType");
9087 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
9088 const previousInstantTypeRef = React37.useRef(null);
9089 useIsoLayoutEffect(() => {
9090 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
9091 if (instantType !== "delay") {
9092 previousInstantTypeRef.current = instantType;
9093 }
9094 store.set("instantType", "delay");
9095 } else if (previousInstantTypeRef.current !== null) {
9096 store.set("instantType", previousInstantTypeRef.current);
9097 previousInstantTypeRef.current = null;
9098 }
9099 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
9100 useIsoLayoutEffect(() => {
9101 if (open) {
9102 if (activeTriggerId == null) {
9103 store.set("payload", void 0);
9104 }
9105 }
9106 }, [store, activeTriggerId, open]);
9107 const handleImperativeClose = React37.useCallback(() => {
9108 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
9109 }, [store]);
9110 React37.useImperativeHandle(actionsRef, () => ({
9111 unmount: forceUnmount,
9112 close: handleImperativeClose
9113 }), [forceUnmount, handleImperativeClose]);
9114 const dismiss = useDismiss(floatingRootContext, {
9115 enabled: !disabled2,
9116 referencePress: () => store.select("closeOnClick")
9117 });
9118 const clientPoint = useClientPoint(floatingRootContext, {
9119 enabled: !disabled2 && trackCursorAxis !== "none",
9120 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
9121 });
9122 const {
9123 getReferenceProps,
9124 getFloatingProps,
9125 getTriggerProps
9126 } = useInteractions([dismiss, clientPoint]);
9127 const activeTriggerProps = React37.useMemo(() => getReferenceProps(), [getReferenceProps]);
9128 const inactiveTriggerProps = React37.useMemo(() => getTriggerProps(), [getTriggerProps]);
9129 const popupProps = React37.useMemo(() => getFloatingProps(), [getFloatingProps]);
9130 store.useSyncedValues({
9131 activeTriggerProps,
9132 inactiveTriggerProps,
9133 popupProps
9134 });
9135 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(TooltipRootContext.Provider, {
9136 value: store,
9137 children: typeof children === "function" ? children({
9138 payload
9139 }) : children
9140 });
9141 });
9142 if (true) TooltipRoot.displayName = "TooltipRoot";
9143
9144 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
9145 var React39 = __toESM(require_react(), 1);
9146
9147 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js
9148 var React38 = __toESM(require_react(), 1);
9149 var TooltipProviderContext = /* @__PURE__ */ React38.createContext(void 0);
9150 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
9151 function useTooltipProviderContext() {
9152 return React38.useContext(TooltipProviderContext);
9153 }
9154
9155 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js
9156 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
9157 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
9158 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
9159 return TooltipTriggerDataAttributes2;
9160 })({});
9161
9162 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js
9163 var OPEN_DELAY = 600;
9164
9165 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
9166 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
9167 const {
9168 className,
9169 render: render4,
9170 handle,
9171 payload,
9172 disabled: disabledProp,
9173 delay,
9174 closeOnClick = true,
9175 closeDelay,
9176 id: idProp,
9177 style,
9178 ...elementProps
9179 } = componentProps;
9180 const rootContext = useTooltipRootContext(true);
9181 const store = handle?.store ?? rootContext;
9182 if (!store) {
9183 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));
9184 }
9185 const thisTriggerId = useBaseUiId(idProp);
9186 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
9187 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
9188 const floatingRootContext = store.useState("floatingRootContext");
9189 const triggerElementRef = React39.useRef(null);
9190 const delayWithDefault = delay ?? OPEN_DELAY;
9191 const closeDelayWithDefault = closeDelay ?? 0;
9192 const {
9193 registerTrigger,
9194 isMountedByThisTrigger
9195 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
9196 payload,
9197 closeOnClick,
9198 closeDelay: closeDelayWithDefault
9199 });
9200 const providerContext = useTooltipProviderContext();
9201 const {
9202 delayRef,
9203 isInstantPhase,
9204 hasProvider
9205 } = useDelayGroup(floatingRootContext, {
9206 open: isOpenedByThisTrigger
9207 });
9208 store.useSyncedValue("isInstantPhase", isInstantPhase);
9209 const rootDisabled = store.useState("disabled");
9210 const disabled2 = disabledProp ?? rootDisabled;
9211 const trackCursorAxis = store.useState("trackCursorAxis");
9212 const disableHoverablePopup = store.useState("disableHoverablePopup");
9213 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
9214 enabled: !disabled2,
9215 mouseOnly: true,
9216 move: false,
9217 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
9218 restMs() {
9219 const providerDelay = providerContext?.delay;
9220 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
9221 let computedRestMs = delayWithDefault;
9222 if (hasProvider) {
9223 if (groupOpenValue !== 0) {
9224 computedRestMs = delay ?? providerDelay ?? delayWithDefault;
9225 } else {
9226 computedRestMs = 0;
9227 }
9228 }
9229 return computedRestMs;
9230 },
9231 delay() {
9232 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
9233 let computedCloseDelay = closeDelayWithDefault;
9234 if (closeDelay == null && hasProvider) {
9235 computedCloseDelay = closeValue;
9236 }
9237 return {
9238 close: computedCloseDelay
9239 };
9240 },
9241 triggerElementRef,
9242 isActiveTrigger: isTriggerActive,
9243 isClosing: () => store.select("transitionStatus") === "ending"
9244 });
9245 const focusProps = useFocus(floatingRootContext, {
9246 enabled: !disabled2
9247 }).reference;
9248 const state = {
9249 open: isOpenedByThisTrigger
9250 };
9251 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
9252 const element = useRenderElement("button", componentProps, {
9253 state,
9254 ref: [forwardedRef, registerTrigger, triggerElementRef],
9255 props: [hoverProps, focusProps, rootTriggerProps, {
9256 onPointerDown() {
9257 store.set("closeOnClick", closeOnClick);
9258 },
9259 id: thisTriggerId,
9260 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0
9261 }, elementProps],
9262 stateAttributesMapping: triggerOpenStateMapping
9263 });
9264 return element;
9265 });
9266 if (true) TooltipTrigger.displayName = "TooltipTrigger";
9267
9268 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
9269 var React41 = __toESM(require_react(), 1);
9270
9271 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js
9272 var React40 = __toESM(require_react(), 1);
9273 var TooltipPortalContext = /* @__PURE__ */ React40.createContext(void 0);
9274 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
9275 function useTooltipPortalContext() {
9276 const value = React40.useContext(TooltipPortalContext);
9277 if (value === void 0) {
9278 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
9279 }
9280 return value;
9281 }
9282
9283 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
9284 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
9285 var TooltipPortal = /* @__PURE__ */ React41.forwardRef(function TooltipPortal2(props, forwardedRef) {
9286 const {
9287 keepMounted = false,
9288 ...portalProps
9289 } = props;
9290 const store = useTooltipRootContext();
9291 const mounted = store.useState("mounted");
9292 const shouldRender = mounted || keepMounted;
9293 if (!shouldRender) {
9294 return null;
9295 }
9296 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(TooltipPortalContext.Provider, {
9297 value: keepMounted,
9298 children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(FloatingPortalLite, {
9299 ref: forwardedRef,
9300 ...portalProps
9301 })
9302 });
9303 });
9304 if (true) TooltipPortal.displayName = "TooltipPortal";
9305
9306 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
9307 var React43 = __toESM(require_react(), 1);
9308
9309 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js
9310 var React42 = __toESM(require_react(), 1);
9311 var TooltipPositionerContext = /* @__PURE__ */ React42.createContext(void 0);
9312 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
9313 function useTooltipPositionerContext() {
9314 const context = React42.useContext(TooltipPositionerContext);
9315 if (context === void 0) {
9316 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
9317 }
9318 return context;
9319 }
9320
9321 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
9322 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
9323 var TooltipPositioner = /* @__PURE__ */ React43.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
9324 const {
9325 render: render4,
9326 className,
9327 anchor,
9328 positionMethod = "absolute",
9329 side = "top",
9330 align = "center",
9331 sideOffset = 0,
9332 alignOffset = 0,
9333 collisionBoundary = "clipping-ancestors",
9334 collisionPadding = 5,
9335 arrowPadding = 5,
9336 sticky = false,
9337 disableAnchorTracking = false,
9338 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
9339 style,
9340 ...elementProps
9341 } = componentProps;
9342 const store = useTooltipRootContext();
9343 const keepMounted = useTooltipPortalContext();
9344 const open = store.useState("open");
9345 const mounted = store.useState("mounted");
9346 const trackCursorAxis = store.useState("trackCursorAxis");
9347 const disableHoverablePopup = store.useState("disableHoverablePopup");
9348 const floatingRootContext = store.useState("floatingRootContext");
9349 const instantType = store.useState("instantType");
9350 const transitionStatus = store.useState("transitionStatus");
9351 const hasViewport = store.useState("hasViewport");
9352 const positioning = useAnchorPositioning({
9353 anchor,
9354 positionMethod,
9355 floatingRootContext,
9356 mounted,
9357 side,
9358 sideOffset,
9359 align,
9360 alignOffset,
9361 collisionBoundary,
9362 collisionPadding,
9363 sticky,
9364 arrowPadding,
9365 disableAnchorTracking,
9366 keepMounted,
9367 collisionAvoidance,
9368 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
9369 });
9370 const state = React43.useMemo(() => ({
9371 open,
9372 side: positioning.side,
9373 align: positioning.align,
9374 anchorHidden: positioning.anchorHidden,
9375 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
9376 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
9377 const element = usePositioner(componentProps, state, {
9378 styles: positioning.positionerStyles,
9379 transitionStatus,
9380 props: elementProps,
9381 refs: [forwardedRef, store.useStateSetter("positionerElement")],
9382 hidden: !mounted,
9383 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
9384 });
9385 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(TooltipPositionerContext.Provider, {
9386 value: positioning,
9387 children: element
9388 });
9389 });
9390 if (true) TooltipPositioner.displayName = "TooltipPositioner";
9391
9392 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js
9393 var React44 = __toESM(require_react(), 1);
9394 var stateAttributesMapping = {
9395 ...popupStateMapping,
9396 ...transitionStatusMapping
9397 };
9398 var TooltipPopup = /* @__PURE__ */ React44.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
9399 const {
9400 className,
9401 render: render4,
9402 style,
9403 ...elementProps
9404 } = componentProps;
9405 const store = useTooltipRootContext();
9406 const {
9407 side,
9408 align
9409 } = useTooltipPositionerContext();
9410 const open = store.useState("open");
9411 const instantType = store.useState("instantType");
9412 const transitionStatus = store.useState("transitionStatus");
9413 const popupProps = store.useState("popupProps");
9414 const floatingContext = store.useState("floatingRootContext");
9415 useOpenChangeComplete({
9416 open,
9417 ref: store.context.popupRef,
9418 onComplete() {
9419 if (open) {
9420 store.context.onOpenChangeComplete?.(true);
9421 }
9422 }
9423 });
9424 const disabled2 = store.useState("disabled");
9425 const closeDelay = store.useState("closeDelay");
9426 useHoverFloatingInteraction(floatingContext, {
9427 enabled: !disabled2,
9428 closeDelay
9429 });
9430 const state = {
9431 open,
9432 side,
9433 align,
9434 instant: instantType,
9435 transitionStatus
9436 };
9437 const element = useRenderElement("div", componentProps, {
9438 state,
9439 ref: [forwardedRef, store.context.popupRef, store.useStateSetter("popupElement")],
9440 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
9441 stateAttributesMapping
9442 });
9443 return element;
9444 });
9445 if (true) TooltipPopup.displayName = "TooltipPopup";
9446
9447 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js
9448 var React45 = __toESM(require_react(), 1);
9449 var TooltipArrow = /* @__PURE__ */ React45.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
9450 const {
9451 className,
9452 render: render4,
9453 style,
9454 ...elementProps
9455 } = componentProps;
9456 const store = useTooltipRootContext();
9457 const open = store.useState("open");
9458 const instantType = store.useState("instantType");
9459 const {
9460 arrowRef,
9461 side,
9462 align,
9463 arrowUncentered,
9464 arrowStyles
9465 } = useTooltipPositionerContext();
9466 const state = {
9467 open,
9468 side,
9469 align,
9470 uncentered: arrowUncentered,
9471 instant: instantType
9472 };
9473 const element = useRenderElement("div", componentProps, {
9474 state,
9475 ref: [forwardedRef, arrowRef],
9476 props: [{
9477 style: arrowStyles,
9478 "aria-hidden": true
9479 }, elementProps],
9480 stateAttributesMapping: popupStateMapping
9481 });
9482 return element;
9483 });
9484 if (true) TooltipArrow.displayName = "TooltipArrow";
9485
9486 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js
9487 var React46 = __toESM(require_react(), 1);
9488 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
9489 var TooltipProvider = function TooltipProvider2(props) {
9490 const {
9491 delay,
9492 closeDelay,
9493 timeout = 400
9494 } = props;
9495 const contextValue = React46.useMemo(() => ({
9496 delay,
9497 closeDelay
9498 }), [delay, closeDelay]);
9499 const delayValue = React46.useMemo(() => ({
9500 open: delay,
9501 close: closeDelay
9502 }), [delay, closeDelay]);
9503 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(TooltipProviderContext.Provider, {
9504 value: contextValue,
9505 children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(FloatingDelayGroup, {
9506 delay: delayValue,
9507 timeoutMs: timeout,
9508 children: props.children
9509 })
9510 });
9511 };
9512 if (true) TooltipProvider.displayName = "TooltipProvider";
9513
9514 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
9515 var React47 = __toESM(require_react(), 1);
9516
9517 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js
9518 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
9519 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
9520 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
9521 return TooltipViewportCssVars2;
9522 })({});
9523
9524 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
9525 var stateAttributesMapping2 = {
9526 activationDirection: (value) => value ? {
9527 "data-activation-direction": value
9528 } : null
9529 };
9530 var TooltipViewport = /* @__PURE__ */ React47.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
9531 const {
9532 render: render4,
9533 className,
9534 style,
9535 children,
9536 ...elementProps
9537 } = componentProps;
9538 const store = useTooltipRootContext();
9539 const positioner = useTooltipPositionerContext();
9540 const instantType = store.useState("instantType");
9541 const {
9542 children: childrenToRender,
9543 state: viewportState
9544 } = usePopupViewport({
9545 store,
9546 side: positioner.side,
9547 cssVars: TooltipViewportCssVars,
9548 children
9549 });
9550 const state = {
9551 activationDirection: viewportState.activationDirection,
9552 transitioning: viewportState.transitioning,
9553 instant: instantType
9554 };
9555 return useRenderElement("div", componentProps, {
9556 state,
9557 ref: forwardedRef,
9558 props: [elementProps, {
9559 children: childrenToRender
9560 }],
9561 stateAttributesMapping: stateAttributesMapping2
9562 });
9563 });
9564 if (true) TooltipViewport.displayName = "TooltipViewport";
9565
9566 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
9567 var TooltipHandle = class {
9568 /**
9569 * Internal store holding the tooltip state.
9570 * @internal
9571 */
9572 constructor() {
9573 this.store = new TooltipStore();
9574 }
9575 /**
9576 * Opens the tooltip and associates it with the trigger with the given ID.
9577 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
9578 *
9579 * This method should only be called in an event handler or an effect (not during rendering).
9580 *
9581 * @param triggerId ID of the trigger to associate with the tooltip.
9582 */
9583 open(triggerId) {
9584 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
9585 if (triggerId && !triggerElement) {
9586 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
9587 }
9588 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
9589 }
9590 /**
9591 * Closes the tooltip.
9592 */
9593 close() {
9594 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
9595 }
9596 /**
9597 * Indicates whether the tooltip is currently open.
9598 */
9599 get isOpen() {
9600 return this.store.state.open;
9601 }
9602 };
9603 function createTooltipHandle() {
9604 return new TooltipHandle();
9605 }
9606
9607 // node_modules/@base-ui/react/esm/use-render/useRender.js
9608 function useRender(params) {
9609 return useRenderElement(params.defaultTagName ?? "div", params, params);
9610 }
9611
9612 // packages/ui/build-module/utils/render-slot-with-children.mjs
9613 var import_element9 = __toESM(require_element(), 1);
9614 function renderSlotWithChildren(slot, defaultSlot, children) {
9615 return (0, import_element9.cloneElement)(
9616 slot ?? defaultSlot,
9617 { children }
9618 );
9619 }
9620
9621 // packages/ui/build-module/lock-unlock.mjs
9622 var import_private_apis = __toESM(require_private_apis(), 1);
9623 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
9624 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
9625 "@wordpress/ui"
9626 );
9627
9628 // packages/ui/build-module/stack/stack.mjs
9629 var import_element10 = __toESM(require_element(), 1);
9630 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
9631 function getRuntime() {
9632 const globalScope = globalThis;
9633 if (globalScope.__wpStyleRuntime) {
9634 return globalScope.__wpStyleRuntime;
9635 }
9636 globalScope.__wpStyleRuntime = {
9637 documents: /* @__PURE__ */ new Map(),
9638 styles: /* @__PURE__ */ new Map(),
9639 injectedStyles: /* @__PURE__ */ new WeakMap()
9640 };
9641 if (typeof document !== "undefined") {
9642 registerDocument(document);
9643 }
9644 return globalScope.__wpStyleRuntime;
9645 }
9646 function documentContainsStyleHash(targetDocument, hash) {
9647 if (!targetDocument.head) {
9648 return false;
9649 }
9650 for (const style of targetDocument.head.querySelectorAll(
9651 `style[${STYLE_HASH_ATTRIBUTE}]`
9652 )) {
9653 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
9654 return true;
9655 }
9656 }
9657 return false;
9658 }
9659 function injectStyle(targetDocument, hash, css) {
9660 if (!targetDocument.head) {
9661 return;
9662 }
9663 const runtime = getRuntime();
9664 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9665 if (!injectedStyles) {
9666 injectedStyles = /* @__PURE__ */ new Set();
9667 runtime.injectedStyles.set(targetDocument, injectedStyles);
9668 }
9669 if (injectedStyles.has(hash)) {
9670 return;
9671 }
9672 if (documentContainsStyleHash(targetDocument, hash)) {
9673 injectedStyles.add(hash);
9674 return;
9675 }
9676 const style = targetDocument.createElement("style");
9677 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
9678 style.appendChild(targetDocument.createTextNode(css));
9679 targetDocument.head.appendChild(style);
9680 injectedStyles.add(hash);
9681 }
9682 function registerDocument(targetDocument) {
9683 const runtime = getRuntime();
9684 runtime.documents.set(
9685 targetDocument,
9686 (runtime.documents.get(targetDocument) ?? 0) + 1
9687 );
9688 for (const [hash, css] of runtime.styles) {
9689 injectStyle(targetDocument, hash, css);
9690 }
9691 return () => {
9692 const count = runtime.documents.get(targetDocument);
9693 if (count === void 0) {
9694 return;
9695 }
9696 if (count <= 1) {
9697 runtime.documents.delete(targetDocument);
9698 return;
9699 }
9700 runtime.documents.set(targetDocument, count - 1);
9701 };
9702 }
9703 function registerStyle(hash, css) {
9704 const runtime = getRuntime();
9705 runtime.styles.set(hash, css);
9706 for (const targetDocument of runtime.documents.keys()) {
9707 injectStyle(targetDocument, hash, css);
9708 }
9709 }
9710 if (typeof process === "undefined" || true) {
9711 registerStyle("b51ff41489", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}");
9712 }
9713 var style_default = { "stack": "_19ce0419607e1896__stack" };
9714 var gapTokens = {
9715 xs: "var(--wpds-dimension-gap-xs, 4px)",
9716 sm: "var(--wpds-dimension-gap-sm, 8px)",
9717 md: "var(--wpds-dimension-gap-md, 12px)",
9718 lg: "var(--wpds-dimension-gap-lg, 16px)",
9719 xl: "var(--wpds-dimension-gap-xl, 24px)",
9720 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
9721 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
9722 };
9723 var Stack = (0, import_element10.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
9724 const style = {
9725 gap: gap && gapTokens[gap],
9726 alignItems: align,
9727 justifyContent: justify,
9728 flexDirection: direction,
9729 flexWrap: wrap
9730 };
9731 const element = useRender({
9732 render: render4,
9733 ref,
9734 props: mergeProps(props, { style, className: style_default.stack })
9735 });
9736 return element;
9737 });
9738
9739 // packages/ui/build-module/tooltip/index.mjs
9740 var tooltip_exports = {};
9741 __export(tooltip_exports, {
9742 Popup: () => Popup,
9743 Portal: () => Portal,
9744 Positioner: () => Positioner,
9745 Provider: () => Provider,
9746 Root: () => Root,
9747 Trigger: () => Trigger
9748 });
9749
9750 // packages/ui/build-module/tooltip/popup.mjs
9751 var import_element13 = __toESM(require_element(), 1);
9752 var import_theme = __toESM(require_theme(), 1);
9753
9754 // packages/ui/build-module/tooltip/portal.mjs
9755 var import_element11 = __toESM(require_element(), 1);
9756
9757 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
9758 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
9759 function getRuntime2() {
9760 const globalScope = globalThis;
9761 if (globalScope.__wpStyleRuntime) {
9762 return globalScope.__wpStyleRuntime;
9763 }
9764 globalScope.__wpStyleRuntime = {
9765 documents: /* @__PURE__ */ new Map(),
9766 styles: /* @__PURE__ */ new Map(),
9767 injectedStyles: /* @__PURE__ */ new WeakMap()
9768 };
9769 if (typeof document !== "undefined") {
9770 registerDocument2(document);
9771 }
9772 return globalScope.__wpStyleRuntime;
9773 }
9774 function documentContainsStyleHash2(targetDocument, hash) {
9775 if (!targetDocument.head) {
9776 return false;
9777 }
9778 for (const style of targetDocument.head.querySelectorAll(
9779 `style[${STYLE_HASH_ATTRIBUTE2}]`
9780 )) {
9781 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
9782 return true;
9783 }
9784 }
9785 return false;
9786 }
9787 function injectStyle2(targetDocument, hash, css) {
9788 if (!targetDocument.head) {
9789 return;
9790 }
9791 const runtime = getRuntime2();
9792 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9793 if (!injectedStyles) {
9794 injectedStyles = /* @__PURE__ */ new Set();
9795 runtime.injectedStyles.set(targetDocument, injectedStyles);
9796 }
9797 if (injectedStyles.has(hash)) {
9798 return;
9799 }
9800 if (documentContainsStyleHash2(targetDocument, hash)) {
9801 injectedStyles.add(hash);
9802 return;
9803 }
9804 const style = targetDocument.createElement("style");
9805 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
9806 style.appendChild(targetDocument.createTextNode(css));
9807 targetDocument.head.appendChild(style);
9808 injectedStyles.add(hash);
9809 }
9810 function registerDocument2(targetDocument) {
9811 const runtime = getRuntime2();
9812 runtime.documents.set(
9813 targetDocument,
9814 (runtime.documents.get(targetDocument) ?? 0) + 1
9815 );
9816 for (const [hash, css] of runtime.styles) {
9817 injectStyle2(targetDocument, hash, css);
9818 }
9819 return () => {
9820 const count = runtime.documents.get(targetDocument);
9821 if (count === void 0) {
9822 return;
9823 }
9824 if (count <= 1) {
9825 runtime.documents.delete(targetDocument);
9826 return;
9827 }
9828 runtime.documents.set(targetDocument, count - 1);
9829 };
9830 }
9831 function registerStyle2(hash, css) {
9832 const runtime = getRuntime2();
9833 runtime.styles.set(hash, css);
9834 for (const targetDocument of runtime.documents.keys()) {
9835 injectStyle2(targetDocument, hash, css);
9836 }
9837 }
9838 if (typeof process === "undefined" || true) {
9839 registerStyle2("45eb1fe20f", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;._11fc52b637ff8a7e__slot{inset:0;isolation:isolate;pointer-events:none;position:fixed;z-index:1000000003}@layer wp-ui-utilities{._11fc52b637ff8a7e__slot>*{pointer-events:auto}}");
9840 }
9841 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
9842 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
9843 function resolveOwnerDocument() {
9844 return typeof document === "undefined" ? null : document;
9845 }
9846 function isInWordPressEnvironment() {
9847 let topWp;
9848 try {
9849 topWp = window.top?.wp;
9850 } catch {
9851 }
9852 const wp = topWp ?? window.wp;
9853 return typeof wp?.components === "object" && wp.components !== null;
9854 }
9855 var cachedSlot = null;
9856 function createSlot(ownerDocument2) {
9857 const element = ownerDocument2.createElement("div");
9858 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
9859 if (wp_compat_overlay_slot_default.slot) {
9860 element.classList.add(wp_compat_overlay_slot_default.slot);
9861 }
9862 ownerDocument2.body.appendChild(element);
9863 return element;
9864 }
9865 function getWpCompatOverlaySlot() {
9866 if (typeof window === "undefined") {
9867 return void 0;
9868 }
9869 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
9870 return void 0;
9871 }
9872 const ownerDocument2 = resolveOwnerDocument();
9873 if (!ownerDocument2 || !ownerDocument2.body) {
9874 return void 0;
9875 }
9876 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
9877 return cachedSlot;
9878 }
9879 const existing = ownerDocument2.querySelector(
9880 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
9881 );
9882 if (existing instanceof HTMLDivElement) {
9883 cachedSlot = existing;
9884 return existing;
9885 }
9886 if (cachedSlot?.isConnected) {
9887 cachedSlot.remove();
9888 }
9889 cachedSlot = createSlot(ownerDocument2);
9890 return cachedSlot;
9891 }
9892
9893 // packages/ui/build-module/tooltip/portal.mjs
9894 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
9895 var Portal = (0, import_element11.forwardRef)(
9896 function TooltipPortal3({ container, ...restProps }, ref) {
9897 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
9898 index_parts_exports.Portal,
9899 {
9900 container: container ?? getWpCompatOverlaySlot(),
9901 ...restProps,
9902 ref
9903 }
9904 );
9905 }
9906 );
9907
9908 // packages/ui/build-module/tooltip/positioner.mjs
9909 var import_element12 = __toESM(require_element(), 1);
9910 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
9911 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
9912 function getRuntime3() {
9913 const globalScope = globalThis;
9914 if (globalScope.__wpStyleRuntime) {
9915 return globalScope.__wpStyleRuntime;
9916 }
9917 globalScope.__wpStyleRuntime = {
9918 documents: /* @__PURE__ */ new Map(),
9919 styles: /* @__PURE__ */ new Map(),
9920 injectedStyles: /* @__PURE__ */ new WeakMap()
9921 };
9922 if (typeof document !== "undefined") {
9923 registerDocument3(document);
9924 }
9925 return globalScope.__wpStyleRuntime;
9926 }
9927 function documentContainsStyleHash3(targetDocument, hash) {
9928 if (!targetDocument.head) {
9929 return false;
9930 }
9931 for (const style of targetDocument.head.querySelectorAll(
9932 `style[${STYLE_HASH_ATTRIBUTE3}]`
9933 )) {
9934 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
9935 return true;
9936 }
9937 }
9938 return false;
9939 }
9940 function injectStyle3(targetDocument, hash, css) {
9941 if (!targetDocument.head) {
9942 return;
9943 }
9944 const runtime = getRuntime3();
9945 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9946 if (!injectedStyles) {
9947 injectedStyles = /* @__PURE__ */ new Set();
9948 runtime.injectedStyles.set(targetDocument, injectedStyles);
9949 }
9950 if (injectedStyles.has(hash)) {
9951 return;
9952 }
9953 if (documentContainsStyleHash3(targetDocument, hash)) {
9954 injectedStyles.add(hash);
9955 return;
9956 }
9957 const style = targetDocument.createElement("style");
9958 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
9959 style.appendChild(targetDocument.createTextNode(css));
9960 targetDocument.head.appendChild(style);
9961 injectedStyles.add(hash);
9962 }
9963 function registerDocument3(targetDocument) {
9964 const runtime = getRuntime3();
9965 runtime.documents.set(
9966 targetDocument,
9967 (runtime.documents.get(targetDocument) ?? 0) + 1
9968 );
9969 for (const [hash, css] of runtime.styles) {
9970 injectStyle3(targetDocument, hash, css);
9971 }
9972 return () => {
9973 const count = runtime.documents.get(targetDocument);
9974 if (count === void 0) {
9975 return;
9976 }
9977 if (count <= 1) {
9978 runtime.documents.delete(targetDocument);
9979 return;
9980 }
9981 runtime.documents.set(targetDocument, count - 1);
9982 };
9983 }
9984 function registerStyle3(hash, css) {
9985 const runtime = getRuntime3();
9986 runtime.styles.set(hash, css);
9987 for (const targetDocument of runtime.documents.keys()) {
9988 injectStyle3(targetDocument, hash, css);
9989 }
9990 }
9991 if (typeof process === "undefined" || true) {
9992 registerStyle3("e3ae230cea", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}");
9993 }
9994 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
9995 if (typeof process === "undefined" || true) {
9996 registerStyle3("8293efbb49", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-sm,2px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}');
9997 }
9998 var style_default2 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9999 var Positioner = (0, import_element12.forwardRef)(
10000 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
10001 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10002 index_parts_exports.Positioner,
10003 {
10004 ref,
10005 align,
10006 side,
10007 sideOffset,
10008 ...props,
10009 className: clsx_default(
10010 resets_default["box-sizing"],
10011 style_default2.positioner,
10012 className
10013 )
10014 }
10015 );
10016 }
10017 );
10018
10019 // packages/ui/build-module/tooltip/popup.mjs
10020 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
10021 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
10022 function getRuntime4() {
10023 const globalScope = globalThis;
10024 if (globalScope.__wpStyleRuntime) {
10025 return globalScope.__wpStyleRuntime;
10026 }
10027 globalScope.__wpStyleRuntime = {
10028 documents: /* @__PURE__ */ new Map(),
10029 styles: /* @__PURE__ */ new Map(),
10030 injectedStyles: /* @__PURE__ */ new WeakMap()
10031 };
10032 if (typeof document !== "undefined") {
10033 registerDocument4(document);
10034 }
10035 return globalScope.__wpStyleRuntime;
10036 }
10037 function documentContainsStyleHash4(targetDocument, hash) {
10038 if (!targetDocument.head) {
10039 return false;
10040 }
10041 for (const style of targetDocument.head.querySelectorAll(
10042 `style[${STYLE_HASH_ATTRIBUTE4}]`
10043 )) {
10044 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
10045 return true;
10046 }
10047 }
10048 return false;
10049 }
10050 function injectStyle4(targetDocument, hash, css) {
10051 if (!targetDocument.head) {
10052 return;
10053 }
10054 const runtime = getRuntime4();
10055 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10056 if (!injectedStyles) {
10057 injectedStyles = /* @__PURE__ */ new Set();
10058 runtime.injectedStyles.set(targetDocument, injectedStyles);
10059 }
10060 if (injectedStyles.has(hash)) {
10061 return;
10062 }
10063 if (documentContainsStyleHash4(targetDocument, hash)) {
10064 injectedStyles.add(hash);
10065 return;
10066 }
10067 const style = targetDocument.createElement("style");
10068 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
10069 style.appendChild(targetDocument.createTextNode(css));
10070 targetDocument.head.appendChild(style);
10071 injectedStyles.add(hash);
10072 }
10073 function registerDocument4(targetDocument) {
10074 const runtime = getRuntime4();
10075 runtime.documents.set(
10076 targetDocument,
10077 (runtime.documents.get(targetDocument) ?? 0) + 1
10078 );
10079 for (const [hash, css] of runtime.styles) {
10080 injectStyle4(targetDocument, hash, css);
10081 }
10082 return () => {
10083 const count = runtime.documents.get(targetDocument);
10084 if (count === void 0) {
10085 return;
10086 }
10087 if (count <= 1) {
10088 runtime.documents.delete(targetDocument);
10089 return;
10090 }
10091 runtime.documents.set(targetDocument, count - 1);
10092 };
10093 }
10094 function registerStyle4(hash, css) {
10095 const runtime = getRuntime4();
10096 runtime.styles.set(hash, css);
10097 for (const targetDocument of runtime.documents.keys()) {
10098 injectStyle4(targetDocument, hash, css);
10099 }
10100 }
10101 if (typeof process === "undefined" || true) {
10102 registerStyle4("8293efbb49", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-sm,2px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}');
10103 }
10104 var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
10105 var ThemeProvider = unlock(import_theme.privateApis).ThemeProvider;
10106 var Popup = (0, import_element13.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
10107 const popupContent = (
10108 /* This should ideally use whatever dark color makes sense,
10109 * and not be hardcoded to #1e1e1e. The solutions would be to:
10110 * - review the design of the tooltip, in case we want to stop
10111 * hardcoding it to a dark background
10112 * - create new semantic tokens as needed (aliasing either the
10113 * "inverted bg" or "perma-dark bg" private tokens) and have
10114 * Tooltip.Popup use them;
10115 * - remove the hardcoded `bg` setting from the `ThemeProvider`
10116 * below
10117 */
10118 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ThemeProvider, { color: { bg: "#1e1e1e" }, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10119 index_parts_exports.Popup,
10120 {
10121 ref,
10122 className: clsx_default(style_default3.popup, className),
10123 ...props,
10124 children
10125 }
10126 ) })
10127 );
10128 const positionedPopup = renderSlotWithChildren(
10129 positioner,
10130 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Positioner, {}),
10131 popupContent
10132 );
10133 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Portal, {}), positionedPopup);
10134 });
10135
10136 // packages/ui/build-module/tooltip/trigger.mjs
10137 var import_element14 = __toESM(require_element(), 1);
10138 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
10139 var Trigger = (0, import_element14.forwardRef)(
10140 function TooltipTrigger3(props, ref) {
10141 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(index_parts_exports.Trigger, { ref, ...props });
10142 }
10143 );
10144
10145 // packages/ui/build-module/tooltip/root.mjs
10146 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
10147 function Root(props) {
10148 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(index_parts_exports.Root, { ...props });
10149 }
10150
10151 // packages/ui/build-module/tooltip/provider.mjs
10152 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
10153 function Provider({ ...props }) {
10154 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(index_parts_exports.Provider, { ...props });
10155 }
10156
10157 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
10158 var import_element15 = __toESM(require_element(), 1);
10159 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
10160 function getRuntime5() {
10161 const globalScope = globalThis;
10162 if (globalScope.__wpStyleRuntime) {
10163 return globalScope.__wpStyleRuntime;
10164 }
10165 globalScope.__wpStyleRuntime = {
10166 documents: /* @__PURE__ */ new Map(),
10167 styles: /* @__PURE__ */ new Map(),
10168 injectedStyles: /* @__PURE__ */ new WeakMap()
10169 };
10170 if (typeof document !== "undefined") {
10171 registerDocument5(document);
10172 }
10173 return globalScope.__wpStyleRuntime;
10174 }
10175 function documentContainsStyleHash5(targetDocument, hash) {
10176 if (!targetDocument.head) {
10177 return false;
10178 }
10179 for (const style of targetDocument.head.querySelectorAll(
10180 `style[${STYLE_HASH_ATTRIBUTE5}]`
10181 )) {
10182 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
10183 return true;
10184 }
10185 }
10186 return false;
10187 }
10188 function injectStyle5(targetDocument, hash, css) {
10189 if (!targetDocument.head) {
10190 return;
10191 }
10192 const runtime = getRuntime5();
10193 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10194 if (!injectedStyles) {
10195 injectedStyles = /* @__PURE__ */ new Set();
10196 runtime.injectedStyles.set(targetDocument, injectedStyles);
10197 }
10198 if (injectedStyles.has(hash)) {
10199 return;
10200 }
10201 if (documentContainsStyleHash5(targetDocument, hash)) {
10202 injectedStyles.add(hash);
10203 return;
10204 }
10205 const style = targetDocument.createElement("style");
10206 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
10207 style.appendChild(targetDocument.createTextNode(css));
10208 targetDocument.head.appendChild(style);
10209 injectedStyles.add(hash);
10210 }
10211 function registerDocument5(targetDocument) {
10212 const runtime = getRuntime5();
10213 runtime.documents.set(
10214 targetDocument,
10215 (runtime.documents.get(targetDocument) ?? 0) + 1
10216 );
10217 for (const [hash, css] of runtime.styles) {
10218 injectStyle5(targetDocument, hash, css);
10219 }
10220 return () => {
10221 const count = runtime.documents.get(targetDocument);
10222 if (count === void 0) {
10223 return;
10224 }
10225 if (count <= 1) {
10226 runtime.documents.delete(targetDocument);
10227 return;
10228 }
10229 runtime.documents.set(targetDocument, count - 1);
10230 };
10231 }
10232 function registerStyle5(hash, css) {
10233 const runtime = getRuntime5();
10234 runtime.styles.set(hash, css);
10235 for (const targetDocument of runtime.documents.keys()) {
10236 injectStyle5(targetDocument, hash, css);
10237 }
10238 }
10239 if (typeof process === "undefined" || true) {
10240 registerStyle5("c46e8cb841", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.f37b9e2e191ebd66__visually-hidden{word-wrap:normal;border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-break:normal}}");
10241 }
10242 var style_default4 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
10243 var VisuallyHidden = (0, import_element15.forwardRef)(
10244 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
10245 const element = useRender({
10246 render: render4,
10247 ref,
10248 props: mergeProps(
10249 { className: style_default4["visually-hidden"] },
10250 restProps,
10251 {
10252 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
10253 "data-visually-hidden": ""
10254 }
10255 )
10256 });
10257 return element;
10258 }
10259 );
10260
10261 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10262 var import_element16 = __toESM(require_element(), 1);
10263
10264 // packages/dataviews/build-module/constants.mjs
10265 var import_i18n7 = __toESM(require_i18n(), 1);
10266 var OPERATOR_IS_ANY = "isAny";
10267 var OPERATOR_IS_NONE = "isNone";
10268 var OPERATOR_IS_ALL = "isAll";
10269 var OPERATOR_IS_NOT_ALL = "isNotAll";
10270 var OPERATOR_BETWEEN = "between";
10271 var OPERATOR_IN_THE_PAST = "inThePast";
10272 var OPERATOR_OVER = "over";
10273 var OPERATOR_IS = "is";
10274 var OPERATOR_IS_NOT = "isNot";
10275 var OPERATOR_LESS_THAN = "lessThan";
10276 var OPERATOR_GREATER_THAN = "greaterThan";
10277 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
10278 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
10279 var OPERATOR_BEFORE = "before";
10280 var OPERATOR_AFTER = "after";
10281 var OPERATOR_BEFORE_INC = "beforeInc";
10282 var OPERATOR_AFTER_INC = "afterInc";
10283 var OPERATOR_CONTAINS = "contains";
10284 var OPERATOR_NOT_CONTAINS = "notContains";
10285 var OPERATOR_STARTS_WITH = "startsWith";
10286 var OPERATOR_ON = "on";
10287 var OPERATOR_NOT_ON = "notOn";
10288 var SORTING_DIRECTIONS = ["asc", "desc"];
10289 var sortArrows = { asc: "\u2191", desc: "\u2193" };
10290 var sortValues = { asc: "ascending", desc: "descending" };
10291 var sortLabels = {
10292 asc: (0, import_i18n7.__)("Sort ascending"),
10293 desc: (0, import_i18n7.__)("Sort descending")
10294 };
10295 var sortIcons = {
10296 asc: arrow_up_default,
10297 desc: arrow_down_default
10298 };
10299 var LAYOUT_TABLE = "table";
10300 var LAYOUT_GRID = "grid";
10301 var LAYOUT_LIST = "list";
10302 var LAYOUT_ACTIVITY = "activity";
10303 var LAYOUT_PICKER_GRID = "pickerGrid";
10304 var LAYOUT_PICKER_TABLE = "pickerTable";
10305
10306 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10307 var DataViewsContext = (0, import_element16.createContext)({
10308 view: { type: LAYOUT_TABLE },
10309 onChangeView: () => {
10310 },
10311 fields: [],
10312 data: [],
10313 paginationInfo: {
10314 totalItems: 0,
10315 totalPages: 0
10316 },
10317 selection: [],
10318 onChangeSelection: () => {
10319 },
10320 setOpenedFilter: () => {
10321 },
10322 openedFilter: null,
10323 getItemId: (item) => item.id,
10324 isItemClickable: () => true,
10325 renderItemLink: void 0,
10326 containerWidth: 0,
10327 containerRef: (0, import_element16.createRef)(),
10328 resizeObserverRef: () => {
10329 },
10330 defaultLayouts: { list: {}, grid: {}, table: {} },
10331 filters: [],
10332 isShowingFilter: false,
10333 setIsShowingFilter: () => {
10334 },
10335 hasInitiallyLoaded: false,
10336 config: {
10337 perPageSizes: []
10338 },
10339 intersectionObserver: null
10340 });
10341 DataViewsContext.displayName = "DataViewsContext";
10342 var dataviews_context_default = DataViewsContext;
10343
10344 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
10345 var import_i18n27 = __toESM(require_i18n(), 1);
10346
10347 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
10348 var import_i18n15 = __toESM(require_i18n(), 1);
10349 var import_components6 = __toESM(require_components(), 1);
10350 var import_element24 = __toESM(require_element(), 1);
10351 var import_keycodes = __toESM(require_keycodes(), 1);
10352
10353 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
10354 var import_components = __toESM(require_components(), 1);
10355 var import_i18n8 = __toESM(require_i18n(), 1);
10356 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
10357 function DataViewsSelectionCheckbox({
10358 selection,
10359 onChangeSelection,
10360 item,
10361 getItemId,
10362 titleField,
10363 disabled: disabled2,
10364 ...extraProps
10365 }) {
10366 const id = getItemId(item);
10367 const isInSelectionArray = selection.includes(id);
10368 const checked = !disabled2 && isInSelectionArray;
10369 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n8.__)("(no title)");
10370 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
10371 import_components.CheckboxControl,
10372 {
10373 className: "dataviews-selection-checkbox",
10374 "aria-label": selectionLabel,
10375 "aria-disabled": disabled2,
10376 checked,
10377 onChange: () => {
10378 if (disabled2) {
10379 return;
10380 }
10381 onChangeSelection(
10382 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
10383 );
10384 },
10385 ...extraProps
10386 }
10387 );
10388 }
10389
10390 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10391 var import_components2 = __toESM(require_components(), 1);
10392 var import_i18n9 = __toESM(require_i18n(), 1);
10393 var import_element17 = __toESM(require_element(), 1);
10394 var import_data = __toESM(require_data(), 1);
10395 var import_compose = __toESM(require_compose(), 1);
10396
10397 // packages/dataviews/build-module/lock-unlock.mjs
10398 var import_private_apis2 = __toESM(require_private_apis(), 1);
10399 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
10400 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
10401 "@wordpress/dataviews"
10402 );
10403
10404 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10405 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
10406 var { Menu, kebabCase } = unlock2(import_components2.privateApis);
10407 function ButtonTrigger({
10408 action,
10409 onClick,
10410 items,
10411 variant
10412 }) {
10413 const label = typeof action.label === "string" ? action.label : action.label(items);
10414 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10415 import_components2.Button,
10416 {
10417 disabled: !!action.disabled,
10418 accessibleWhenDisabled: true,
10419 size: "compact",
10420 variant,
10421 onClick,
10422 children: label
10423 }
10424 );
10425 }
10426 function MenuItemTrigger({
10427 action,
10428 onClick,
10429 items
10430 }) {
10431 const label = typeof action.label === "string" ? action.label : action.label(items);
10432 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Menu.ItemLabel, { children: label }) });
10433 }
10434 function ActionModal({
10435 action,
10436 items,
10437 closeModal
10438 }) {
10439 const label = typeof action.label === "string" ? action.label : action.label(items);
10440 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
10441 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10442 import_components2.Modal,
10443 {
10444 title: modalHeader || label,
10445 __experimentalHideHeader: !!action.hideModalHeader,
10446 onRequestClose: closeModal,
10447 focusOnMount: action.modalFocusOnMount ?? true,
10448 size: action.modalSize || "medium",
10449 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
10450 action.id
10451 )}`,
10452 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(action.RenderModal, { items, closeModal })
10453 }
10454 );
10455 }
10456 function ActionsMenuGroup({
10457 actions,
10458 item,
10459 registry,
10460 setActiveModalAction
10461 }) {
10462 const { primaryActions, regularActions } = (0, import_element17.useMemo)(() => {
10463 return actions.reduce(
10464 (acc, action) => {
10465 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
10466 return acc;
10467 },
10468 {
10469 primaryActions: [],
10470 regularActions: []
10471 }
10472 );
10473 }, [actions]);
10474 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10475 MenuItemTrigger,
10476 {
10477 action,
10478 onClick: () => {
10479 if ("RenderModal" in action) {
10480 setActiveModalAction(action);
10481 return;
10482 }
10483 action.callback([item], { registry });
10484 },
10485 items: [item]
10486 },
10487 action.id
10488 ));
10489 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(Menu.Group, { children: [
10490 renderActionGroup(primaryActions),
10491 renderActionGroup(regularActions)
10492 ] });
10493 }
10494 function ItemActions({
10495 item,
10496 actions,
10497 isCompact
10498 }) {
10499 const registry = (0, import_data.useRegistry)();
10500 const { primaryActions, eligibleActions } = (0, import_element17.useMemo)(() => {
10501 const _eligibleActions = actions.filter(
10502 (action) => !action.isEligible || action.isEligible(item)
10503 );
10504 const _primaryActions = _eligibleActions.filter(
10505 (action) => action.isPrimary
10506 );
10507 return {
10508 primaryActions: _primaryActions,
10509 eligibleActions: _eligibleActions
10510 };
10511 }, [actions, item]);
10512 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10513 if (isCompact) {
10514 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10515 CompactItemActions,
10516 {
10517 item,
10518 actions: eligibleActions,
10519 isSmall: true,
10520 registry
10521 }
10522 );
10523 }
10524 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
10525 Stack,
10526 {
10527 direction: "row",
10528 justify: "flex-end",
10529 className: "dataviews-item-actions",
10530 style: {
10531 flexShrink: 0,
10532 width: "auto"
10533 },
10534 children: [
10535 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10536 PrimaryActions,
10537 {
10538 item,
10539 actions: primaryActions,
10540 registry
10541 }
10542 ),
10543 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
10544 // there if there are any actions at all.
10545 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10546 CompactItemActions,
10547 {
10548 item,
10549 actions: eligibleActions,
10550 registry
10551 }
10552 )
10553 ]
10554 }
10555 );
10556 }
10557 function CompactItemActions({
10558 item,
10559 actions,
10560 isSmall,
10561 registry
10562 }) {
10563 const [activeModalAction, setActiveModalAction] = (0, import_element17.useState)(
10564 null
10565 );
10566 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_jsx_runtime48.Fragment, { children: [
10567 /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(Menu, { placement: "bottom-end", children: [
10568 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10569 Menu.TriggerButton,
10570 {
10571 render: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10572 import_components2.Button,
10573 {
10574 size: isSmall ? "small" : "compact",
10575 icon: more_vertical_default,
10576 label: (0, import_i18n9.__)("Actions"),
10577 accessibleWhenDisabled: true,
10578 disabled: !actions.length,
10579 className: "dataviews-all-actions-button"
10580 }
10581 )
10582 }
10583 ),
10584 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10585 ActionsMenuGroup,
10586 {
10587 actions,
10588 item,
10589 registry,
10590 setActiveModalAction
10591 }
10592 ) })
10593 ] }),
10594 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10595 ActionModal,
10596 {
10597 action: activeModalAction,
10598 items: [item],
10599 closeModal: () => setActiveModalAction(null)
10600 }
10601 )
10602 ] });
10603 }
10604 function PrimaryActions({
10605 item,
10606 actions,
10607 registry,
10608 buttonVariant
10609 }) {
10610 const [activeModalAction, setActiveModalAction] = (0, import_element17.useState)(null);
10611 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10612 if (isMobileViewport) {
10613 return null;
10614 }
10615 if (!Array.isArray(actions) || actions.length === 0) {
10616 return null;
10617 }
10618 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_jsx_runtime48.Fragment, { children: [
10619 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10620 ButtonTrigger,
10621 {
10622 action,
10623 onClick: () => {
10624 if ("RenderModal" in action) {
10625 setActiveModalAction(action);
10626 return;
10627 }
10628 action.callback([item], { registry });
10629 },
10630 items: [item],
10631 variant: buttonVariant
10632 },
10633 action.id
10634 )),
10635 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10636 ActionModal,
10637 {
10638 action: activeModalAction,
10639 items: [item],
10640 closeModal: () => setActiveModalAction(null)
10641 }
10642 )
10643 ] });
10644 }
10645
10646 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10647 var import_components3 = __toESM(require_components(), 1);
10648 var import_i18n11 = __toESM(require_i18n(), 1);
10649 var import_element18 = __toESM(require_element(), 1);
10650 var import_data2 = __toESM(require_data(), 1);
10651 var import_compose2 = __toESM(require_compose(), 1);
10652
10653 // packages/dataviews/build-module/utils/get-footer-message.mjs
10654 var import_i18n10 = __toESM(require_i18n(), 1);
10655 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
10656 if (selectionCount > 0) {
10657 return (0, import_i18n10.sprintf)(
10658 /* translators: %d: number of items. */
10659 (0, import_i18n10._n)("%d Item selected", "%d Items selected", selectionCount),
10660 selectionCount
10661 );
10662 }
10663 if (onlyTotalCount || totalItems <= itemsCount) {
10664 return (0, import_i18n10.sprintf)(
10665 /* translators: %d: number of items. */
10666 (0, import_i18n10._n)("%d Item", "%d Items", totalItems),
10667 totalItems
10668 );
10669 }
10670 return (0, import_i18n10.sprintf)(
10671 /* translators: %1$d: number of items. %2$d: total number of items. */
10672 (0, import_i18n10._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
10673 itemsCount,
10674 totalItems
10675 );
10676 }
10677
10678 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10679 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
10680 function useHasAPossibleBulkAction(actions, item) {
10681 return (0, import_element18.useMemo)(() => {
10682 return actions.some((action) => {
10683 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10684 });
10685 }, [actions, item]);
10686 }
10687 function useSomeItemHasAPossibleBulkAction(actions, data) {
10688 return (0, import_element18.useMemo)(() => {
10689 return data.some((item) => {
10690 return actions.some((action) => {
10691 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10692 });
10693 });
10694 }, [actions, data]);
10695 }
10696 function BulkSelectionCheckbox({
10697 selection,
10698 onChangeSelection,
10699 data,
10700 actions,
10701 getItemId,
10702 disableSelectAll = false
10703 }) {
10704 const selectableItems = (0, import_element18.useMemo)(() => {
10705 return data.filter((item) => {
10706 return actions.some(
10707 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
10708 );
10709 });
10710 }, [data, actions]);
10711 const selectedItems = data.filter(
10712 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
10713 );
10714 const hasSelection = selection.length > 0;
10715 const areAllSelected = selectedItems.length === selectableItems.length;
10716 if (disableSelectAll) {
10717 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10718 import_components3.CheckboxControl,
10719 {
10720 className: "dataviews-view-table-selection-checkbox",
10721 checked: hasSelection,
10722 disabled: !hasSelection,
10723 onChange: () => {
10724 onChangeSelection([]);
10725 },
10726 "aria-label": (0, import_i18n11.__)("Deselect all")
10727 }
10728 );
10729 }
10730 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10731 import_components3.CheckboxControl,
10732 {
10733 className: "dataviews-view-table-selection-checkbox",
10734 checked: areAllSelected,
10735 indeterminate: !areAllSelected && !!selectedItems.length,
10736 onChange: () => {
10737 if (areAllSelected) {
10738 onChangeSelection([]);
10739 } else {
10740 onChangeSelection(
10741 selectableItems.map((item) => getItemId(item))
10742 );
10743 }
10744 },
10745 "aria-label": areAllSelected ? (0, import_i18n11.__)("Deselect all") : (0, import_i18n11.__)("Select all")
10746 }
10747 );
10748 }
10749
10750 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
10751 var import_i18n12 = __toESM(require_i18n(), 1);
10752 var import_components4 = __toESM(require_components(), 1);
10753 var import_element19 = __toESM(require_element(), 1);
10754
10755 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
10756 function getHideableFields(view, fields) {
10757 const togglableFields = [
10758 view?.titleField,
10759 view?.mediaField,
10760 view?.descriptionField
10761 ].filter(Boolean);
10762 return fields.filter(
10763 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
10764 );
10765 }
10766
10767 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
10768 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
10769 var { Menu: Menu2 } = unlock2(import_components4.privateApis);
10770 function WithMenuSeparators({ children }) {
10771 return import_element19.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_element19.Fragment, { children: [
10772 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Separator, {}),
10773 child
10774 ] }, i2));
10775 }
10776 var _HeaderMenu = (0, import_element19.forwardRef)(function HeaderMenu({
10777 fieldId,
10778 view,
10779 fields,
10780 onChangeView,
10781 onHide,
10782 setOpenedFilter,
10783 canMove = true,
10784 canInsertLeft = true,
10785 canInsertRight = true
10786 }, ref) {
10787 const visibleFieldIds = view.fields ?? [];
10788 const index2 = visibleFieldIds?.indexOf(fieldId);
10789 const isSorted = view.sort?.field === fieldId;
10790 let isHidable = false;
10791 let isSortable = false;
10792 let canAddFilter = false;
10793 let operators = [];
10794 const field = fields.find((f2) => f2.id === fieldId);
10795 const { setIsShowingFilter } = (0, import_element19.useContext)(dataviews_context_default);
10796 if (!field) {
10797 return null;
10798 }
10799 isHidable = field.enableHiding !== false;
10800 isSortable = field.enableSorting !== false;
10801 const header = field.header;
10802 operators = !!field.filterBy && field.filterBy?.operators || [];
10803 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
10804 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
10805 return header;
10806 }
10807 const hiddenFields = getHideableFields(view, fields).filter(
10808 (f2) => !visibleFieldIds.includes(f2.id)
10809 );
10810 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
10811 const isRtl = (0, import_i18n12.isRTL)();
10812 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2, { children: [
10813 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
10814 Menu2.TriggerButton,
10815 {
10816 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10817 import_components4.Button,
10818 {
10819 size: "compact",
10820 className: "dataviews-view-table-header-button",
10821 ref,
10822 variant: "tertiary"
10823 }
10824 ),
10825 children: [
10826 header,
10827 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
10828 ]
10829 }
10830 ),
10831 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(WithMenuSeparators, { children: [
10832 isSortable && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
10833 (direction) => {
10834 const isChecked = view.sort && isSorted && view.sort.direction === direction;
10835 const value = `${fieldId}-${direction}`;
10836 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10837 Menu2.RadioItem,
10838 {
10839 name: "view-table-sorting",
10840 value,
10841 checked: isChecked,
10842 onChange: () => {
10843 onChangeView({
10844 ...view,
10845 sort: {
10846 field: fieldId,
10847 direction
10848 },
10849 showLevels: false
10850 });
10851 },
10852 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
10853 },
10854 value
10855 );
10856 }
10857 ) }),
10858 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10859 Menu2.Item,
10860 {
10861 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: funnel_default }),
10862 onClick: () => {
10863 setOpenedFilter(fieldId);
10864 setIsShowingFilter(true);
10865 onChangeView({
10866 ...view,
10867 page: 1,
10868 filters: [
10869 ...view.filters || [],
10870 {
10871 field: fieldId,
10872 value: void 0,
10873 operator: operators[0]
10874 }
10875 ]
10876 });
10877 },
10878 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Add filter") })
10879 }
10880 ) }),
10881 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2.Group, { children: [
10882 canMove && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10883 Menu2.Item,
10884 {
10885 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: arrow_left_default }),
10886 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
10887 onClick: () => {
10888 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
10889 const newFields = [
10890 ...visibleFieldIds
10891 ];
10892 newFields.splice(index2, 1);
10893 newFields.splice(
10894 targetIndex,
10895 0,
10896 fieldId
10897 );
10898 onChangeView({
10899 ...view,
10900 fields: newFields
10901 });
10902 },
10903 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Move left") })
10904 }
10905 ),
10906 canMove && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10907 Menu2.Item,
10908 {
10909 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: arrow_right_default }),
10910 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
10911 onClick: () => {
10912 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
10913 const newFields = [
10914 ...visibleFieldIds
10915 ];
10916 newFields.splice(index2, 1);
10917 newFields.splice(
10918 targetIndex,
10919 0,
10920 fieldId
10921 );
10922 onChangeView({
10923 ...view,
10924 fields: newFields
10925 });
10926 },
10927 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Move right") })
10928 }
10929 ),
10930 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2, { children: [
10931 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Insert left") }) }),
10932 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
10933 const insertIndex = isRtl ? index2 + 1 : index2;
10934 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10935 Menu2.Item,
10936 {
10937 onClick: () => {
10938 onChangeView({
10939 ...view,
10940 fields: [
10941 ...visibleFieldIds.slice(
10942 0,
10943 insertIndex
10944 ),
10945 hiddenField.id,
10946 ...visibleFieldIds.slice(
10947 insertIndex
10948 )
10949 ]
10950 });
10951 },
10952 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
10953 },
10954 hiddenField.id
10955 );
10956 }) })
10957 ] }),
10958 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2, { children: [
10959 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Insert right") }) }),
10960 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
10961 const insertIndex = isRtl ? index2 : index2 + 1;
10962 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10963 Menu2.Item,
10964 {
10965 onClick: () => {
10966 onChangeView({
10967 ...view,
10968 fields: [
10969 ...visibleFieldIds.slice(
10970 0,
10971 insertIndex
10972 ),
10973 hiddenField.id,
10974 ...visibleFieldIds.slice(
10975 insertIndex
10976 )
10977 ]
10978 });
10979 },
10980 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
10981 },
10982 hiddenField.id
10983 );
10984 }) })
10985 ] }),
10986 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10987 Menu2.Item,
10988 {
10989 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: unseen_default }),
10990 onClick: () => {
10991 onHide(field);
10992 onChangeView({
10993 ...view,
10994 fields: visibleFieldIds.filter(
10995 (id) => id !== fieldId
10996 )
10997 });
10998 },
10999 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Hide column") })
11000 }
11001 )
11002 ] })
11003 ] }) })
11004 ] });
11005 });
11006 var ColumnHeaderMenu = _HeaderMenu;
11007 var column_header_menu_default = ColumnHeaderMenu;
11008
11009 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
11010 var import_element20 = __toESM(require_element(), 1);
11011 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
11012 function getClickableItemProps({
11013 item,
11014 isItemClickable: isItemClickable2,
11015 onClickItem,
11016 className
11017 }) {
11018 if (!isItemClickable2(item) || !onClickItem) {
11019 return { className };
11020 }
11021 return {
11022 className: className ? `${className} ${className}--clickable` : void 0,
11023 role: "button",
11024 tabIndex: 0,
11025 onClick: (event) => {
11026 event.stopPropagation();
11027 onClickItem(item);
11028 },
11029 onKeyDown: (event) => {
11030 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11031 event.stopPropagation();
11032 onClickItem(item);
11033 }
11034 }
11035 };
11036 }
11037 function ItemClickWrapper({
11038 item,
11039 isItemClickable: isItemClickable2,
11040 onClickItem,
11041 renderItemLink,
11042 className,
11043 children,
11044 ...extraProps
11045 }) {
11046 if (!isItemClickable2(item)) {
11047 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className, ...extraProps, children });
11048 }
11049 if (renderItemLink) {
11050 const renderedElement = renderItemLink({
11051 item,
11052 className: `${className} ${className}--clickable`,
11053 ...extraProps,
11054 children
11055 });
11056 return (0, import_element20.cloneElement)(renderedElement, {
11057 onClick: (event) => {
11058 event.stopPropagation();
11059 if (renderedElement.props.onClick) {
11060 renderedElement.props.onClick(event);
11061 }
11062 },
11063 onKeyDown: (event) => {
11064 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11065 event.stopPropagation();
11066 if (renderedElement.props.onKeyDown) {
11067 renderedElement.props.onKeyDown(event);
11068 }
11069 }
11070 }
11071 });
11072 }
11073 const clickProps = getClickableItemProps({
11074 item,
11075 isItemClickable: isItemClickable2,
11076 onClickItem,
11077 className
11078 });
11079 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { ...clickProps, ...extraProps, children });
11080 }
11081
11082 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
11083 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
11084 function ColumnPrimary({
11085 item,
11086 level,
11087 titleField,
11088 mediaField,
11089 descriptionField: descriptionField2,
11090 onClickItem,
11091 renderItemLink,
11092 isItemClickable: isItemClickable2
11093 }) {
11094 return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
11095 mediaField && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
11096 ItemClickWrapper,
11097 {
11098 item,
11099 isItemClickable: isItemClickable2,
11100 onClickItem,
11101 renderItemLink,
11102 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
11103 "aria-label": isItemClickable2(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
11104 children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
11105 mediaField.render,
11106 {
11107 item,
11108 field: mediaField,
11109 config: { sizes: "32px" }
11110 }
11111 )
11112 }
11113 ),
11114 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
11115 Stack,
11116 {
11117 direction: "column",
11118 align: "flex-start",
11119 className: "dataviews-view-table__primary-column-content",
11120 children: [
11121 titleField && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
11122 ItemClickWrapper,
11123 {
11124 item,
11125 isItemClickable: isItemClickable2,
11126 onClickItem,
11127 renderItemLink,
11128 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
11129 children: [
11130 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("span", { className: "dataviews-view-table__level", children: [
11131 Array(level).fill("\u2014").join(" "),
11132 "\xA0"
11133 ] }),
11134 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(titleField.render, { item, field: titleField })
11135 ]
11136 }
11137 ),
11138 descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
11139 descriptionField2.render,
11140 {
11141 item,
11142 field: descriptionField2
11143 }
11144 )
11145 ]
11146 }
11147 )
11148 ] });
11149 }
11150 var column_primary_default = ColumnPrimary;
11151
11152 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
11153 var import_element21 = __toESM(require_element(), 1);
11154 var import_i18n13 = __toESM(require_i18n(), 1);
11155 var isScrolledToEnd = (element) => {
11156 if ((0, import_i18n13.isRTL)()) {
11157 const scrollLeft = Math.abs(element.scrollLeft);
11158 return scrollLeft <= 1;
11159 }
11160 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
11161 };
11162 function useScrollState({
11163 scrollContainerRef,
11164 enabledHorizontal = false
11165 }) {
11166 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element21.useState)(false);
11167 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element21.useState)(false);
11168 const handleScroll = (0, import_element21.useCallback)(() => {
11169 const scrollContainer = scrollContainerRef.current;
11170 if (!scrollContainer) {
11171 return;
11172 }
11173 if (enabledHorizontal) {
11174 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
11175 }
11176 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
11177 }, [scrollContainerRef, enabledHorizontal]);
11178 (0, import_element21.useEffect)(() => {
11179 if (typeof window === "undefined" || !scrollContainerRef.current) {
11180 return () => {
11181 };
11182 }
11183 const scrollContainer = scrollContainerRef.current;
11184 handleScroll();
11185 scrollContainer.addEventListener("scroll", handleScroll);
11186 window.addEventListener("resize", handleScroll);
11187 return () => {
11188 scrollContainer.removeEventListener("scroll", handleScroll);
11189 window.removeEventListener("resize", handleScroll);
11190 };
11191 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
11192 return { isHorizontalScrollEnd, isVerticallyScrolled };
11193 }
11194
11195 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
11196 function getDataByGroup(data, groupByField) {
11197 return data.reduce((groups, item) => {
11198 const groupName = groupByField.getValue({ item });
11199 if (!groups.has(groupName)) {
11200 groups.set(groupName, []);
11201 }
11202 groups.get(groupName)?.push(item);
11203 return groups;
11204 }, /* @__PURE__ */ new Map());
11205 }
11206
11207 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
11208 var import_components5 = __toESM(require_components(), 1);
11209 var import_i18n14 = __toESM(require_i18n(), 1);
11210 var import_element22 = __toESM(require_element(), 1);
11211 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
11212 function FieldItem({
11213 field,
11214 isVisible: isVisible2,
11215 onToggleVisibility
11216 }) {
11217 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components5.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
11218 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components5.Icon, { icon: check_default }) }),
11219 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
11220 ] }) });
11221 }
11222 function isDefined(item) {
11223 return !!item;
11224 }
11225 function PropertiesSection({
11226 showLabel = true
11227 }) {
11228 const { view, fields, onChangeView } = (0, import_element22.useContext)(dataviews_context_default);
11229 const regularFields = getHideableFields(view, fields);
11230 if (!regularFields?.length) {
11231 return null;
11232 }
11233 const titleField = fields.find((f2) => f2.id === view.titleField);
11234 const previewField = fields.find((f2) => f2.id === view.mediaField);
11235 const descriptionField2 = fields.find(
11236 (f2) => f2.id === view.descriptionField
11237 );
11238 const lockedFields = [
11239 {
11240 field: titleField,
11241 isVisibleFlag: "showTitle"
11242 },
11243 {
11244 field: previewField,
11245 isVisibleFlag: "showMedia"
11246 },
11247 {
11248 field: descriptionField2,
11249 isVisibleFlag: "showDescription"
11250 }
11251 ].filter(({ field }) => isDefined(field));
11252 const visibleFieldIds = view.fields ?? [];
11253 const visibleRegularFieldsCount = regularFields.filter(
11254 (f2) => visibleFieldIds.includes(f2.id)
11255 ).length;
11256 const visibleLockedFields = lockedFields.filter(
11257 ({ isVisibleFlag }) => (
11258 // @ts-expect-error
11259 view[isVisibleFlag] ?? true
11260 )
11261 );
11262 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
11263 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
11264 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
11265 showLabel && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n14.__)("Properties") }),
11266 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11267 Stack,
11268 {
11269 direction: "column",
11270 className: "dataviews-view-config__properties",
11271 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
11272 lockedFields.map(({ field, isVisibleFlag }) => {
11273 const isVisible2 = view[isVisibleFlag] ?? true;
11274 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
11275 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11276 FieldItem,
11277 {
11278 field: fieldToRender,
11279 isVisible: isVisible2,
11280 onToggleVisibility: () => {
11281 onChangeView({
11282 ...view,
11283 [isVisibleFlag]: !isVisible2
11284 });
11285 }
11286 },
11287 field.id
11288 );
11289 }),
11290 regularFields.map((field) => {
11291 const isVisible2 = visibleFieldIds.includes(field.id);
11292 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
11293 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11294 FieldItem,
11295 {
11296 field: fieldToRender,
11297 isVisible: isVisible2,
11298 onToggleVisibility: () => {
11299 onChangeView({
11300 ...view,
11301 fields: isVisible2 ? visibleFieldIds.filter(
11302 (fieldId) => fieldId !== field.id
11303 ) : [...visibleFieldIds, field.id]
11304 });
11305 }
11306 },
11307 field.id
11308 );
11309 })
11310 ] })
11311 }
11312 )
11313 ] });
11314 }
11315
11316 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
11317 var import_element23 = __toESM(require_element(), 1);
11318 function useDelayedLoading(isLoading, options = { delay: 400 }) {
11319 const [showLoader, setShowLoader] = (0, import_element23.useState)(false);
11320 (0, import_element23.useEffect)(() => {
11321 if (!isLoading) {
11322 return;
11323 }
11324 const timeout = setTimeout(() => {
11325 setShowLoader(true);
11326 }, options.delay);
11327 return () => {
11328 clearTimeout(timeout);
11329 setShowLoader(false);
11330 };
11331 }, [isLoading, options.delay]);
11332 return showLoader;
11333 }
11334
11335 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
11336 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
11337 function getEffectiveAlign(explicitAlign, fieldType) {
11338 if (explicitAlign) {
11339 return explicitAlign;
11340 }
11341 if (fieldType === "integer" || fieldType === "number") {
11342 return "end";
11343 }
11344 return void 0;
11345 }
11346 function TableColumnField({
11347 item,
11348 fields,
11349 column,
11350 align
11351 }) {
11352 const field = fields.find((f2) => f2.id === column);
11353 if (!field) {
11354 return null;
11355 }
11356 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
11357 "dataviews-view-table__cell-align-end": align === "end",
11358 "dataviews-view-table__cell-align-center": align === "center"
11359 });
11360 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(field.render, { item, field }) });
11361 }
11362 function TableRow({
11363 hasBulkActions,
11364 item,
11365 level,
11366 actions,
11367 fields,
11368 id,
11369 view,
11370 titleField,
11371 mediaField,
11372 descriptionField: descriptionField2,
11373 selection,
11374 getItemId,
11375 isItemClickable: isItemClickable2,
11376 onClickItem,
11377 renderItemLink,
11378 onChangeSelection,
11379 isActionsColumnSticky,
11380 posinset
11381 }) {
11382 const { paginationInfo } = (0, import_element24.useContext)(dataviews_context_default);
11383 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
11384 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
11385 const {
11386 showTitle = true,
11387 showMedia = true,
11388 showDescription = true,
11389 infiniteScrollEnabled
11390 } = view;
11391 const isTouchDeviceRef = (0, import_element24.useRef)(false);
11392 const columns = view.fields ?? [];
11393 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
11394 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
11395 "tr",
11396 {
11397 className: clsx_default("dataviews-view-table__row", {
11398 "is-selected": hasPossibleBulkAction && isSelected2,
11399 "has-bulk-actions": hasPossibleBulkAction
11400 }),
11401 onTouchStart: () => {
11402 isTouchDeviceRef.current = true;
11403 },
11404 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
11405 "aria-posinset": posinset,
11406 role: infiniteScrollEnabled ? "article" : void 0,
11407 onMouseDown: (event) => {
11408 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11409 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
11410 event?.preventDefault();
11411 }
11412 },
11413 onClick: (event) => {
11414 if (!hasPossibleBulkAction) {
11415 return;
11416 }
11417 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11418 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
11419 onChangeSelection(
11420 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
11421 );
11422 }
11423 },
11424 children: [
11425 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11426 DataViewsSelectionCheckbox,
11427 {
11428 item,
11429 selection,
11430 onChangeSelection,
11431 getItemId,
11432 titleField,
11433 disabled: !hasPossibleBulkAction
11434 }
11435 ) }) }),
11436 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11437 column_primary_default,
11438 {
11439 item,
11440 level,
11441 titleField: showTitle ? titleField : void 0,
11442 mediaField: showMedia ? mediaField : void 0,
11443 descriptionField: showDescription ? descriptionField2 : void 0,
11444 isItemClickable: isItemClickable2,
11445 onClickItem,
11446 renderItemLink
11447 }
11448 ) }),
11449 columns.map((column) => {
11450 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
11451 const field = fields.find((f2) => f2.id === column);
11452 const effectiveAlign = getEffectiveAlign(align, field?.type);
11453 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11454 "td",
11455 {
11456 style: {
11457 width,
11458 maxWidth,
11459 minWidth
11460 },
11461 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11462 TableColumnField,
11463 {
11464 fields,
11465 item,
11466 column,
11467 align: effectiveAlign
11468 }
11469 )
11470 },
11471 column
11472 );
11473 }),
11474 !!actions?.length && // Disable reason: we are not making the element interactive,
11475 // but preventing any click events from bubbling up to the
11476 // table row. This allows us to add a click handler to the row
11477 // itself (to toggle row selection) without erroneously
11478 // intercepting click events from ItemActions.
11479 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11480 "td",
11481 {
11482 className: clsx_default("dataviews-view-table__actions-column", {
11483 "dataviews-view-table__actions-column--sticky": true,
11484 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
11485 }),
11486 onClick: (e2) => e2.stopPropagation(),
11487 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(ItemActions, { item, actions })
11488 }
11489 )
11490 ]
11491 }
11492 );
11493 }
11494 function ViewTable({
11495 actions,
11496 data,
11497 fields,
11498 getItemId,
11499 getItemLevel,
11500 isLoading = false,
11501 onChangeView,
11502 onChangeSelection,
11503 selection,
11504 setOpenedFilter,
11505 onClickItem,
11506 isItemClickable: isItemClickable2,
11507 renderItemLink,
11508 view,
11509 className,
11510 empty
11511 }) {
11512 const { containerRef } = (0, import_element24.useContext)(dataviews_context_default);
11513 const isDelayedLoading = useDelayedLoading(isLoading);
11514 const headerMenuRefs = (0, import_element24.useRef)(/* @__PURE__ */ new Map());
11515 const headerMenuToFocusRef = (0, import_element24.useRef)(void 0);
11516 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element24.useState)();
11517 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element24.useState)(null);
11518 (0, import_element24.useEffect)(() => {
11519 if (headerMenuToFocusRef.current) {
11520 headerMenuToFocusRef.current.focus();
11521 headerMenuToFocusRef.current = void 0;
11522 }
11523 });
11524 const tableNoticeId = (0, import_element24.useId)();
11525 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
11526 scrollContainerRef: containerRef,
11527 enabledHorizontal: !!actions?.length
11528 });
11529 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
11530 if (nextHeaderMenuToFocus) {
11531 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
11532 setNextHeaderMenuToFocus(void 0);
11533 return;
11534 }
11535 const onHide = (field) => {
11536 const hidden = headerMenuRefs.current.get(field.id);
11537 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
11538 setNextHeaderMenuToFocus(fallback?.node);
11539 };
11540 const handleHeaderContextMenu = (event) => {
11541 event.preventDefault();
11542 event.stopPropagation();
11543 const virtualAnchor = {
11544 getBoundingClientRect: () => ({
11545 x: event.clientX,
11546 y: event.clientY,
11547 top: event.clientY,
11548 left: event.clientX,
11549 right: event.clientX,
11550 bottom: event.clientY,
11551 width: 0,
11552 height: 0,
11553 toJSON: () => ({})
11554 })
11555 };
11556 window.requestAnimationFrame(() => {
11557 setContextMenuAnchor(virtualAnchor);
11558 });
11559 };
11560 const hasData = !!data?.length;
11561 const titleField = fields.find((field) => field.id === view.titleField);
11562 const mediaField = fields.find((field) => field.id === view.mediaField);
11563 const descriptionField2 = fields.find(
11564 (field) => field.id === view.descriptionField
11565 );
11566 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
11567 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
11568 const { showTitle = true, showMedia = true, showDescription = true } = view;
11569 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
11570 const columns = view.fields ?? [];
11571 const headerMenuRef = (column, index2) => (node) => {
11572 if (node) {
11573 headerMenuRefs.current.set(column, {
11574 node,
11575 fallback: columns[index2 > 0 ? index2 - 1 : 1]
11576 });
11577 } else {
11578 headerMenuRefs.current.delete(column);
11579 }
11580 };
11581 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
11582 const isRtl = (0, import_i18n15.isRTL)();
11583 if (!hasData) {
11584 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11585 "div",
11586 {
11587 className: clsx_default("dataviews-no-results", {
11588 "is-refreshing": isDelayedLoading
11589 }),
11590 id: tableNoticeId,
11591 children: empty
11592 }
11593 );
11594 }
11595 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_jsx_runtime54.Fragment, { children: [
11596 /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
11597 "table",
11598 {
11599 className: clsx_default("dataviews-view-table", className, {
11600 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
11601 view.layout.density
11602 ),
11603 "has-bulk-actions": hasBulkActions,
11604 "is-refreshing": !isInfiniteScroll && isDelayedLoading
11605 }),
11606 "aria-busy": isLoading,
11607 "aria-describedby": tableNoticeId,
11608 role: isInfiniteScroll ? "feed" : void 0,
11609 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
11610 children: [
11611 /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("colgroup", { children: [
11612 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
11613 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
11614 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11615 "col",
11616 {
11617 className: clsx_default(
11618 `dataviews-view-table__col-${column}`,
11619 {
11620 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
11621 }
11622 )
11623 },
11624 `col-${column}`
11625 )),
11626 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("col", { className: "dataviews-view-table__col-actions" })
11627 ] }),
11628 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11629 import_components6.Popover,
11630 {
11631 anchor: contextMenuAnchor,
11632 onClose: () => setContextMenuAnchor(null),
11633 placement: "bottom-start",
11634 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(PropertiesSection, { showLabel: false })
11635 }
11636 ),
11637 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11638 "thead",
11639 {
11640 className: clsx_default({
11641 "dataviews-view-table__thead--stuck": isVerticallyScrolled
11642 }),
11643 onContextMenu: handleHeaderContextMenu,
11644 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("tr", { className: "dataviews-view-table__row", children: [
11645 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11646 "th",
11647 {
11648 className: "dataviews-view-table__checkbox-column",
11649 scope: "col",
11650 onContextMenu: handleHeaderContextMenu,
11651 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11652 BulkSelectionCheckbox,
11653 {
11654 selection,
11655 onChangeSelection,
11656 data,
11657 actions,
11658 getItemId
11659 }
11660 )
11661 }
11662 ),
11663 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11664 column_header_menu_default,
11665 {
11666 ref: headerMenuRef(
11667 titleField.id,
11668 0
11669 ),
11670 fieldId: titleField.id,
11671 view,
11672 fields,
11673 onChangeView,
11674 onHide,
11675 setOpenedFilter,
11676 canMove: false,
11677 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
11678 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
11679 }
11680 ) }),
11681 columns.map((column, index2) => {
11682 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
11683 const field = fields.find(
11684 (f2) => f2.id === column
11685 );
11686 const effectiveAlign = getEffectiveAlign(
11687 align,
11688 field?.type
11689 );
11690 const canInsertOrMove = view.layout?.enableMoving ?? true;
11691 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11692 "th",
11693 {
11694 style: {
11695 width,
11696 maxWidth,
11697 minWidth,
11698 textAlign: effectiveAlign
11699 },
11700 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
11701 scope: "col",
11702 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11703 column_header_menu_default,
11704 {
11705 ref: headerMenuRef(column, index2),
11706 fieldId: column,
11707 view,
11708 fields,
11709 onChangeView,
11710 onHide,
11711 setOpenedFilter,
11712 canMove: canInsertOrMove,
11713 canInsertLeft: canInsertOrMove,
11714 canInsertRight: canInsertOrMove
11715 }
11716 )
11717 },
11718 column
11719 );
11720 }),
11721 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11722 "th",
11723 {
11724 className: clsx_default(
11725 "dataviews-view-table__actions-column",
11726 {
11727 "dataviews-view-table__actions-column--sticky": true,
11728 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
11729 }
11730 ),
11731 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n15.__)("Actions") })
11732 }
11733 )
11734 ] })
11735 }
11736 ),
11737 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
11738 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("tbody", { children: [
11739 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11740 "td",
11741 {
11742 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
11743 className: "dataviews-view-table__group-header-cell",
11744 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n15.sprintf)(
11745 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
11746 (0, import_i18n15.__)("%1$s: %2$s"),
11747 groupField.label,
11748 groupName
11749 )
11750 }
11751 ) }),
11752 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11753 TableRow,
11754 {
11755 item,
11756 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
11757 hasBulkActions,
11758 actions,
11759 fields,
11760 id: getItemId(item) || index2.toString(),
11761 view,
11762 titleField,
11763 mediaField,
11764 descriptionField: descriptionField2,
11765 selection,
11766 getItemId,
11767 onChangeSelection,
11768 onClickItem,
11769 renderItemLink,
11770 isItemClickable: isItemClickable2,
11771 isActionsColumnSticky: !isHorizontalScrollEnd
11772 },
11773 getItemId(item)
11774 ))
11775 ] }, `group-${groupName}`)
11776 ) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("tbody", { children: hasData && data.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11777 TableRow,
11778 {
11779 item,
11780 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
11781 hasBulkActions,
11782 actions,
11783 fields,
11784 id: getItemId(item) || index2.toString(),
11785 view,
11786 titleField,
11787 mediaField,
11788 descriptionField: descriptionField2,
11789 selection,
11790 getItemId,
11791 onChangeSelection,
11792 onClickItem,
11793 renderItemLink,
11794 isItemClickable: isItemClickable2,
11795 isActionsColumnSticky: !isHorizontalScrollEnd,
11796 posinset: isInfiniteScroll ? index2 + 1 : void 0
11797 },
11798 getItemId(item)
11799 )) })
11800 ]
11801 }
11802 ),
11803 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components6.Spinner, {}) }) })
11804 ] });
11805 }
11806 var table_default = ViewTable;
11807
11808 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
11809 var import_components9 = __toESM(require_components(), 1);
11810 var import_i18n18 = __toESM(require_i18n(), 1);
11811
11812 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
11813 var import_components8 = __toESM(require_components(), 1);
11814 var import_i18n17 = __toESM(require_i18n(), 1);
11815 var import_compose3 = __toESM(require_compose(), 1);
11816 var import_keycodes2 = __toESM(require_keycodes(), 1);
11817 var import_element28 = __toESM(require_element(), 1);
11818
11819 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
11820 var import_components7 = __toESM(require_components(), 1);
11821 var import_i18n16 = __toESM(require_i18n(), 1);
11822 var import_element25 = __toESM(require_element(), 1);
11823 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
11824 var imageSizes = [
11825 {
11826 value: 120,
11827 breakpoint: 1
11828 },
11829 {
11830 value: 170,
11831 breakpoint: 1
11832 },
11833 {
11834 value: 230,
11835 breakpoint: 1
11836 },
11837 {
11838 value: 290,
11839 breakpoint: 1112
11840 // at minimum image width, 4 images display at this container size
11841 },
11842 {
11843 value: 350,
11844 breakpoint: 1636
11845 // at minimum image width, 6 images display at this container size
11846 },
11847 {
11848 value: 430,
11849 breakpoint: 588
11850 // at minimum image width, 2 images display at this container size
11851 }
11852 ];
11853 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
11854 function useGridColumns() {
11855 const context = (0, import_element25.useContext)(dataviews_context_default);
11856 const view = context.view;
11857 return (0, import_element25.useMemo)(() => {
11858 const containerWidth = context.containerWidth;
11859 const gap = 32;
11860 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
11861 const columns = Math.floor(
11862 (containerWidth + gap) / (previewSize + gap)
11863 );
11864 return Math.max(1, columns);
11865 }, [context.containerWidth, view.layout?.previewSize]);
11866 }
11867
11868 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
11869 var import_element26 = __toESM(require_element(), 1);
11870 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
11871 var GridItems = (0, import_element26.forwardRef)(({ className, previewSize, ...props }, ref) => {
11872 return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
11873 "div",
11874 {
11875 ref,
11876 className: clsx_default("dataviews-view-grid-items", className),
11877 style: {
11878 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
11879 },
11880 ...props
11881 }
11882 );
11883 });
11884
11885 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
11886 var import_element27 = __toESM(require_element(), 1);
11887 function useIntersectionObserver(elementRef, posinset) {
11888 const { intersectionObserver } = (0, import_element27.useContext)(dataviews_context_default);
11889 (0, import_element27.useEffect)(() => {
11890 const element = elementRef.current;
11891 if (!element || posinset === void 0 || !intersectionObserver) {
11892 return;
11893 }
11894 intersectionObserver.observe(element);
11895 return () => {
11896 intersectionObserver.unobserve(element);
11897 };
11898 }, [elementRef, intersectionObserver, posinset]);
11899 }
11900 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
11901 const hasData = !!data?.length;
11902 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
11903 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
11904 }
11905
11906 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
11907 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
11908 var { Badge: WCBadge } = unlock2(import_components8.privateApis);
11909 function chunk(array, size4) {
11910 const chunks = [];
11911 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
11912 chunks.push(array.slice(i2, i2 + size4));
11913 }
11914 return chunks;
11915 }
11916 var GridItem = (0, import_element28.forwardRef)(
11917 function GridItem2({
11918 view,
11919 selection,
11920 onChangeSelection,
11921 onClickItem,
11922 isItemClickable: isItemClickable2,
11923 renderItemLink,
11924 getItemId,
11925 item,
11926 actions,
11927 mediaField,
11928 titleField,
11929 descriptionField: descriptionField2,
11930 regularFields,
11931 badgeFields,
11932 hasBulkActions,
11933 config,
11934 posinset,
11935 setsize,
11936 ...props
11937 }, forwardedRef) {
11938 const {
11939 showTitle = true,
11940 showMedia = true,
11941 showDescription = true
11942 } = view;
11943 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
11944 const id = getItemId(item);
11945 const elementRef = (0, import_element28.useRef)(null);
11946 const setRefs = (0, import_element28.useCallback)(
11947 (node) => {
11948 elementRef.current = node;
11949 if (typeof forwardedRef === "function") {
11950 forwardedRef(node);
11951 } else if (forwardedRef) {
11952 forwardedRef.current = node;
11953 }
11954 },
11955 [forwardedRef]
11956 );
11957 useIntersectionObserver(elementRef, posinset);
11958 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
11959 const isSelected2 = selection.includes(id);
11960 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
11961 const rendersMediaField = showMedia && mediaField?.render;
11962 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
11963 mediaField.render,
11964 {
11965 item,
11966 field: mediaField,
11967 config
11968 }
11969 ) : mediaPlaceholder;
11970 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(titleField.render, { item, field: titleField }) : null;
11971 let mediaA11yProps;
11972 let titleA11yProps;
11973 if (isItemClickable2(item) && onClickItem) {
11974 if (renderedTitleField) {
11975 mediaA11yProps = {
11976 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
11977 };
11978 titleA11yProps = {
11979 id: `dataviews-view-grid__title-field-${instanceId}`
11980 };
11981 } else {
11982 mediaA11yProps = {
11983 "aria-label": (0, import_i18n17.__)("Navigate to item")
11984 };
11985 }
11986 }
11987 return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
11988 Stack,
11989 {
11990 direction: "column",
11991 ...props,
11992 ref: setRefs,
11993 "aria-setsize": setsize,
11994 "aria-posinset": posinset,
11995 className: clsx_default(
11996 props.className,
11997 "dataviews-view-grid__row__gridcell",
11998 "dataviews-view-grid__card",
11999 {
12000 "is-selected": hasBulkAction && isSelected2
12001 }
12002 ),
12003 onClickCapture: (event) => {
12004 props.onClickCapture?.(event);
12005 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
12006 event.stopPropagation();
12007 event.preventDefault();
12008 if (!hasBulkAction) {
12009 return;
12010 }
12011 onChangeSelection(
12012 isSelected2 ? selection.filter(
12013 (itemId) => id !== itemId
12014 ) : [...selection, id]
12015 );
12016 }
12017 },
12018 children: [
12019 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12020 ItemClickWrapper,
12021 {
12022 item,
12023 isItemClickable: isItemClickable2,
12024 onClickItem,
12025 renderItemLink,
12026 className: clsx_default("dataviews-view-grid__media", {
12027 "dataviews-view-grid__media--placeholder": !rendersMediaField
12028 }),
12029 ...mediaA11yProps,
12030 children: renderedMediaField
12031 }
12032 ),
12033 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12034 DataViewsSelectionCheckbox,
12035 {
12036 item,
12037 selection,
12038 onChangeSelection,
12039 getItemId,
12040 titleField,
12041 disabled: !hasBulkAction
12042 }
12043 ),
12044 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12045 ItemActions,
12046 {
12047 item,
12048 actions,
12049 isCompact: true
12050 }
12051 ) }),
12052 showTitle && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12053 ItemClickWrapper,
12054 {
12055 item,
12056 isItemClickable: isItemClickable2,
12057 onClickItem,
12058 renderItemLink,
12059 className: "dataviews-view-grid__title-field dataviews-title-field",
12060 ...titleA11yProps,
12061 title: titleField?.getValueFormatted({
12062 item,
12063 field: titleField
12064 }) || void 0,
12065 children: renderedTitleField
12066 }
12067 ) }),
12068 /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(Stack, { direction: "column", gap: "xs", children: [
12069 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12070 descriptionField2.render,
12071 {
12072 item,
12073 field: descriptionField2
12074 }
12075 ),
12076 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12077 Stack,
12078 {
12079 direction: "row",
12080 className: "dataviews-view-grid__badge-fields",
12081 gap: "sm",
12082 wrap: "wrap",
12083 align: "top",
12084 justify: "flex-start",
12085 children: badgeFields.map((field) => {
12086 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12087 WCBadge,
12088 {
12089 className: "dataviews-view-grid__field-value",
12090 children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12091 field.render,
12092 {
12093 item,
12094 field
12095 }
12096 )
12097 },
12098 field.id
12099 );
12100 })
12101 }
12102 ),
12103 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12104 Stack,
12105 {
12106 direction: "column",
12107 className: "dataviews-view-grid__fields",
12108 gap: "xs",
12109 children: regularFields.map((field) => {
12110 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12111 import_components8.Flex,
12112 {
12113 className: "dataviews-view-grid__field",
12114 gap: 1,
12115 justify: "flex-start",
12116 expanded: true,
12117 style: { height: "auto" },
12118 direction: "row",
12119 children: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, { children: [
12120 /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(tooltip_exports.Root, { children: [
12121 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12122 tooltip_exports.Trigger,
12123 {
12124 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
12125 }
12126 ),
12127 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(tooltip_exports.Popup, { children: field.label })
12128 ] }),
12129 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12130 import_components8.FlexItem,
12131 {
12132 className: "dataviews-view-grid__field-value",
12133 style: { maxHeight: "none" },
12134 children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12135 field.render,
12136 {
12137 item,
12138 field
12139 }
12140 )
12141 }
12142 )
12143 ] })
12144 },
12145 field.id
12146 );
12147 })
12148 }
12149 )
12150 ] })
12151 ]
12152 }
12153 );
12154 }
12155 );
12156 function CompositeGrid({
12157 data,
12158 isInfiniteScroll,
12159 className,
12160 inert,
12161 isLoading,
12162 view,
12163 fields,
12164 selection,
12165 onChangeSelection,
12166 onClickItem,
12167 isItemClickable: isItemClickable2,
12168 renderItemLink,
12169 getItemId,
12170 actions
12171 }) {
12172 const { paginationInfo, resizeObserverRef } = (0, import_element28.useContext)(dataviews_context_default);
12173 const gridColumns = useGridColumns();
12174 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12175 const titleField = fields.find(
12176 (field) => field.id === view?.titleField
12177 );
12178 const mediaField = fields.find(
12179 (field) => field.id === view?.mediaField
12180 );
12181 const descriptionField2 = fields.find(
12182 (field) => field.id === view?.descriptionField
12183 );
12184 const otherFields = view.fields ?? [];
12185 const { regularFields, badgeFields } = otherFields.reduce(
12186 (accumulator, fieldId) => {
12187 const field = fields.find((f2) => f2.id === fieldId);
12188 if (!field) {
12189 return accumulator;
12190 }
12191 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
12192 accumulator[key].push(field);
12193 return accumulator;
12194 },
12195 { regularFields: [], badgeFields: [] }
12196 );
12197 const size4 = "900px";
12198 const totalRows = Math.ceil(data.length / gridColumns);
12199 const placeholdersNeeded = usePlaceholdersNeeded(
12200 data,
12201 isInfiniteScroll,
12202 gridColumns
12203 );
12204 return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, {
12205 // Render infinite scroll layout (no rows, feed semantics)
12206 children: [
12207 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
12208 import_components8.Composite,
12209 {
12210 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12211 GridItems,
12212 {
12213 className: clsx_default(
12214 "dataviews-view-grid-infinite-scroll",
12215 className,
12216 {
12217 [`has-${view.layout?.density}-density`]: view.layout?.density && [
12218 "compact",
12219 "comfortable"
12220 ].includes(view.layout.density)
12221 }
12222 ),
12223 previewSize: view.layout?.previewSize,
12224 "aria-busy": isLoading,
12225 ref: resizeObserverRef
12226 }
12227 ),
12228 role: "feed",
12229 focusWrap: true,
12230 inert,
12231 children: [
12232 Array.from({ length: placeholdersNeeded }).map(
12233 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12234 import_components8.Composite.Item,
12235 {
12236 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12237 Stack,
12238 {
12239 ...props,
12240 direction: "column",
12241 role: "article",
12242 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
12243 }
12244 ),
12245 "aria-hidden": true,
12246 tabIndex: -1
12247 },
12248 `placeholder-${index2}`
12249 )
12250 ),
12251 data.map((item) => {
12252 const itemId = getItemId(item);
12253 const stablePosition = item.position;
12254 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12255 import_components8.Composite.Item,
12256 {
12257 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12258 GridItem,
12259 {
12260 ...props,
12261 id: itemId,
12262 role: "article",
12263 view,
12264 selection,
12265 onChangeSelection,
12266 onClickItem,
12267 isItemClickable: isItemClickable2,
12268 renderItemLink,
12269 getItemId,
12270 item,
12271 actions,
12272 mediaField,
12273 titleField,
12274 descriptionField: descriptionField2,
12275 regularFields,
12276 badgeFields,
12277 hasBulkActions,
12278 posinset: stablePosition,
12279 setsize: paginationInfo.totalItems,
12280 config: {
12281 sizes: size4
12282 }
12283 }
12284 )
12285 },
12286 itemId
12287 );
12288 })
12289 ]
12290 }
12291 ),
12292 // Render standard grid layout (with rows, grid semantics)
12293 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12294 import_components8.Composite,
12295 {
12296 role: "grid",
12297 className: clsx_default("dataviews-view-grid", className, {
12298 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12299 view.layout.density
12300 )
12301 }),
12302 focusWrap: true,
12303 "aria-busy": isLoading,
12304 "aria-rowcount": totalRows,
12305 ref: resizeObserverRef,
12306 inert,
12307 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12308 import_components8.Composite.Row,
12309 {
12310 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12311 "div",
12312 {
12313 role: "row",
12314 "aria-rowindex": i2 + 1,
12315 "aria-label": (0, import_i18n17.sprintf)(
12316 /* translators: %d: The row number in the grid */
12317 (0, import_i18n17.__)("Row %d"),
12318 i2 + 1
12319 ),
12320 className: "dataviews-view-grid__row",
12321 style: {
12322 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
12323 }
12324 }
12325 ),
12326 children: row.map((item) => {
12327 const itemId = getItemId(item);
12328 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12329 import_components8.Composite.Item,
12330 {
12331 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12332 GridItem,
12333 {
12334 ...props,
12335 id: itemId,
12336 role: "gridcell",
12337 view,
12338 selection,
12339 onChangeSelection,
12340 onClickItem,
12341 isItemClickable: isItemClickable2,
12342 renderItemLink,
12343 getItemId,
12344 item,
12345 actions,
12346 mediaField,
12347 titleField,
12348 descriptionField: descriptionField2,
12349 regularFields,
12350 badgeFields,
12351 hasBulkActions,
12352 config: {
12353 sizes: size4
12354 }
12355 }
12356 )
12357 },
12358 itemId
12359 );
12360 })
12361 },
12362 i2
12363 ))
12364 }
12365 )
12366 ]
12367 });
12368 }
12369
12370 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12371 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
12372 function ViewGrid({
12373 actions,
12374 data,
12375 fields,
12376 getItemId,
12377 isLoading,
12378 onChangeSelection,
12379 onClickItem,
12380 isItemClickable: isItemClickable2,
12381 renderItemLink,
12382 selection,
12383 view,
12384 className,
12385 empty
12386 }) {
12387 const isDelayedLoading = useDelayedLoading(!!isLoading);
12388 const hasData = !!data?.length;
12389 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12390 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12391 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12392 if (!hasData) {
12393 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12394 "div",
12395 {
12396 className: clsx_default("dataviews-no-results", {
12397 "is-refreshing": isDelayedLoading
12398 }),
12399 children: empty
12400 }
12401 );
12402 }
12403 const gridProps = {
12404 className: clsx_default(className, {
12405 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12406 }),
12407 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
12408 isLoading,
12409 view,
12410 fields,
12411 selection,
12412 onChangeSelection,
12413 onClickItem,
12414 isItemClickable: isItemClickable2,
12415 renderItemLink,
12416 getItemId,
12417 actions
12418 };
12419 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, {
12420 // Render multiple groups.
12421 children: [
12422 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
12423 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12424 Stack,
12425 {
12426 direction: "column",
12427 gap: "sm",
12428 children: [
12429 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n18.sprintf)(
12430 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12431 (0, import_i18n18.__)("%1$s: %2$s"),
12432 groupField.label,
12433 groupName
12434 ) }),
12435 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12436 CompositeGrid,
12437 {
12438 ...gridProps,
12439 data: groupItems,
12440 isInfiniteScroll: false
12441 }
12442 )
12443 ]
12444 },
12445 groupName
12446 )
12447 ) }),
12448 // Render a single grid with all data.
12449 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12450 CompositeGrid,
12451 {
12452 ...gridProps,
12453 data,
12454 isInfiniteScroll: !!isInfiniteScroll
12455 }
12456 ),
12457 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components9.Spinner, {}) })
12458 ]
12459 });
12460 }
12461 var grid_default = ViewGrid;
12462
12463 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
12464 var import_compose4 = __toESM(require_compose(), 1);
12465 var import_components10 = __toESM(require_components(), 1);
12466 var import_element29 = __toESM(require_element(), 1);
12467 var import_i18n19 = __toESM(require_i18n(), 1);
12468 var import_data3 = __toESM(require_data(), 1);
12469 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
12470 var { Menu: Menu3 } = unlock2(import_components10.privateApis);
12471 function generateItemWrapperCompositeId(idPrefix) {
12472 return `${idPrefix}-item-wrapper`;
12473 }
12474 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
12475 return `${idPrefix}-primary-action-${primaryActionId}`;
12476 }
12477 function generateDropdownTriggerCompositeId(idPrefix) {
12478 return `${idPrefix}-dropdown`;
12479 }
12480 function PrimaryActionGridCell({
12481 idPrefix,
12482 primaryAction,
12483 item
12484 }) {
12485 const registry = (0, import_data3.useRegistry)();
12486 const [isModalOpen, setIsModalOpen] = (0, import_element29.useState)(false);
12487 const compositeItemId = generatePrimaryActionCompositeId(
12488 idPrefix,
12489 primaryAction.id
12490 );
12491 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
12492 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12493 import_components10.Composite.Item,
12494 {
12495 id: compositeItemId,
12496 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12497 import_components10.Button,
12498 {
12499 disabled: !!primaryAction.disabled,
12500 accessibleWhenDisabled: true,
12501 text: label,
12502 size: "small",
12503 onClick: () => setIsModalOpen(true)
12504 }
12505 ),
12506 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12507 ActionModal,
12508 {
12509 action: primaryAction,
12510 items: [item],
12511 closeModal: () => setIsModalOpen(false)
12512 }
12513 )
12514 }
12515 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12516 import_components10.Composite.Item,
12517 {
12518 id: compositeItemId,
12519 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12520 import_components10.Button,
12521 {
12522 disabled: !!primaryAction.disabled,
12523 accessibleWhenDisabled: true,
12524 size: "small",
12525 onClick: () => {
12526 primaryAction.callback([item], { registry });
12527 },
12528 children: label
12529 }
12530 )
12531 }
12532 ) }, primaryAction.id);
12533 }
12534 function ListItem({
12535 view,
12536 actions,
12537 idPrefix,
12538 isSelected: isSelected2,
12539 item,
12540 titleField,
12541 mediaField,
12542 descriptionField: descriptionField2,
12543 onSelect,
12544 otherFields,
12545 onDropdownTriggerKeyDown,
12546 posinset
12547 }) {
12548 const {
12549 showTitle = true,
12550 showMedia = true,
12551 showDescription = true,
12552 infiniteScrollEnabled
12553 } = view;
12554 const itemRef = (0, import_element29.useRef)(null);
12555 const labelId = `${idPrefix}-label`;
12556 const descriptionId = `${idPrefix}-description`;
12557 const registry = (0, import_data3.useRegistry)();
12558 const [isHovered, setIsHovered] = (0, import_element29.useState)(false);
12559 const [activeModalAction, setActiveModalAction] = (0, import_element29.useState)(
12560 null
12561 );
12562 const handleHover = ({ type }) => {
12563 const isHover = type === "mouseenter";
12564 setIsHovered(isHover);
12565 };
12566 const { paginationInfo } = (0, import_element29.useContext)(dataviews_context_default);
12567 (0, import_element29.useEffect)(() => {
12568 if (isSelected2) {
12569 itemRef.current?.scrollIntoView({
12570 behavior: "auto",
12571 block: "nearest",
12572 inline: "nearest"
12573 });
12574 }
12575 }, [isSelected2]);
12576 const { primaryAction, eligibleActions } = (0, import_element29.useMemo)(() => {
12577 const _eligibleActions = actions.filter(
12578 (action) => !action.isEligible || action.isEligible(item)
12579 );
12580 const _primaryActions = _eligibleActions.filter(
12581 (action) => action.isPrimary
12582 );
12583 return {
12584 primaryAction: _primaryActions[0],
12585 eligibleActions: _eligibleActions
12586 };
12587 }, [actions, item]);
12588 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
12589 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12590 mediaField.render,
12591 {
12592 item,
12593 field: mediaField,
12594 config: { sizes: "52px" }
12595 }
12596 ) }) : null;
12597 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(titleField.render, { item, field: titleField }) : null;
12598 const renderDescription = showDescription && descriptionField2?.render;
12599 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
12600 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
12601 Stack,
12602 {
12603 direction: "row",
12604 gap: "md",
12605 className: "dataviews-view-list__item-actions",
12606 children: [
12607 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12608 PrimaryActionGridCell,
12609 {
12610 idPrefix,
12611 primaryAction,
12612 item
12613 }
12614 ),
12615 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { role: "gridcell", children: [
12616 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(Menu3, { placement: "bottom-end", children: [
12617 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12618 Menu3.TriggerButton,
12619 {
12620 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12621 import_components10.Composite.Item,
12622 {
12623 id: generateDropdownTriggerCompositeId(
12624 idPrefix
12625 ),
12626 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12627 import_components10.Button,
12628 {
12629 size: "small",
12630 icon: more_vertical_default,
12631 label: (0, import_i18n19.__)("Actions"),
12632 accessibleWhenDisabled: true,
12633 disabled: !actions.length,
12634 onKeyDown: onDropdownTriggerKeyDown
12635 }
12636 )
12637 }
12638 )
12639 }
12640 ),
12641 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12642 ActionsMenuGroup,
12643 {
12644 actions: eligibleActions,
12645 item,
12646 registry,
12647 setActiveModalAction
12648 }
12649 ) })
12650 ] }),
12651 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12652 ActionModal,
12653 {
12654 action: activeModalAction,
12655 items: [item],
12656 closeModal: () => setActiveModalAction(null)
12657 }
12658 )
12659 ] })
12660 ]
12661 }
12662 );
12663 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12664 import_components10.Composite.Row,
12665 {
12666 ref: itemRef,
12667 render: (
12668 /* aria-posinset breaks Composite.Row if passed to it directly. */
12669 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12670 "div",
12671 {
12672 "aria-posinset": posinset,
12673 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
12674 }
12675 )
12676 ),
12677 role: infiniteScrollEnabled ? "article" : "row",
12678 className: clsx_default({
12679 "is-selected": isSelected2,
12680 "is-hovered": isHovered
12681 }),
12682 onMouseEnter: handleHover,
12683 onMouseLeave: handleHover,
12684 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
12685 Stack,
12686 {
12687 direction: "row",
12688 className: "dataviews-view-list__item-wrapper",
12689 children: [
12690 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12691 import_components10.Composite.Item,
12692 {
12693 id: generateItemWrapperCompositeId(idPrefix),
12694 "aria-pressed": isSelected2,
12695 "aria-labelledby": labelId,
12696 "aria-describedby": descriptionId,
12697 className: "dataviews-view-list__item",
12698 onClick: () => onSelect(item)
12699 }
12700 ) }),
12701 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
12702 Stack,
12703 {
12704 direction: "row",
12705 gap: "md",
12706 justify: "start",
12707 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
12708 style: { flex: 1, minWidth: 0 },
12709 children: [
12710 renderedMediaField,
12711 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
12712 Stack,
12713 {
12714 direction: "column",
12715 gap: "xs",
12716 className: "dataviews-view-list__field-wrapper",
12717 children: [
12718 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(Stack, { direction: "row", align: "center", children: [
12719 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12720 "div",
12721 {
12722 className: "dataviews-title-field dataviews-view-list__title-field",
12723 id: labelId,
12724 children: renderedTitleField
12725 }
12726 ),
12727 usedActions
12728 ] }),
12729 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12730 descriptionField2.render,
12731 {
12732 item,
12733 field: descriptionField2
12734 }
12735 ) }),
12736 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12737 "div",
12738 {
12739 className: "dataviews-view-list__fields",
12740 id: descriptionId,
12741 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
12742 "div",
12743 {
12744 className: "dataviews-view-list__field",
12745 children: [
12746 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12747 VisuallyHidden,
12748 {
12749 className: "dataviews-view-list__field-label",
12750 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", {}),
12751 children: field.label
12752 }
12753 ),
12754 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12755 field.render,
12756 {
12757 item,
12758 field
12759 }
12760 ) })
12761 ]
12762 },
12763 field.id
12764 ))
12765 }
12766 )
12767 ]
12768 }
12769 )
12770 ]
12771 }
12772 )
12773 ]
12774 }
12775 )
12776 }
12777 );
12778 }
12779 function isDefined2(item) {
12780 return !!item;
12781 }
12782 function ViewList(props) {
12783 const {
12784 actions,
12785 data,
12786 fields,
12787 getItemId,
12788 isLoading,
12789 onChangeSelection,
12790 selection,
12791 view,
12792 className,
12793 empty
12794 } = props;
12795 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
12796 const isDelayedLoading = useDelayedLoading(!!isLoading);
12797 const selectedItem = data?.findLast(
12798 (item) => selection.includes(getItemId(item))
12799 );
12800 const titleField = fields.find((field) => field.id === view.titleField);
12801 const mediaField = fields.find((field) => field.id === view.mediaField);
12802 const descriptionField2 = fields.find(
12803 (field) => field.id === view.descriptionField
12804 );
12805 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
12806 const onSelect = (item) => onChangeSelection([getItemId(item)]);
12807 const generateCompositeItemIdPrefix = (0, import_element29.useCallback)(
12808 (item) => `${baseId}-${getItemId(item)}`,
12809 [baseId, getItemId]
12810 );
12811 const isActiveCompositeItem = (0, import_element29.useCallback)(
12812 (item, idToCheck) => {
12813 return idToCheck.startsWith(
12814 generateCompositeItemIdPrefix(item)
12815 );
12816 },
12817 [generateCompositeItemIdPrefix]
12818 );
12819 const [activeCompositeId, setActiveCompositeId] = (0, import_element29.useState)(void 0);
12820 const compositeRef = (0, import_element29.useRef)(null);
12821 (0, import_element29.useEffect)(() => {
12822 if (selectedItem) {
12823 setActiveCompositeId(
12824 generateItemWrapperCompositeId(
12825 generateCompositeItemIdPrefix(selectedItem)
12826 )
12827 );
12828 }
12829 }, [selectedItem, generateCompositeItemIdPrefix]);
12830 const activeItemIndex = data.findIndex(
12831 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
12832 );
12833 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
12834 const isActiveIdInList = activeItemIndex !== -1;
12835 const selectCompositeItem = (0, import_element29.useCallback)(
12836 (targetIndex, generateCompositeId) => {
12837 const clampedIndex = Math.min(
12838 data.length - 1,
12839 Math.max(0, targetIndex)
12840 );
12841 if (!data[clampedIndex]) {
12842 return;
12843 }
12844 const itemIdPrefix = generateCompositeItemIdPrefix(
12845 data[clampedIndex]
12846 );
12847 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
12848 setActiveCompositeId(targetCompositeItemId);
12849 if (compositeRef.current?.contains(
12850 compositeRef.current.ownerDocument.activeElement
12851 )) {
12852 document.getElementById(targetCompositeItemId)?.focus();
12853 }
12854 },
12855 [data, generateCompositeItemIdPrefix]
12856 );
12857 (0, import_element29.useEffect)(() => {
12858 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
12859 if (!isActiveIdInList && wasActiveIdInList) {
12860 selectCompositeItem(
12861 previousActiveItemIndex,
12862 generateItemWrapperCompositeId
12863 );
12864 }
12865 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
12866 const onDropdownTriggerKeyDown = (0, import_element29.useCallback)(
12867 (event) => {
12868 if (event.key === "ArrowDown") {
12869 event.preventDefault();
12870 selectCompositeItem(
12871 activeItemIndex + 1,
12872 generateDropdownTriggerCompositeId
12873 );
12874 }
12875 if (event.key === "ArrowUp") {
12876 event.preventDefault();
12877 selectCompositeItem(
12878 activeItemIndex - 1,
12879 generateDropdownTriggerCompositeId
12880 );
12881 }
12882 },
12883 [selectCompositeItem, activeItemIndex]
12884 );
12885 const hasData = !!data?.length;
12886 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
12887 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
12888 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12889 if (!hasData) {
12890 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12891 "div",
12892 {
12893 className: clsx_default("dataviews-no-results", {
12894 "is-refreshing": isDelayedLoading
12895 }),
12896 children: empty
12897 }
12898 );
12899 }
12900 if (hasData && groupField && dataByGroup) {
12901 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12902 import_components10.Composite,
12903 {
12904 ref: compositeRef,
12905 id: `${baseId}`,
12906 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", {}),
12907 className: "dataviews-view-list__group",
12908 role: "grid",
12909 activeId: activeCompositeId,
12910 setActiveId: setActiveCompositeId,
12911 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12912 Stack,
12913 {
12914 direction: "column",
12915 gap: "lg",
12916 className: clsx_default("dataviews-view-list", className),
12917 children: Array.from(dataByGroup.entries()).map(
12918 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
12919 Stack,
12920 {
12921 direction: "column",
12922 gap: "sm",
12923 children: [
12924 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n19.sprintf)(
12925 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12926 (0, import_i18n19.__)("%1$s: %2$s"),
12927 groupField.label,
12928 groupName
12929 ) }),
12930 groupItems.map((item) => {
12931 const id = generateCompositeItemIdPrefix(item);
12932 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12933 ListItem,
12934 {
12935 view,
12936 idPrefix: id,
12937 actions,
12938 item,
12939 isSelected: item === selectedItem,
12940 onSelect,
12941 mediaField,
12942 titleField,
12943 descriptionField: descriptionField2,
12944 otherFields,
12945 onDropdownTriggerKeyDown
12946 },
12947 id
12948 );
12949 })
12950 ]
12951 },
12952 groupName
12953 )
12954 )
12955 }
12956 )
12957 }
12958 );
12959 }
12960 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, { children: [
12961 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12962 import_components10.Composite,
12963 {
12964 ref: compositeRef,
12965 id: baseId,
12966 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", {}),
12967 className: clsx_default("dataviews-view-list", className, {
12968 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12969 view.layout.density
12970 ),
12971 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12972 }),
12973 role: view.infiniteScrollEnabled ? "feed" : "grid",
12974 activeId: activeCompositeId,
12975 setActiveId: setActiveCompositeId,
12976 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
12977 children: data.map((item, index2) => {
12978 const id = generateCompositeItemIdPrefix(item);
12979 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12980 ListItem,
12981 {
12982 view,
12983 idPrefix: id,
12984 actions,
12985 item,
12986 isSelected: item === selectedItem,
12987 onSelect,
12988 mediaField,
12989 titleField,
12990 descriptionField: descriptionField2,
12991 otherFields,
12992 onDropdownTriggerKeyDown,
12993 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
12994 },
12995 id
12996 );
12997 })
12998 }
12999 ),
13000 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components10.Spinner, {}) })
13001 ] });
13002 }
13003
13004 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13005 var import_components11 = __toESM(require_components(), 1);
13006
13007 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
13008 var import_i18n20 = __toESM(require_i18n(), 1);
13009 var import_element30 = __toESM(require_element(), 1);
13010 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
13011 function ActivityGroup({
13012 groupName,
13013 groupData,
13014 groupField,
13015 showLabel = true,
13016 children
13017 }) {
13018 const groupHeader = showLabel ? (0, import_element30.createInterpolateElement)(
13019 // translators: %s: The label of the field e.g. "Status".
13020 (0, import_i18n20.sprintf)((0, import_i18n20.__)("%s: <groupName />"), groupField.label).trim(),
13021 {
13022 groupName: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13023 groupField.render,
13024 {
13025 item: groupData[0],
13026 field: groupField
13027 }
13028 )
13029 }
13030 ) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(groupField.render, { item: groupData[0], field: groupField });
13031 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13032 Stack,
13033 {
13034 direction: "column",
13035 className: "dataviews-view-activity__group",
13036 children: [
13037 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
13038 children
13039 ]
13040 },
13041 groupName
13042 );
13043 }
13044
13045 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
13046 var import_element31 = __toESM(require_element(), 1);
13047 var import_data4 = __toESM(require_data(), 1);
13048 var import_compose5 = __toESM(require_compose(), 1);
13049 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
13050 function ActivityItem(props) {
13051 const {
13052 view,
13053 actions,
13054 item,
13055 titleField,
13056 mediaField,
13057 descriptionField: descriptionField2,
13058 otherFields,
13059 posinset,
13060 onClickItem,
13061 renderItemLink,
13062 isItemClickable: isItemClickable2
13063 } = props;
13064 const {
13065 showTitle = true,
13066 showMedia = true,
13067 showDescription = true,
13068 infiniteScrollEnabled
13069 } = view;
13070 const itemRef = (0, import_element31.useRef)(null);
13071 const registry = (0, import_data4.useRegistry)();
13072 const { paginationInfo } = (0, import_element31.useContext)(dataviews_context_default);
13073 const { primaryActions, eligibleActions } = (0, import_element31.useMemo)(() => {
13074 const _eligibleActions = actions.filter(
13075 (action) => !action.isEligible || action.isEligible(item)
13076 );
13077 const _primaryActions = _eligibleActions.filter(
13078 (action) => action.isPrimary
13079 );
13080 return {
13081 primaryActions: _primaryActions,
13082 eligibleActions: _eligibleActions
13083 };
13084 }, [actions, item]);
13085 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
13086 const density = view.layout?.density ?? "balanced";
13087 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13088 mediaField.render,
13089 {
13090 item,
13091 field: mediaField,
13092 config: {
13093 sizes: density === "comfortable" ? "32px" : "24px"
13094 }
13095 }
13096 ) : null;
13097 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13098 "span",
13099 {
13100 className: "dataviews-view-activity__item-bullet",
13101 "aria-hidden": "true"
13102 }
13103 ) });
13104 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(titleField.render, { item, field: titleField }) : null;
13105 const verticalGap = (0, import_element31.useMemo)(() => {
13106 switch (density) {
13107 case "comfortable":
13108 return "md";
13109 default:
13110 return "sm";
13111 }
13112 }, [density]);
13113 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13114 "div",
13115 {
13116 ref: itemRef,
13117 role: infiniteScrollEnabled ? "article" : void 0,
13118 "aria-posinset": posinset,
13119 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
13120 className: clsx_default(
13121 "dataviews-view-activity__item",
13122 density === "compact" && "is-compact",
13123 density === "balanced" && "is-balanced",
13124 density === "comfortable" && "is-comfortable"
13125 ),
13126 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
13127 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13128 Stack,
13129 {
13130 direction: "column",
13131 gap: "xs",
13132 align: "center",
13133 className: "dataviews-view-activity__item-type",
13134 children: renderedMediaField
13135 }
13136 ),
13137 /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
13138 Stack,
13139 {
13140 direction: "column",
13141 gap: verticalGap,
13142 align: "flex-start",
13143 className: "dataviews-view-activity__item-content",
13144 children: [
13145 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13146 ItemClickWrapper,
13147 {
13148 item,
13149 isItemClickable: isItemClickable2,
13150 onClickItem,
13151 renderItemLink,
13152 className: "dataviews-view-activity__item-title",
13153 children: renderedTitleField
13154 }
13155 ),
13156 showDescription && descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13157 descriptionField2.render,
13158 {
13159 item,
13160 field: descriptionField2
13161 }
13162 ) }),
13163 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
13164 "div",
13165 {
13166 className: "dataviews-view-activity__item-field",
13167 children: [
13168 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13169 VisuallyHidden,
13170 {
13171 className: "dataviews-view-activity__item-field-label",
13172 render: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", {}),
13173 children: field.label
13174 }
13175 ),
13176 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13177 field.render,
13178 {
13179 item,
13180 field
13181 }
13182 ) })
13183 ]
13184 },
13185 field.id
13186 )) }),
13187 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13188 PrimaryActions,
13189 {
13190 item,
13191 actions: primaryActions,
13192 registry,
13193 buttonVariant: "secondary"
13194 }
13195 )
13196 ]
13197 }
13198 ),
13199 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13200 // there if there are any actions at all.
13201 isMobileViewport && // At the same time, only show the menu if there are actions to show.
13202 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13203 ItemActions,
13204 {
13205 item,
13206 actions: eligibleActions,
13207 isCompact: true
13208 }
13209 ) })
13210 ] })
13211 }
13212 );
13213 }
13214 var activity_item_default = ActivityItem;
13215
13216 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
13217 var import_react5 = __toESM(require_react(), 1);
13218 function isDefined3(item) {
13219 return !!item;
13220 }
13221 function ActivityItems(props) {
13222 const { data, fields, getItemId, view } = props;
13223 const titleField = fields.find((field) => field.id === view.titleField);
13224 const mediaField = fields.find((field) => field.id === view.mediaField);
13225 const descriptionField2 = fields.find(
13226 (field) => field.id === view.descriptionField
13227 );
13228 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
13229 return data.map((item, index2) => {
13230 return /* @__PURE__ */ (0, import_react5.createElement)(
13231 activity_item_default,
13232 {
13233 ...props,
13234 key: getItemId(item),
13235 item,
13236 mediaField,
13237 titleField,
13238 descriptionField: descriptionField2,
13239 otherFields,
13240 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13241 }
13242 );
13243 });
13244 }
13245
13246 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13247 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
13248 function ViewActivity(props) {
13249 const { empty, data, fields, isLoading, view, className } = props;
13250 const isDelayedLoading = useDelayedLoading(!!isLoading);
13251 const hasData = !!data?.length;
13252 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13253 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13254 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13255 if (!hasData) {
13256 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13257 "div",
13258 {
13259 className: clsx_default("dataviews-no-results", {
13260 "is-refreshing": isDelayedLoading
13261 }),
13262 children: empty
13263 }
13264 );
13265 }
13266 const isInert = !isInfiniteScroll && !!isLoading;
13267 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
13268 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13269 });
13270 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
13271 if (hasData && groupField && dataByGroup) {
13272 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13273 Stack,
13274 {
13275 direction: "column",
13276 gap: "sm",
13277 className: wrapperClassName,
13278 inert: isInert ? "true" : void 0,
13279 children: groupedEntries.map(
13280 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13281 ActivityGroup,
13282 {
13283 groupName,
13284 groupData,
13285 groupField,
13286 showLabel: view.groupBy?.showLabel !== false,
13287 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13288 ActivityItems,
13289 {
13290 ...props,
13291 data: groupData
13292 }
13293 )
13294 },
13295 groupName
13296 )
13297 )
13298 }
13299 );
13300 }
13301 return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_jsx_runtime62.Fragment, { children: [
13302 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13303 "div",
13304 {
13305 className: wrapperClassName,
13306 role: view.infiniteScrollEnabled ? "feed" : void 0,
13307 inert: isInert ? "true" : void 0,
13308 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(ActivityItems, { ...props })
13309 }
13310 ),
13311 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_components11.Spinner, {}) })
13312 ] });
13313 }
13314
13315 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13316 var import_components14 = __toESM(require_components(), 1);
13317 var import_i18n23 = __toESM(require_i18n(), 1);
13318 var import_compose6 = __toESM(require_compose(), 1);
13319 var import_element34 = __toESM(require_element(), 1);
13320
13321 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13322 var import_components13 = __toESM(require_components(), 1);
13323 var import_data5 = __toESM(require_data(), 1);
13324 var import_element33 = __toESM(require_element(), 1);
13325 var import_i18n22 = __toESM(require_i18n(), 1);
13326
13327 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
13328 var import_components12 = __toESM(require_components(), 1);
13329 var import_element32 = __toESM(require_element(), 1);
13330 var import_i18n21 = __toESM(require_i18n(), 1);
13331 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
13332 function DataViewsPagination() {
13333 const {
13334 view,
13335 onChangeView,
13336 paginationInfo: { totalItems = 0, totalPages }
13337 } = (0, import_element32.useContext)(dataviews_context_default);
13338 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
13339 return null;
13340 }
13341 const currentPage = view.page ?? 1;
13342 const pageSelectOptions = Array.from(Array(totalPages)).map(
13343 (_, i2) => {
13344 const page = i2 + 1;
13345 return {
13346 value: page.toString(),
13347 label: page.toString(),
13348 "aria-label": currentPage === page ? (0, import_i18n21.sprintf)(
13349 // translators: 1: current page number. 2: total number of pages.
13350 (0, import_i18n21.__)("Page %1$d of %2$d"),
13351 currentPage,
13352 totalPages
13353 ) : page.toString()
13354 };
13355 }
13356 );
13357 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(
13358 Stack,
13359 {
13360 direction: "row",
13361 className: "dataviews-pagination",
13362 justify: "end",
13363 align: "center",
13364 gap: "xl",
13365 children: [
13366 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13367 Stack,
13368 {
13369 direction: "row",
13370 justify: "flex-start",
13371 align: "center",
13372 gap: "xs",
13373 className: "dataviews-pagination__page-select",
13374 children: (0, import_element32.createInterpolateElement)(
13375 (0, import_i18n21.sprintf)(
13376 // translators: 1: Current page number, 2: Total number of pages.
13377 (0, import_i18n21._x)(
13378 "<div>Page</div>%1$s<div>of %2$d</div>",
13379 "paging"
13380 ),
13381 "<CurrentPage />",
13382 totalPages
13383 ),
13384 {
13385 div: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { "aria-hidden": true }),
13386 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
13387 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13388 import_components12.SelectControl,
13389 {
13390 "aria-label": (0, import_i18n21.__)("Current page"),
13391 value: currentPage.toString(),
13392 options: pageSelectOptions,
13393 onChange: (newValue) => {
13394 onChangeView({
13395 ...view,
13396 page: +newValue
13397 });
13398 },
13399 size: "small",
13400 variant: "minimal"
13401 }
13402 )
13403 }
13404 )
13405 }
13406 ),
13407 /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
13408 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13409 import_components12.Button,
13410 {
13411 onClick: () => onChangeView({
13412 ...view,
13413 page: currentPage - 1
13414 }),
13415 disabled: currentPage === 1,
13416 accessibleWhenDisabled: true,
13417 label: (0, import_i18n21.__)("Previous page"),
13418 icon: (0, import_i18n21.isRTL)() ? next_default : previous_default,
13419 showTooltip: true,
13420 size: "compact",
13421 tooltipPosition: "top"
13422 }
13423 ),
13424 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13425 import_components12.Button,
13426 {
13427 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
13428 disabled: currentPage >= totalPages,
13429 accessibleWhenDisabled: true,
13430 label: (0, import_i18n21.__)("Next page"),
13431 icon: (0, import_i18n21.isRTL)() ? previous_default : next_default,
13432 showTooltip: true,
13433 size: "compact",
13434 tooltipPosition: "top"
13435 }
13436 )
13437 ] })
13438 ]
13439 }
13440 );
13441 }
13442 var dataviews_pagination_default = (0, import_element32.memo)(DataViewsPagination);
13443
13444 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13445 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
13446 var EMPTY_ARRAY2 = [];
13447 function useIsMultiselectPicker(actions) {
13448 return (0, import_element33.useMemo)(() => {
13449 return actions?.every((action) => action.supportsBulk);
13450 }, [actions]);
13451 }
13452 function BulkSelectionCheckbox2({
13453 selection,
13454 selectedItems,
13455 onChangeSelection,
13456 data,
13457 getItemId,
13458 disableSelectAll = false
13459 }) {
13460 const hasSelection = selection.length > 0;
13461 const areAllSelected = selectedItems.length === data.length;
13462 if (disableSelectAll) {
13463 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13464 import_components13.CheckboxControl,
13465 {
13466 className: "dataviews-view-table-selection-checkbox",
13467 checked: hasSelection,
13468 disabled: !hasSelection,
13469 onChange: () => {
13470 onChangeSelection([]);
13471 },
13472 "aria-label": (0, import_i18n22.__)("Deselect all")
13473 }
13474 );
13475 }
13476 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13477 import_components13.CheckboxControl,
13478 {
13479 className: "dataviews-view-table-selection-checkbox",
13480 checked: areAllSelected,
13481 indeterminate: !areAllSelected && !!selectedItems.length,
13482 onChange: () => {
13483 if (areAllSelected) {
13484 onChangeSelection(
13485 selection.filter(
13486 (id) => !data.some(
13487 (item) => id === getItemId(item)
13488 )
13489 )
13490 );
13491 } else {
13492 const selectionSet = /* @__PURE__ */ new Set([
13493 ...selection,
13494 ...data.map((item) => getItemId(item))
13495 ]);
13496 onChangeSelection(Array.from(selectionSet));
13497 }
13498 },
13499 "aria-label": areAllSelected ? (0, import_i18n22.__)("Deselect all") : (0, import_i18n22.__)("Select all")
13500 }
13501 );
13502 }
13503 function ActionButtons({
13504 actions,
13505 items,
13506 selection
13507 }) {
13508 const registry = (0, import_data5.useRegistry)();
13509 const [actionInProgress, setActionInProgress] = (0, import_element33.useState)(
13510 null
13511 );
13512 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Stack, { direction: "row", gap: "xs", children: actions.map((action) => {
13513 if (!("callback" in action)) {
13514 return null;
13515 }
13516 const { id, label, icon, isPrimary, callback } = action;
13517 const _label = typeof label === "string" ? label : label(items);
13518 const variant = isPrimary ? "primary" : "tertiary";
13519 const isInProgress = id === actionInProgress;
13520 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13521 import_components13.Button,
13522 {
13523 accessibleWhenDisabled: true,
13524 icon,
13525 disabled: isInProgress || !selection?.length,
13526 isBusy: isInProgress,
13527 onClick: async () => {
13528 setActionInProgress(id);
13529 await callback(items, {
13530 registry
13531 });
13532 setActionInProgress(null);
13533 },
13534 size: "compact",
13535 variant,
13536 children: _label
13537 },
13538 id
13539 );
13540 }) });
13541 }
13542 function DataViewsPickerFooter() {
13543 const {
13544 data,
13545 selection,
13546 onChangeSelection,
13547 getItemId,
13548 actions = EMPTY_ARRAY2,
13549 paginationInfo,
13550 view
13551 } = (0, import_element33.useContext)(dataviews_context_default);
13552 const isMultiselect = useIsMultiselectPicker(actions);
13553 const message2 = getFooterMessage(
13554 selection.length,
13555 data.length,
13556 paginationInfo.totalItems,
13557 !!view.infiniteScrollEnabled
13558 );
13559 const selectedItems = (0, import_element33.useMemo)(
13560 () => data.filter((item) => selection.includes(getItemId(item))),
13561 [selection, getItemId, data]
13562 );
13563 return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
13564 Stack,
13565 {
13566 direction: "row",
13567 justify: "space-between",
13568 align: "center",
13569 className: "dataviews-footer",
13570 gap: "sm",
13571 children: [
13572 /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
13573 Stack,
13574 {
13575 direction: "row",
13576 className: "dataviews-picker-footer__bulk-selection",
13577 gap: "md",
13578 align: "center",
13579 children: [
13580 isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13581 BulkSelectionCheckbox2,
13582 {
13583 selection,
13584 selectedItems,
13585 onChangeSelection,
13586 data,
13587 getItemId,
13588 disableSelectAll: !!view.infiniteScrollEnabled
13589 }
13590 ),
13591 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 })
13592 ]
13593 }
13594 ),
13595 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(dataviews_pagination_default, {}),
13596 Boolean(actions?.length) && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "dataviews-picker-footer__actions", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13597 ActionButtons,
13598 {
13599 actions,
13600 items: selectedItems,
13601 selection
13602 }
13603 ) })
13604 ]
13605 }
13606 );
13607 }
13608
13609 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13610 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
13611 var { Badge: WCBadge2 } = unlock2(import_components14.privateApis);
13612 function GridItem3({
13613 view,
13614 multiselect,
13615 selection,
13616 onChangeSelection,
13617 getItemId,
13618 item,
13619 mediaField,
13620 titleField,
13621 descriptionField: descriptionField2,
13622 regularFields,
13623 badgeFields,
13624 config,
13625 posinset,
13626 setsize
13627 }) {
13628 const { showTitle = true, showMedia = true, showDescription = true } = view;
13629 const id = getItemId(item);
13630 const elementRef = (0, import_element34.useRef)(null);
13631 const isSelected2 = selection.includes(id);
13632 useIntersectionObserver(elementRef, posinset);
13633 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13634 mediaField.render,
13635 {
13636 item,
13637 field: mediaField,
13638 config
13639 }
13640 ) : null;
13641 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(titleField.render, { item, field: titleField }) : null;
13642 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
13643 import_components14.Composite.Item,
13644 {
13645 ref: elementRef,
13646 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n23.__)("(no title)") : void 0,
13647 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(Stack, { direction: "column", children, ...props }),
13648 role: "option",
13649 "aria-posinset": posinset,
13650 "aria-setsize": setsize,
13651 className: clsx_default("dataviews-view-picker-grid__card", {
13652 "is-selected": isSelected2
13653 }),
13654 "aria-selected": isSelected2,
13655 onClick: () => {
13656 if (isSelected2) {
13657 onChangeSelection(
13658 selection.filter((itemId) => id !== itemId)
13659 );
13660 } else {
13661 const newSelection = multiselect ? [...selection, id] : [id];
13662 onChangeSelection(newSelection);
13663 }
13664 },
13665 children: [
13666 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
13667 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13668 DataViewsSelectionCheckbox,
13669 {
13670 item,
13671 selection,
13672 onChangeSelection,
13673 getItemId,
13674 titleField,
13675 disabled: false,
13676 "aria-hidden": true,
13677 tabIndex: -1
13678 }
13679 ),
13680 showTitle && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13681 Stack,
13682 {
13683 direction: "row",
13684 justify: "space-between",
13685 className: "dataviews-view-picker-grid__title-actions",
13686 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
13687 }
13688 ),
13689 /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(Stack, { direction: "column", gap: "xs", children: [
13690 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13691 descriptionField2.render,
13692 {
13693 item,
13694 field: descriptionField2
13695 }
13696 ),
13697 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13698 Stack,
13699 {
13700 direction: "row",
13701 className: "dataviews-view-picker-grid__badge-fields",
13702 gap: "sm",
13703 wrap: "wrap",
13704 align: "top",
13705 justify: "flex-start",
13706 children: badgeFields.map((field) => {
13707 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13708 WCBadge2,
13709 {
13710 className: "dataviews-view-picker-grid__field-value",
13711 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13712 field.render,
13713 {
13714 item,
13715 field
13716 }
13717 )
13718 },
13719 field.id
13720 );
13721 })
13722 }
13723 ),
13724 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13725 Stack,
13726 {
13727 direction: "column",
13728 className: "dataviews-view-picker-grid__fields",
13729 gap: "xs",
13730 children: regularFields.map((field) => {
13731 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13732 import_components14.Flex,
13733 {
13734 className: "dataviews-view-picker-grid__field",
13735 gap: 1,
13736 justify: "flex-start",
13737 expanded: true,
13738 style: { height: "auto" },
13739 direction: "row",
13740 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { children: [
13741 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
13742 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13743 import_components14.FlexItem,
13744 {
13745 className: "dataviews-view-picker-grid__field-value",
13746 style: { maxHeight: "none" },
13747 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13748 field.render,
13749 {
13750 item,
13751 field
13752 }
13753 )
13754 }
13755 )
13756 ] })
13757 },
13758 field.id
13759 );
13760 })
13761 }
13762 )
13763 ] })
13764 ]
13765 },
13766 id
13767 );
13768 }
13769 function GridGroup({
13770 groupName,
13771 groupField,
13772 showLabel = true,
13773 children
13774 }) {
13775 const headerId = (0, import_compose6.useInstanceId)(
13776 GridGroup,
13777 "dataviews-view-picker-grid-group__header"
13778 );
13779 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
13780 Stack,
13781 {
13782 direction: "column",
13783 gap: "sm",
13784 role: "group",
13785 "aria-labelledby": headerId,
13786 children: [
13787 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13788 "h3",
13789 {
13790 className: "dataviews-view-picker-grid-group__header",
13791 id: headerId,
13792 children: showLabel ? (0, import_i18n23.sprintf)(
13793 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13794 (0, import_i18n23.__)("%1$s: %2$s"),
13795 groupField.label,
13796 groupName
13797 ) : groupName
13798 }
13799 ),
13800 children
13801 ]
13802 },
13803 groupName
13804 );
13805 }
13806 function ViewPickerGrid({
13807 actions,
13808 data,
13809 fields,
13810 getItemId,
13811 isLoading,
13812 onChangeSelection,
13813 selection,
13814 view,
13815 className,
13816 empty
13817 }) {
13818 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element34.useContext)(dataviews_context_default);
13819 const titleField = fields.find(
13820 (field) => field.id === view?.titleField
13821 );
13822 const mediaField = fields.find(
13823 (field) => field.id === view?.mediaField
13824 );
13825 const descriptionField2 = fields.find(
13826 (field) => field.id === view?.descriptionField
13827 );
13828 const otherFields = view.fields ?? [];
13829 const { regularFields, badgeFields } = otherFields.reduce(
13830 (accumulator, fieldId) => {
13831 const field = fields.find((f2) => f2.id === fieldId);
13832 if (!field) {
13833 return accumulator;
13834 }
13835 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
13836 accumulator[key].push(field);
13837 return accumulator;
13838 },
13839 { regularFields: [], badgeFields: [] }
13840 );
13841 const hasData = !!data?.length;
13842 const usedPreviewSize = view.layout?.previewSize;
13843 const isMultiselect = useIsMultiselectPicker(actions);
13844 const size4 = "900px";
13845 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
13846 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
13847 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
13848 const currentPage = view?.page ?? 1;
13849 const perPage = view?.perPage ?? 0;
13850 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
13851 const gridColumns = useGridColumns();
13852 const placeholdersNeeded = usePlaceholdersNeeded(
13853 data,
13854 isInfiniteScroll,
13855 gridColumns
13856 );
13857 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, {
13858 // Render multiple groups.
13859 children: [
13860 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13861 import_components14.Composite,
13862 {
13863 virtualFocus: true,
13864 orientation: "horizontal",
13865 role: "listbox",
13866 "aria-multiselectable": isMultiselect,
13867 className: clsx_default(
13868 "dataviews-view-picker-grid",
13869 className,
13870 {
13871 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
13872 view.layout.density
13873 )
13874 }
13875 ),
13876 "aria-label": itemListLabel,
13877 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13878 Stack,
13879 {
13880 direction: "column",
13881 gap: "lg",
13882 children,
13883 ...props
13884 }
13885 ),
13886 children: Array.from(dataByGroup.entries()).map(
13887 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13888 GridGroup,
13889 {
13890 groupName,
13891 groupField,
13892 showLabel: view.groupBy?.showLabel !== false,
13893 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13894 GridItems,
13895 {
13896 previewSize: usedPreviewSize,
13897 style: {
13898 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
13899 },
13900 "aria-busy": isLoading,
13901 ref: resizeObserverRef,
13902 children: groupItems.map((item) => {
13903 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
13904 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13905 GridItem3,
13906 {
13907 view,
13908 multiselect: isMultiselect,
13909 selection,
13910 onChangeSelection,
13911 getItemId,
13912 item,
13913 mediaField,
13914 titleField,
13915 descriptionField: descriptionField2,
13916 regularFields,
13917 badgeFields,
13918 config: {
13919 sizes: size4
13920 },
13921 posinset: posInSet,
13922 setsize: setSize
13923 },
13924 getItemId(item)
13925 );
13926 })
13927 }
13928 )
13929 },
13930 groupName
13931 )
13932 )
13933 }
13934 ),
13935 // Render a single grid with all data.
13936 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
13937 import_components14.Composite,
13938 {
13939 render: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13940 GridItems,
13941 {
13942 className: clsx_default(
13943 "dataviews-view-picker-grid",
13944 className,
13945 {
13946 [`has-${view.layout?.density}-density`]: view.layout?.density && [
13947 "compact",
13948 "comfortable"
13949 ].includes(view.layout.density)
13950 }
13951 ),
13952 previewSize: usedPreviewSize,
13953 "aria-busy": isLoading,
13954 ref: resizeObserverRef
13955 }
13956 ),
13957 virtualFocus: true,
13958 orientation: "horizontal",
13959 role: "listbox",
13960 "aria-multiselectable": isMultiselect,
13961 "aria-label": itemListLabel,
13962 children: [
13963 Array.from({ length: placeholdersNeeded }).map(
13964 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13965 import_components14.Composite.Item,
13966 {
13967 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13968 Stack,
13969 {
13970 direction: "column",
13971 children,
13972 ...props
13973 }
13974 ),
13975 role: "option",
13976 "aria-hidden": true,
13977 tabIndex: -1,
13978 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
13979 },
13980 `placeholder-${index2}`
13981 )
13982 ),
13983 data.map((item) => {
13984 const posinset = item.position;
13985 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13986 GridItem3,
13987 {
13988 view,
13989 multiselect: isMultiselect,
13990 selection,
13991 onChangeSelection,
13992 getItemId,
13993 item,
13994 mediaField,
13995 titleField,
13996 descriptionField: descriptionField2,
13997 regularFields,
13998 badgeFields,
13999 config: {
14000 sizes: size4
14001 },
14002 posinset,
14003 setsize: setSize
14004 },
14005 getItemId(item)
14006 );
14007 })
14008 ]
14009 }
14010 ),
14011 // Render empty state.
14012 !hasData && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14013 "div",
14014 {
14015 className: clsx_default({
14016 "dataviews-loading": isLoading,
14017 "dataviews-no-results": !isLoading
14018 }),
14019 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components14.Spinner, {}) }) : empty
14020 }
14021 ),
14022 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components14.Spinner, {}) })
14023 ]
14024 });
14025 }
14026 var picker_grid_default = ViewPickerGrid;
14027
14028 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
14029 var import_i18n24 = __toESM(require_i18n(), 1);
14030 var import_components15 = __toESM(require_components(), 1);
14031 var import_element35 = __toESM(require_element(), 1);
14032 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
14033 function TableColumnField2({
14034 item,
14035 fields,
14036 column,
14037 align
14038 }) {
14039 const field = fields.find((f2) => f2.id === column);
14040 if (!field) {
14041 return null;
14042 }
14043 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
14044 "dataviews-view-table__cell-align-end": align === "end",
14045 "dataviews-view-table__cell-align-center": align === "center"
14046 });
14047 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(field.render, { item, field }) });
14048 }
14049 function TableRow2({
14050 item,
14051 fields,
14052 id,
14053 view,
14054 titleField,
14055 mediaField,
14056 descriptionField: descriptionField2,
14057 selection,
14058 getItemId,
14059 onChangeSelection,
14060 multiselect,
14061 posinset
14062 }) {
14063 const { paginationInfo } = (0, import_element35.useContext)(dataviews_context_default);
14064 const isSelected2 = selection.includes(id);
14065 const [isHovered, setIsHovered] = (0, import_element35.useState)(false);
14066 const elementRef = (0, import_element35.useRef)(null);
14067 useIntersectionObserver(elementRef, posinset);
14068 const {
14069 showTitle = true,
14070 showMedia = true,
14071 showDescription = true,
14072 infiniteScrollEnabled
14073 } = view;
14074 const handleMouseEnter = () => {
14075 setIsHovered(true);
14076 };
14077 const handleMouseLeave = () => {
14078 setIsHovered(false);
14079 };
14080 const columns = view.fields ?? [];
14081 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
14082 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14083 import_components15.Composite.Item,
14084 {
14085 ref: elementRef,
14086 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14087 "tr",
14088 {
14089 className: clsx_default("dataviews-view-table__row", {
14090 "is-selected": isSelected2,
14091 "is-hovered": isHovered
14092 }),
14093 onMouseEnter: handleMouseEnter,
14094 onMouseLeave: handleMouseLeave,
14095 children,
14096 ...props
14097 }
14098 ),
14099 "aria-selected": isSelected2,
14100 "aria-setsize": paginationInfo.totalItems || void 0,
14101 "aria-posinset": posinset,
14102 role: infiniteScrollEnabled ? "article" : "option",
14103 onMouseDown: (event) => {
14104 if (event.button !== 0) {
14105 return;
14106 }
14107 event.currentTarget.parentElement?.focus({
14108 preventScroll: true
14109 });
14110 },
14111 onClick: () => {
14112 if (isSelected2) {
14113 onChangeSelection(
14114 selection.filter((itemId) => id !== itemId)
14115 );
14116 } else {
14117 const newSelection = multiselect ? [...selection, id] : [id];
14118 onChangeSelection(newSelection);
14119 }
14120 },
14121 children: [
14122 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14123 "td",
14124 {
14125 className: "dataviews-view-table__checkbox-column",
14126 role: "presentation",
14127 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14128 DataViewsSelectionCheckbox,
14129 {
14130 item,
14131 selection,
14132 onChangeSelection,
14133 getItemId,
14134 titleField,
14135 disabled: false,
14136 "aria-hidden": true,
14137 tabIndex: -1
14138 }
14139 ) })
14140 }
14141 ),
14142 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14143 "td",
14144 {
14145 role: "presentation",
14146 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14147 column_primary_default,
14148 {
14149 item,
14150 titleField: showTitle ? titleField : void 0,
14151 mediaField: showMedia ? mediaField : void 0,
14152 descriptionField: showDescription ? descriptionField2 : void 0,
14153 isItemClickable: () => false
14154 }
14155 )
14156 }
14157 ),
14158 columns.map((column) => {
14159 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14160 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14161 "td",
14162 {
14163 style: {
14164 width,
14165 maxWidth,
14166 minWidth
14167 },
14168 role: "presentation",
14169 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14170 TableColumnField2,
14171 {
14172 fields,
14173 item,
14174 column,
14175 align
14176 }
14177 )
14178 },
14179 column
14180 );
14181 })
14182 ]
14183 },
14184 id
14185 );
14186 }
14187 function ViewPickerTable({
14188 actions,
14189 data,
14190 fields,
14191 getItemId,
14192 isLoading = false,
14193 onChangeView,
14194 onChangeSelection,
14195 selection,
14196 setOpenedFilter,
14197 view,
14198 className,
14199 empty
14200 }) {
14201 const headerMenuRefs = (0, import_element35.useRef)(/* @__PURE__ */ new Map());
14202 const headerMenuToFocusRef = (0, import_element35.useRef)(void 0);
14203 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element35.useState)();
14204 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
14205 (0, import_element35.useEffect)(() => {
14206 if (headerMenuToFocusRef.current) {
14207 headerMenuToFocusRef.current.focus();
14208 headerMenuToFocusRef.current = void 0;
14209 }
14210 });
14211 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14212 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14213 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14214 const tableNoticeId = (0, import_element35.useId)();
14215 if (nextHeaderMenuToFocus) {
14216 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
14217 setNextHeaderMenuToFocus(void 0);
14218 return;
14219 }
14220 const onHide = (field) => {
14221 const hidden = headerMenuRefs.current.get(field.id);
14222 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
14223 setNextHeaderMenuToFocus(fallback?.node);
14224 };
14225 const hasData = !!data?.length;
14226 const titleField = fields.find((field) => field.id === view.titleField);
14227 const mediaField = fields.find((field) => field.id === view.mediaField);
14228 const descriptionField2 = fields.find(
14229 (field) => field.id === view.descriptionField
14230 );
14231 const { showTitle = true, showMedia = true, showDescription = true } = view;
14232 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
14233 const columns = view.fields ?? [];
14234 const headerMenuRef = (column, index2) => (node) => {
14235 if (node) {
14236 headerMenuRefs.current.set(column, {
14237 node,
14238 fallback: columns[index2 > 0 ? index2 - 1 : 1]
14239 });
14240 } else {
14241 headerMenuRefs.current.delete(column);
14242 }
14243 };
14244 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
14245 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14246 "table",
14247 {
14248 className: clsx_default(
14249 "dataviews-view-table",
14250 "dataviews-view-picker-table",
14251 className,
14252 {
14253 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14254 view.layout.density
14255 )
14256 }
14257 ),
14258 "aria-busy": isLoading,
14259 "aria-describedby": tableNoticeId,
14260 role: isInfiniteScroll ? "feed" : "listbox",
14261 children: [
14262 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14263 "tr",
14264 {
14265 className: "dataviews-view-table__row",
14266 role: "presentation",
14267 children: [
14268 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14269 BulkSelectionCheckbox,
14270 {
14271 selection,
14272 onChangeSelection,
14273 data,
14274 actions,
14275 getItemId,
14276 disableSelectAll: isInfiniteScroll
14277 }
14278 ) }),
14279 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14280 column_header_menu_default,
14281 {
14282 ref: headerMenuRef(
14283 titleField.id,
14284 0
14285 ),
14286 fieldId: titleField.id,
14287 view,
14288 fields,
14289 onChangeView,
14290 onHide,
14291 setOpenedFilter,
14292 canMove: false
14293 }
14294 ) }),
14295 columns.map((column, index2) => {
14296 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14297 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14298 "th",
14299 {
14300 style: {
14301 width,
14302 maxWidth,
14303 minWidth,
14304 textAlign: align
14305 },
14306 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14307 scope: "col",
14308 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14309 column_header_menu_default,
14310 {
14311 ref: headerMenuRef(column, index2),
14312 fieldId: column,
14313 view,
14314 fields,
14315 onChangeView,
14316 onHide,
14317 setOpenedFilter,
14318 canMove: view.layout?.enableMoving ?? true
14319 }
14320 )
14321 },
14322 column
14323 );
14324 })
14325 ]
14326 }
14327 ) }),
14328 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14329 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14330 import_components15.Composite,
14331 {
14332 virtualFocus: true,
14333 orientation: "vertical",
14334 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("tbody", { role: "group" }),
14335 children: [
14336 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14337 "tr",
14338 {
14339 className: "dataviews-view-table__group-header-row",
14340 role: "presentation",
14341 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14342 "td",
14343 {
14344 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
14345 className: "dataviews-view-table__group-header-cell",
14346 role: "presentation",
14347 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n24.sprintf)(
14348 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14349 (0, import_i18n24.__)("%1$s: %2$s"),
14350 groupField.label,
14351 groupName
14352 )
14353 }
14354 )
14355 }
14356 ),
14357 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14358 TableRow2,
14359 {
14360 item,
14361 fields,
14362 id: getItemId(item) || index2.toString(),
14363 view,
14364 titleField,
14365 mediaField,
14366 descriptionField: descriptionField2,
14367 selection,
14368 getItemId,
14369 onChangeSelection,
14370 multiselect: isMultiselect
14371 },
14372 getItemId(item)
14373 ))
14374 ]
14375 },
14376 `group-${groupName}`
14377 )
14378 ) : /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14379 import_components15.Composite,
14380 {
14381 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("tbody", { role: "presentation" }),
14382 virtualFocus: true,
14383 orientation: "vertical",
14384 children: hasData && data.map((item, index2) => {
14385 const itemId = getItemId(item);
14386 const posinset = item.position;
14387 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14388 TableRow2,
14389 {
14390 item,
14391 fields,
14392 id: itemId || index2.toString(),
14393 view,
14394 titleField,
14395 mediaField,
14396 descriptionField: descriptionField2,
14397 selection,
14398 getItemId,
14399 onChangeSelection,
14400 multiselect: isMultiselect,
14401 posinset
14402 },
14403 itemId
14404 );
14405 })
14406 }
14407 )
14408 ]
14409 }
14410 ),
14411 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14412 "div",
14413 {
14414 className: clsx_default({
14415 "dataviews-loading": isLoading,
14416 "dataviews-no-results": !hasData && !isLoading
14417 }),
14418 id: tableNoticeId,
14419 children: [
14420 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components15.Spinner, {}) }) : empty),
14421 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components15.Spinner, {}) })
14422 ]
14423 }
14424 )
14425 ] });
14426 }
14427 var picker_table_default = ViewPickerTable;
14428
14429 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
14430 var import_components16 = __toESM(require_components(), 1);
14431 var import_i18n25 = __toESM(require_i18n(), 1);
14432 var import_element36 = __toESM(require_element(), 1);
14433 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
14434 function DensityPicker() {
14435 const context = (0, import_element36.useContext)(dataviews_context_default);
14436 const view = context.view;
14437 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14438 import_components16.__experimentalToggleGroupControl,
14439 {
14440 size: "__unstable-large",
14441 label: (0, import_i18n25.__)("Density"),
14442 value: view.layout?.density || "balanced",
14443 onChange: (value) => {
14444 context.onChangeView({
14445 ...view,
14446 layout: {
14447 ...view.layout,
14448 density: value
14449 }
14450 });
14451 },
14452 isBlock: true,
14453 children: [
14454 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14455 import_components16.__experimentalToggleGroupControlOption,
14456 {
14457 value: "comfortable",
14458 label: (0, import_i18n25._x)(
14459 "Comfortable",
14460 "Density option for DataView layout"
14461 )
14462 },
14463 "comfortable"
14464 ),
14465 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14466 import_components16.__experimentalToggleGroupControlOption,
14467 {
14468 value: "balanced",
14469 label: (0, import_i18n25._x)("Balanced", "Density option for DataView layout")
14470 },
14471 "balanced"
14472 ),
14473 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14474 import_components16.__experimentalToggleGroupControlOption,
14475 {
14476 value: "compact",
14477 label: (0, import_i18n25._x)("Compact", "Density option for DataView layout")
14478 },
14479 "compact"
14480 )
14481 ]
14482 }
14483 );
14484 }
14485
14486 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
14487 var import_components17 = __toESM(require_components(), 1);
14488 var import_i18n26 = __toESM(require_i18n(), 1);
14489 var import_element37 = __toESM(require_element(), 1);
14490 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
14491 var imageSizes2 = [
14492 {
14493 value: 120,
14494 breakpoint: 1
14495 },
14496 {
14497 value: 170,
14498 breakpoint: 1
14499 },
14500 {
14501 value: 230,
14502 breakpoint: 1
14503 },
14504 {
14505 value: 290,
14506 breakpoint: 1112
14507 // at minimum image width, 4 images display at this container size
14508 },
14509 {
14510 value: 350,
14511 breakpoint: 1636
14512 // at minimum image width, 6 images display at this container size
14513 },
14514 {
14515 value: 430,
14516 breakpoint: 588
14517 // at minimum image width, 2 images display at this container size
14518 }
14519 ];
14520 function PreviewSizePicker() {
14521 const context = (0, import_element37.useContext)(dataviews_context_default);
14522 const view = context.view;
14523 const breakValues = imageSizes2.filter((size4) => {
14524 return context.containerWidth >= size4.breakpoint;
14525 });
14526 const layoutPreviewSize = view.layout?.previewSize ?? 230;
14527 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
14528 const marks = breakValues.map((size4, index2) => {
14529 return {
14530 value: index2
14531 };
14532 });
14533 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14534 import_components17.RangeControl,
14535 {
14536 __next40pxDefaultSize: true,
14537 showTooltip: false,
14538 label: (0, import_i18n26.__)("Preview size"),
14539 value: previewSizeToUse,
14540 min: 0,
14541 max: breakValues.length - 1,
14542 withInputField: false,
14543 onChange: (value = 0) => {
14544 context.onChangeView({
14545 ...view,
14546 layout: {
14547 ...view.layout,
14548 previewSize: breakValues[value].value
14549 }
14550 });
14551 },
14552 step: 1,
14553 marks
14554 }
14555 );
14556 }
14557
14558 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
14559 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
14560 function GridConfigOptions() {
14561 return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(import_jsx_runtime69.Fragment, { children: [
14562 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(DensityPicker, {}),
14563 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(PreviewSizePicker, {})
14564 ] });
14565 }
14566
14567 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
14568 var VIEW_LAYOUTS = [
14569 {
14570 type: LAYOUT_TABLE,
14571 label: (0, import_i18n27.__)("Table"),
14572 component: table_default,
14573 icon: block_table_default,
14574 viewConfigOptions: DensityPicker
14575 },
14576 {
14577 type: LAYOUT_GRID,
14578 label: (0, import_i18n27.__)("Grid"),
14579 component: grid_default,
14580 icon: category_default,
14581 viewConfigOptions: GridConfigOptions
14582 },
14583 {
14584 type: LAYOUT_LIST,
14585 label: (0, import_i18n27.__)("List"),
14586 component: ViewList,
14587 icon: (0, import_i18n27.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
14588 viewConfigOptions: DensityPicker
14589 },
14590 {
14591 type: LAYOUT_ACTIVITY,
14592 label: (0, import_i18n27.__)("Activity"),
14593 component: ViewActivity,
14594 icon: scheduled_default,
14595 viewConfigOptions: DensityPicker
14596 },
14597 {
14598 type: LAYOUT_PICKER_GRID,
14599 label: (0, import_i18n27.__)("Grid"),
14600 component: picker_grid_default,
14601 icon: category_default,
14602 viewConfigOptions: GridConfigOptions,
14603 isPicker: true
14604 },
14605 {
14606 type: LAYOUT_PICKER_TABLE,
14607 label: (0, import_i18n27.__)("Table"),
14608 component: picker_table_default,
14609 icon: block_table_default,
14610 viewConfigOptions: DensityPicker,
14611 isPicker: true
14612 }
14613 ];
14614
14615 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
14616 var import_element45 = __toESM(require_element(), 1);
14617
14618 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
14619 var import_components20 = __toESM(require_components(), 1);
14620 var import_i18n30 = __toESM(require_i18n(), 1);
14621 var import_element42 = __toESM(require_element(), 1);
14622
14623 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
14624 function noop5(..._) {
14625 }
14626 function applyState(argument, currentValue) {
14627 if (isUpdater(argument)) {
14628 const value = isLazyValue(currentValue) ? currentValue() : currentValue;
14629 return argument(value);
14630 }
14631 return argument;
14632 }
14633 function isUpdater(argument) {
14634 return typeof argument === "function";
14635 }
14636 function isLazyValue(value) {
14637 return typeof value === "function";
14638 }
14639 function hasOwnProperty(object, prop) {
14640 if (typeof Object.hasOwn === "function") {
14641 return Object.hasOwn(object, prop);
14642 }
14643 return Object.prototype.hasOwnProperty.call(object, prop);
14644 }
14645 function chain(...fns) {
14646 return (...args) => {
14647 for (const fn of fns) {
14648 if (typeof fn === "function") {
14649 fn(...args);
14650 }
14651 }
14652 };
14653 }
14654 function normalizeString(str) {
14655 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
14656 }
14657 function omit(object, keys) {
14658 const result = { ...object };
14659 for (const key of keys) {
14660 if (hasOwnProperty(result, key)) {
14661 delete result[key];
14662 }
14663 }
14664 return result;
14665 }
14666 function pick(object, paths) {
14667 const result = {};
14668 for (const key of paths) {
14669 if (hasOwnProperty(object, key)) {
14670 result[key] = object[key];
14671 }
14672 }
14673 return result;
14674 }
14675 function identity(value) {
14676 return value;
14677 }
14678 function invariant(condition, message2) {
14679 if (condition) return;
14680 if (typeof message2 !== "string") throw new Error("Invariant failed");
14681 throw new Error(message2);
14682 }
14683 function getKeys(obj) {
14684 return Object.keys(obj);
14685 }
14686 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
14687 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
14688 if (result == null) return false;
14689 return !result;
14690 }
14691 function disabledFromProps(props) {
14692 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
14693 }
14694 function removeUndefinedValues(obj) {
14695 const result = {};
14696 for (const key in obj) {
14697 if (obj[key] !== void 0) {
14698 result[key] = obj[key];
14699 }
14700 }
14701 return result;
14702 }
14703 function defaultValue(...values) {
14704 for (const value of values) {
14705 if (value !== void 0) return value;
14706 }
14707 return void 0;
14708 }
14709
14710 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
14711 var import_react6 = __toESM(require_react(), 1);
14712 function setRef(ref, value) {
14713 if (typeof ref === "function") {
14714 ref(value);
14715 } else if (ref) {
14716 ref.current = value;
14717 }
14718 }
14719 function isValidElementWithRef(element) {
14720 if (!element) return false;
14721 if (!(0, import_react6.isValidElement)(element)) return false;
14722 if ("ref" in element.props) return true;
14723 if ("ref" in element) return true;
14724 return false;
14725 }
14726 function getRefProperty(element) {
14727 if (!isValidElementWithRef(element)) return null;
14728 const props = { ...element.props };
14729 return props.ref || element.ref;
14730 }
14731 function mergeProps3(base, overrides) {
14732 const props = { ...base };
14733 for (const key in overrides) {
14734 if (!hasOwnProperty(overrides, key)) continue;
14735 if (key === "className") {
14736 const prop = "className";
14737 props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
14738 continue;
14739 }
14740 if (key === "style") {
14741 const prop = "style";
14742 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
14743 continue;
14744 }
14745 const overrideValue = overrides[key];
14746 if (typeof overrideValue === "function" && key.startsWith("on")) {
14747 const baseValue = base[key];
14748 if (typeof baseValue === "function") {
14749 props[key] = (...args) => {
14750 overrideValue(...args);
14751 baseValue(...args);
14752 };
14753 continue;
14754 }
14755 }
14756 props[key] = overrideValue;
14757 }
14758 return props;
14759 }
14760
14761 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
14762 var canUseDOM = checkIsBrowser();
14763 function checkIsBrowser() {
14764 var _a;
14765 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
14766 }
14767 function getDocument(node) {
14768 if (!node) return document;
14769 if ("self" in node) return node.document;
14770 return node.ownerDocument || document;
14771 }
14772 function getActiveElement(node, activeDescendant = false) {
14773 var _a;
14774 const { activeElement: activeElement2 } = getDocument(node);
14775 if (!(activeElement2 == null ? void 0 : activeElement2.nodeName)) {
14776 return null;
14777 }
14778 if (isFrame(activeElement2) && ((_a = activeElement2.contentDocument) == null ? void 0 : _a.body)) {
14779 return getActiveElement(
14780 activeElement2.contentDocument.body,
14781 activeDescendant
14782 );
14783 }
14784 if (activeDescendant) {
14785 const id = activeElement2.getAttribute("aria-activedescendant");
14786 if (id) {
14787 const element = getDocument(activeElement2).getElementById(id);
14788 if (element) {
14789 return element;
14790 }
14791 }
14792 }
14793 return activeElement2;
14794 }
14795 function contains2(parent, child) {
14796 return parent === child || parent.contains(child);
14797 }
14798 function isFrame(element) {
14799 return element.tagName === "IFRAME";
14800 }
14801 function isButton(element) {
14802 const tagName = element.tagName.toLowerCase();
14803 if (tagName === "button") return true;
14804 if (tagName === "input" && element.type) {
14805 return buttonInputTypes.indexOf(element.type) !== -1;
14806 }
14807 return false;
14808 }
14809 var buttonInputTypes = [
14810 "button",
14811 "color",
14812 "file",
14813 "image",
14814 "reset",
14815 "submit"
14816 ];
14817 function isVisible(element) {
14818 if (typeof element.checkVisibility === "function") {
14819 return element.checkVisibility();
14820 }
14821 const htmlElement = element;
14822 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
14823 }
14824 function isTextField(element) {
14825 try {
14826 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
14827 const isTextArea = element.tagName === "TEXTAREA";
14828 return isTextInput || isTextArea || false;
14829 } catch (_error) {
14830 return false;
14831 }
14832 }
14833 function isTextbox(element) {
14834 return element.isContentEditable || isTextField(element);
14835 }
14836 function getTextboxValue(element) {
14837 if (isTextField(element)) {
14838 return element.value;
14839 }
14840 if (element.isContentEditable) {
14841 const range = getDocument(element).createRange();
14842 range.selectNodeContents(element);
14843 return range.toString();
14844 }
14845 return "";
14846 }
14847 function getTextboxSelection(element) {
14848 let start = 0;
14849 let end = 0;
14850 if (isTextField(element)) {
14851 start = element.selectionStart || 0;
14852 end = element.selectionEnd || 0;
14853 } else if (element.isContentEditable) {
14854 const selection = getDocument(element).getSelection();
14855 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
14856 const range = selection.getRangeAt(0);
14857 const nextRange = range.cloneRange();
14858 nextRange.selectNodeContents(element);
14859 nextRange.setEnd(range.startContainer, range.startOffset);
14860 start = nextRange.toString().length;
14861 nextRange.setEnd(range.endContainer, range.endOffset);
14862 end = nextRange.toString().length;
14863 }
14864 }
14865 return { start, end };
14866 }
14867 function getPopupRole(element, fallback) {
14868 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
14869 const role = element == null ? void 0 : element.getAttribute("role");
14870 if (role && allowedPopupRoles.indexOf(role) !== -1) {
14871 return role;
14872 }
14873 return fallback;
14874 }
14875 function getScrollingElement(element) {
14876 if (!element) return null;
14877 const isScrollableOverflow = (overflow) => {
14878 if (overflow === "auto") return true;
14879 if (overflow === "scroll") return true;
14880 return false;
14881 };
14882 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
14883 const { overflowY } = getComputedStyle(element);
14884 if (isScrollableOverflow(overflowY)) return element;
14885 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
14886 const { overflowX } = getComputedStyle(element);
14887 if (isScrollableOverflow(overflowX)) return element;
14888 }
14889 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
14890 }
14891 function setSelectionRange(element, ...args) {
14892 if (/text|search|password|tel|url/i.test(element.type)) {
14893 element.setSelectionRange(...args);
14894 }
14895 }
14896 function sortBasedOnDOMPosition(items, getElement) {
14897 const pairs = items.map((item, index2) => [index2, item]);
14898 let isOrderDifferent = false;
14899 pairs.sort(([indexA, a2], [indexB, b2]) => {
14900 const elementA = getElement(a2);
14901 const elementB = getElement(b2);
14902 if (elementA === elementB) return 0;
14903 if (!elementA || !elementB) return 0;
14904 if (isElementPreceding(elementA, elementB)) {
14905 if (indexA > indexB) {
14906 isOrderDifferent = true;
14907 }
14908 return -1;
14909 }
14910 if (indexA < indexB) {
14911 isOrderDifferent = true;
14912 }
14913 return 1;
14914 });
14915 if (isOrderDifferent) {
14916 return pairs.map(([_, item]) => item);
14917 }
14918 return items;
14919 }
14920 function isElementPreceding(a2, b2) {
14921 return Boolean(
14922 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING
14923 );
14924 }
14925
14926 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
14927 function isTouchDevice() {
14928 return canUseDOM && !!navigator.maxTouchPoints;
14929 }
14930 function isApple() {
14931 if (!canUseDOM) return false;
14932 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
14933 }
14934 function isSafari2() {
14935 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
14936 }
14937 function isFirefox2() {
14938 return canUseDOM && /firefox\//i.test(navigator.userAgent);
14939 }
14940
14941 // node_modules/@ariakit/core/esm/utils/events.js
14942 function isPortalEvent(event) {
14943 return Boolean(
14944 event.currentTarget && !contains2(event.currentTarget, event.target)
14945 );
14946 }
14947 function isSelfTarget(event) {
14948 return event.target === event.currentTarget;
14949 }
14950 function isOpeningInNewTab(event) {
14951 const element = event.currentTarget;
14952 if (!element) return false;
14953 const isAppleDevice = isApple();
14954 if (isAppleDevice && !event.metaKey) return false;
14955 if (!isAppleDevice && !event.ctrlKey) return false;
14956 const tagName = element.tagName.toLowerCase();
14957 if (tagName === "a") return true;
14958 if (tagName === "button" && element.type === "submit") return true;
14959 if (tagName === "input" && element.type === "submit") return true;
14960 return false;
14961 }
14962 function isDownloading(event) {
14963 const element = event.currentTarget;
14964 if (!element) return false;
14965 const tagName = element.tagName.toLowerCase();
14966 if (!event.altKey) return false;
14967 if (tagName === "a") return true;
14968 if (tagName === "button" && element.type === "submit") return true;
14969 if (tagName === "input" && element.type === "submit") return true;
14970 return false;
14971 }
14972 function fireBlurEvent(element, eventInit) {
14973 const event = new FocusEvent("blur", eventInit);
14974 const defaultAllowed = element.dispatchEvent(event);
14975 const bubbleInit = { ...eventInit, bubbles: true };
14976 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
14977 return defaultAllowed;
14978 }
14979 function fireKeyboardEvent(element, type, eventInit) {
14980 const event = new KeyboardEvent(type, eventInit);
14981 return element.dispatchEvent(event);
14982 }
14983 function fireClickEvent(element, eventInit) {
14984 const event = new MouseEvent("click", eventInit);
14985 return element.dispatchEvent(event);
14986 }
14987 function isFocusEventOutside(event, container) {
14988 const containerElement = container || event.currentTarget;
14989 const relatedTarget = event.relatedTarget;
14990 return !relatedTarget || !contains2(containerElement, relatedTarget);
14991 }
14992 function queueBeforeEvent(element, type, callback, timeout) {
14993 const createTimer = (callback2) => {
14994 if (timeout) {
14995 const timerId2 = setTimeout(callback2, timeout);
14996 return () => clearTimeout(timerId2);
14997 }
14998 const timerId = requestAnimationFrame(callback2);
14999 return () => cancelAnimationFrame(timerId);
15000 };
15001 const cancelTimer = createTimer(() => {
15002 element.removeEventListener(type, callSync, true);
15003 callback();
15004 });
15005 const callSync = () => {
15006 cancelTimer();
15007 callback();
15008 };
15009 element.addEventListener(type, callSync, { once: true, capture: true });
15010 return cancelTimer;
15011 }
15012 function addGlobalEventListener(type, listener, options, scope = window) {
15013 const children = [];
15014 try {
15015 scope.document.addEventListener(type, listener, options);
15016 for (const frame of Array.from(scope.frames)) {
15017 children.push(addGlobalEventListener(type, listener, options, frame));
15018 }
15019 } catch (e2) {
15020 }
15021 const removeEventListener = () => {
15022 try {
15023 scope.document.removeEventListener(type, listener, options);
15024 } catch (e2) {
15025 }
15026 for (const remove of children) {
15027 remove();
15028 }
15029 };
15030 return removeEventListener;
15031 }
15032
15033 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
15034 var React48 = __toESM(require_react(), 1);
15035 var import_react7 = __toESM(require_react(), 1);
15036 var _React = { ...React48 };
15037 var useReactId = _React.useId;
15038 var useReactDeferredValue = _React.useDeferredValue;
15039 var useReactInsertionEffect = _React.useInsertionEffect;
15040 var useSafeLayoutEffect = canUseDOM ? import_react7.useLayoutEffect : import_react7.useEffect;
15041 function useInitialValue(value) {
15042 const [initialValue] = (0, import_react7.useState)(value);
15043 return initialValue;
15044 }
15045 function useLiveRef(value) {
15046 const ref = (0, import_react7.useRef)(value);
15047 useSafeLayoutEffect(() => {
15048 ref.current = value;
15049 });
15050 return ref;
15051 }
15052 function useEvent(callback) {
15053 const ref = (0, import_react7.useRef)(() => {
15054 throw new Error("Cannot call an event handler while rendering.");
15055 });
15056 if (useReactInsertionEffect) {
15057 useReactInsertionEffect(() => {
15058 ref.current = callback;
15059 });
15060 } else {
15061 ref.current = callback;
15062 }
15063 return (0, import_react7.useCallback)((...args) => {
15064 var _a;
15065 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
15066 }, []);
15067 }
15068 function useTransactionState(callback) {
15069 const [state, setState] = (0, import_react7.useState)(null);
15070 useSafeLayoutEffect(() => {
15071 if (state == null) return;
15072 if (!callback) return;
15073 let prevState = null;
15074 callback((prev) => {
15075 prevState = prev;
15076 return state;
15077 });
15078 return () => {
15079 callback(prevState);
15080 };
15081 }, [state, callback]);
15082 return [state, setState];
15083 }
15084 function useMergeRefs(...refs) {
15085 return (0, import_react7.useMemo)(() => {
15086 if (!refs.some(Boolean)) return;
15087 return (value) => {
15088 for (const ref of refs) {
15089 setRef(ref, value);
15090 }
15091 };
15092 }, refs);
15093 }
15094 function useId4(defaultId) {
15095 if (useReactId) {
15096 const reactId = useReactId();
15097 if (defaultId) return defaultId;
15098 return reactId;
15099 }
15100 const [id, setId] = (0, import_react7.useState)(defaultId);
15101 useSafeLayoutEffect(() => {
15102 if (defaultId || id) return;
15103 const random = Math.random().toString(36).slice(2, 8);
15104 setId(`id-${random}`);
15105 }, [defaultId, id]);
15106 return defaultId || id;
15107 }
15108 function useTagName(refOrElement, type) {
15109 const stringOrUndefined = (type2) => {
15110 if (typeof type2 !== "string") return;
15111 return type2;
15112 };
15113 const [tagName, setTagName] = (0, import_react7.useState)(() => stringOrUndefined(type));
15114 useSafeLayoutEffect(() => {
15115 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
15116 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
15117 }, [refOrElement, type]);
15118 return tagName;
15119 }
15120 function useAttribute(refOrElement, attributeName, defaultValue2) {
15121 const initialValue = useInitialValue(defaultValue2);
15122 const [attribute, setAttribute] = (0, import_react7.useState)(initialValue);
15123 (0, import_react7.useEffect)(() => {
15124 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
15125 if (!element) return;
15126 const callback = () => {
15127 const value = element.getAttribute(attributeName);
15128 setAttribute(value == null ? initialValue : value);
15129 };
15130 const observer = new MutationObserver(callback);
15131 observer.observe(element, { attributeFilter: [attributeName] });
15132 callback();
15133 return () => observer.disconnect();
15134 }, [refOrElement, attributeName, initialValue]);
15135 return attribute;
15136 }
15137 function useUpdateEffect(effect, deps) {
15138 const mounted = (0, import_react7.useRef)(false);
15139 (0, import_react7.useEffect)(() => {
15140 if (mounted.current) {
15141 return effect();
15142 }
15143 mounted.current = true;
15144 }, deps);
15145 (0, import_react7.useEffect)(
15146 () => () => {
15147 mounted.current = false;
15148 },
15149 []
15150 );
15151 }
15152 function useUpdateLayoutEffect(effect, deps) {
15153 const mounted = (0, import_react7.useRef)(false);
15154 useSafeLayoutEffect(() => {
15155 if (mounted.current) {
15156 return effect();
15157 }
15158 mounted.current = true;
15159 }, deps);
15160 useSafeLayoutEffect(
15161 () => () => {
15162 mounted.current = false;
15163 },
15164 []
15165 );
15166 }
15167 function useForceUpdate() {
15168 return (0, import_react7.useReducer)(() => [], []);
15169 }
15170 function useBooleanEvent(booleanOrCallback) {
15171 return useEvent(
15172 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
15173 );
15174 }
15175 function useWrapElement(props, callback, deps = []) {
15176 const wrapElement = (0, import_react7.useCallback)(
15177 (element) => {
15178 if (props.wrapElement) {
15179 element = props.wrapElement(element);
15180 }
15181 return callback(element);
15182 },
15183 [...deps, props.wrapElement]
15184 );
15185 return { ...props, wrapElement };
15186 }
15187 function useMetadataProps(props, key, value) {
15188 const parent = props.onLoadedMetadataCapture;
15189 const onLoadedMetadataCapture = (0, import_react7.useMemo)(() => {
15190 return Object.assign(() => {
15191 }, { ...parent, [key]: value });
15192 }, [parent, key, value]);
15193 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }];
15194 }
15195 var hasInstalledGlobalEventListeners = false;
15196 function useIsMouseMoving() {
15197 (0, import_react7.useEffect)(() => {
15198 if (hasInstalledGlobalEventListeners) return;
15199 addGlobalEventListener("mousemove", setMouseMoving, true);
15200 addGlobalEventListener("mousedown", resetMouseMoving, true);
15201 addGlobalEventListener("mouseup", resetMouseMoving, true);
15202 addGlobalEventListener("keydown", resetMouseMoving, true);
15203 addGlobalEventListener("scroll", resetMouseMoving, true);
15204 hasInstalledGlobalEventListeners = true;
15205 }, []);
15206 const isMouseMoving = useEvent(() => mouseMoving);
15207 return isMouseMoving;
15208 }
15209 var mouseMoving = false;
15210 var previousScreenX = 0;
15211 var previousScreenY = 0;
15212 function hasMouseMovement(event) {
15213 const movementX = event.movementX || event.screenX - previousScreenX;
15214 const movementY = event.movementY || event.screenY - previousScreenY;
15215 previousScreenX = event.screenX;
15216 previousScreenY = event.screenY;
15217 return movementX || movementY || false;
15218 }
15219 function setMouseMoving(event) {
15220 if (!hasMouseMovement(event)) return;
15221 mouseMoving = true;
15222 }
15223 function resetMouseMoving() {
15224 mouseMoving = false;
15225 }
15226
15227 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
15228 var React49 = __toESM(require_react(), 1);
15229 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
15230 function forwardRef22(render4) {
15231 const Role = React49.forwardRef(
15232 // @ts-ignore Incompatible with React 19 types. Ignore for now.
15233 (props, ref) => render4({ ...props, ref })
15234 );
15235 Role.displayName = render4.displayName || render4.name;
15236 return Role;
15237 }
15238 function memo22(Component2, propsAreEqual) {
15239 return React49.memo(Component2, propsAreEqual);
15240 }
15241 function createElement3(Type, props) {
15242 const { wrapElement, render: render4, ...rest } = props;
15243 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
15244 let element;
15245 if (React49.isValidElement(render4)) {
15246 const renderProps = {
15247 // @ts-ignore Incompatible with React 19 types. Ignore for now.
15248 ...render4.props,
15249 ref: mergedRef
15250 };
15251 element = React49.cloneElement(render4, mergeProps3(rest, renderProps));
15252 } else if (render4) {
15253 element = render4(rest);
15254 } else {
15255 element = /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Type, { ...rest });
15256 }
15257 if (wrapElement) {
15258 return wrapElement(element);
15259 }
15260 return element;
15261 }
15262 function createHook(useProps) {
15263 const useRole = (props = {}) => {
15264 return useProps(props);
15265 };
15266 useRole.displayName = useProps.name;
15267 return useRole;
15268 }
15269 function createStoreContext(providers = [], scopedProviders = []) {
15270 const context = React49.createContext(void 0);
15271 const scopedContext = React49.createContext(void 0);
15272 const useContext210 = () => React49.useContext(context);
15273 const useScopedContext = (onlyScoped = false) => {
15274 const scoped = React49.useContext(scopedContext);
15275 const store = useContext210();
15276 if (onlyScoped) return scoped;
15277 return scoped || store;
15278 };
15279 const useProviderContext = () => {
15280 const scoped = React49.useContext(scopedContext);
15281 const store = useContext210();
15282 if (scoped && scoped === store) return;
15283 return store;
15284 };
15285 const ContextProvider = (props) => {
15286 return providers.reduceRight(
15287 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Provider2, { ...props, children }),
15288 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(context.Provider, { ...props })
15289 );
15290 };
15291 const ScopedContextProvider = (props) => {
15292 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
15293 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Provider2, { ...props, children }),
15294 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(scopedContext.Provider, { ...props })
15295 ) });
15296 };
15297 return {
15298 context,
15299 scopedContext,
15300 useContext: useContext210,
15301 useScopedContext,
15302 useProviderContext,
15303 ContextProvider,
15304 ScopedContextProvider
15305 };
15306 }
15307
15308 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
15309 var ctx = createStoreContext();
15310 var useCollectionContext = ctx.useContext;
15311 var useCollectionScopedContext = ctx.useScopedContext;
15312 var useCollectionProviderContext = ctx.useProviderContext;
15313 var CollectionContextProvider = ctx.ContextProvider;
15314 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
15315
15316 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
15317 var import_react8 = __toESM(require_react(), 1);
15318 var ctx2 = createStoreContext(
15319 [CollectionContextProvider],
15320 [CollectionScopedContextProvider]
15321 );
15322 var useCompositeContext = ctx2.useContext;
15323 var useCompositeScopedContext = ctx2.useScopedContext;
15324 var useCompositeProviderContext = ctx2.useProviderContext;
15325 var CompositeContextProvider = ctx2.ContextProvider;
15326 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
15327 var CompositeItemContext = (0, import_react8.createContext)(
15328 void 0
15329 );
15330 var CompositeRowContext = (0, import_react8.createContext)(
15331 void 0
15332 );
15333
15334 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
15335 function findFirstEnabledItem(items, excludeId) {
15336 return items.find((item) => {
15337 if (excludeId) {
15338 return !item.disabled && item.id !== excludeId;
15339 }
15340 return !item.disabled;
15341 });
15342 }
15343 function getEnabledItem(store, id) {
15344 if (!id) return null;
15345 return store.item(id) || null;
15346 }
15347 function groupItemsByRows(items) {
15348 const rows = [];
15349 for (const item of items) {
15350 const row = rows.find((currentRow) => {
15351 var _a;
15352 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
15353 });
15354 if (row) {
15355 row.push(item);
15356 } else {
15357 rows.push([item]);
15358 }
15359 }
15360 return rows;
15361 }
15362 function selectTextField(element, collapseToEnd = false) {
15363 if (isTextField(element)) {
15364 element.setSelectionRange(
15365 collapseToEnd ? element.value.length : 0,
15366 element.value.length
15367 );
15368 } else if (element.isContentEditable) {
15369 const selection = getDocument(element).getSelection();
15370 selection == null ? void 0 : selection.selectAllChildren(element);
15371 if (collapseToEnd) {
15372 selection == null ? void 0 : selection.collapseToEnd();
15373 }
15374 }
15375 }
15376 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
15377 function focusSilently(element) {
15378 element[FOCUS_SILENTLY] = true;
15379 element.focus({ preventScroll: true });
15380 }
15381 function silentlyFocused(element) {
15382 const isSilentlyFocused = element[FOCUS_SILENTLY];
15383 delete element[FOCUS_SILENTLY];
15384 return isSilentlyFocused;
15385 }
15386 function isItem(store, element, exclude) {
15387 if (!element) return false;
15388 if (element === exclude) return false;
15389 const item = store.item(element.id);
15390 if (!item) return false;
15391 if (exclude && item.element === exclude) return false;
15392 return true;
15393 }
15394
15395 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
15396 var import_react9 = __toESM(require_react(), 1);
15397 var TagName = "div";
15398 var useCollectionItem = createHook(
15399 function useCollectionItem2({
15400 store,
15401 shouldRegisterItem = true,
15402 getItem = identity,
15403 // @ts-expect-error This prop may come from a collection renderer.
15404 element,
15405 ...props
15406 }) {
15407 const context = useCollectionContext();
15408 store = store || context;
15409 const id = useId4(props.id);
15410 const ref = (0, import_react9.useRef)(element);
15411 (0, import_react9.useEffect)(() => {
15412 const element2 = ref.current;
15413 if (!id) return;
15414 if (!element2) return;
15415 if (!shouldRegisterItem) return;
15416 const item = getItem({ id, element: element2 });
15417 return store == null ? void 0 : store.renderItem(item);
15418 }, [id, shouldRegisterItem, getItem, store]);
15419 props = {
15420 ...props,
15421 ref: useMergeRefs(ref, props.ref)
15422 };
15423 return removeUndefinedValues(props);
15424 }
15425 );
15426 var CollectionItem = forwardRef22(function CollectionItem2(props) {
15427 const htmlProps = useCollectionItem(props);
15428 return createElement3(TagName, htmlProps);
15429 });
15430
15431 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
15432 var import_react10 = __toESM(require_react(), 1);
15433 var FocusableContext = (0, import_react10.createContext)(true);
15434
15435 // node_modules/@ariakit/core/esm/utils/focus.js
15436 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'])";
15437 function isFocusable(element) {
15438 if (!element.matches(selector)) return false;
15439 if (!isVisible(element)) return false;
15440 if (element.closest("[inert]")) return false;
15441 return true;
15442 }
15443 function getClosestFocusable(element) {
15444 while (element && !isFocusable(element)) {
15445 element = element.closest(selector);
15446 }
15447 return element || null;
15448 }
15449 function hasFocus(element) {
15450 const activeElement2 = getActiveElement(element);
15451 if (!activeElement2) return false;
15452 if (activeElement2 === element) return true;
15453 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15454 if (!activeDescendant) return false;
15455 return activeDescendant === element.id;
15456 }
15457 function hasFocusWithin(element) {
15458 const activeElement2 = getActiveElement(element);
15459 if (!activeElement2) return false;
15460 if (contains2(element, activeElement2)) return true;
15461 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15462 if (!activeDescendant) return false;
15463 if (!("id" in element)) return false;
15464 if (activeDescendant === element.id) return true;
15465 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
15466 }
15467 function focusIfNeeded(element) {
15468 if (!hasFocusWithin(element) && isFocusable(element)) {
15469 element.focus();
15470 }
15471 }
15472 function focusIntoView(element, options) {
15473 if (!("scrollIntoView" in element)) {
15474 element.focus();
15475 } else {
15476 element.focus({ preventScroll: true });
15477 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
15478 }
15479 }
15480
15481 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
15482 var import_react11 = __toESM(require_react(), 1);
15483 var TagName2 = "div";
15484 var isSafariBrowser = isSafari2();
15485 var alwaysFocusVisibleInputTypes = [
15486 "text",
15487 "search",
15488 "url",
15489 "tel",
15490 "email",
15491 "password",
15492 "number",
15493 "date",
15494 "month",
15495 "week",
15496 "time",
15497 "datetime",
15498 "datetime-local"
15499 ];
15500 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
15501 function markSafariFocusAncestor(element, value) {
15502 if (!element) return;
15503 element[safariFocusAncestorSymbol] = value;
15504 }
15505 function isAlwaysFocusVisible(element) {
15506 const { tagName, readOnly, type } = element;
15507 if (tagName === "TEXTAREA" && !readOnly) return true;
15508 if (tagName === "SELECT" && !readOnly) return true;
15509 if (tagName === "INPUT" && !readOnly) {
15510 return alwaysFocusVisibleInputTypes.includes(type);
15511 }
15512 if (element.isContentEditable) return true;
15513 const role = element.getAttribute("role");
15514 if (role === "combobox" && element.dataset.name) {
15515 return true;
15516 }
15517 return false;
15518 }
15519 function getLabels(element) {
15520 if ("labels" in element) {
15521 return element.labels;
15522 }
15523 return null;
15524 }
15525 function isNativeCheckboxOrRadio(element) {
15526 const tagName = element.tagName.toLowerCase();
15527 if (tagName === "input" && element.type) {
15528 return element.type === "radio" || element.type === "checkbox";
15529 }
15530 return false;
15531 }
15532 function isNativeTabbable(tagName) {
15533 if (!tagName) return true;
15534 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
15535 }
15536 function supportsDisabledAttribute(tagName) {
15537 if (!tagName) return true;
15538 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
15539 }
15540 function getTabIndex2(focusable2, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
15541 if (!focusable2) {
15542 return tabIndexProp;
15543 }
15544 if (trulyDisabled) {
15545 if (nativeTabbable && !supportsDisabled) {
15546 return -1;
15547 }
15548 return;
15549 }
15550 if (nativeTabbable) {
15551 return tabIndexProp;
15552 }
15553 return tabIndexProp || 0;
15554 }
15555 function useDisableEvent(onEvent, disabled2) {
15556 return useEvent((event) => {
15557 onEvent == null ? void 0 : onEvent(event);
15558 if (event.defaultPrevented) return;
15559 if (disabled2) {
15560 event.stopPropagation();
15561 event.preventDefault();
15562 }
15563 });
15564 }
15565 var hasInstalledGlobalEventListeners2 = false;
15566 var isKeyboardModality = true;
15567 function onGlobalMouseDown(event) {
15568 const target = event.target;
15569 if (target && "hasAttribute" in target) {
15570 if (!target.hasAttribute("data-focus-visible")) {
15571 isKeyboardModality = false;
15572 }
15573 }
15574 }
15575 function onGlobalKeyDown(event) {
15576 if (event.metaKey) return;
15577 if (event.ctrlKey) return;
15578 if (event.altKey) return;
15579 isKeyboardModality = true;
15580 }
15581 var useFocusable = createHook(
15582 function useFocusable2({
15583 focusable: focusable2 = true,
15584 accessibleWhenDisabled,
15585 autoFocus,
15586 onFocusVisible,
15587 ...props
15588 }) {
15589 const ref = (0, import_react11.useRef)(null);
15590 (0, import_react11.useEffect)(() => {
15591 if (!focusable2) return;
15592 if (hasInstalledGlobalEventListeners2) return;
15593 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
15594 addGlobalEventListener("keydown", onGlobalKeyDown, true);
15595 hasInstalledGlobalEventListeners2 = true;
15596 }, [focusable2]);
15597 if (isSafariBrowser) {
15598 (0, import_react11.useEffect)(() => {
15599 if (!focusable2) return;
15600 const element = ref.current;
15601 if (!element) return;
15602 if (!isNativeCheckboxOrRadio(element)) return;
15603 const labels = getLabels(element);
15604 if (!labels) return;
15605 const onMouseUp = () => queueMicrotask(() => element.focus());
15606 for (const label of labels) {
15607 label.addEventListener("mouseup", onMouseUp);
15608 }
15609 return () => {
15610 for (const label of labels) {
15611 label.removeEventListener("mouseup", onMouseUp);
15612 }
15613 };
15614 }, [focusable2]);
15615 }
15616 const disabled2 = focusable2 && disabledFromProps(props);
15617 const trulyDisabled = !!disabled2 && !accessibleWhenDisabled;
15618 const [focusVisible, setFocusVisible] = (0, import_react11.useState)(false);
15619 (0, import_react11.useEffect)(() => {
15620 if (!focusable2) return;
15621 if (trulyDisabled && focusVisible) {
15622 setFocusVisible(false);
15623 }
15624 }, [focusable2, trulyDisabled, focusVisible]);
15625 (0, import_react11.useEffect)(() => {
15626 if (!focusable2) return;
15627 if (!focusVisible) return;
15628 const element = ref.current;
15629 if (!element) return;
15630 if (typeof IntersectionObserver === "undefined") return;
15631 const observer = new IntersectionObserver(() => {
15632 if (!isFocusable(element)) {
15633 setFocusVisible(false);
15634 }
15635 });
15636 observer.observe(element);
15637 return () => observer.disconnect();
15638 }, [focusable2, focusVisible]);
15639 const onKeyPressCapture = useDisableEvent(
15640 props.onKeyPressCapture,
15641 disabled2
15642 );
15643 const onMouseDownCapture = useDisableEvent(
15644 props.onMouseDownCapture,
15645 disabled2
15646 );
15647 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
15648 const onMouseDownProp = props.onMouseDown;
15649 const onMouseDown = useEvent((event) => {
15650 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
15651 if (event.defaultPrevented) return;
15652 if (!focusable2) return;
15653 const element = event.currentTarget;
15654 if (!isSafariBrowser) return;
15655 if (isPortalEvent(event)) return;
15656 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
15657 let receivedFocus = false;
15658 const onFocus = () => {
15659 receivedFocus = true;
15660 };
15661 const options = { capture: true, once: true };
15662 element.addEventListener("focusin", onFocus, options);
15663 const focusableContainer = getClosestFocusable(element.parentElement);
15664 markSafariFocusAncestor(focusableContainer, true);
15665 queueBeforeEvent(element, "mouseup", () => {
15666 element.removeEventListener("focusin", onFocus, true);
15667 markSafariFocusAncestor(focusableContainer, false);
15668 if (receivedFocus) return;
15669 focusIfNeeded(element);
15670 });
15671 });
15672 const handleFocusVisible = (event, currentTarget) => {
15673 if (currentTarget) {
15674 event.currentTarget = currentTarget;
15675 }
15676 if (!focusable2) return;
15677 const element = event.currentTarget;
15678 if (!element) return;
15679 if (!hasFocus(element)) return;
15680 onFocusVisible == null ? void 0 : onFocusVisible(event);
15681 if (event.defaultPrevented) return;
15682 element.dataset.focusVisible = "true";
15683 setFocusVisible(true);
15684 };
15685 const onKeyDownCaptureProp = props.onKeyDownCapture;
15686 const onKeyDownCapture = useEvent((event) => {
15687 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
15688 if (event.defaultPrevented) return;
15689 if (!focusable2) return;
15690 if (focusVisible) return;
15691 if (event.metaKey) return;
15692 if (event.altKey) return;
15693 if (event.ctrlKey) return;
15694 if (!isSelfTarget(event)) return;
15695 const element = event.currentTarget;
15696 const applyFocusVisible = () => handleFocusVisible(event, element);
15697 queueBeforeEvent(element, "focusout", applyFocusVisible);
15698 });
15699 const onFocusCaptureProp = props.onFocusCapture;
15700 const onFocusCapture = useEvent((event) => {
15701 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
15702 if (event.defaultPrevented) return;
15703 if (!focusable2) return;
15704 if (!isSelfTarget(event)) {
15705 setFocusVisible(false);
15706 return;
15707 }
15708 const element = event.currentTarget;
15709 const applyFocusVisible = () => handleFocusVisible(event, element);
15710 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
15711 queueBeforeEvent(event.target, "focusout", applyFocusVisible);
15712 } else {
15713 setFocusVisible(false);
15714 }
15715 });
15716 const onBlurProp = props.onBlur;
15717 const onBlur = useEvent((event) => {
15718 onBlurProp == null ? void 0 : onBlurProp(event);
15719 if (!focusable2) return;
15720 if (!isFocusEventOutside(event)) return;
15721 event.currentTarget.removeAttribute("data-focus-visible");
15722 setFocusVisible(false);
15723 });
15724 const autoFocusOnShow = (0, import_react11.useContext)(FocusableContext);
15725 const autoFocusRef = useEvent((element) => {
15726 if (!focusable2) return;
15727 if (!autoFocus) return;
15728 if (!element) return;
15729 if (!autoFocusOnShow) return;
15730 queueMicrotask(() => {
15731 if (hasFocus(element)) return;
15732 if (!isFocusable(element)) return;
15733 element.focus();
15734 });
15735 });
15736 const tagName = useTagName(ref);
15737 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
15738 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
15739 const styleProp = props.style;
15740 const style = (0, import_react11.useMemo)(() => {
15741 if (trulyDisabled) {
15742 return { pointerEvents: "none", ...styleProp };
15743 }
15744 return styleProp;
15745 }, [trulyDisabled, styleProp]);
15746 props = {
15747 "data-focus-visible": focusable2 && focusVisible || void 0,
15748 "data-autofocus": autoFocus || void 0,
15749 "aria-disabled": disabled2 || void 0,
15750 ...props,
15751 ref: useMergeRefs(ref, autoFocusRef, props.ref),
15752 style,
15753 tabIndex: getTabIndex2(
15754 focusable2,
15755 trulyDisabled,
15756 nativeTabbable,
15757 supportsDisabled,
15758 props.tabIndex
15759 ),
15760 disabled: supportsDisabled && trulyDisabled ? true : void 0,
15761 // TODO: Test Focusable contentEditable.
15762 contentEditable: disabled2 ? void 0 : props.contentEditable,
15763 onKeyPressCapture,
15764 onClickCapture,
15765 onMouseDownCapture,
15766 onMouseDown,
15767 onKeyDownCapture,
15768 onFocusCapture,
15769 onBlur
15770 };
15771 return removeUndefinedValues(props);
15772 }
15773 );
15774 var Focusable = forwardRef22(function Focusable2(props) {
15775 const htmlProps = useFocusable(props);
15776 return createElement3(TagName2, htmlProps);
15777 });
15778
15779 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
15780 var import_react12 = __toESM(require_react(), 1);
15781 var TagName3 = "button";
15782 function isNativeClick(event) {
15783 if (!event.isTrusted) return false;
15784 const element = event.currentTarget;
15785 if (event.key === "Enter") {
15786 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
15787 }
15788 if (event.key === " ") {
15789 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
15790 }
15791 return false;
15792 }
15793 var symbol = /* @__PURE__ */ Symbol("command");
15794 var useCommand = createHook(
15795 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
15796 const ref = (0, import_react12.useRef)(null);
15797 const [isNativeButton, setIsNativeButton] = (0, import_react12.useState)(false);
15798 (0, import_react12.useEffect)(() => {
15799 if (!ref.current) return;
15800 setIsNativeButton(isButton(ref.current));
15801 }, []);
15802 const [active, setActive] = (0, import_react12.useState)(false);
15803 const activeRef = (0, import_react12.useRef)(false);
15804 const disabled2 = disabledFromProps(props);
15805 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
15806 const onKeyDownProp = props.onKeyDown;
15807 const onKeyDown = useEvent((event) => {
15808 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
15809 const element = event.currentTarget;
15810 if (event.defaultPrevented) return;
15811 if (isDuplicate) return;
15812 if (disabled2) return;
15813 if (!isSelfTarget(event)) return;
15814 if (isTextField(element)) return;
15815 if (element.isContentEditable) return;
15816 const isEnter = clickOnEnter && event.key === "Enter";
15817 const isSpace = clickOnSpace && event.key === " ";
15818 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
15819 const shouldPreventSpace = event.key === " " && !clickOnSpace;
15820 if (shouldPreventEnter || shouldPreventSpace) {
15821 event.preventDefault();
15822 return;
15823 }
15824 if (isEnter || isSpace) {
15825 const nativeClick = isNativeClick(event);
15826 if (isEnter) {
15827 if (!nativeClick) {
15828 event.preventDefault();
15829 const { view, ...eventInit } = event;
15830 const click = () => fireClickEvent(element, eventInit);
15831 if (isFirefox2()) {
15832 queueBeforeEvent(element, "keyup", click);
15833 } else {
15834 queueMicrotask(click);
15835 }
15836 }
15837 } else if (isSpace) {
15838 activeRef.current = true;
15839 if (!nativeClick) {
15840 event.preventDefault();
15841 setActive(true);
15842 }
15843 }
15844 }
15845 });
15846 const onKeyUpProp = props.onKeyUp;
15847 const onKeyUp = useEvent((event) => {
15848 onKeyUpProp == null ? void 0 : onKeyUpProp(event);
15849 if (event.defaultPrevented) return;
15850 if (isDuplicate) return;
15851 if (disabled2) return;
15852 if (event.metaKey) return;
15853 const isSpace = clickOnSpace && event.key === " ";
15854 if (activeRef.current && isSpace) {
15855 activeRef.current = false;
15856 if (!isNativeClick(event)) {
15857 event.preventDefault();
15858 setActive(false);
15859 const element = event.currentTarget;
15860 const { view, ...eventInit } = event;
15861 queueMicrotask(() => fireClickEvent(element, eventInit));
15862 }
15863 }
15864 });
15865 props = {
15866 "data-active": active || void 0,
15867 type: isNativeButton ? "button" : void 0,
15868 ...metadataProps,
15869 ...props,
15870 ref: useMergeRefs(ref, props.ref),
15871 onKeyDown,
15872 onKeyUp
15873 };
15874 props = useFocusable(props);
15875 return props;
15876 }
15877 );
15878 var Command = forwardRef22(function Command2(props) {
15879 const htmlProps = useCommand(props);
15880 return createElement3(TagName3, htmlProps);
15881 });
15882
15883 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
15884 function getInternal(store, key) {
15885 const internals = store.__unstableInternals;
15886 invariant(internals, "Invalid store");
15887 return internals[key];
15888 }
15889 function createStore(initialState, ...stores) {
15890 let state = initialState;
15891 let prevStateBatch = state;
15892 let lastUpdate = /* @__PURE__ */ Symbol();
15893 let destroy = noop5;
15894 const instances = /* @__PURE__ */ new Set();
15895 const updatedKeys = /* @__PURE__ */ new Set();
15896 const setups = /* @__PURE__ */ new Set();
15897 const listeners = /* @__PURE__ */ new Set();
15898 const batchListeners = /* @__PURE__ */ new Set();
15899 const disposables = /* @__PURE__ */ new WeakMap();
15900 const listenerKeys = /* @__PURE__ */ new WeakMap();
15901 const storeSetup = (callback) => {
15902 setups.add(callback);
15903 return () => setups.delete(callback);
15904 };
15905 const storeInit = () => {
15906 const initialized = instances.size;
15907 const instance = /* @__PURE__ */ Symbol();
15908 instances.add(instance);
15909 const maybeDestroy = () => {
15910 instances.delete(instance);
15911 if (instances.size) return;
15912 destroy();
15913 };
15914 if (initialized) return maybeDestroy;
15915 const desyncs = getKeys(state).map(
15916 (key) => chain(
15917 ...stores.map((store) => {
15918 var _a;
15919 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store);
15920 if (!storeState) return;
15921 if (!hasOwnProperty(storeState, key)) return;
15922 return sync(store, [key], (state2) => {
15923 setState(
15924 key,
15925 state2[key],
15926 // @ts-expect-error - Not public API. This is just to prevent
15927 // infinite loops.
15928 true
15929 );
15930 });
15931 })
15932 )
15933 );
15934 const teardowns = [];
15935 for (const setup2 of setups) {
15936 teardowns.push(setup2());
15937 }
15938 const cleanups = stores.map(init);
15939 destroy = chain(...desyncs, ...teardowns, ...cleanups);
15940 return maybeDestroy;
15941 };
15942 const sub = (keys, listener, set2 = listeners) => {
15943 set2.add(listener);
15944 listenerKeys.set(listener, keys);
15945 return () => {
15946 var _a;
15947 (_a = disposables.get(listener)) == null ? void 0 : _a();
15948 disposables.delete(listener);
15949 listenerKeys.delete(listener);
15950 set2.delete(listener);
15951 };
15952 };
15953 const storeSubscribe = (keys, listener) => sub(keys, listener);
15954 const storeSync = (keys, listener) => {
15955 disposables.set(listener, listener(state, state));
15956 return sub(keys, listener);
15957 };
15958 const storeBatch = (keys, listener) => {
15959 disposables.set(listener, listener(state, prevStateBatch));
15960 return sub(keys, listener, batchListeners);
15961 };
15962 const storePick = (keys) => createStore(pick(state, keys), finalStore);
15963 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
15964 const getState = () => state;
15965 const setState = (key, value, fromStores = false) => {
15966 var _a;
15967 if (!hasOwnProperty(state, key)) return;
15968 const nextValue = applyState(value, state[key]);
15969 if (nextValue === state[key]) return;
15970 if (!fromStores) {
15971 for (const store of stores) {
15972 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue);
15973 }
15974 }
15975 const prevState = state;
15976 state = { ...state, [key]: nextValue };
15977 const thisUpdate = /* @__PURE__ */ Symbol();
15978 lastUpdate = thisUpdate;
15979 updatedKeys.add(key);
15980 const run = (listener, prev, uKeys) => {
15981 var _a2;
15982 const keys = listenerKeys.get(listener);
15983 const updated = (k) => uKeys ? uKeys.has(k) : k === key;
15984 if (!keys || keys.some(updated)) {
15985 (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
15986 disposables.set(listener, listener(state, prev));
15987 }
15988 };
15989 for (const listener of listeners) {
15990 run(listener, prevState);
15991 }
15992 queueMicrotask(() => {
15993 if (lastUpdate !== thisUpdate) return;
15994 const snapshot = state;
15995 for (const listener of batchListeners) {
15996 run(listener, prevStateBatch, updatedKeys);
15997 }
15998 prevStateBatch = snapshot;
15999 updatedKeys.clear();
16000 });
16001 };
16002 const finalStore = {
16003 getState,
16004 setState,
16005 __unstableInternals: {
16006 setup: storeSetup,
16007 init: storeInit,
16008 subscribe: storeSubscribe,
16009 sync: storeSync,
16010 batch: storeBatch,
16011 pick: storePick,
16012 omit: storeOmit
16013 }
16014 };
16015 return finalStore;
16016 }
16017 function setup(store, ...args) {
16018 if (!store) return;
16019 return getInternal(store, "setup")(...args);
16020 }
16021 function init(store, ...args) {
16022 if (!store) return;
16023 return getInternal(store, "init")(...args);
16024 }
16025 function subscribe(store, ...args) {
16026 if (!store) return;
16027 return getInternal(store, "subscribe")(...args);
16028 }
16029 function sync(store, ...args) {
16030 if (!store) return;
16031 return getInternal(store, "sync")(...args);
16032 }
16033 function batch(store, ...args) {
16034 if (!store) return;
16035 return getInternal(store, "batch")(...args);
16036 }
16037 function omit2(store, ...args) {
16038 if (!store) return;
16039 return getInternal(store, "omit")(...args);
16040 }
16041 function pick2(store, ...args) {
16042 if (!store) return;
16043 return getInternal(store, "pick")(...args);
16044 }
16045 function mergeStore(...stores) {
16046 var _a;
16047 const initialState = {};
16048 for (const store2 of stores) {
16049 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
16050 if (nextState) {
16051 Object.assign(initialState, nextState);
16052 }
16053 }
16054 const store = createStore(initialState, ...stores);
16055 return Object.assign({}, ...stores, store);
16056 }
16057 function throwOnConflictingProps(props, store) {
16058 if (false) return;
16059 if (!store) return;
16060 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
16061 var _a;
16062 const stateKey = key.replace("default", "");
16063 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
16064 });
16065 if (!defaultKeys.length) return;
16066 const storeState = store.getState();
16067 const conflictingProps = defaultKeys.filter(
16068 (key) => hasOwnProperty(storeState, key)
16069 );
16070 if (!conflictingProps.length) return;
16071 throw new Error(
16072 `Passing a store prop in conjunction with a default state is not supported.
16073
16074 const store = useSelectStore();
16075 <SelectProvider store={store} defaultValue="Apple" />
16076 ^ ^
16077
16078 Instead, pass the default state to the topmost store:
16079
16080 const store = useSelectStore({ defaultValue: "Apple" });
16081 <SelectProvider store={store} />
16082
16083 See https://github.com/ariakit/ariakit/pull/2745 for more details.
16084
16085 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
16086 `
16087 );
16088 }
16089
16090 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
16091 var React50 = __toESM(require_react(), 1);
16092 var import_shim2 = __toESM(require_shim(), 1);
16093 var { useSyncExternalStore: useSyncExternalStore2 } = import_shim2.default;
16094 var noopSubscribe = () => () => {
16095 };
16096 function useStoreState(store, keyOrSelector = identity) {
16097 const storeSubscribe = React50.useCallback(
16098 (callback) => {
16099 if (!store) return noopSubscribe();
16100 return subscribe(store, null, callback);
16101 },
16102 [store]
16103 );
16104 const getSnapshot = () => {
16105 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
16106 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
16107 const state = store == null ? void 0 : store.getState();
16108 if (selector2) return selector2(state);
16109 if (!state) return;
16110 if (!key) return;
16111 if (!hasOwnProperty(state, key)) return;
16112 return state[key];
16113 };
16114 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
16115 }
16116 function useStoreStateObject(store, object) {
16117 const objRef = React50.useRef(
16118 {}
16119 );
16120 const storeSubscribe = React50.useCallback(
16121 (callback) => {
16122 if (!store) return noopSubscribe();
16123 return subscribe(store, null, callback);
16124 },
16125 [store]
16126 );
16127 const getSnapshot = () => {
16128 const state = store == null ? void 0 : store.getState();
16129 let updated = false;
16130 const obj = objRef.current;
16131 for (const prop in object) {
16132 const keyOrSelector = object[prop];
16133 if (typeof keyOrSelector === "function") {
16134 const value = keyOrSelector(state);
16135 if (value !== obj[prop]) {
16136 obj[prop] = value;
16137 updated = true;
16138 }
16139 }
16140 if (typeof keyOrSelector === "string") {
16141 if (!state) continue;
16142 if (!hasOwnProperty(state, keyOrSelector)) continue;
16143 const value = state[keyOrSelector];
16144 if (value !== obj[prop]) {
16145 obj[prop] = value;
16146 updated = true;
16147 }
16148 }
16149 }
16150 if (updated) {
16151 objRef.current = { ...obj };
16152 }
16153 return objRef.current;
16154 };
16155 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
16156 }
16157 function useStoreProps(store, props, key, setKey) {
16158 const value = hasOwnProperty(props, key) ? props[key] : void 0;
16159 const setValue = setKey ? props[setKey] : void 0;
16160 const propsRef = useLiveRef({ value, setValue });
16161 useSafeLayoutEffect(() => {
16162 return sync(store, [key], (state, prev) => {
16163 const { value: value2, setValue: setValue2 } = propsRef.current;
16164 if (!setValue2) return;
16165 if (state[key] === prev[key]) return;
16166 if (state[key] === value2) return;
16167 setValue2(state[key]);
16168 });
16169 }, [store, key]);
16170 useSafeLayoutEffect(() => {
16171 if (value === void 0) return;
16172 store.setState(key, value);
16173 return batch(store, [key], () => {
16174 if (value === void 0) return;
16175 store.setState(key, value);
16176 });
16177 });
16178 }
16179 function useStore2(createStore2, props) {
16180 const [store, setStore] = React50.useState(() => createStore2(props));
16181 useSafeLayoutEffect(() => init(store), [store]);
16182 const useState210 = React50.useCallback(
16183 (keyOrSelector) => useStoreState(store, keyOrSelector),
16184 [store]
16185 );
16186 const memoizedStore = React50.useMemo(
16187 () => ({ ...store, useState: useState210 }),
16188 [store, useState210]
16189 );
16190 const updateStore = useEvent(() => {
16191 setStore((store2) => createStore2({ ...props, ...store2.getState() }));
16192 });
16193 return [memoizedStore, updateStore];
16194 }
16195
16196 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
16197 var import_react13 = __toESM(require_react(), 1);
16198 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
16199 var TagName4 = "button";
16200 function isEditableElement(element) {
16201 if (isTextbox(element)) return true;
16202 return element.tagName === "INPUT" && !isButton(element);
16203 }
16204 function getNextPageOffset(scrollingElement, pageUp = false) {
16205 const height = scrollingElement.clientHeight;
16206 const { top } = scrollingElement.getBoundingClientRect();
16207 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
16208 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
16209 if (scrollingElement.tagName === "HTML") {
16210 return pageOffset + scrollingElement.scrollTop;
16211 }
16212 return pageOffset;
16213 }
16214 function getItemOffset(itemElement, pageUp = false) {
16215 const { top } = itemElement.getBoundingClientRect();
16216 if (pageUp) {
16217 return top + itemElement.clientHeight;
16218 }
16219 return top;
16220 }
16221 function findNextPageItemId(element, store, next, pageUp = false) {
16222 var _a;
16223 if (!store) return;
16224 if (!next) return;
16225 const { renderedItems } = store.getState();
16226 const scrollingElement = getScrollingElement(element);
16227 if (!scrollingElement) return;
16228 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
16229 let id;
16230 let prevDifference;
16231 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
16232 const previousId = id;
16233 id = next(i2);
16234 if (!id) break;
16235 if (id === previousId) continue;
16236 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element;
16237 if (!itemElement) continue;
16238 const itemOffset = getItemOffset(itemElement, pageUp);
16239 const difference = itemOffset - nextPageOffset;
16240 const absDifference = Math.abs(difference);
16241 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
16242 if (prevDifference !== void 0 && prevDifference < absDifference) {
16243 id = previousId;
16244 }
16245 break;
16246 }
16247 prevDifference = absDifference;
16248 }
16249 return id;
16250 }
16251 function targetIsAnotherItem(event, store) {
16252 if (isSelfTarget(event)) return false;
16253 return isItem(store, event.target);
16254 }
16255 var useCompositeItem = createHook(
16256 function useCompositeItem2({
16257 store,
16258 rowId: rowIdProp,
16259 preventScrollOnKeyDown = false,
16260 moveOnKeyPress = true,
16261 tabbable: tabbable2 = false,
16262 getItem: getItemProp,
16263 "aria-setsize": ariaSetSizeProp,
16264 "aria-posinset": ariaPosInSetProp,
16265 ...props
16266 }) {
16267 const context = useCompositeContext();
16268 store = store || context;
16269 const id = useId4(props.id);
16270 const ref = (0, import_react13.useRef)(null);
16271 const row = (0, import_react13.useContext)(CompositeRowContext);
16272 const disabled2 = disabledFromProps(props);
16273 const trulyDisabled = disabled2 && !props.accessibleWhenDisabled;
16274 const {
16275 rowId,
16276 baseElement,
16277 isActiveItem,
16278 ariaSetSize,
16279 ariaPosInSet,
16280 isTabbable
16281 } = useStoreStateObject(store, {
16282 rowId(state) {
16283 if (rowIdProp) return rowIdProp;
16284 if (!state) return;
16285 if (!(row == null ? void 0 : row.baseElement)) return;
16286 if (row.baseElement !== state.baseElement) return;
16287 return row.id;
16288 },
16289 baseElement(state) {
16290 return (state == null ? void 0 : state.baseElement) || void 0;
16291 },
16292 isActiveItem(state) {
16293 return !!state && state.activeId === id;
16294 },
16295 ariaSetSize(state) {
16296 if (ariaSetSizeProp != null) return ariaSetSizeProp;
16297 if (!state) return;
16298 if (!(row == null ? void 0 : row.ariaSetSize)) return;
16299 if (row.baseElement !== state.baseElement) return;
16300 return row.ariaSetSize;
16301 },
16302 ariaPosInSet(state) {
16303 if (ariaPosInSetProp != null) return ariaPosInSetProp;
16304 if (!state) return;
16305 if (!(row == null ? void 0 : row.ariaPosInSet)) return;
16306 if (row.baseElement !== state.baseElement) return;
16307 const itemsInRow = state.renderedItems.filter(
16308 (item) => item.rowId === rowId
16309 );
16310 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
16311 },
16312 isTabbable(state) {
16313 if (!(state == null ? void 0 : state.renderedItems.length)) return true;
16314 if (state.virtualFocus) return false;
16315 if (tabbable2) return true;
16316 if (state.activeId === null) return false;
16317 const item = store == null ? void 0 : store.item(state.activeId);
16318 if (item == null ? void 0 : item.disabled) return true;
16319 if (!(item == null ? void 0 : item.element)) return true;
16320 return state.activeId === id;
16321 }
16322 });
16323 const getItem = (0, import_react13.useCallback)(
16324 (item) => {
16325 var _a;
16326 const nextItem = {
16327 ...item,
16328 id: id || item.id,
16329 rowId,
16330 disabled: !!trulyDisabled,
16331 children: (_a = item.element) == null ? void 0 : _a.textContent
16332 };
16333 if (getItemProp) {
16334 return getItemProp(nextItem);
16335 }
16336 return nextItem;
16337 },
16338 [id, rowId, trulyDisabled, getItemProp]
16339 );
16340 const onFocusProp = props.onFocus;
16341 const hasFocusedComposite = (0, import_react13.useRef)(false);
16342 const onFocus = useEvent((event) => {
16343 onFocusProp == null ? void 0 : onFocusProp(event);
16344 if (event.defaultPrevented) return;
16345 if (isPortalEvent(event)) return;
16346 if (!id) return;
16347 if (!store) return;
16348 if (targetIsAnotherItem(event, store)) return;
16349 const { virtualFocus, baseElement: baseElement2 } = store.getState();
16350 store.setActiveId(id);
16351 if (isTextbox(event.currentTarget)) {
16352 selectTextField(event.currentTarget);
16353 }
16354 if (!virtualFocus) return;
16355 if (!isSelfTarget(event)) return;
16356 if (isEditableElement(event.currentTarget)) return;
16357 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
16358 if (isSafari2() && event.currentTarget.hasAttribute("data-autofocus")) {
16359 event.currentTarget.scrollIntoView({
16360 block: "nearest",
16361 inline: "nearest"
16362 });
16363 }
16364 hasFocusedComposite.current = true;
16365 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget);
16366 if (fromComposite) {
16367 focusSilently(baseElement2);
16368 } else {
16369 baseElement2.focus();
16370 }
16371 });
16372 const onBlurCaptureProp = props.onBlurCapture;
16373 const onBlurCapture = useEvent((event) => {
16374 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
16375 if (event.defaultPrevented) return;
16376 const state = store == null ? void 0 : store.getState();
16377 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
16378 hasFocusedComposite.current = false;
16379 event.preventDefault();
16380 event.stopPropagation();
16381 }
16382 });
16383 const onKeyDownProp = props.onKeyDown;
16384 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
16385 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
16386 const onKeyDown = useEvent((event) => {
16387 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
16388 if (event.defaultPrevented) return;
16389 if (!isSelfTarget(event)) return;
16390 if (!store) return;
16391 const { currentTarget } = event;
16392 const state = store.getState();
16393 const item = store.item(id);
16394 const isGrid2 = !!(item == null ? void 0 : item.rowId);
16395 const isVertical = state.orientation !== "horizontal";
16396 const isHorizontal = state.orientation !== "vertical";
16397 const canHomeEnd = () => {
16398 if (isGrid2) return true;
16399 if (isHorizontal) return true;
16400 if (!state.baseElement) return true;
16401 if (!isTextField(state.baseElement)) return true;
16402 return false;
16403 };
16404 const keyMap = {
16405 ArrowUp: (isGrid2 || isVertical) && store.up,
16406 ArrowRight: (isGrid2 || isHorizontal) && store.next,
16407 ArrowDown: (isGrid2 || isVertical) && store.down,
16408 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
16409 Home: () => {
16410 if (!canHomeEnd()) return;
16411 if (!isGrid2 || event.ctrlKey) {
16412 return store == null ? void 0 : store.first();
16413 }
16414 return store == null ? void 0 : store.previous(-1);
16415 },
16416 End: () => {
16417 if (!canHomeEnd()) return;
16418 if (!isGrid2 || event.ctrlKey) {
16419 return store == null ? void 0 : store.last();
16420 }
16421 return store == null ? void 0 : store.next(-1);
16422 },
16423 PageUp: () => {
16424 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true);
16425 },
16426 PageDown: () => {
16427 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down);
16428 }
16429 };
16430 const action = keyMap[event.key];
16431 if (action) {
16432 if (isTextbox(currentTarget)) {
16433 const selection = getTextboxSelection(currentTarget);
16434 const isLeft = isHorizontal && event.key === "ArrowLeft";
16435 const isRight = isHorizontal && event.key === "ArrowRight";
16436 const isUp = isVertical && event.key === "ArrowUp";
16437 const isDown = isVertical && event.key === "ArrowDown";
16438 if (isRight || isDown) {
16439 const { length: valueLength } = getTextboxValue(currentTarget);
16440 if (selection.end !== valueLength) return;
16441 } else if ((isLeft || isUp) && selection.start !== 0) return;
16442 }
16443 const nextId = action();
16444 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
16445 if (!moveOnKeyPressProp(event)) return;
16446 event.preventDefault();
16447 store.move(nextId);
16448 }
16449 }
16450 });
16451 const providerValue = (0, import_react13.useMemo)(
16452 () => ({ id, baseElement }),
16453 [id, baseElement]
16454 );
16455 props = useWrapElement(
16456 props,
16457 (element) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
16458 [providerValue]
16459 );
16460 props = {
16461 id,
16462 "data-active-item": isActiveItem || void 0,
16463 ...props,
16464 ref: useMergeRefs(ref, props.ref),
16465 tabIndex: isTabbable ? props.tabIndex : -1,
16466 onFocus,
16467 onBlurCapture,
16468 onKeyDown
16469 };
16470 props = useCommand(props);
16471 props = useCollectionItem({
16472 store,
16473 ...props,
16474 getItem,
16475 shouldRegisterItem: id ? props.shouldRegisterItem : false
16476 });
16477 return removeUndefinedValues({
16478 ...props,
16479 "aria-setsize": ariaSetSize,
16480 "aria-posinset": ariaPosInSet
16481 });
16482 }
16483 );
16484 var CompositeItem = memo22(
16485 forwardRef22(function CompositeItem2(props) {
16486 const htmlProps = useCompositeItem(props);
16487 return createElement3(TagName4, htmlProps);
16488 })
16489 );
16490
16491 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
16492 function toArray(arg) {
16493 if (Array.isArray(arg)) {
16494 return arg;
16495 }
16496 return typeof arg !== "undefined" ? [arg] : [];
16497 }
16498 function flatten2DArray(array) {
16499 const flattened = [];
16500 for (const row of array) {
16501 flattened.push(...row);
16502 }
16503 return flattened;
16504 }
16505 function reverseArray(array) {
16506 return array.slice().reverse();
16507 }
16508
16509 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
16510 var import_react14 = __toESM(require_react(), 1);
16511 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
16512 var TagName5 = "div";
16513 function isGrid(items) {
16514 return items.some((item) => !!item.rowId);
16515 }
16516 function isPrintableKey(event) {
16517 const target = event.target;
16518 if (target && !isTextField(target)) return false;
16519 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
16520 }
16521 function isModifierKey(event) {
16522 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
16523 }
16524 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
16525 return useEvent((event) => {
16526 var _a;
16527 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
16528 if (event.defaultPrevented) return;
16529 if (event.isPropagationStopped()) return;
16530 if (!isSelfTarget(event)) return;
16531 if (isModifierKey(event)) return;
16532 if (isPrintableKey(event)) return;
16533 const state = store.getState();
16534 const activeElement2 = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element;
16535 if (!activeElement2) return;
16536 const { view, ...eventInit } = event;
16537 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
16538 if (activeElement2 !== previousElement) {
16539 activeElement2.focus();
16540 }
16541 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) {
16542 event.preventDefault();
16543 }
16544 if (event.currentTarget.contains(activeElement2)) {
16545 event.stopPropagation();
16546 }
16547 });
16548 }
16549 function findFirstEnabledItemInTheLastRow(items) {
16550 return findFirstEnabledItem(
16551 flatten2DArray(reverseArray(groupItemsByRows(items)))
16552 );
16553 }
16554 function useScheduleFocus(store) {
16555 const [scheduled, setScheduled] = (0, import_react14.useState)(false);
16556 const schedule = (0, import_react14.useCallback)(() => setScheduled(true), []);
16557 const activeItem = store.useState(
16558 (state) => getEnabledItem(store, state.activeId)
16559 );
16560 (0, import_react14.useEffect)(() => {
16561 const activeElement2 = activeItem == null ? void 0 : activeItem.element;
16562 if (!scheduled) return;
16563 if (!activeElement2) return;
16564 setScheduled(false);
16565 activeElement2.focus({ preventScroll: true });
16566 }, [activeItem, scheduled]);
16567 return schedule;
16568 }
16569 var useComposite = createHook(
16570 function useComposite2({
16571 store,
16572 composite = true,
16573 focusOnMove = composite,
16574 moveOnKeyPress = true,
16575 ...props
16576 }) {
16577 const context = useCompositeProviderContext();
16578 store = store || context;
16579 invariant(
16580 store,
16581 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
16582 );
16583 const ref = (0, import_react14.useRef)(null);
16584 const previousElementRef = (0, import_react14.useRef)(null);
16585 const scheduleFocus = useScheduleFocus(store);
16586 const moves = store.useState("moves");
16587 const [, setBaseElement] = useTransactionState(
16588 composite ? store.setBaseElement : null
16589 );
16590 (0, import_react14.useEffect)(() => {
16591 var _a;
16592 if (!store) return;
16593 if (!moves) return;
16594 if (!composite) return;
16595 if (!focusOnMove) return;
16596 const { activeId: activeId2 } = store.getState();
16597 const itemElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
16598 if (!itemElement) return;
16599 focusIntoView(itemElement);
16600 }, [store, moves, composite, focusOnMove]);
16601 useSafeLayoutEffect(() => {
16602 if (!store) return;
16603 if (!moves) return;
16604 if (!composite) return;
16605 const { baseElement, activeId: activeId2 } = store.getState();
16606 const isSelfAcive = activeId2 === null;
16607 if (!isSelfAcive) return;
16608 if (!baseElement) return;
16609 const previousElement = previousElementRef.current;
16610 previousElementRef.current = null;
16611 if (previousElement) {
16612 fireBlurEvent(previousElement, { relatedTarget: baseElement });
16613 }
16614 if (!hasFocus(baseElement)) {
16615 baseElement.focus();
16616 }
16617 }, [store, moves, composite]);
16618 const activeId = store.useState("activeId");
16619 const virtualFocus = store.useState("virtualFocus");
16620 useSafeLayoutEffect(() => {
16621 var _a;
16622 if (!store) return;
16623 if (!composite) return;
16624 if (!virtualFocus) return;
16625 const previousElement = previousElementRef.current;
16626 previousElementRef.current = null;
16627 if (!previousElement) return;
16628 const activeElement2 = (_a = getEnabledItem(store, activeId)) == null ? void 0 : _a.element;
16629 const relatedTarget = activeElement2 || getActiveElement(previousElement);
16630 if (relatedTarget === previousElement) return;
16631 fireBlurEvent(previousElement, { relatedTarget });
16632 }, [store, activeId, virtualFocus, composite]);
16633 const onKeyDownCapture = useKeyboardEventProxy(
16634 store,
16635 props.onKeyDownCapture,
16636 previousElementRef
16637 );
16638 const onKeyUpCapture = useKeyboardEventProxy(
16639 store,
16640 props.onKeyUpCapture,
16641 previousElementRef
16642 );
16643 const onFocusCaptureProp = props.onFocusCapture;
16644 const onFocusCapture = useEvent((event) => {
16645 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
16646 if (event.defaultPrevented) return;
16647 if (!store) return;
16648 const { virtualFocus: virtualFocus2 } = store.getState();
16649 if (!virtualFocus2) return;
16650 const previousActiveElement = event.relatedTarget;
16651 const isSilentlyFocused = silentlyFocused(event.currentTarget);
16652 if (isSelfTarget(event) && isSilentlyFocused) {
16653 event.stopPropagation();
16654 previousElementRef.current = previousActiveElement;
16655 }
16656 });
16657 const onFocusProp = props.onFocus;
16658 const onFocus = useEvent((event) => {
16659 onFocusProp == null ? void 0 : onFocusProp(event);
16660 if (event.defaultPrevented) return;
16661 if (!composite) return;
16662 if (!store) return;
16663 const { relatedTarget } = event;
16664 const { virtualFocus: virtualFocus2 } = store.getState();
16665 if (virtualFocus2) {
16666 if (isSelfTarget(event) && !isItem(store, relatedTarget)) {
16667 queueMicrotask(scheduleFocus);
16668 }
16669 } else if (isSelfTarget(event)) {
16670 store.setActiveId(null);
16671 }
16672 });
16673 const onBlurCaptureProp = props.onBlurCapture;
16674 const onBlurCapture = useEvent((event) => {
16675 var _a;
16676 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
16677 if (event.defaultPrevented) return;
16678 if (!store) return;
16679 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
16680 if (!virtualFocus2) return;
16681 const activeElement2 = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
16682 const nextActiveElement = event.relatedTarget;
16683 const nextActiveElementIsItem = isItem(store, nextActiveElement);
16684 const previousElement = previousElementRef.current;
16685 previousElementRef.current = null;
16686 if (isSelfTarget(event) && nextActiveElementIsItem) {
16687 if (nextActiveElement === activeElement2) {
16688 if (previousElement && previousElement !== nextActiveElement) {
16689 fireBlurEvent(previousElement, event);
16690 }
16691 } else if (activeElement2) {
16692 fireBlurEvent(activeElement2, event);
16693 } else if (previousElement) {
16694 fireBlurEvent(previousElement, event);
16695 }
16696 event.stopPropagation();
16697 } else {
16698 const targetIsItem = isItem(store, event.target);
16699 if (!targetIsItem && activeElement2) {
16700 fireBlurEvent(activeElement2, event);
16701 }
16702 }
16703 });
16704 const onKeyDownProp = props.onKeyDown;
16705 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
16706 const onKeyDown = useEvent((event) => {
16707 var _a;
16708 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
16709 if (event.nativeEvent.isComposing) return;
16710 if (event.defaultPrevented) return;
16711 if (!store) return;
16712 if (!isSelfTarget(event)) return;
16713 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
16714 const activeItem = getEnabledItem(store, activeId2);
16715 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
16716 const isVertical = orientation !== "horizontal";
16717 const isHorizontal = orientation !== "vertical";
16718 const grid = isGrid(renderedItems);
16719 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
16720 if (isHorizontalKey && isTextField(event.currentTarget)) return;
16721 const up = () => {
16722 if (grid) {
16723 const item = findFirstEnabledItemInTheLastRow(renderedItems);
16724 return item == null ? void 0 : item.id;
16725 }
16726 return store == null ? void 0 : store.last();
16727 };
16728 const keyMap = {
16729 ArrowUp: (grid || isVertical) && up,
16730 ArrowRight: (grid || isHorizontal) && store.first,
16731 ArrowDown: (grid || isVertical) && store.first,
16732 ArrowLeft: (grid || isHorizontal) && store.last,
16733 Home: store.first,
16734 End: store.last,
16735 PageUp: store.first,
16736 PageDown: store.last
16737 };
16738 const action = keyMap[event.key];
16739 if (action) {
16740 const id = action();
16741 if (id !== void 0) {
16742 if (!moveOnKeyPressProp(event)) return;
16743 event.preventDefault();
16744 store.move(id);
16745 }
16746 }
16747 });
16748 props = useWrapElement(
16749 props,
16750 (element) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(CompositeContextProvider, { value: store, children: element }),
16751 [store]
16752 );
16753 const activeDescendant = store.useState((state) => {
16754 var _a;
16755 if (!store) return;
16756 if (!composite) return;
16757 if (!state.virtualFocus) return;
16758 return (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.id;
16759 });
16760 props = {
16761 "aria-activedescendant": activeDescendant,
16762 ...props,
16763 ref: useMergeRefs(ref, setBaseElement, props.ref),
16764 onKeyDownCapture,
16765 onKeyUpCapture,
16766 onFocusCapture,
16767 onFocus,
16768 onBlurCapture,
16769 onKeyDown
16770 };
16771 const focusable2 = store.useState(
16772 (state) => composite && (state.virtualFocus || state.activeId === null)
16773 );
16774 props = useFocusable({ focusable: focusable2, ...props });
16775 return props;
16776 }
16777 );
16778 var Composite5 = forwardRef22(function Composite22(props) {
16779 const htmlProps = useComposite(props);
16780 return createElement3(TagName5, htmlProps);
16781 });
16782
16783 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
16784 var ctx3 = createStoreContext();
16785 var useDisclosureContext = ctx3.useContext;
16786 var useDisclosureScopedContext = ctx3.useScopedContext;
16787 var useDisclosureProviderContext = ctx3.useProviderContext;
16788 var DisclosureContextProvider = ctx3.ContextProvider;
16789 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
16790
16791 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
16792 var import_react15 = __toESM(require_react(), 1);
16793 var ctx4 = createStoreContext(
16794 [DisclosureContextProvider],
16795 [DisclosureScopedContextProvider]
16796 );
16797 var useDialogContext = ctx4.useContext;
16798 var useDialogScopedContext = ctx4.useScopedContext;
16799 var useDialogProviderContext = ctx4.useProviderContext;
16800 var DialogContextProvider = ctx4.ContextProvider;
16801 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
16802 var DialogHeadingContext = (0, import_react15.createContext)(void 0);
16803 var DialogDescriptionContext = (0, import_react15.createContext)(void 0);
16804
16805 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
16806 var import_react16 = __toESM(require_react(), 1);
16807 var import_react_dom4 = __toESM(require_react_dom(), 1);
16808 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
16809 var TagName6 = "div";
16810 function afterTimeout(timeoutMs, cb) {
16811 const timeoutId = setTimeout(cb, timeoutMs);
16812 return () => clearTimeout(timeoutId);
16813 }
16814 function afterPaint2(cb) {
16815 let raf = requestAnimationFrame(() => {
16816 raf = requestAnimationFrame(cb);
16817 });
16818 return () => cancelAnimationFrame(raf);
16819 }
16820 function parseCSSTime(...times) {
16821 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
16822 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
16823 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
16824 if (currentTime > longestTime) return currentTime;
16825 return longestTime;
16826 }, 0);
16827 }
16828 function isHidden(mounted, hidden, alwaysVisible) {
16829 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
16830 }
16831 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) {
16832 const context = useDisclosureProviderContext();
16833 store = store || context;
16834 invariant(
16835 store,
16836 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
16837 );
16838 const ref = (0, import_react16.useRef)(null);
16839 const id = useId4(props.id);
16840 const [transition, setTransition] = (0, import_react16.useState)(null);
16841 const open = store.useState("open");
16842 const mounted = store.useState("mounted");
16843 const animated = store.useState("animated");
16844 const contentElement = store.useState("contentElement");
16845 const otherElement = useStoreState(store.disclosure, "contentElement");
16846 useSafeLayoutEffect(() => {
16847 if (!ref.current) return;
16848 store == null ? void 0 : store.setContentElement(ref.current);
16849 }, [store]);
16850 useSafeLayoutEffect(() => {
16851 let previousAnimated;
16852 store == null ? void 0 : store.setState("animated", (animated2) => {
16853 previousAnimated = animated2;
16854 return true;
16855 });
16856 return () => {
16857 if (previousAnimated === void 0) return;
16858 store == null ? void 0 : store.setState("animated", previousAnimated);
16859 };
16860 }, [store]);
16861 useSafeLayoutEffect(() => {
16862 if (!animated) return;
16863 if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
16864 setTransition(null);
16865 return;
16866 }
16867 return afterPaint2(() => {
16868 setTransition(open ? "enter" : mounted ? "leave" : null);
16869 });
16870 }, [animated, contentElement, open, mounted]);
16871 useSafeLayoutEffect(() => {
16872 if (!store) return;
16873 if (!animated) return;
16874 if (!transition) return;
16875 if (!contentElement) return;
16876 const stopAnimation = () => store == null ? void 0 : store.setState("animating", false);
16877 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
16878 if (transition === "leave" && open) return;
16879 if (transition === "enter" && !open) return;
16880 if (typeof animated === "number") {
16881 const timeout2 = animated;
16882 return afterTimeout(timeout2, stopAnimationSync);
16883 }
16884 const {
16885 transitionDuration,
16886 animationDuration,
16887 transitionDelay,
16888 animationDelay
16889 } = getComputedStyle(contentElement);
16890 const {
16891 transitionDuration: transitionDuration2 = "0",
16892 animationDuration: animationDuration2 = "0",
16893 transitionDelay: transitionDelay2 = "0",
16894 animationDelay: animationDelay2 = "0"
16895 } = otherElement ? getComputedStyle(otherElement) : {};
16896 const delay = parseCSSTime(
16897 transitionDelay,
16898 animationDelay,
16899 transitionDelay2,
16900 animationDelay2
16901 );
16902 const duration = parseCSSTime(
16903 transitionDuration,
16904 animationDuration,
16905 transitionDuration2,
16906 animationDuration2
16907 );
16908 const timeout = delay + duration;
16909 if (!timeout) {
16910 if (transition === "enter") {
16911 store.setState("animated", false);
16912 }
16913 stopAnimation();
16914 return;
16915 }
16916 const frameRate = 1e3 / 60;
16917 const maxTimeout = Math.max(timeout - frameRate, 0);
16918 return afterTimeout(maxTimeout, stopAnimationSync);
16919 }, [store, animated, contentElement, otherElement, open, transition]);
16920 props = useWrapElement(
16921 props,
16922 (element) => /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DialogScopedContextProvider, { value: store, children: element }),
16923 [store]
16924 );
16925 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
16926 const styleProp = props.style;
16927 const style = (0, import_react16.useMemo)(() => {
16928 if (hidden) {
16929 return { ...styleProp, display: "none" };
16930 }
16931 return styleProp;
16932 }, [hidden, styleProp]);
16933 props = {
16934 id,
16935 "data-open": open || void 0,
16936 "data-enter": transition === "enter" || void 0,
16937 "data-leave": transition === "leave" || void 0,
16938 hidden,
16939 ...props,
16940 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
16941 style
16942 };
16943 return removeUndefinedValues(props);
16944 });
16945 var DisclosureContentImpl = forwardRef22(function DisclosureContentImpl2(props) {
16946 const htmlProps = useDisclosureContent(props);
16947 return createElement3(TagName6, htmlProps);
16948 });
16949 var DisclosureContent = forwardRef22(function DisclosureContent2({
16950 unmountOnHide,
16951 ...props
16952 }) {
16953 const context = useDisclosureProviderContext();
16954 const store = props.store || context;
16955 const mounted = useStoreState(
16956 store,
16957 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
16958 );
16959 if (mounted === false) return null;
16960 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DisclosureContentImpl, { ...props });
16961 });
16962
16963 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
16964 function createDisclosureStore(props = {}) {
16965 const store = mergeStore(
16966 props.store,
16967 omit2(props.disclosure, ["contentElement", "disclosureElement"])
16968 );
16969 throwOnConflictingProps(props, store);
16970 const syncState = store == null ? void 0 : store.getState();
16971 const open = defaultValue(
16972 props.open,
16973 syncState == null ? void 0 : syncState.open,
16974 props.defaultOpen,
16975 false
16976 );
16977 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
16978 const initialState = {
16979 open,
16980 animated,
16981 animating: !!animated && open,
16982 mounted: open,
16983 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
16984 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
16985 };
16986 const disclosure = createStore(initialState, store);
16987 setup(
16988 disclosure,
16989 () => sync(disclosure, ["animated", "animating"], (state) => {
16990 if (state.animated) return;
16991 disclosure.setState("animating", false);
16992 })
16993 );
16994 setup(
16995 disclosure,
16996 () => subscribe(disclosure, ["open"], () => {
16997 if (!disclosure.getState().animated) return;
16998 disclosure.setState("animating", true);
16999 })
17000 );
17001 setup(
17002 disclosure,
17003 () => sync(disclosure, ["open", "animating"], (state) => {
17004 disclosure.setState("mounted", state.open || state.animating);
17005 })
17006 );
17007 return {
17008 ...disclosure,
17009 disclosure: props.disclosure,
17010 setOpen: (value) => disclosure.setState("open", value),
17011 show: () => disclosure.setState("open", true),
17012 hide: () => disclosure.setState("open", false),
17013 toggle: () => disclosure.setState("open", (open2) => !open2),
17014 stopAnimation: () => disclosure.setState("animating", false),
17015 setContentElement: (value) => disclosure.setState("contentElement", value),
17016 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
17017 };
17018 }
17019
17020 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
17021 function useDisclosureStoreProps(store, update2, props) {
17022 useUpdateEffect(update2, [props.store, props.disclosure]);
17023 useStoreProps(store, props, "open", "setOpen");
17024 useStoreProps(store, props, "mounted", "setMounted");
17025 useStoreProps(store, props, "animated");
17026 return Object.assign(store, { disclosure: props.disclosure });
17027 }
17028
17029 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
17030 var ctx5 = createStoreContext(
17031 [DialogContextProvider],
17032 [DialogScopedContextProvider]
17033 );
17034 var usePopoverContext = ctx5.useContext;
17035 var usePopoverScopedContext = ctx5.useScopedContext;
17036 var usePopoverProviderContext = ctx5.useProviderContext;
17037 var PopoverContextProvider = ctx5.ContextProvider;
17038 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
17039
17040 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
17041 function getCommonParent(items) {
17042 var _a;
17043 const firstItem = items.find((item) => !!item.element);
17044 const lastItem = [...items].reverse().find((item) => !!item.element);
17045 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
17046 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
17047 const parent = parentElement;
17048 if (lastItem && parent.contains(lastItem.element)) {
17049 return parentElement;
17050 }
17051 parentElement = parentElement.parentElement;
17052 }
17053 return getDocument(parentElement).body;
17054 }
17055 function getPrivateStore(store) {
17056 return store == null ? void 0 : store.__unstablePrivateStore;
17057 }
17058 function createCollectionStore(props = {}) {
17059 var _a;
17060 throwOnConflictingProps(props, props.store);
17061 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
17062 const items = defaultValue(
17063 props.items,
17064 syncState == null ? void 0 : syncState.items,
17065 props.defaultItems,
17066 []
17067 );
17068 const itemsMap = new Map(items.map((item) => [item.id, item]));
17069 const initialState = {
17070 items,
17071 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
17072 };
17073 const syncPrivateStore = getPrivateStore(props.store);
17074 const privateStore = createStore(
17075 { items, renderedItems: initialState.renderedItems },
17076 syncPrivateStore
17077 );
17078 const collection = createStore(initialState, props.store);
17079 const sortItems = (renderedItems) => {
17080 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
17081 privateStore.setState("renderedItems", sortedItems);
17082 collection.setState("renderedItems", sortedItems);
17083 };
17084 setup(collection, () => init(privateStore));
17085 setup(privateStore, () => {
17086 return batch(privateStore, ["items"], (state) => {
17087 collection.setState("items", state.items);
17088 });
17089 });
17090 setup(privateStore, () => {
17091 return batch(privateStore, ["renderedItems"], (state) => {
17092 let firstRun = true;
17093 let raf = requestAnimationFrame(() => {
17094 const { renderedItems } = collection.getState();
17095 if (state.renderedItems === renderedItems) return;
17096 sortItems(state.renderedItems);
17097 });
17098 if (typeof IntersectionObserver !== "function") {
17099 return () => cancelAnimationFrame(raf);
17100 }
17101 const ioCallback = () => {
17102 if (firstRun) {
17103 firstRun = false;
17104 return;
17105 }
17106 cancelAnimationFrame(raf);
17107 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
17108 };
17109 const root = getCommonParent(state.renderedItems);
17110 const observer = new IntersectionObserver(ioCallback, { root });
17111 for (const item of state.renderedItems) {
17112 if (!item.element) continue;
17113 observer.observe(item.element);
17114 }
17115 return () => {
17116 cancelAnimationFrame(raf);
17117 observer.disconnect();
17118 };
17119 });
17120 });
17121 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
17122 let prevItem;
17123 setItems((items2) => {
17124 const index2 = items2.findIndex(({ id }) => id === item.id);
17125 const nextItems = items2.slice();
17126 if (index2 !== -1) {
17127 prevItem = items2[index2];
17128 const nextItem = { ...prevItem, ...item };
17129 nextItems[index2] = nextItem;
17130 itemsMap.set(item.id, nextItem);
17131 } else {
17132 nextItems.push(item);
17133 itemsMap.set(item.id, item);
17134 }
17135 return nextItems;
17136 });
17137 const unmergeItem = () => {
17138 setItems((items2) => {
17139 if (!prevItem) {
17140 if (canDeleteFromMap) {
17141 itemsMap.delete(item.id);
17142 }
17143 return items2.filter(({ id }) => id !== item.id);
17144 }
17145 const index2 = items2.findIndex(({ id }) => id === item.id);
17146 if (index2 === -1) return items2;
17147 const nextItems = items2.slice();
17148 nextItems[index2] = prevItem;
17149 itemsMap.set(item.id, prevItem);
17150 return nextItems;
17151 });
17152 };
17153 return unmergeItem;
17154 };
17155 const registerItem = (item) => mergeItem(
17156 item,
17157 (getItems) => privateStore.setState("items", getItems),
17158 true
17159 );
17160 return {
17161 ...collection,
17162 registerItem,
17163 renderItem: (item) => chain(
17164 registerItem(item),
17165 mergeItem(
17166 item,
17167 (getItems) => privateStore.setState("renderedItems", getItems)
17168 )
17169 ),
17170 item: (id) => {
17171 if (!id) return null;
17172 let item = itemsMap.get(id);
17173 if (!item) {
17174 const { items: items2 } = privateStore.getState();
17175 item = items2.find((item2) => item2.id === id);
17176 if (item) {
17177 itemsMap.set(id, item);
17178 }
17179 }
17180 return item || null;
17181 },
17182 // @ts-expect-error Internal
17183 __unstablePrivateStore: privateStore
17184 };
17185 }
17186
17187 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
17188 function useCollectionStoreProps(store, update2, props) {
17189 useUpdateEffect(update2, [props.store]);
17190 useStoreProps(store, props, "items", "setItems");
17191 return store;
17192 }
17193
17194 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
17195 var NULL_ITEM = { id: null };
17196 function findFirstEnabledItem2(items, excludeId) {
17197 return items.find((item) => {
17198 if (excludeId) {
17199 return !item.disabled && item.id !== excludeId;
17200 }
17201 return !item.disabled;
17202 });
17203 }
17204 function getEnabledItems(items, excludeId) {
17205 return items.filter((item) => {
17206 if (excludeId) {
17207 return !item.disabled && item.id !== excludeId;
17208 }
17209 return !item.disabled;
17210 });
17211 }
17212 function getItemsInRow(items, rowId) {
17213 return items.filter((item) => item.rowId === rowId);
17214 }
17215 function flipItems(items, activeId, shouldInsertNullItem = false) {
17216 const index2 = items.findIndex((item) => item.id === activeId);
17217 return [
17218 ...items.slice(index2 + 1),
17219 ...shouldInsertNullItem ? [NULL_ITEM] : [],
17220 ...items.slice(0, index2)
17221 ];
17222 }
17223 function groupItemsByRows2(items) {
17224 const rows = [];
17225 for (const item of items) {
17226 const row = rows.find((currentRow) => {
17227 var _a;
17228 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
17229 });
17230 if (row) {
17231 row.push(item);
17232 } else {
17233 rows.push([item]);
17234 }
17235 }
17236 return rows;
17237 }
17238 function getMaxRowLength(array) {
17239 let maxLength = 0;
17240 for (const { length } of array) {
17241 if (length > maxLength) {
17242 maxLength = length;
17243 }
17244 }
17245 return maxLength;
17246 }
17247 function createEmptyItem(rowId) {
17248 return {
17249 id: "__EMPTY_ITEM__",
17250 disabled: true,
17251 rowId
17252 };
17253 }
17254 function normalizeRows(rows, activeId, focusShift) {
17255 const maxLength = getMaxRowLength(rows);
17256 for (const row of rows) {
17257 for (let i2 = 0; i2 < maxLength; i2 += 1) {
17258 const item = row[i2];
17259 if (!item || focusShift && item.disabled) {
17260 const isFirst = i2 === 0;
17261 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
17262 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
17263 }
17264 }
17265 }
17266 return rows;
17267 }
17268 function verticalizeItems(items) {
17269 const rows = groupItemsByRows2(items);
17270 const maxLength = getMaxRowLength(rows);
17271 const verticalized = [];
17272 for (let i2 = 0; i2 < maxLength; i2 += 1) {
17273 for (const row of rows) {
17274 const item = row[i2];
17275 if (item) {
17276 verticalized.push({
17277 ...item,
17278 // If there's no rowId, it means that it's not a grid composite, but
17279 // a single row instead. So, instead of verticalizing it, that is,
17280 // assigning a different rowId based on the column index, we keep it
17281 // undefined so they will be part of the same row. This is useful
17282 // when using up/down on one-dimensional composites.
17283 rowId: item.rowId ? `${i2}` : void 0
17284 });
17285 }
17286 }
17287 }
17288 return verticalized;
17289 }
17290 function createCompositeStore(props = {}) {
17291 var _a;
17292 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
17293 const collection = createCollectionStore(props);
17294 const activeId = defaultValue(
17295 props.activeId,
17296 syncState == null ? void 0 : syncState.activeId,
17297 props.defaultActiveId
17298 );
17299 const initialState = {
17300 ...collection.getState(),
17301 id: defaultValue(
17302 props.id,
17303 syncState == null ? void 0 : syncState.id,
17304 `id-${Math.random().toString(36).slice(2, 8)}`
17305 ),
17306 activeId,
17307 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
17308 includesBaseElement: defaultValue(
17309 props.includesBaseElement,
17310 syncState == null ? void 0 : syncState.includesBaseElement,
17311 activeId === null
17312 ),
17313 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
17314 orientation: defaultValue(
17315 props.orientation,
17316 syncState == null ? void 0 : syncState.orientation,
17317 "both"
17318 ),
17319 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
17320 virtualFocus: defaultValue(
17321 props.virtualFocus,
17322 syncState == null ? void 0 : syncState.virtualFocus,
17323 false
17324 ),
17325 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
17326 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
17327 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
17328 };
17329 const composite = createStore(initialState, collection, props.store);
17330 setup(
17331 composite,
17332 () => sync(composite, ["renderedItems", "activeId"], (state) => {
17333 composite.setState("activeId", (activeId2) => {
17334 var _a2;
17335 if (activeId2 !== void 0) return activeId2;
17336 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
17337 });
17338 })
17339 );
17340 const getNextId = (direction = "next", options = {}) => {
17341 var _a2, _b;
17342 const defaultState = composite.getState();
17343 const {
17344 skip = 0,
17345 activeId: activeId2 = defaultState.activeId,
17346 focusShift = defaultState.focusShift,
17347 focusLoop = defaultState.focusLoop,
17348 focusWrap = defaultState.focusWrap,
17349 includesBaseElement = defaultState.includesBaseElement,
17350 renderedItems = defaultState.renderedItems,
17351 rtl = defaultState.rtl
17352 } = options;
17353 const isVerticalDirection = direction === "up" || direction === "down";
17354 const isNextDirection = direction === "next" || direction === "down";
17355 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
17356 const canShift = focusShift && !skip;
17357 let items = !isVerticalDirection ? renderedItems : flatten2DArray(
17358 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
17359 );
17360 items = canReverse ? reverseArray(items) : items;
17361 items = isVerticalDirection ? verticalizeItems(items) : items;
17362 if (activeId2 == null) {
17363 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
17364 }
17365 const activeItem = items.find((item) => item.id === activeId2);
17366 if (!activeItem) {
17367 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
17368 }
17369 const isGrid2 = items.some((item) => item.rowId);
17370 const activeIndex = items.indexOf(activeItem);
17371 const nextItems = items.slice(activeIndex + 1);
17372 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
17373 if (skip) {
17374 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
17375 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
17376 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
17377 return nextItem2 == null ? void 0 : nextItem2.id;
17378 }
17379 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
17380 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
17381 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
17382 if (canLoop) {
17383 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
17384 const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
17385 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
17386 return nextItem2 == null ? void 0 : nextItem2.id;
17387 }
17388 if (canWrap) {
17389 const nextItem2 = findFirstEnabledItem2(
17390 // We can use nextItems, which contains all the next items, including
17391 // items from other rows, to wrap between rows. However, if there is a
17392 // null item (the composite container), we'll only use the next items in
17393 // the row. So moving next from the last item will focus on the
17394 // composite container. On grid composites, horizontal navigation never
17395 // focuses on the composite container, only vertical.
17396 hasNullItem ? nextItemsInRow : nextItems,
17397 activeId2
17398 );
17399 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
17400 return nextId;
17401 }
17402 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
17403 if (!nextItem && hasNullItem) {
17404 return null;
17405 }
17406 return nextItem == null ? void 0 : nextItem.id;
17407 };
17408 return {
17409 ...collection,
17410 ...composite,
17411 setBaseElement: (element) => composite.setState("baseElement", element),
17412 setActiveId: (id) => composite.setState("activeId", id),
17413 move: (id) => {
17414 if (id === void 0) return;
17415 composite.setState("activeId", id);
17416 composite.setState("moves", (moves) => moves + 1);
17417 },
17418 first: () => {
17419 var _a2;
17420 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
17421 },
17422 last: () => {
17423 var _a2;
17424 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
17425 },
17426 next: (options) => {
17427 if (options !== void 0 && typeof options === "number") {
17428 options = { skip: options };
17429 }
17430 return getNextId("next", options);
17431 },
17432 previous: (options) => {
17433 if (options !== void 0 && typeof options === "number") {
17434 options = { skip: options };
17435 }
17436 return getNextId("previous", options);
17437 },
17438 down: (options) => {
17439 if (options !== void 0 && typeof options === "number") {
17440 options = { skip: options };
17441 }
17442 return getNextId("down", options);
17443 },
17444 up: (options) => {
17445 if (options !== void 0 && typeof options === "number") {
17446 options = { skip: options };
17447 }
17448 return getNextId("up", options);
17449 }
17450 };
17451 }
17452
17453 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
17454 function useCompositeStoreOptions(props) {
17455 const id = useId4(props.id);
17456 return { id, ...props };
17457 }
17458 function useCompositeStoreProps(store, update2, props) {
17459 store = useCollectionStoreProps(store, update2, props);
17460 useStoreProps(store, props, "activeId", "setActiveId");
17461 useStoreProps(store, props, "includesBaseElement");
17462 useStoreProps(store, props, "virtualFocus");
17463 useStoreProps(store, props, "orientation");
17464 useStoreProps(store, props, "rtl");
17465 useStoreProps(store, props, "focusLoop");
17466 useStoreProps(store, props, "focusWrap");
17467 useStoreProps(store, props, "focusShift");
17468 return store;
17469 }
17470
17471 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
17472 var import_react17 = __toESM(require_react(), 1);
17473 var ComboboxListRoleContext = (0, import_react17.createContext)(
17474 void 0
17475 );
17476 var ctx6 = createStoreContext(
17477 [PopoverContextProvider, CompositeContextProvider],
17478 [PopoverScopedContextProvider, CompositeScopedContextProvider]
17479 );
17480 var useComboboxContext = ctx6.useContext;
17481 var useComboboxScopedContext = ctx6.useScopedContext;
17482 var useComboboxProviderContext = ctx6.useProviderContext;
17483 var ComboboxContextProvider = ctx6.ContextProvider;
17484 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
17485 var ComboboxItemValueContext = (0, import_react17.createContext)(
17486 void 0
17487 );
17488 var ComboboxItemCheckedContext = (0, import_react17.createContext)(false);
17489
17490 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
17491 function createDialogStore(props = {}) {
17492 return createDisclosureStore(props);
17493 }
17494
17495 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
17496 function useDialogStoreProps(store, update2, props) {
17497 return useDisclosureStoreProps(store, update2, props);
17498 }
17499
17500 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
17501 function createPopoverStore({
17502 popover: otherPopover,
17503 ...props
17504 } = {}) {
17505 const store = mergeStore(
17506 props.store,
17507 omit2(otherPopover, [
17508 "arrowElement",
17509 "anchorElement",
17510 "contentElement",
17511 "popoverElement",
17512 "disclosureElement"
17513 ])
17514 );
17515 throwOnConflictingProps(props, store);
17516 const syncState = store == null ? void 0 : store.getState();
17517 const dialog = createDialogStore({ ...props, store });
17518 const placement = defaultValue(
17519 props.placement,
17520 syncState == null ? void 0 : syncState.placement,
17521 "bottom"
17522 );
17523 const initialState = {
17524 ...dialog.getState(),
17525 placement,
17526 currentPlacement: placement,
17527 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
17528 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
17529 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
17530 rendered: /* @__PURE__ */ Symbol("rendered")
17531 };
17532 const popover = createStore(initialState, dialog, store);
17533 return {
17534 ...dialog,
17535 ...popover,
17536 setAnchorElement: (element) => popover.setState("anchorElement", element),
17537 setPopoverElement: (element) => popover.setState("popoverElement", element),
17538 setArrowElement: (element) => popover.setState("arrowElement", element),
17539 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
17540 };
17541 }
17542
17543 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
17544 function usePopoverStoreProps(store, update2, props) {
17545 useUpdateEffect(update2, [props.popover]);
17546 useStoreProps(store, props, "placement");
17547 return useDialogStoreProps(store, update2, props);
17548 }
17549
17550 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
17551 var TagName7 = "div";
17552 var usePopoverAnchor = createHook(
17553 function usePopoverAnchor2({ store, ...props }) {
17554 const context = usePopoverProviderContext();
17555 store = store || context;
17556 props = {
17557 ...props,
17558 ref: useMergeRefs(store == null ? void 0 : store.setAnchorElement, props.ref)
17559 };
17560 return props;
17561 }
17562 );
17563 var PopoverAnchor = forwardRef22(function PopoverAnchor2(props) {
17564 const htmlProps = usePopoverAnchor(props);
17565 return createElement3(TagName7, htmlProps);
17566 });
17567
17568 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
17569 var import_react18 = __toESM(require_react(), 1);
17570 var TagName8 = "div";
17571 function getMouseDestination(event) {
17572 const relatedTarget = event.relatedTarget;
17573 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
17574 return relatedTarget;
17575 }
17576 return null;
17577 }
17578 function hoveringInside(event) {
17579 const nextElement = getMouseDestination(event);
17580 if (!nextElement) return false;
17581 return contains2(event.currentTarget, nextElement);
17582 }
17583 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
17584 function movingToAnotherItem(event) {
17585 let dest = getMouseDestination(event);
17586 if (!dest) return false;
17587 do {
17588 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
17589 dest = dest.parentElement;
17590 } while (dest);
17591 return false;
17592 }
17593 var useCompositeHover = createHook(
17594 function useCompositeHover2({
17595 store,
17596 focusOnHover = true,
17597 blurOnHoverEnd = !!focusOnHover,
17598 ...props
17599 }) {
17600 const context = useCompositeContext();
17601 store = store || context;
17602 invariant(
17603 store,
17604 "CompositeHover must be wrapped in a Composite component."
17605 );
17606 const isMouseMoving = useIsMouseMoving();
17607 const onMouseMoveProp = props.onMouseMove;
17608 const focusOnHoverProp = useBooleanEvent(focusOnHover);
17609 const onMouseMove = useEvent((event) => {
17610 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
17611 if (event.defaultPrevented) return;
17612 if (!isMouseMoving()) return;
17613 if (!focusOnHoverProp(event)) return;
17614 if (!hasFocusWithin(event.currentTarget)) {
17615 const baseElement = store == null ? void 0 : store.getState().baseElement;
17616 if (baseElement && !hasFocus(baseElement)) {
17617 baseElement.focus();
17618 }
17619 }
17620 store == null ? void 0 : store.setActiveId(event.currentTarget.id);
17621 });
17622 const onMouseLeaveProp = props.onMouseLeave;
17623 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
17624 const onMouseLeave = useEvent((event) => {
17625 var _a;
17626 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
17627 if (event.defaultPrevented) return;
17628 if (!isMouseMoving()) return;
17629 if (hoveringInside(event)) return;
17630 if (movingToAnotherItem(event)) return;
17631 if (!focusOnHoverProp(event)) return;
17632 if (!blurOnHoverEndProp(event)) return;
17633 store == null ? void 0 : store.setActiveId(null);
17634 (_a = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a.focus();
17635 });
17636 const ref = (0, import_react18.useCallback)((element) => {
17637 if (!element) return;
17638 element[symbol2] = true;
17639 }, []);
17640 props = {
17641 ...props,
17642 ref: useMergeRefs(ref, props.ref),
17643 onMouseMove,
17644 onMouseLeave
17645 };
17646 return removeUndefinedValues(props);
17647 }
17648 );
17649 var CompositeHover = memo22(
17650 forwardRef22(function CompositeHover2(props) {
17651 const htmlProps = useCompositeHover(props);
17652 return createElement3(TagName8, htmlProps);
17653 })
17654 );
17655
17656 // node_modules/@ariakit/react-core/esm/combobox/combobox.js
17657 var import_react19 = __toESM(require_react(), 1);
17658 var TagName9 = "input";
17659 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
17660 if (!autoSelect) return false;
17661 const firstItem = items.find((item) => !item.disabled && item.value);
17662 return (firstItem == null ? void 0 : firstItem.value) === activeValue;
17663 }
17664 function hasCompletionString(value, activeValue) {
17665 if (!activeValue) return false;
17666 if (value == null) return false;
17667 value = normalizeString(value);
17668 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
17669 }
17670 function isInputEvent(event) {
17671 return event.type === "input";
17672 }
17673 function isAriaAutoCompleteValue(value) {
17674 return value === "inline" || value === "list" || value === "both" || value === "none";
17675 }
17676 function getDefaultAutoSelectId(items) {
17677 const item = items.find((item2) => {
17678 var _a;
17679 if (item2.disabled) return false;
17680 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
17681 });
17682 return item == null ? void 0 : item.id;
17683 }
17684 var useCombobox = createHook(
17685 function useCombobox2({
17686 store,
17687 focusable: focusable2 = true,
17688 autoSelect: autoSelectProp = false,
17689 getAutoSelectId,
17690 setValueOnChange,
17691 showMinLength = 0,
17692 showOnChange,
17693 showOnMouseDown,
17694 showOnClick = showOnMouseDown,
17695 showOnKeyDown,
17696 showOnKeyPress = showOnKeyDown,
17697 blurActiveItemOnClick,
17698 setValueOnClick = true,
17699 moveOnKeyPress = true,
17700 autoComplete = "list",
17701 ...props
17702 }) {
17703 const context = useComboboxProviderContext();
17704 store = store || context;
17705 invariant(
17706 store,
17707 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
17708 );
17709 const ref = (0, import_react19.useRef)(null);
17710 const [valueUpdated, forceValueUpdate] = useForceUpdate();
17711 const canAutoSelectRef = (0, import_react19.useRef)(false);
17712 const composingRef = (0, import_react19.useRef)(false);
17713 const autoSelect = store.useState(
17714 (state) => state.virtualFocus && autoSelectProp
17715 );
17716 const inline4 = autoComplete === "inline" || autoComplete === "both";
17717 const [canInline, setCanInline] = (0, import_react19.useState)(inline4);
17718 useUpdateLayoutEffect(() => {
17719 if (!inline4) return;
17720 setCanInline(true);
17721 }, [inline4]);
17722 const storeValue = store.useState("value");
17723 const prevSelectedValueRef = (0, import_react19.useRef)(void 0);
17724 (0, import_react19.useEffect)(() => {
17725 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
17726 prevSelectedValueRef.current = prev.selectedValue;
17727 });
17728 }, []);
17729 const inlineActiveValue = store.useState((state) => {
17730 var _a;
17731 if (!inline4) return;
17732 if (!canInline) return;
17733 if (state.activeValue && Array.isArray(state.selectedValue)) {
17734 if (state.selectedValue.includes(state.activeValue)) return;
17735 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
17736 }
17737 return state.activeValue;
17738 });
17739 const items = store.useState("renderedItems");
17740 const open = store.useState("open");
17741 const contentElement = store.useState("contentElement");
17742 const value = (0, import_react19.useMemo)(() => {
17743 if (!inline4) return storeValue;
17744 if (!canInline) return storeValue;
17745 const firstItemAutoSelected = isFirstItemAutoSelected(
17746 items,
17747 inlineActiveValue,
17748 autoSelect
17749 );
17750 if (firstItemAutoSelected) {
17751 if (hasCompletionString(storeValue, inlineActiveValue)) {
17752 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
17753 return storeValue + slice;
17754 }
17755 return storeValue;
17756 }
17757 return inlineActiveValue || storeValue;
17758 }, [inline4, canInline, items, inlineActiveValue, autoSelect, storeValue]);
17759 (0, import_react19.useEffect)(() => {
17760 const element = ref.current;
17761 if (!element) return;
17762 const onCompositeItemMove = () => setCanInline(true);
17763 element.addEventListener("combobox-item-move", onCompositeItemMove);
17764 return () => {
17765 element.removeEventListener("combobox-item-move", onCompositeItemMove);
17766 };
17767 }, []);
17768 (0, import_react19.useEffect)(() => {
17769 if (!inline4) return;
17770 if (!canInline) return;
17771 if (!inlineActiveValue) return;
17772 const firstItemAutoSelected = isFirstItemAutoSelected(
17773 items,
17774 inlineActiveValue,
17775 autoSelect
17776 );
17777 if (!firstItemAutoSelected) return;
17778 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
17779 let cleanup = noop5;
17780 queueMicrotask(() => {
17781 const element = ref.current;
17782 if (!element) return;
17783 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
17784 const nextStart = storeValue.length;
17785 const nextEnd = inlineActiveValue.length;
17786 setSelectionRange(element, nextStart, nextEnd);
17787 cleanup = () => {
17788 if (!hasFocus(element)) return;
17789 const { start, end } = getTextboxSelection(element);
17790 if (start !== nextStart) return;
17791 if (end !== nextEnd) return;
17792 setSelectionRange(element, prevStart, prevEnd);
17793 };
17794 });
17795 return () => cleanup();
17796 }, [
17797 valueUpdated,
17798 inline4,
17799 canInline,
17800 inlineActiveValue,
17801 items,
17802 autoSelect,
17803 storeValue
17804 ]);
17805 const scrollingElementRef = (0, import_react19.useRef)(null);
17806 const getAutoSelectIdProp = useEvent(getAutoSelectId);
17807 const autoSelectIdRef = (0, import_react19.useRef)(null);
17808 (0, import_react19.useEffect)(() => {
17809 if (!open) return;
17810 if (!contentElement) return;
17811 const scrollingElement = getScrollingElement(contentElement);
17812 if (!scrollingElement) return;
17813 scrollingElementRef.current = scrollingElement;
17814 const onUserScroll = () => {
17815 canAutoSelectRef.current = false;
17816 };
17817 const onScroll = () => {
17818 if (!store) return;
17819 if (!canAutoSelectRef.current) return;
17820 const { activeId } = store.getState();
17821 if (activeId === null) return;
17822 if (activeId === autoSelectIdRef.current) return;
17823 canAutoSelectRef.current = false;
17824 };
17825 const options = { passive: true, capture: true };
17826 scrollingElement.addEventListener("wheel", onUserScroll, options);
17827 scrollingElement.addEventListener("touchmove", onUserScroll, options);
17828 scrollingElement.addEventListener("scroll", onScroll, options);
17829 return () => {
17830 scrollingElement.removeEventListener("wheel", onUserScroll, true);
17831 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
17832 scrollingElement.removeEventListener("scroll", onScroll, true);
17833 };
17834 }, [open, contentElement, store]);
17835 useSafeLayoutEffect(() => {
17836 if (!storeValue) return;
17837 if (composingRef.current) return;
17838 canAutoSelectRef.current = true;
17839 }, [storeValue]);
17840 useSafeLayoutEffect(() => {
17841 if (autoSelect !== "always" && open) return;
17842 canAutoSelectRef.current = open;
17843 }, [autoSelect, open]);
17844 const resetValueOnSelect = store.useState("resetValueOnSelect");
17845 useUpdateEffect(() => {
17846 var _a, _b;
17847 const canAutoSelect = canAutoSelectRef.current;
17848 if (!store) return;
17849 if (!open) return;
17850 if (!canAutoSelect && !resetValueOnSelect) return;
17851 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
17852 if (baseElement && !hasFocus(baseElement)) return;
17853 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
17854 const observer = new MutationObserver(forceValueUpdate);
17855 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
17856 return () => observer.disconnect();
17857 }
17858 if (autoSelect && canAutoSelect) {
17859 const userAutoSelectId = getAutoSelectIdProp(items);
17860 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store.first();
17861 autoSelectIdRef.current = autoSelectId;
17862 store.move(autoSelectId != null ? autoSelectId : null);
17863 } else {
17864 const element = (_b = store.item(activeId || store.first())) == null ? void 0 : _b.element;
17865 if (element && "scrollIntoView" in element) {
17866 element.scrollIntoView({ block: "nearest", inline: "nearest" });
17867 }
17868 }
17869 return;
17870 }, [
17871 store,
17872 open,
17873 valueUpdated,
17874 storeValue,
17875 autoSelect,
17876 resetValueOnSelect,
17877 getAutoSelectIdProp,
17878 items
17879 ]);
17880 (0, import_react19.useEffect)(() => {
17881 if (!inline4) return;
17882 const combobox = ref.current;
17883 if (!combobox) return;
17884 const elements = [combobox, contentElement].filter(
17885 (value2) => !!value2
17886 );
17887 const onBlur2 = (event) => {
17888 if (elements.every((el) => isFocusEventOutside(event, el))) {
17889 store == null ? void 0 : store.setValue(value);
17890 }
17891 };
17892 for (const element of elements) {
17893 element.addEventListener("focusout", onBlur2);
17894 }
17895 return () => {
17896 for (const element of elements) {
17897 element.removeEventListener("focusout", onBlur2);
17898 }
17899 };
17900 }, [inline4, contentElement, store, value]);
17901 const canShow = (event) => {
17902 const currentTarget = event.currentTarget;
17903 return currentTarget.value.length >= showMinLength;
17904 };
17905 const onChangeProp = props.onChange;
17906 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
17907 const setValueOnChangeProp = useBooleanEvent(
17908 // If the combobox is combined with tags, the value will be set by the tag
17909 // input component.
17910 setValueOnChange != null ? setValueOnChange : !store.tag
17911 );
17912 const onChange = useEvent((event) => {
17913 onChangeProp == null ? void 0 : onChangeProp(event);
17914 if (event.defaultPrevented) return;
17915 if (!store) return;
17916 const currentTarget = event.currentTarget;
17917 const { value: value2, selectionStart, selectionEnd } = currentTarget;
17918 const nativeEvent = event.nativeEvent;
17919 canAutoSelectRef.current = true;
17920 if (isInputEvent(nativeEvent)) {
17921 if (nativeEvent.isComposing) {
17922 canAutoSelectRef.current = false;
17923 composingRef.current = true;
17924 }
17925 if (inline4) {
17926 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
17927 const caretAtEnd = selectionStart === value2.length;
17928 setCanInline(textInserted && caretAtEnd);
17929 }
17930 }
17931 if (setValueOnChangeProp(event)) {
17932 const isSameValue = value2 === store.getState().value;
17933 store.setValue(value2);
17934 queueMicrotask(() => {
17935 setSelectionRange(currentTarget, selectionStart, selectionEnd);
17936 });
17937 if (inline4 && autoSelect && isSameValue) {
17938 forceValueUpdate();
17939 }
17940 }
17941 if (showOnChangeProp(event)) {
17942 store.show();
17943 }
17944 if (!autoSelect || !canAutoSelectRef.current) {
17945 store.setActiveId(null);
17946 }
17947 });
17948 const onCompositionEndProp = props.onCompositionEnd;
17949 const onCompositionEnd = useEvent((event) => {
17950 canAutoSelectRef.current = true;
17951 composingRef.current = false;
17952 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
17953 if (event.defaultPrevented) return;
17954 if (!autoSelect) return;
17955 forceValueUpdate();
17956 });
17957 const onMouseDownProp = props.onMouseDown;
17958 const blurActiveItemOnClickProp = useBooleanEvent(
17959 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store == null ? void 0 : store.getState().includesBaseElement))
17960 );
17961 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
17962 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
17963 const onMouseDown = useEvent((event) => {
17964 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
17965 if (event.defaultPrevented) return;
17966 if (event.button) return;
17967 if (event.ctrlKey) return;
17968 if (!store) return;
17969 if (blurActiveItemOnClickProp(event)) {
17970 store.setActiveId(null);
17971 }
17972 if (setValueOnClickProp(event)) {
17973 store.setValue(value);
17974 }
17975 if (showOnClickProp(event)) {
17976 queueBeforeEvent(event.currentTarget, "mouseup", store.show);
17977 }
17978 });
17979 const onKeyDownProp = props.onKeyDown;
17980 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
17981 const onKeyDown = useEvent((event) => {
17982 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
17983 if (!event.repeat) {
17984 canAutoSelectRef.current = false;
17985 }
17986 if (event.defaultPrevented) return;
17987 if (event.ctrlKey) return;
17988 if (event.altKey) return;
17989 if (event.shiftKey) return;
17990 if (event.metaKey) return;
17991 if (!store) return;
17992 const { open: open2 } = store.getState();
17993 if (open2) return;
17994 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
17995 if (showOnKeyPressProp(event)) {
17996 event.preventDefault();
17997 store.show();
17998 }
17999 }
18000 });
18001 const onBlurProp = props.onBlur;
18002 const onBlur = useEvent((event) => {
18003 canAutoSelectRef.current = false;
18004 onBlurProp == null ? void 0 : onBlurProp(event);
18005 if (event.defaultPrevented) return;
18006 });
18007 const id = useId4(props.id);
18008 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
18009 const isActiveItem = store.useState((state) => state.activeId === null);
18010 props = {
18011 id,
18012 role: "combobox",
18013 "aria-autocomplete": ariaAutoComplete,
18014 "aria-haspopup": getPopupRole(contentElement, "listbox"),
18015 "aria-expanded": open,
18016 "aria-controls": contentElement == null ? void 0 : contentElement.id,
18017 "data-active-item": isActiveItem || void 0,
18018 value,
18019 ...props,
18020 ref: useMergeRefs(ref, props.ref),
18021 onChange,
18022 onCompositionEnd,
18023 onMouseDown,
18024 onKeyDown,
18025 onBlur
18026 };
18027 props = useComposite({
18028 store,
18029 focusable: focusable2,
18030 ...props,
18031 // Enable inline autocomplete when the user moves from the combobox input
18032 // to an item.
18033 moveOnKeyPress: (event) => {
18034 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
18035 if (inline4) setCanInline(true);
18036 return true;
18037 }
18038 });
18039 props = usePopoverAnchor({ store, ...props });
18040 return { autoComplete: "off", ...props };
18041 }
18042 );
18043 var Combobox = forwardRef22(function Combobox2(props) {
18044 const htmlProps = useCombobox(props);
18045 return createElement3(TagName9, htmlProps);
18046 });
18047
18048 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
18049 var import_react20 = __toESM(require_react(), 1);
18050 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
18051 var TagName10 = "div";
18052 function isSelected(storeValue, itemValue) {
18053 if (itemValue == null) return;
18054 if (storeValue == null) return false;
18055 if (Array.isArray(storeValue)) {
18056 return storeValue.includes(itemValue);
18057 }
18058 return storeValue === itemValue;
18059 }
18060 function getItemRole(popupRole) {
18061 var _a;
18062 const itemRoleByPopupRole = {
18063 menu: "menuitem",
18064 listbox: "option",
18065 tree: "treeitem"
18066 };
18067 const key = popupRole;
18068 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
18069 }
18070 var useComboboxItem = createHook(
18071 function useComboboxItem2({
18072 store,
18073 value,
18074 hideOnClick,
18075 setValueOnClick,
18076 selectValueOnClick = true,
18077 resetValueOnSelect,
18078 focusOnHover = false,
18079 moveOnKeyPress = true,
18080 getItem: getItemProp,
18081 ...props
18082 }) {
18083 var _a;
18084 const context = useComboboxScopedContext();
18085 store = store || context;
18086 invariant(
18087 store,
18088 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
18089 );
18090 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
18091 resetValueOnSelectState: "resetValueOnSelect",
18092 multiSelectable(state) {
18093 return Array.isArray(state.selectedValue);
18094 },
18095 selected(state) {
18096 return isSelected(state.selectedValue, value);
18097 }
18098 });
18099 const getItem = (0, import_react20.useCallback)(
18100 (item) => {
18101 const nextItem = { ...item, value };
18102 if (getItemProp) {
18103 return getItemProp(nextItem);
18104 }
18105 return nextItem;
18106 },
18107 [value, getItemProp]
18108 );
18109 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
18110 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
18111 const onClickProp = props.onClick;
18112 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18113 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
18114 const resetValueOnSelectProp = useBooleanEvent(
18115 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
18116 );
18117 const hideOnClickProp = useBooleanEvent(hideOnClick);
18118 const onClick = useEvent((event) => {
18119 onClickProp == null ? void 0 : onClickProp(event);
18120 if (event.defaultPrevented) return;
18121 if (isDownloading(event)) return;
18122 if (isOpeningInNewTab(event)) return;
18123 if (value != null) {
18124 if (selectValueOnClickProp(event)) {
18125 if (resetValueOnSelectProp(event)) {
18126 store == null ? void 0 : store.resetValue();
18127 }
18128 store == null ? void 0 : store.setSelectedValue((prevValue) => {
18129 if (!Array.isArray(prevValue)) return value;
18130 if (prevValue.includes(value)) {
18131 return prevValue.filter((v2) => v2 !== value);
18132 }
18133 return [...prevValue, value];
18134 });
18135 }
18136 if (setValueOnClickProp(event)) {
18137 store == null ? void 0 : store.setValue(value);
18138 }
18139 }
18140 if (hideOnClickProp(event)) {
18141 store == null ? void 0 : store.hide();
18142 }
18143 });
18144 const onKeyDownProp = props.onKeyDown;
18145 const onKeyDown = useEvent((event) => {
18146 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
18147 if (event.defaultPrevented) return;
18148 const baseElement = store == null ? void 0 : store.getState().baseElement;
18149 if (!baseElement) return;
18150 if (hasFocus(baseElement)) return;
18151 const printable = event.key.length === 1;
18152 if (printable || event.key === "Backspace" || event.key === "Delete") {
18153 queueMicrotask(() => baseElement.focus());
18154 if (isTextField(baseElement)) {
18155 store == null ? void 0 : store.setValue(baseElement.value);
18156 }
18157 }
18158 });
18159 if (multiSelectable && selected != null) {
18160 props = {
18161 "aria-selected": selected,
18162 ...props
18163 };
18164 }
18165 props = useWrapElement(
18166 props,
18167 (element) => /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }),
18168 [value, selected]
18169 );
18170 const popupRole = (0, import_react20.useContext)(ComboboxListRoleContext);
18171 props = {
18172 role: getItemRole(popupRole),
18173 children: value,
18174 ...props,
18175 onClick,
18176 onKeyDown
18177 };
18178 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
18179 props = useCompositeItem({
18180 store,
18181 ...props,
18182 getItem,
18183 // Dispatch a custom event on the combobox input when moving to an item
18184 // with the keyboard so the Combobox component can enable inline
18185 // autocompletion.
18186 moveOnKeyPress: (event) => {
18187 if (!moveOnKeyPressProp(event)) return false;
18188 const moveEvent = new Event("combobox-item-move");
18189 const baseElement = store == null ? void 0 : store.getState().baseElement;
18190 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
18191 return true;
18192 }
18193 });
18194 props = useCompositeHover({ store, focusOnHover, ...props });
18195 return props;
18196 }
18197 );
18198 var ComboboxItem = memo22(
18199 forwardRef22(function ComboboxItem2(props) {
18200 const htmlProps = useComboboxItem(props);
18201 return createElement3(TagName10, htmlProps);
18202 })
18203 );
18204
18205 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
18206 var import_react21 = __toESM(require_react(), 1);
18207 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
18208 var TagName11 = "span";
18209 function normalizeValue(value) {
18210 return normalizeString(value).toLowerCase();
18211 }
18212 function getOffsets(string, values) {
18213 const offsets = [];
18214 for (const value of values) {
18215 let pos = 0;
18216 const length = value.length;
18217 while (string.indexOf(value, pos) !== -1) {
18218 const index2 = string.indexOf(value, pos);
18219 if (index2 !== -1) {
18220 offsets.push([index2, length]);
18221 }
18222 pos = index2 + 1;
18223 }
18224 }
18225 return offsets;
18226 }
18227 function filterOverlappingOffsets(offsets) {
18228 return offsets.filter(([offset4, length], i2, arr) => {
18229 return !arr.some(
18230 ([o2, l2], j2) => j2 !== i2 && o2 <= offset4 && o2 + l2 >= offset4 + length
18231 );
18232 });
18233 }
18234 function sortOffsets(offsets) {
18235 return offsets.sort(([a2], [b2]) => a2 - b2);
18236 }
18237 function splitValue(itemValue, userValue) {
18238 if (!itemValue) return itemValue;
18239 if (!userValue) return itemValue;
18240 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
18241 const parts = [];
18242 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
18243 "span",
18244 {
18245 "data-autocomplete-value": autocomplete ? "" : void 0,
18246 "data-user-value": autocomplete ? void 0 : "",
18247 children: value
18248 },
18249 parts.length
18250 );
18251 const offsets = sortOffsets(
18252 filterOverlappingOffsets(
18253 // Convert userValues into a set to avoid duplicates
18254 getOffsets(normalizeValue(itemValue), new Set(userValues))
18255 )
18256 );
18257 if (!offsets.length) {
18258 parts.push(span(itemValue, true));
18259 return parts;
18260 }
18261 const [firstOffset] = offsets[0];
18262 const values = [
18263 itemValue.slice(0, firstOffset),
18264 ...offsets.flatMap(([offset4, length], i2) => {
18265 var _a;
18266 const value = itemValue.slice(offset4, offset4 + length);
18267 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0];
18268 const nextValue = itemValue.slice(offset4 + length, nextOffset);
18269 return [value, nextValue];
18270 })
18271 ];
18272 values.forEach((value, i2) => {
18273 if (!value) return;
18274 parts.push(span(value, i2 % 2 === 0));
18275 });
18276 return parts;
18277 }
18278 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
18279 const context = useComboboxScopedContext();
18280 store = store || context;
18281 const itemContext = (0, import_react21.useContext)(ComboboxItemValueContext);
18282 const itemValue = value != null ? value : itemContext;
18283 const inputValue = useStoreState(store, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
18284 const children = (0, import_react21.useMemo)(() => {
18285 if (!itemValue) return;
18286 if (!inputValue) return itemValue;
18287 return splitValue(itemValue, inputValue);
18288 }, [itemValue, inputValue]);
18289 props = {
18290 children,
18291 ...props
18292 };
18293 return removeUndefinedValues(props);
18294 });
18295 var ComboboxItemValue = forwardRef22(function ComboboxItemValue2(props) {
18296 const htmlProps = useComboboxItemValue(props);
18297 return createElement3(TagName11, htmlProps);
18298 });
18299
18300 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
18301 var TagName12 = "label";
18302 var useComboboxLabel = createHook(
18303 function useComboboxLabel2({ store, ...props }) {
18304 const context = useComboboxProviderContext();
18305 store = store || context;
18306 invariant(
18307 store,
18308 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
18309 );
18310 const comboboxId = store.useState((state) => {
18311 var _a;
18312 return (_a = state.baseElement) == null ? void 0 : _a.id;
18313 });
18314 props = {
18315 htmlFor: comboboxId,
18316 ...props
18317 };
18318 return removeUndefinedValues(props);
18319 }
18320 );
18321 var ComboboxLabel = memo22(
18322 forwardRef22(function ComboboxLabel2(props) {
18323 const htmlProps = useComboboxLabel(props);
18324 return createElement3(TagName12, htmlProps);
18325 })
18326 );
18327
18328 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
18329 var import_react22 = __toESM(require_react(), 1);
18330 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
18331 var TagName13 = "div";
18332 var useComboboxList = createHook(
18333 function useComboboxList2({ store, alwaysVisible, ...props }) {
18334 const scopedContext = useComboboxScopedContext(true);
18335 const context = useComboboxContext();
18336 store = store || context;
18337 const scopedContextSameStore = !!store && store === scopedContext;
18338 invariant(
18339 store,
18340 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
18341 );
18342 const ref = (0, import_react22.useRef)(null);
18343 const id = useId4(props.id);
18344 const mounted = store.useState("mounted");
18345 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
18346 const style = hidden ? { ...props.style, display: "none" } : props.style;
18347 const multiSelectable = store.useState(
18348 (state) => Array.isArray(state.selectedValue)
18349 );
18350 const role = useAttribute(ref, "role", props.role);
18351 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
18352 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
18353 const [hasListboxInside, setHasListboxInside] = (0, import_react22.useState)(false);
18354 const contentElement = store.useState("contentElement");
18355 useSafeLayoutEffect(() => {
18356 if (!mounted) return;
18357 const element = ref.current;
18358 if (!element) return;
18359 if (contentElement !== element) return;
18360 const callback = () => {
18361 setHasListboxInside(!!element.querySelector("[role='listbox']"));
18362 };
18363 const observer = new MutationObserver(callback);
18364 observer.observe(element, {
18365 subtree: true,
18366 childList: true,
18367 attributeFilter: ["role"]
18368 });
18369 callback();
18370 return () => observer.disconnect();
18371 }, [mounted, contentElement]);
18372 if (!hasListboxInside) {
18373 props = {
18374 role: "listbox",
18375 "aria-multiselectable": ariaMultiSelectable,
18376 ...props
18377 };
18378 }
18379 props = useWrapElement(
18380 props,
18381 (element) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ComboboxScopedContextProvider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
18382 [store, role]
18383 );
18384 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
18385 props = {
18386 id,
18387 hidden,
18388 ...props,
18389 ref: useMergeRefs(setContentElement, ref, props.ref),
18390 style
18391 };
18392 return removeUndefinedValues(props);
18393 }
18394 );
18395 var ComboboxList = forwardRef22(function ComboboxList2(props) {
18396 const htmlProps = useComboboxList(props);
18397 return createElement3(TagName13, htmlProps);
18398 });
18399
18400 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
18401 var import_react23 = __toESM(require_react(), 1);
18402 var TagValueContext = (0, import_react23.createContext)(null);
18403 var TagRemoveIdContext = (0, import_react23.createContext)(
18404 null
18405 );
18406 var ctx7 = createStoreContext(
18407 [CompositeContextProvider],
18408 [CompositeScopedContextProvider]
18409 );
18410 var useTagContext = ctx7.useContext;
18411 var useTagScopedContext = ctx7.useScopedContext;
18412 var useTagProviderContext = ctx7.useProviderContext;
18413 var TagContextProvider = ctx7.ContextProvider;
18414 var TagScopedContextProvider = ctx7.ScopedContextProvider;
18415
18416 // node_modules/@ariakit/core/esm/combobox/combobox-store.js
18417 var isTouchSafari = isSafari2() && isTouchDevice();
18418 function createComboboxStore({
18419 tag,
18420 ...props
18421 } = {}) {
18422 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
18423 throwOnConflictingProps(props, store);
18424 const tagState = tag == null ? void 0 : tag.getState();
18425 const syncState = store == null ? void 0 : store.getState();
18426 const activeId = defaultValue(
18427 props.activeId,
18428 syncState == null ? void 0 : syncState.activeId,
18429 props.defaultActiveId,
18430 null
18431 );
18432 const composite = createCompositeStore({
18433 ...props,
18434 activeId,
18435 includesBaseElement: defaultValue(
18436 props.includesBaseElement,
18437 syncState == null ? void 0 : syncState.includesBaseElement,
18438 true
18439 ),
18440 orientation: defaultValue(
18441 props.orientation,
18442 syncState == null ? void 0 : syncState.orientation,
18443 "vertical"
18444 ),
18445 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
18446 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
18447 virtualFocus: defaultValue(
18448 props.virtualFocus,
18449 syncState == null ? void 0 : syncState.virtualFocus,
18450 true
18451 )
18452 });
18453 const popover = createPopoverStore({
18454 ...props,
18455 placement: defaultValue(
18456 props.placement,
18457 syncState == null ? void 0 : syncState.placement,
18458 "bottom-start"
18459 )
18460 });
18461 const value = defaultValue(
18462 props.value,
18463 syncState == null ? void 0 : syncState.value,
18464 props.defaultValue,
18465 ""
18466 );
18467 const selectedValue = defaultValue(
18468 props.selectedValue,
18469 syncState == null ? void 0 : syncState.selectedValue,
18470 tagState == null ? void 0 : tagState.values,
18471 props.defaultSelectedValue,
18472 ""
18473 );
18474 const multiSelectable = Array.isArray(selectedValue);
18475 const initialState = {
18476 ...composite.getState(),
18477 ...popover.getState(),
18478 value,
18479 selectedValue,
18480 resetValueOnSelect: defaultValue(
18481 props.resetValueOnSelect,
18482 syncState == null ? void 0 : syncState.resetValueOnSelect,
18483 multiSelectable
18484 ),
18485 resetValueOnHide: defaultValue(
18486 props.resetValueOnHide,
18487 syncState == null ? void 0 : syncState.resetValueOnHide,
18488 multiSelectable && !tag
18489 ),
18490 activeValue: syncState == null ? void 0 : syncState.activeValue
18491 };
18492 const combobox = createStore(initialState, composite, popover, store);
18493 if (isTouchSafari) {
18494 setup(
18495 combobox,
18496 () => sync(combobox, ["virtualFocus"], () => {
18497 combobox.setState("virtualFocus", false);
18498 })
18499 );
18500 }
18501 setup(combobox, () => {
18502 if (!tag) return;
18503 return chain(
18504 sync(combobox, ["selectedValue"], (state) => {
18505 if (!Array.isArray(state.selectedValue)) return;
18506 tag.setValues(state.selectedValue);
18507 }),
18508 sync(tag, ["values"], (state) => {
18509 combobox.setState("selectedValue", state.values);
18510 })
18511 );
18512 });
18513 setup(
18514 combobox,
18515 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
18516 if (!state.resetValueOnHide) return;
18517 if (state.mounted) return;
18518 combobox.setState("value", value);
18519 })
18520 );
18521 setup(
18522 combobox,
18523 () => sync(combobox, ["open"], (state) => {
18524 if (state.open) return;
18525 combobox.setState("activeId", activeId);
18526 combobox.setState("moves", 0);
18527 })
18528 );
18529 setup(
18530 combobox,
18531 () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
18532 if (state.moves === prevState.moves) {
18533 combobox.setState("activeValue", void 0);
18534 }
18535 })
18536 );
18537 setup(
18538 combobox,
18539 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
18540 if (state.moves === prev.moves) return;
18541 const { activeId: activeId2 } = combobox.getState();
18542 const activeItem = composite.item(activeId2);
18543 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
18544 })
18545 );
18546 return {
18547 ...popover,
18548 ...composite,
18549 ...combobox,
18550 tag,
18551 setValue: (value2) => combobox.setState("value", value2),
18552 resetValue: () => combobox.setState("value", initialState.value),
18553 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
18554 };
18555 }
18556
18557 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
18558 function useComboboxStoreOptions(props) {
18559 const tag = useTagContext();
18560 props = {
18561 ...props,
18562 tag: props.tag !== void 0 ? props.tag : tag
18563 };
18564 return useCompositeStoreOptions(props);
18565 }
18566 function useComboboxStoreProps(store, update2, props) {
18567 useUpdateEffect(update2, [props.tag]);
18568 useStoreProps(store, props, "value", "setValue");
18569 useStoreProps(store, props, "selectedValue", "setSelectedValue");
18570 useStoreProps(store, props, "resetValueOnHide");
18571 useStoreProps(store, props, "resetValueOnSelect");
18572 return Object.assign(
18573 useCompositeStoreProps(
18574 usePopoverStoreProps(store, update2, props),
18575 update2,
18576 props
18577 ),
18578 { tag: props.tag }
18579 );
18580 }
18581 function useComboboxStore(props = {}) {
18582 props = useComboboxStoreOptions(props);
18583 const [store, update2] = useStore2(createComboboxStore, props);
18584 return useComboboxStoreProps(store, update2, props);
18585 }
18586
18587 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
18588 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
18589 function ComboboxProvider(props = {}) {
18590 const store = useComboboxStore(props);
18591 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(ComboboxContextProvider, { value: store, children: props.children });
18592 }
18593
18594 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18595 var import_remove_accents = __toESM(require_remove_accents(), 1);
18596 var import_compose7 = __toESM(require_compose(), 1);
18597 var import_i18n28 = __toESM(require_i18n(), 1);
18598 var import_element39 = __toESM(require_element(), 1);
18599 var import_components18 = __toESM(require_components(), 1);
18600
18601 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
18602 var EMPTY_ARRAY3 = [];
18603 var getCurrentValue = (filterDefinition, currentFilter) => {
18604 if (filterDefinition.singleSelection) {
18605 return currentFilter?.value;
18606 }
18607 if (Array.isArray(currentFilter?.value)) {
18608 return currentFilter.value;
18609 }
18610 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
18611 return [currentFilter.value];
18612 }
18613 return EMPTY_ARRAY3;
18614 };
18615
18616 // packages/dataviews/build-module/hooks/use-elements.mjs
18617 var import_element38 = __toESM(require_element(), 1);
18618 var EMPTY_ARRAY4 = [];
18619 function useElements({
18620 elements,
18621 getElements
18622 }) {
18623 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
18624 const [records, setRecords] = (0, import_element38.useState)(staticElements);
18625 const [isLoading, setIsLoading] = (0, import_element38.useState)(false);
18626 (0, import_element38.useEffect)(() => {
18627 if (!getElements) {
18628 setRecords(staticElements);
18629 return;
18630 }
18631 let cancelled = false;
18632 setIsLoading(true);
18633 getElements().then((fetchedElements) => {
18634 if (!cancelled) {
18635 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
18636 setRecords(dynamicElements);
18637 }
18638 }).catch(() => {
18639 if (!cancelled) {
18640 setRecords(staticElements);
18641 }
18642 }).finally(() => {
18643 if (!cancelled) {
18644 setIsLoading(false);
18645 }
18646 });
18647 return () => {
18648 cancelled = true;
18649 };
18650 }, [getElements, staticElements]);
18651 return {
18652 elements: records,
18653 isLoading
18654 };
18655 }
18656
18657 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18658 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
18659 function normalizeSearchInput(input = "") {
18660 return (0, import_remove_accents.default)(input.trim().toLowerCase());
18661 }
18662 var getNewValue = (filterDefinition, currentFilter, value) => {
18663 if (filterDefinition.singleSelection) {
18664 return value;
18665 }
18666 if (Array.isArray(currentFilter?.value)) {
18667 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
18668 }
18669 return [value];
18670 };
18671 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
18672 return `${prefix}-${filterElementValue}`;
18673 }
18674 var MultiSelectionOption = ({ selected }) => {
18675 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18676 "span",
18677 {
18678 className: clsx_default(
18679 "dataviews-filters__search-widget-listitem-multi-selection",
18680 { "is-selected": selected }
18681 ),
18682 children: selected && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components18.Icon, { icon: check_default })
18683 }
18684 );
18685 };
18686 var SingleSelectionOption = ({ selected }) => {
18687 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18688 "span",
18689 {
18690 className: clsx_default(
18691 "dataviews-filters__search-widget-listitem-single-selection",
18692 { "is-selected": selected }
18693 )
18694 }
18695 );
18696 };
18697 function ListBox({ view, filter, onChangeView }) {
18698 const baseId = (0, import_compose7.useInstanceId)(ListBox, "dataviews-filter-list-box");
18699 const [activeCompositeId, setActiveCompositeId] = (0, import_element39.useState)(
18700 // When there are one or less operators, the first item is set as active
18701 // (by setting the initial `activeId` to `undefined`).
18702 // With 2 or more operators, the focus is moved on the operators control
18703 // (by setting the initial `activeId` to `null`), meaning that there won't
18704 // be an active item initially. Focus is then managed via the
18705 // `onFocusVisible` callback.
18706 filter.operators?.length === 1 ? void 0 : null
18707 );
18708 const currentFilter = view.filters?.find(
18709 (f2) => f2.field === filter.field
18710 );
18711 const currentValue = getCurrentValue(filter, currentFilter);
18712 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18713 import_components18.Composite,
18714 {
18715 virtualFocus: true,
18716 focusLoop: true,
18717 activeId: activeCompositeId,
18718 setActiveId: setActiveCompositeId,
18719 role: "listbox",
18720 className: "dataviews-filters__search-widget-listbox",
18721 "aria-label": (0, import_i18n28.sprintf)(
18722 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
18723 (0, import_i18n28.__)("List of: %1$s"),
18724 filter.name
18725 ),
18726 onFocusVisible: () => {
18727 if (!activeCompositeId && filter.elements.length) {
18728 setActiveCompositeId(
18729 generateFilterElementCompositeItemId(
18730 baseId,
18731 filter.elements[0].value
18732 )
18733 );
18734 }
18735 },
18736 render: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components18.Composite.Typeahead, {}),
18737 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
18738 import_components18.Composite.Hover,
18739 {
18740 render: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18741 import_components18.Composite.Item,
18742 {
18743 id: generateFilterElementCompositeItemId(
18744 baseId,
18745 element.value
18746 ),
18747 render: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18748 "div",
18749 {
18750 "aria-label": element.label,
18751 role: "option",
18752 className: "dataviews-filters__search-widget-listitem"
18753 }
18754 ),
18755 onClick: () => {
18756 const newFilters = currentFilter ? [
18757 ...(view.filters ?? []).map(
18758 (_filter) => {
18759 if (_filter.field === filter.field) {
18760 return {
18761 ..._filter,
18762 operator: currentFilter.operator || filter.operators[0],
18763 value: getNewValue(
18764 filter,
18765 currentFilter,
18766 element.value
18767 )
18768 };
18769 }
18770 return _filter;
18771 }
18772 )
18773 ] : [
18774 ...view.filters ?? [],
18775 {
18776 field: filter.field,
18777 operator: filter.operators[0],
18778 value: getNewValue(
18779 filter,
18780 currentFilter,
18781 element.value
18782 )
18783 }
18784 ];
18785 onChangeView({
18786 ...view,
18787 page: 1,
18788 filters: newFilters
18789 });
18790 }
18791 }
18792 ),
18793 children: [
18794 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18795 SingleSelectionOption,
18796 {
18797 selected: currentValue === element.value
18798 }
18799 ),
18800 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18801 MultiSelectionOption,
18802 {
18803 selected: currentValue.includes(element.value)
18804 }
18805 ),
18806 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18807 "span",
18808 {
18809 className: "dataviews-filters__search-widget-listitem-value",
18810 title: element.label,
18811 children: element.label
18812 }
18813 )
18814 ]
18815 },
18816 element.value
18817 ))
18818 }
18819 );
18820 }
18821 function ComboboxList22({ view, filter, onChangeView }) {
18822 const [searchValue, setSearchValue] = (0, import_element39.useState)("");
18823 const deferredSearchValue = (0, import_element39.useDeferredValue)(searchValue);
18824 const currentFilter = view.filters?.find(
18825 (_filter) => _filter.field === filter.field
18826 );
18827 const currentValue = getCurrentValue(filter, currentFilter);
18828 const matches = (0, import_element39.useMemo)(() => {
18829 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
18830 return filter.elements.filter(
18831 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
18832 );
18833 }, [filter.elements, deferredSearchValue]);
18834 return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
18835 ComboboxProvider,
18836 {
18837 selectedValue: currentValue,
18838 setSelectedValue: (value) => {
18839 const newFilters = currentFilter ? [
18840 ...(view.filters ?? []).map((_filter) => {
18841 if (_filter.field === filter.field) {
18842 return {
18843 ..._filter,
18844 operator: currentFilter.operator || filter.operators[0],
18845 value
18846 };
18847 }
18848 return _filter;
18849 })
18850 ] : [
18851 ...view.filters ?? [],
18852 {
18853 field: filter.field,
18854 operator: filter.operators[0],
18855 value
18856 }
18857 ];
18858 onChangeView({
18859 ...view,
18860 page: 1,
18861 filters: newFilters
18862 });
18863 },
18864 setValue: setSearchValue,
18865 children: [
18866 /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
18867 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ComboboxLabel, {}), children: (0, import_i18n28.__)("Search items") }),
18868 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18869 Combobox,
18870 {
18871 autoSelect: "always",
18872 placeholder: (0, import_i18n28.__)("Search"),
18873 className: "dataviews-filters__search-widget-filter-combobox__input"
18874 }
18875 ),
18876 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components18.Icon, { icon: search_default }) })
18877 ] }),
18878 /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
18879 ComboboxList,
18880 {
18881 className: "dataviews-filters__search-widget-filter-combobox-list",
18882 alwaysVisible: true,
18883 children: [
18884 matches.map((element) => {
18885 return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
18886 ComboboxItem,
18887 {
18888 resetValueOnSelect: false,
18889 value: element.value,
18890 className: "dataviews-filters__search-widget-listitem",
18891 hideOnClick: false,
18892 setValueOnClick: false,
18893 focusOnHover: true,
18894 children: [
18895 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18896 SingleSelectionOption,
18897 {
18898 selected: currentValue === element.value
18899 }
18900 ),
18901 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18902 MultiSelectionOption,
18903 {
18904 selected: currentValue.includes(
18905 element.value
18906 )
18907 }
18908 ),
18909 /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
18910 "span",
18911 {
18912 className: "dataviews-filters__search-widget-listitem-value",
18913 title: element.label,
18914 children: [
18915 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18916 ComboboxItemValue,
18917 {
18918 className: "dataviews-filters__search-widget-filter-combobox-item-value",
18919 value: element.label
18920 }
18921 ),
18922 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
18923 ]
18924 }
18925 )
18926 ]
18927 },
18928 element.value
18929 );
18930 }),
18931 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("p", { children: (0, import_i18n28.__)("No results found") })
18932 ]
18933 }
18934 )
18935 ]
18936 }
18937 );
18938 }
18939 function SearchWidget(props) {
18940 const { elements, isLoading } = useElements({
18941 elements: props.filter.elements,
18942 getElements: props.filter.getElements
18943 });
18944 if (isLoading) {
18945 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components18.Spinner, {}) });
18946 }
18947 if (elements.length === 0) {
18948 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n28.__)("No elements found") });
18949 }
18950 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
18951 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
18952 }
18953
18954 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
18955 var import_es6 = __toESM(require_es6(), 1);
18956 var import_compose8 = __toESM(require_compose(), 1);
18957 var import_element40 = __toESM(require_element(), 1);
18958 var import_components19 = __toESM(require_components(), 1);
18959 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
18960 function InputWidget({
18961 filter,
18962 view,
18963 onChangeView,
18964 fields
18965 }) {
18966 const currentFilter = view.filters?.find(
18967 (f2) => f2.field === filter.field
18968 );
18969 const currentValue = getCurrentValue(filter, currentFilter);
18970 const field = (0, import_element40.useMemo)(() => {
18971 const currentField = fields.find((f2) => f2.id === filter.field);
18972 if (currentField) {
18973 return {
18974 ...currentField,
18975 // Deactivate validation for filters.
18976 isValid: {},
18977 // Filter controls are always enabled.
18978 isDisabled: () => false,
18979 // Filter controls are always visible.
18980 isVisible: () => true,
18981 // Configure getValue/setValue as if Item was a plain object.
18982 getValue: ({ item }) => item[currentField.id],
18983 setValue: ({ value }) => ({
18984 [currentField.id]: value
18985 })
18986 };
18987 }
18988 return currentField;
18989 }, [fields, filter.field]);
18990 const data = (0, import_element40.useMemo)(() => {
18991 return (view.filters ?? []).reduce(
18992 (acc, activeFilter) => {
18993 acc[activeFilter.field] = activeFilter.value;
18994 return acc;
18995 },
18996 {}
18997 );
18998 }, [view.filters]);
18999 const handleChange = (0, import_compose8.useEvent)((updatedData) => {
19000 if (!field || !currentFilter) {
19001 return;
19002 }
19003 const nextValue = field.getValue({ item: updatedData });
19004 if ((0, import_es6.default)(nextValue, currentValue)) {
19005 return;
19006 }
19007 onChangeView({
19008 ...view,
19009 filters: (view.filters ?? []).map(
19010 (_filter) => _filter.field === filter.field ? {
19011 ..._filter,
19012 operator: currentFilter.operator || filter.operators[0],
19013 // Consider empty strings as undefined:
19014 //
19015 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
19016 // - empty string as value means "search empty string": returns only the records that have an empty string as value
19017 //
19018 // In practice, this means the filter will not be able to find an empty string as the value.
19019 value: nextValue === "" ? void 0 : nextValue
19020 } : _filter
19021 )
19022 });
19023 });
19024 if (!field || !field.Edit || !currentFilter) {
19025 return null;
19026 }
19027 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19028 import_components19.Flex,
19029 {
19030 className: "dataviews-filters__user-input-widget",
19031 gap: 2.5,
19032 direction: "column",
19033 children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19034 field.Edit,
19035 {
19036 hideLabelFromVision: true,
19037 data,
19038 field,
19039 operator: currentFilter.operator,
19040 onChange: handleChange
19041 }
19042 )
19043 }
19044 );
19045 }
19046
19047 // node_modules/date-fns/constants.js
19048 var daysInYear = 365.2425;
19049 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
19050 var minTime = -maxTime;
19051 var millisecondsInWeek = 6048e5;
19052 var millisecondsInDay = 864e5;
19053 var secondsInHour = 3600;
19054 var secondsInDay = secondsInHour * 24;
19055 var secondsInWeek = secondsInDay * 7;
19056 var secondsInYear = secondsInDay * daysInYear;
19057 var secondsInMonth = secondsInYear / 12;
19058 var secondsInQuarter = secondsInMonth * 3;
19059 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
19060
19061 // node_modules/date-fns/constructFrom.js
19062 function constructFrom(date, value) {
19063 if (typeof date === "function") return date(value);
19064 if (date && typeof date === "object" && constructFromSymbol in date)
19065 return date[constructFromSymbol](value);
19066 if (date instanceof Date) return new date.constructor(value);
19067 return new Date(value);
19068 }
19069
19070 // node_modules/date-fns/toDate.js
19071 function toDate(argument, context) {
19072 return constructFrom(context || argument, argument);
19073 }
19074
19075 // node_modules/date-fns/addDays.js
19076 function addDays(date, amount, options) {
19077 const _date = toDate(date, options?.in);
19078 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19079 if (!amount) return _date;
19080 _date.setDate(_date.getDate() + amount);
19081 return _date;
19082 }
19083
19084 // node_modules/date-fns/addMonths.js
19085 function addMonths(date, amount, options) {
19086 const _date = toDate(date, options?.in);
19087 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19088 if (!amount) {
19089 return _date;
19090 }
19091 const dayOfMonth = _date.getDate();
19092 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
19093 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
19094 const daysInMonth = endOfDesiredMonth.getDate();
19095 if (dayOfMonth >= daysInMonth) {
19096 return endOfDesiredMonth;
19097 } else {
19098 _date.setFullYear(
19099 endOfDesiredMonth.getFullYear(),
19100 endOfDesiredMonth.getMonth(),
19101 dayOfMonth
19102 );
19103 return _date;
19104 }
19105 }
19106
19107 // node_modules/date-fns/_lib/defaultOptions.js
19108 var defaultOptions = {};
19109 function getDefaultOptions() {
19110 return defaultOptions;
19111 }
19112
19113 // node_modules/date-fns/startOfWeek.js
19114 function startOfWeek(date, options) {
19115 const defaultOptions2 = getDefaultOptions();
19116 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
19117 const _date = toDate(date, options?.in);
19118 const day = _date.getDay();
19119 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
19120 _date.setDate(_date.getDate() - diff);
19121 _date.setHours(0, 0, 0, 0);
19122 return _date;
19123 }
19124
19125 // node_modules/date-fns/startOfISOWeek.js
19126 function startOfISOWeek(date, options) {
19127 return startOfWeek(date, { ...options, weekStartsOn: 1 });
19128 }
19129
19130 // node_modules/date-fns/getISOWeekYear.js
19131 function getISOWeekYear(date, options) {
19132 const _date = toDate(date, options?.in);
19133 const year = _date.getFullYear();
19134 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
19135 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
19136 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
19137 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
19138 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
19139 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
19140 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
19141 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
19142 if (_date.getTime() >= startOfNextYear.getTime()) {
19143 return year + 1;
19144 } else if (_date.getTime() >= startOfThisYear.getTime()) {
19145 return year;
19146 } else {
19147 return year - 1;
19148 }
19149 }
19150
19151 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
19152 function getTimezoneOffsetInMilliseconds(date) {
19153 const _date = toDate(date);
19154 const utcDate = new Date(
19155 Date.UTC(
19156 _date.getFullYear(),
19157 _date.getMonth(),
19158 _date.getDate(),
19159 _date.getHours(),
19160 _date.getMinutes(),
19161 _date.getSeconds(),
19162 _date.getMilliseconds()
19163 )
19164 );
19165 utcDate.setUTCFullYear(_date.getFullYear());
19166 return +date - +utcDate;
19167 }
19168
19169 // node_modules/date-fns/_lib/normalizeDates.js
19170 function normalizeDates(context, ...dates) {
19171 const normalize = constructFrom.bind(
19172 null,
19173 context || dates.find((date) => typeof date === "object")
19174 );
19175 return dates.map(normalize);
19176 }
19177
19178 // node_modules/date-fns/startOfDay.js
19179 function startOfDay(date, options) {
19180 const _date = toDate(date, options?.in);
19181 _date.setHours(0, 0, 0, 0);
19182 return _date;
19183 }
19184
19185 // node_modules/date-fns/differenceInCalendarDays.js
19186 function differenceInCalendarDays(laterDate, earlierDate, options) {
19187 const [laterDate_, earlierDate_] = normalizeDates(
19188 options?.in,
19189 laterDate,
19190 earlierDate
19191 );
19192 const laterStartOfDay = startOfDay(laterDate_);
19193 const earlierStartOfDay = startOfDay(earlierDate_);
19194 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
19195 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
19196 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
19197 }
19198
19199 // node_modules/date-fns/startOfISOWeekYear.js
19200 function startOfISOWeekYear(date, options) {
19201 const year = getISOWeekYear(date, options);
19202 const fourthOfJanuary = constructFrom(options?.in || date, 0);
19203 fourthOfJanuary.setFullYear(year, 0, 4);
19204 fourthOfJanuary.setHours(0, 0, 0, 0);
19205 return startOfISOWeek(fourthOfJanuary);
19206 }
19207
19208 // node_modules/date-fns/addWeeks.js
19209 function addWeeks(date, amount, options) {
19210 return addDays(date, amount * 7, options);
19211 }
19212
19213 // node_modules/date-fns/addYears.js
19214 function addYears(date, amount, options) {
19215 return addMonths(date, amount * 12, options);
19216 }
19217
19218 // node_modules/date-fns/isDate.js
19219 function isDate(value) {
19220 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
19221 }
19222
19223 // node_modules/date-fns/isValid.js
19224 function isValid(date) {
19225 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
19226 }
19227
19228 // node_modules/date-fns/startOfMonth.js
19229 function startOfMonth(date, options) {
19230 const _date = toDate(date, options?.in);
19231 _date.setDate(1);
19232 _date.setHours(0, 0, 0, 0);
19233 return _date;
19234 }
19235
19236 // node_modules/date-fns/startOfYear.js
19237 function startOfYear(date, options) {
19238 const date_ = toDate(date, options?.in);
19239 date_.setFullYear(date_.getFullYear(), 0, 1);
19240 date_.setHours(0, 0, 0, 0);
19241 return date_;
19242 }
19243
19244 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
19245 var formatDistanceLocale = {
19246 lessThanXSeconds: {
19247 one: "less than a second",
19248 other: "less than {{count}} seconds"
19249 },
19250 xSeconds: {
19251 one: "1 second",
19252 other: "{{count}} seconds"
19253 },
19254 halfAMinute: "half a minute",
19255 lessThanXMinutes: {
19256 one: "less than a minute",
19257 other: "less than {{count}} minutes"
19258 },
19259 xMinutes: {
19260 one: "1 minute",
19261 other: "{{count}} minutes"
19262 },
19263 aboutXHours: {
19264 one: "about 1 hour",
19265 other: "about {{count}} hours"
19266 },
19267 xHours: {
19268 one: "1 hour",
19269 other: "{{count}} hours"
19270 },
19271 xDays: {
19272 one: "1 day",
19273 other: "{{count}} days"
19274 },
19275 aboutXWeeks: {
19276 one: "about 1 week",
19277 other: "about {{count}} weeks"
19278 },
19279 xWeeks: {
19280 one: "1 week",
19281 other: "{{count}} weeks"
19282 },
19283 aboutXMonths: {
19284 one: "about 1 month",
19285 other: "about {{count}} months"
19286 },
19287 xMonths: {
19288 one: "1 month",
19289 other: "{{count}} months"
19290 },
19291 aboutXYears: {
19292 one: "about 1 year",
19293 other: "about {{count}} years"
19294 },
19295 xYears: {
19296 one: "1 year",
19297 other: "{{count}} years"
19298 },
19299 overXYears: {
19300 one: "over 1 year",
19301 other: "over {{count}} years"
19302 },
19303 almostXYears: {
19304 one: "almost 1 year",
19305 other: "almost {{count}} years"
19306 }
19307 };
19308 var formatDistance = (token, count, options) => {
19309 let result;
19310 const tokenValue = formatDistanceLocale[token];
19311 if (typeof tokenValue === "string") {
19312 result = tokenValue;
19313 } else if (count === 1) {
19314 result = tokenValue.one;
19315 } else {
19316 result = tokenValue.other.replace("{{count}}", count.toString());
19317 }
19318 if (options?.addSuffix) {
19319 if (options.comparison && options.comparison > 0) {
19320 return "in " + result;
19321 } else {
19322 return result + " ago";
19323 }
19324 }
19325 return result;
19326 };
19327
19328 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
19329 function buildFormatLongFn(args) {
19330 return (options = {}) => {
19331 const width = options.width ? String(options.width) : args.defaultWidth;
19332 const format6 = args.formats[width] || args.formats[args.defaultWidth];
19333 return format6;
19334 };
19335 }
19336
19337 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
19338 var dateFormats = {
19339 full: "EEEE, MMMM do, y",
19340 long: "MMMM do, y",
19341 medium: "MMM d, y",
19342 short: "MM/dd/yyyy"
19343 };
19344 var timeFormats = {
19345 full: "h:mm:ss a zzzz",
19346 long: "h:mm:ss a z",
19347 medium: "h:mm:ss a",
19348 short: "h:mm a"
19349 };
19350 var dateTimeFormats = {
19351 full: "{{date}} 'at' {{time}}",
19352 long: "{{date}} 'at' {{time}}",
19353 medium: "{{date}}, {{time}}",
19354 short: "{{date}}, {{time}}"
19355 };
19356 var formatLong = {
19357 date: buildFormatLongFn({
19358 formats: dateFormats,
19359 defaultWidth: "full"
19360 }),
19361 time: buildFormatLongFn({
19362 formats: timeFormats,
19363 defaultWidth: "full"
19364 }),
19365 dateTime: buildFormatLongFn({
19366 formats: dateTimeFormats,
19367 defaultWidth: "full"
19368 })
19369 };
19370
19371 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
19372 var formatRelativeLocale = {
19373 lastWeek: "'last' eeee 'at' p",
19374 yesterday: "'yesterday at' p",
19375 today: "'today at' p",
19376 tomorrow: "'tomorrow at' p",
19377 nextWeek: "eeee 'at' p",
19378 other: "P"
19379 };
19380 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
19381
19382 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
19383 function buildLocalizeFn(args) {
19384 return (value, options) => {
19385 const context = options?.context ? String(options.context) : "standalone";
19386 let valuesArray;
19387 if (context === "formatting" && args.formattingValues) {
19388 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
19389 const width = options?.width ? String(options.width) : defaultWidth;
19390 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
19391 } else {
19392 const defaultWidth = args.defaultWidth;
19393 const width = options?.width ? String(options.width) : args.defaultWidth;
19394 valuesArray = args.values[width] || args.values[defaultWidth];
19395 }
19396 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
19397 return valuesArray[index2];
19398 };
19399 }
19400
19401 // node_modules/date-fns/locale/en-US/_lib/localize.js
19402 var eraValues = {
19403 narrow: ["B", "A"],
19404 abbreviated: ["BC", "AD"],
19405 wide: ["Before Christ", "Anno Domini"]
19406 };
19407 var quarterValues = {
19408 narrow: ["1", "2", "3", "4"],
19409 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
19410 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
19411 };
19412 var monthValues = {
19413 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
19414 abbreviated: [
19415 "Jan",
19416 "Feb",
19417 "Mar",
19418 "Apr",
19419 "May",
19420 "Jun",
19421 "Jul",
19422 "Aug",
19423 "Sep",
19424 "Oct",
19425 "Nov",
19426 "Dec"
19427 ],
19428 wide: [
19429 "January",
19430 "February",
19431 "March",
19432 "April",
19433 "May",
19434 "June",
19435 "July",
19436 "August",
19437 "September",
19438 "October",
19439 "November",
19440 "December"
19441 ]
19442 };
19443 var dayValues = {
19444 narrow: ["S", "M", "T", "W", "T", "F", "S"],
19445 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
19446 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
19447 wide: [
19448 "Sunday",
19449 "Monday",
19450 "Tuesday",
19451 "Wednesday",
19452 "Thursday",
19453 "Friday",
19454 "Saturday"
19455 ]
19456 };
19457 var dayPeriodValues = {
19458 narrow: {
19459 am: "a",
19460 pm: "p",
19461 midnight: "mi",
19462 noon: "n",
19463 morning: "morning",
19464 afternoon: "afternoon",
19465 evening: "evening",
19466 night: "night"
19467 },
19468 abbreviated: {
19469 am: "AM",
19470 pm: "PM",
19471 midnight: "midnight",
19472 noon: "noon",
19473 morning: "morning",
19474 afternoon: "afternoon",
19475 evening: "evening",
19476 night: "night"
19477 },
19478 wide: {
19479 am: "a.m.",
19480 pm: "p.m.",
19481 midnight: "midnight",
19482 noon: "noon",
19483 morning: "morning",
19484 afternoon: "afternoon",
19485 evening: "evening",
19486 night: "night"
19487 }
19488 };
19489 var formattingDayPeriodValues = {
19490 narrow: {
19491 am: "a",
19492 pm: "p",
19493 midnight: "mi",
19494 noon: "n",
19495 morning: "in the morning",
19496 afternoon: "in the afternoon",
19497 evening: "in the evening",
19498 night: "at night"
19499 },
19500 abbreviated: {
19501 am: "AM",
19502 pm: "PM",
19503 midnight: "midnight",
19504 noon: "noon",
19505 morning: "in the morning",
19506 afternoon: "in the afternoon",
19507 evening: "in the evening",
19508 night: "at night"
19509 },
19510 wide: {
19511 am: "a.m.",
19512 pm: "p.m.",
19513 midnight: "midnight",
19514 noon: "noon",
19515 morning: "in the morning",
19516 afternoon: "in the afternoon",
19517 evening: "in the evening",
19518 night: "at night"
19519 }
19520 };
19521 var ordinalNumber = (dirtyNumber, _options) => {
19522 const number = Number(dirtyNumber);
19523 const rem100 = number % 100;
19524 if (rem100 > 20 || rem100 < 10) {
19525 switch (rem100 % 10) {
19526 case 1:
19527 return number + "st";
19528 case 2:
19529 return number + "nd";
19530 case 3:
19531 return number + "rd";
19532 }
19533 }
19534 return number + "th";
19535 };
19536 var localize = {
19537 ordinalNumber,
19538 era: buildLocalizeFn({
19539 values: eraValues,
19540 defaultWidth: "wide"
19541 }),
19542 quarter: buildLocalizeFn({
19543 values: quarterValues,
19544 defaultWidth: "wide",
19545 argumentCallback: (quarter) => quarter - 1
19546 }),
19547 month: buildLocalizeFn({
19548 values: monthValues,
19549 defaultWidth: "wide"
19550 }),
19551 day: buildLocalizeFn({
19552 values: dayValues,
19553 defaultWidth: "wide"
19554 }),
19555 dayPeriod: buildLocalizeFn({
19556 values: dayPeriodValues,
19557 defaultWidth: "wide",
19558 formattingValues: formattingDayPeriodValues,
19559 defaultFormattingWidth: "wide"
19560 })
19561 };
19562
19563 // node_modules/date-fns/locale/_lib/buildMatchFn.js
19564 function buildMatchFn(args) {
19565 return (string, options = {}) => {
19566 const width = options.width;
19567 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
19568 const matchResult = string.match(matchPattern);
19569 if (!matchResult) {
19570 return null;
19571 }
19572 const matchedString = matchResult[0];
19573 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
19574 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
19575 // [TODO] -- I challenge you to fix the type
19576 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
19577 );
19578 let value;
19579 value = args.valueCallback ? args.valueCallback(key) : key;
19580 value = options.valueCallback ? (
19581 // [TODO] -- I challenge you to fix the type
19582 options.valueCallback(value)
19583 ) : value;
19584 const rest = string.slice(matchedString.length);
19585 return { value, rest };
19586 };
19587 }
19588 function findKey(object, predicate) {
19589 for (const key in object) {
19590 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
19591 return key;
19592 }
19593 }
19594 return void 0;
19595 }
19596 function findIndex(array, predicate) {
19597 for (let key = 0; key < array.length; key++) {
19598 if (predicate(array[key])) {
19599 return key;
19600 }
19601 }
19602 return void 0;
19603 }
19604
19605 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
19606 function buildMatchPatternFn(args) {
19607 return (string, options = {}) => {
19608 const matchResult = string.match(args.matchPattern);
19609 if (!matchResult) return null;
19610 const matchedString = matchResult[0];
19611 const parseResult = string.match(args.parsePattern);
19612 if (!parseResult) return null;
19613 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
19614 value = options.valueCallback ? options.valueCallback(value) : value;
19615 const rest = string.slice(matchedString.length);
19616 return { value, rest };
19617 };
19618 }
19619
19620 // node_modules/date-fns/locale/en-US/_lib/match.js
19621 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
19622 var parseOrdinalNumberPattern = /\d+/i;
19623 var matchEraPatterns = {
19624 narrow: /^(b|a)/i,
19625 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
19626 wide: /^(before christ|before common era|anno domini|common era)/i
19627 };
19628 var parseEraPatterns = {
19629 any: [/^b/i, /^(a|c)/i]
19630 };
19631 var matchQuarterPatterns = {
19632 narrow: /^[1234]/i,
19633 abbreviated: /^q[1234]/i,
19634 wide: /^[1234](th|st|nd|rd)? quarter/i
19635 };
19636 var parseQuarterPatterns = {
19637 any: [/1/i, /2/i, /3/i, /4/i]
19638 };
19639 var matchMonthPatterns = {
19640 narrow: /^[jfmasond]/i,
19641 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
19642 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
19643 };
19644 var parseMonthPatterns = {
19645 narrow: [
19646 /^j/i,
19647 /^f/i,
19648 /^m/i,
19649 /^a/i,
19650 /^m/i,
19651 /^j/i,
19652 /^j/i,
19653 /^a/i,
19654 /^s/i,
19655 /^o/i,
19656 /^n/i,
19657 /^d/i
19658 ],
19659 any: [
19660 /^ja/i,
19661 /^f/i,
19662 /^mar/i,
19663 /^ap/i,
19664 /^may/i,
19665 /^jun/i,
19666 /^jul/i,
19667 /^au/i,
19668 /^s/i,
19669 /^o/i,
19670 /^n/i,
19671 /^d/i
19672 ]
19673 };
19674 var matchDayPatterns = {
19675 narrow: /^[smtwf]/i,
19676 short: /^(su|mo|tu|we|th|fr|sa)/i,
19677 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
19678 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
19679 };
19680 var parseDayPatterns = {
19681 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
19682 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
19683 };
19684 var matchDayPeriodPatterns = {
19685 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
19686 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
19687 };
19688 var parseDayPeriodPatterns = {
19689 any: {
19690 am: /^a/i,
19691 pm: /^p/i,
19692 midnight: /^mi/i,
19693 noon: /^no/i,
19694 morning: /morning/i,
19695 afternoon: /afternoon/i,
19696 evening: /evening/i,
19697 night: /night/i
19698 }
19699 };
19700 var match = {
19701 ordinalNumber: buildMatchPatternFn({
19702 matchPattern: matchOrdinalNumberPattern,
19703 parsePattern: parseOrdinalNumberPattern,
19704 valueCallback: (value) => parseInt(value, 10)
19705 }),
19706 era: buildMatchFn({
19707 matchPatterns: matchEraPatterns,
19708 defaultMatchWidth: "wide",
19709 parsePatterns: parseEraPatterns,
19710 defaultParseWidth: "any"
19711 }),
19712 quarter: buildMatchFn({
19713 matchPatterns: matchQuarterPatterns,
19714 defaultMatchWidth: "wide",
19715 parsePatterns: parseQuarterPatterns,
19716 defaultParseWidth: "any",
19717 valueCallback: (index2) => index2 + 1
19718 }),
19719 month: buildMatchFn({
19720 matchPatterns: matchMonthPatterns,
19721 defaultMatchWidth: "wide",
19722 parsePatterns: parseMonthPatterns,
19723 defaultParseWidth: "any"
19724 }),
19725 day: buildMatchFn({
19726 matchPatterns: matchDayPatterns,
19727 defaultMatchWidth: "wide",
19728 parsePatterns: parseDayPatterns,
19729 defaultParseWidth: "any"
19730 }),
19731 dayPeriod: buildMatchFn({
19732 matchPatterns: matchDayPeriodPatterns,
19733 defaultMatchWidth: "any",
19734 parsePatterns: parseDayPeriodPatterns,
19735 defaultParseWidth: "any"
19736 })
19737 };
19738
19739 // node_modules/date-fns/locale/en-US.js
19740 var enUS = {
19741 code: "en-US",
19742 formatDistance,
19743 formatLong,
19744 formatRelative,
19745 localize,
19746 match,
19747 options: {
19748 weekStartsOn: 0,
19749 firstWeekContainsDate: 1
19750 }
19751 };
19752
19753 // node_modules/date-fns/getDayOfYear.js
19754 function getDayOfYear(date, options) {
19755 const _date = toDate(date, options?.in);
19756 const diff = differenceInCalendarDays(_date, startOfYear(_date));
19757 const dayOfYear = diff + 1;
19758 return dayOfYear;
19759 }
19760
19761 // node_modules/date-fns/getISOWeek.js
19762 function getISOWeek(date, options) {
19763 const _date = toDate(date, options?.in);
19764 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
19765 return Math.round(diff / millisecondsInWeek) + 1;
19766 }
19767
19768 // node_modules/date-fns/getWeekYear.js
19769 function getWeekYear(date, options) {
19770 const _date = toDate(date, options?.in);
19771 const year = _date.getFullYear();
19772 const defaultOptions2 = getDefaultOptions();
19773 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
19774 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
19775 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
19776 firstWeekOfNextYear.setHours(0, 0, 0, 0);
19777 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
19778 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
19779 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
19780 firstWeekOfThisYear.setHours(0, 0, 0, 0);
19781 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
19782 if (+_date >= +startOfNextYear) {
19783 return year + 1;
19784 } else if (+_date >= +startOfThisYear) {
19785 return year;
19786 } else {
19787 return year - 1;
19788 }
19789 }
19790
19791 // node_modules/date-fns/startOfWeekYear.js
19792 function startOfWeekYear(date, options) {
19793 const defaultOptions2 = getDefaultOptions();
19794 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
19795 const year = getWeekYear(date, options);
19796 const firstWeek = constructFrom(options?.in || date, 0);
19797 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
19798 firstWeek.setHours(0, 0, 0, 0);
19799 const _date = startOfWeek(firstWeek, options);
19800 return _date;
19801 }
19802
19803 // node_modules/date-fns/getWeek.js
19804 function getWeek(date, options) {
19805 const _date = toDate(date, options?.in);
19806 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
19807 return Math.round(diff / millisecondsInWeek) + 1;
19808 }
19809
19810 // node_modules/date-fns/_lib/addLeadingZeros.js
19811 function addLeadingZeros(number, targetLength) {
19812 const sign = number < 0 ? "-" : "";
19813 const output = Math.abs(number).toString().padStart(targetLength, "0");
19814 return sign + output;
19815 }
19816
19817 // node_modules/date-fns/_lib/format/lightFormatters.js
19818 var lightFormatters = {
19819 // Year
19820 y(date, token) {
19821 const signedYear = date.getFullYear();
19822 const year = signedYear > 0 ? signedYear : 1 - signedYear;
19823 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
19824 },
19825 // Month
19826 M(date, token) {
19827 const month = date.getMonth();
19828 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
19829 },
19830 // Day of the month
19831 d(date, token) {
19832 return addLeadingZeros(date.getDate(), token.length);
19833 },
19834 // AM or PM
19835 a(date, token) {
19836 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
19837 switch (token) {
19838 case "a":
19839 case "aa":
19840 return dayPeriodEnumValue.toUpperCase();
19841 case "aaa":
19842 return dayPeriodEnumValue;
19843 case "aaaaa":
19844 return dayPeriodEnumValue[0];
19845 case "aaaa":
19846 default:
19847 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
19848 }
19849 },
19850 // Hour [1-12]
19851 h(date, token) {
19852 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
19853 },
19854 // Hour [0-23]
19855 H(date, token) {
19856 return addLeadingZeros(date.getHours(), token.length);
19857 },
19858 // Minute
19859 m(date, token) {
19860 return addLeadingZeros(date.getMinutes(), token.length);
19861 },
19862 // Second
19863 s(date, token) {
19864 return addLeadingZeros(date.getSeconds(), token.length);
19865 },
19866 // Fraction of second
19867 S(date, token) {
19868 const numberOfDigits = token.length;
19869 const milliseconds = date.getMilliseconds();
19870 const fractionalSeconds = Math.trunc(
19871 milliseconds * Math.pow(10, numberOfDigits - 3)
19872 );
19873 return addLeadingZeros(fractionalSeconds, token.length);
19874 }
19875 };
19876
19877 // node_modules/date-fns/_lib/format/formatters.js
19878 var dayPeriodEnum = {
19879 am: "am",
19880 pm: "pm",
19881 midnight: "midnight",
19882 noon: "noon",
19883 morning: "morning",
19884 afternoon: "afternoon",
19885 evening: "evening",
19886 night: "night"
19887 };
19888 var formatters = {
19889 // Era
19890 G: function(date, token, localize2) {
19891 const era = date.getFullYear() > 0 ? 1 : 0;
19892 switch (token) {
19893 // AD, BC
19894 case "G":
19895 case "GG":
19896 case "GGG":
19897 return localize2.era(era, { width: "abbreviated" });
19898 // A, B
19899 case "GGGGG":
19900 return localize2.era(era, { width: "narrow" });
19901 // Anno Domini, Before Christ
19902 case "GGGG":
19903 default:
19904 return localize2.era(era, { width: "wide" });
19905 }
19906 },
19907 // Year
19908 y: function(date, token, localize2) {
19909 if (token === "yo") {
19910 const signedYear = date.getFullYear();
19911 const year = signedYear > 0 ? signedYear : 1 - signedYear;
19912 return localize2.ordinalNumber(year, { unit: "year" });
19913 }
19914 return lightFormatters.y(date, token);
19915 },
19916 // Local week-numbering year
19917 Y: function(date, token, localize2, options) {
19918 const signedWeekYear = getWeekYear(date, options);
19919 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
19920 if (token === "YY") {
19921 const twoDigitYear = weekYear % 100;
19922 return addLeadingZeros(twoDigitYear, 2);
19923 }
19924 if (token === "Yo") {
19925 return localize2.ordinalNumber(weekYear, { unit: "year" });
19926 }
19927 return addLeadingZeros(weekYear, token.length);
19928 },
19929 // ISO week-numbering year
19930 R: function(date, token) {
19931 const isoWeekYear = getISOWeekYear(date);
19932 return addLeadingZeros(isoWeekYear, token.length);
19933 },
19934 // Extended year. This is a single number designating the year of this calendar system.
19935 // The main difference between `y` and `u` localizers are B.C. years:
19936 // | Year | `y` | `u` |
19937 // |------|-----|-----|
19938 // | AC 1 | 1 | 1 |
19939 // | BC 1 | 1 | 0 |
19940 // | BC 2 | 2 | -1 |
19941 // Also `yy` always returns the last two digits of a year,
19942 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
19943 u: function(date, token) {
19944 const year = date.getFullYear();
19945 return addLeadingZeros(year, token.length);
19946 },
19947 // Quarter
19948 Q: function(date, token, localize2) {
19949 const quarter = Math.ceil((date.getMonth() + 1) / 3);
19950 switch (token) {
19951 // 1, 2, 3, 4
19952 case "Q":
19953 return String(quarter);
19954 // 01, 02, 03, 04
19955 case "QQ":
19956 return addLeadingZeros(quarter, 2);
19957 // 1st, 2nd, 3rd, 4th
19958 case "Qo":
19959 return localize2.ordinalNumber(quarter, { unit: "quarter" });
19960 // Q1, Q2, Q3, Q4
19961 case "QQQ":
19962 return localize2.quarter(quarter, {
19963 width: "abbreviated",
19964 context: "formatting"
19965 });
19966 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
19967 case "QQQQQ":
19968 return localize2.quarter(quarter, {
19969 width: "narrow",
19970 context: "formatting"
19971 });
19972 // 1st quarter, 2nd quarter, ...
19973 case "QQQQ":
19974 default:
19975 return localize2.quarter(quarter, {
19976 width: "wide",
19977 context: "formatting"
19978 });
19979 }
19980 },
19981 // Stand-alone quarter
19982 q: function(date, token, localize2) {
19983 const quarter = Math.ceil((date.getMonth() + 1) / 3);
19984 switch (token) {
19985 // 1, 2, 3, 4
19986 case "q":
19987 return String(quarter);
19988 // 01, 02, 03, 04
19989 case "qq":
19990 return addLeadingZeros(quarter, 2);
19991 // 1st, 2nd, 3rd, 4th
19992 case "qo":
19993 return localize2.ordinalNumber(quarter, { unit: "quarter" });
19994 // Q1, Q2, Q3, Q4
19995 case "qqq":
19996 return localize2.quarter(quarter, {
19997 width: "abbreviated",
19998 context: "standalone"
19999 });
20000 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20001 case "qqqqq":
20002 return localize2.quarter(quarter, {
20003 width: "narrow",
20004 context: "standalone"
20005 });
20006 // 1st quarter, 2nd quarter, ...
20007 case "qqqq":
20008 default:
20009 return localize2.quarter(quarter, {
20010 width: "wide",
20011 context: "standalone"
20012 });
20013 }
20014 },
20015 // Month
20016 M: function(date, token, localize2) {
20017 const month = date.getMonth();
20018 switch (token) {
20019 case "M":
20020 case "MM":
20021 return lightFormatters.M(date, token);
20022 // 1st, 2nd, ..., 12th
20023 case "Mo":
20024 return localize2.ordinalNumber(month + 1, { unit: "month" });
20025 // Jan, Feb, ..., Dec
20026 case "MMM":
20027 return localize2.month(month, {
20028 width: "abbreviated",
20029 context: "formatting"
20030 });
20031 // J, F, ..., D
20032 case "MMMMM":
20033 return localize2.month(month, {
20034 width: "narrow",
20035 context: "formatting"
20036 });
20037 // January, February, ..., December
20038 case "MMMM":
20039 default:
20040 return localize2.month(month, { width: "wide", context: "formatting" });
20041 }
20042 },
20043 // Stand-alone month
20044 L: function(date, token, localize2) {
20045 const month = date.getMonth();
20046 switch (token) {
20047 // 1, 2, ..., 12
20048 case "L":
20049 return String(month + 1);
20050 // 01, 02, ..., 12
20051 case "LL":
20052 return addLeadingZeros(month + 1, 2);
20053 // 1st, 2nd, ..., 12th
20054 case "Lo":
20055 return localize2.ordinalNumber(month + 1, { unit: "month" });
20056 // Jan, Feb, ..., Dec
20057 case "LLL":
20058 return localize2.month(month, {
20059 width: "abbreviated",
20060 context: "standalone"
20061 });
20062 // J, F, ..., D
20063 case "LLLLL":
20064 return localize2.month(month, {
20065 width: "narrow",
20066 context: "standalone"
20067 });
20068 // January, February, ..., December
20069 case "LLLL":
20070 default:
20071 return localize2.month(month, { width: "wide", context: "standalone" });
20072 }
20073 },
20074 // Local week of year
20075 w: function(date, token, localize2, options) {
20076 const week = getWeek(date, options);
20077 if (token === "wo") {
20078 return localize2.ordinalNumber(week, { unit: "week" });
20079 }
20080 return addLeadingZeros(week, token.length);
20081 },
20082 // ISO week of year
20083 I: function(date, token, localize2) {
20084 const isoWeek = getISOWeek(date);
20085 if (token === "Io") {
20086 return localize2.ordinalNumber(isoWeek, { unit: "week" });
20087 }
20088 return addLeadingZeros(isoWeek, token.length);
20089 },
20090 // Day of the month
20091 d: function(date, token, localize2) {
20092 if (token === "do") {
20093 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
20094 }
20095 return lightFormatters.d(date, token);
20096 },
20097 // Day of year
20098 D: function(date, token, localize2) {
20099 const dayOfYear = getDayOfYear(date);
20100 if (token === "Do") {
20101 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
20102 }
20103 return addLeadingZeros(dayOfYear, token.length);
20104 },
20105 // Day of week
20106 E: function(date, token, localize2) {
20107 const dayOfWeek = date.getDay();
20108 switch (token) {
20109 // Tue
20110 case "E":
20111 case "EE":
20112 case "EEE":
20113 return localize2.day(dayOfWeek, {
20114 width: "abbreviated",
20115 context: "formatting"
20116 });
20117 // T
20118 case "EEEEE":
20119 return localize2.day(dayOfWeek, {
20120 width: "narrow",
20121 context: "formatting"
20122 });
20123 // Tu
20124 case "EEEEEE":
20125 return localize2.day(dayOfWeek, {
20126 width: "short",
20127 context: "formatting"
20128 });
20129 // Tuesday
20130 case "EEEE":
20131 default:
20132 return localize2.day(dayOfWeek, {
20133 width: "wide",
20134 context: "formatting"
20135 });
20136 }
20137 },
20138 // Local day of week
20139 e: function(date, token, localize2, options) {
20140 const dayOfWeek = date.getDay();
20141 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20142 switch (token) {
20143 // Numerical value (Nth day of week with current locale or weekStartsOn)
20144 case "e":
20145 return String(localDayOfWeek);
20146 // Padded numerical value
20147 case "ee":
20148 return addLeadingZeros(localDayOfWeek, 2);
20149 // 1st, 2nd, ..., 7th
20150 case "eo":
20151 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20152 case "eee":
20153 return localize2.day(dayOfWeek, {
20154 width: "abbreviated",
20155 context: "formatting"
20156 });
20157 // T
20158 case "eeeee":
20159 return localize2.day(dayOfWeek, {
20160 width: "narrow",
20161 context: "formatting"
20162 });
20163 // Tu
20164 case "eeeeee":
20165 return localize2.day(dayOfWeek, {
20166 width: "short",
20167 context: "formatting"
20168 });
20169 // Tuesday
20170 case "eeee":
20171 default:
20172 return localize2.day(dayOfWeek, {
20173 width: "wide",
20174 context: "formatting"
20175 });
20176 }
20177 },
20178 // Stand-alone local day of week
20179 c: function(date, token, localize2, options) {
20180 const dayOfWeek = date.getDay();
20181 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20182 switch (token) {
20183 // Numerical value (same as in `e`)
20184 case "c":
20185 return String(localDayOfWeek);
20186 // Padded numerical value
20187 case "cc":
20188 return addLeadingZeros(localDayOfWeek, token.length);
20189 // 1st, 2nd, ..., 7th
20190 case "co":
20191 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20192 case "ccc":
20193 return localize2.day(dayOfWeek, {
20194 width: "abbreviated",
20195 context: "standalone"
20196 });
20197 // T
20198 case "ccccc":
20199 return localize2.day(dayOfWeek, {
20200 width: "narrow",
20201 context: "standalone"
20202 });
20203 // Tu
20204 case "cccccc":
20205 return localize2.day(dayOfWeek, {
20206 width: "short",
20207 context: "standalone"
20208 });
20209 // Tuesday
20210 case "cccc":
20211 default:
20212 return localize2.day(dayOfWeek, {
20213 width: "wide",
20214 context: "standalone"
20215 });
20216 }
20217 },
20218 // ISO day of week
20219 i: function(date, token, localize2) {
20220 const dayOfWeek = date.getDay();
20221 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
20222 switch (token) {
20223 // 2
20224 case "i":
20225 return String(isoDayOfWeek);
20226 // 02
20227 case "ii":
20228 return addLeadingZeros(isoDayOfWeek, token.length);
20229 // 2nd
20230 case "io":
20231 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
20232 // Tue
20233 case "iii":
20234 return localize2.day(dayOfWeek, {
20235 width: "abbreviated",
20236 context: "formatting"
20237 });
20238 // T
20239 case "iiiii":
20240 return localize2.day(dayOfWeek, {
20241 width: "narrow",
20242 context: "formatting"
20243 });
20244 // Tu
20245 case "iiiiii":
20246 return localize2.day(dayOfWeek, {
20247 width: "short",
20248 context: "formatting"
20249 });
20250 // Tuesday
20251 case "iiii":
20252 default:
20253 return localize2.day(dayOfWeek, {
20254 width: "wide",
20255 context: "formatting"
20256 });
20257 }
20258 },
20259 // AM or PM
20260 a: function(date, token, localize2) {
20261 const hours = date.getHours();
20262 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20263 switch (token) {
20264 case "a":
20265 case "aa":
20266 return localize2.dayPeriod(dayPeriodEnumValue, {
20267 width: "abbreviated",
20268 context: "formatting"
20269 });
20270 case "aaa":
20271 return localize2.dayPeriod(dayPeriodEnumValue, {
20272 width: "abbreviated",
20273 context: "formatting"
20274 }).toLowerCase();
20275 case "aaaaa":
20276 return localize2.dayPeriod(dayPeriodEnumValue, {
20277 width: "narrow",
20278 context: "formatting"
20279 });
20280 case "aaaa":
20281 default:
20282 return localize2.dayPeriod(dayPeriodEnumValue, {
20283 width: "wide",
20284 context: "formatting"
20285 });
20286 }
20287 },
20288 // AM, PM, midnight, noon
20289 b: function(date, token, localize2) {
20290 const hours = date.getHours();
20291 let dayPeriodEnumValue;
20292 if (hours === 12) {
20293 dayPeriodEnumValue = dayPeriodEnum.noon;
20294 } else if (hours === 0) {
20295 dayPeriodEnumValue = dayPeriodEnum.midnight;
20296 } else {
20297 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20298 }
20299 switch (token) {
20300 case "b":
20301 case "bb":
20302 return localize2.dayPeriod(dayPeriodEnumValue, {
20303 width: "abbreviated",
20304 context: "formatting"
20305 });
20306 case "bbb":
20307 return localize2.dayPeriod(dayPeriodEnumValue, {
20308 width: "abbreviated",
20309 context: "formatting"
20310 }).toLowerCase();
20311 case "bbbbb":
20312 return localize2.dayPeriod(dayPeriodEnumValue, {
20313 width: "narrow",
20314 context: "formatting"
20315 });
20316 case "bbbb":
20317 default:
20318 return localize2.dayPeriod(dayPeriodEnumValue, {
20319 width: "wide",
20320 context: "formatting"
20321 });
20322 }
20323 },
20324 // in the morning, in the afternoon, in the evening, at night
20325 B: function(date, token, localize2) {
20326 const hours = date.getHours();
20327 let dayPeriodEnumValue;
20328 if (hours >= 17) {
20329 dayPeriodEnumValue = dayPeriodEnum.evening;
20330 } else if (hours >= 12) {
20331 dayPeriodEnumValue = dayPeriodEnum.afternoon;
20332 } else if (hours >= 4) {
20333 dayPeriodEnumValue = dayPeriodEnum.morning;
20334 } else {
20335 dayPeriodEnumValue = dayPeriodEnum.night;
20336 }
20337 switch (token) {
20338 case "B":
20339 case "BB":
20340 case "BBB":
20341 return localize2.dayPeriod(dayPeriodEnumValue, {
20342 width: "abbreviated",
20343 context: "formatting"
20344 });
20345 case "BBBBB":
20346 return localize2.dayPeriod(dayPeriodEnumValue, {
20347 width: "narrow",
20348 context: "formatting"
20349 });
20350 case "BBBB":
20351 default:
20352 return localize2.dayPeriod(dayPeriodEnumValue, {
20353 width: "wide",
20354 context: "formatting"
20355 });
20356 }
20357 },
20358 // Hour [1-12]
20359 h: function(date, token, localize2) {
20360 if (token === "ho") {
20361 let hours = date.getHours() % 12;
20362 if (hours === 0) hours = 12;
20363 return localize2.ordinalNumber(hours, { unit: "hour" });
20364 }
20365 return lightFormatters.h(date, token);
20366 },
20367 // Hour [0-23]
20368 H: function(date, token, localize2) {
20369 if (token === "Ho") {
20370 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
20371 }
20372 return lightFormatters.H(date, token);
20373 },
20374 // Hour [0-11]
20375 K: function(date, token, localize2) {
20376 const hours = date.getHours() % 12;
20377 if (token === "Ko") {
20378 return localize2.ordinalNumber(hours, { unit: "hour" });
20379 }
20380 return addLeadingZeros(hours, token.length);
20381 },
20382 // Hour [1-24]
20383 k: function(date, token, localize2) {
20384 let hours = date.getHours();
20385 if (hours === 0) hours = 24;
20386 if (token === "ko") {
20387 return localize2.ordinalNumber(hours, { unit: "hour" });
20388 }
20389 return addLeadingZeros(hours, token.length);
20390 },
20391 // Minute
20392 m: function(date, token, localize2) {
20393 if (token === "mo") {
20394 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
20395 }
20396 return lightFormatters.m(date, token);
20397 },
20398 // Second
20399 s: function(date, token, localize2) {
20400 if (token === "so") {
20401 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
20402 }
20403 return lightFormatters.s(date, token);
20404 },
20405 // Fraction of second
20406 S: function(date, token) {
20407 return lightFormatters.S(date, token);
20408 },
20409 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
20410 X: function(date, token, _localize) {
20411 const timezoneOffset = date.getTimezoneOffset();
20412 if (timezoneOffset === 0) {
20413 return "Z";
20414 }
20415 switch (token) {
20416 // Hours and optional minutes
20417 case "X":
20418 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20419 // Hours, minutes and optional seconds without `:` delimiter
20420 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20421 // so this token always has the same output as `XX`
20422 case "XXXX":
20423 case "XX":
20424 return formatTimezone(timezoneOffset);
20425 // Hours, minutes and optional seconds with `:` delimiter
20426 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20427 // so this token always has the same output as `XXX`
20428 case "XXXXX":
20429 case "XXX":
20430 // Hours and minutes with `:` delimiter
20431 default:
20432 return formatTimezone(timezoneOffset, ":");
20433 }
20434 },
20435 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
20436 x: function(date, token, _localize) {
20437 const timezoneOffset = date.getTimezoneOffset();
20438 switch (token) {
20439 // Hours and optional minutes
20440 case "x":
20441 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20442 // Hours, minutes and optional seconds without `:` delimiter
20443 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20444 // so this token always has the same output as `xx`
20445 case "xxxx":
20446 case "xx":
20447 return formatTimezone(timezoneOffset);
20448 // Hours, minutes and optional seconds with `:` delimiter
20449 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20450 // so this token always has the same output as `xxx`
20451 case "xxxxx":
20452 case "xxx":
20453 // Hours and minutes with `:` delimiter
20454 default:
20455 return formatTimezone(timezoneOffset, ":");
20456 }
20457 },
20458 // Timezone (GMT)
20459 O: function(date, token, _localize) {
20460 const timezoneOffset = date.getTimezoneOffset();
20461 switch (token) {
20462 // Short
20463 case "O":
20464 case "OO":
20465 case "OOO":
20466 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20467 // Long
20468 case "OOOO":
20469 default:
20470 return "GMT" + formatTimezone(timezoneOffset, ":");
20471 }
20472 },
20473 // Timezone (specific non-location)
20474 z: function(date, token, _localize) {
20475 const timezoneOffset = date.getTimezoneOffset();
20476 switch (token) {
20477 // Short
20478 case "z":
20479 case "zz":
20480 case "zzz":
20481 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20482 // Long
20483 case "zzzz":
20484 default:
20485 return "GMT" + formatTimezone(timezoneOffset, ":");
20486 }
20487 },
20488 // Seconds timestamp
20489 t: function(date, token, _localize) {
20490 const timestamp = Math.trunc(+date / 1e3);
20491 return addLeadingZeros(timestamp, token.length);
20492 },
20493 // Milliseconds timestamp
20494 T: function(date, token, _localize) {
20495 return addLeadingZeros(+date, token.length);
20496 }
20497 };
20498 function formatTimezoneShort(offset4, delimiter = "") {
20499 const sign = offset4 > 0 ? "-" : "+";
20500 const absOffset = Math.abs(offset4);
20501 const hours = Math.trunc(absOffset / 60);
20502 const minutes = absOffset % 60;
20503 if (minutes === 0) {
20504 return sign + String(hours);
20505 }
20506 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
20507 }
20508 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
20509 if (offset4 % 60 === 0) {
20510 const sign = offset4 > 0 ? "-" : "+";
20511 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
20512 }
20513 return formatTimezone(offset4, delimiter);
20514 }
20515 function formatTimezone(offset4, delimiter = "") {
20516 const sign = offset4 > 0 ? "-" : "+";
20517 const absOffset = Math.abs(offset4);
20518 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
20519 const minutes = addLeadingZeros(absOffset % 60, 2);
20520 return sign + hours + delimiter + minutes;
20521 }
20522
20523 // node_modules/date-fns/_lib/format/longFormatters.js
20524 var dateLongFormatter = (pattern, formatLong2) => {
20525 switch (pattern) {
20526 case "P":
20527 return formatLong2.date({ width: "short" });
20528 case "PP":
20529 return formatLong2.date({ width: "medium" });
20530 case "PPP":
20531 return formatLong2.date({ width: "long" });
20532 case "PPPP":
20533 default:
20534 return formatLong2.date({ width: "full" });
20535 }
20536 };
20537 var timeLongFormatter = (pattern, formatLong2) => {
20538 switch (pattern) {
20539 case "p":
20540 return formatLong2.time({ width: "short" });
20541 case "pp":
20542 return formatLong2.time({ width: "medium" });
20543 case "ppp":
20544 return formatLong2.time({ width: "long" });
20545 case "pppp":
20546 default:
20547 return formatLong2.time({ width: "full" });
20548 }
20549 };
20550 var dateTimeLongFormatter = (pattern, formatLong2) => {
20551 const matchResult = pattern.match(/(P+)(p+)?/) || [];
20552 const datePattern = matchResult[1];
20553 const timePattern = matchResult[2];
20554 if (!timePattern) {
20555 return dateLongFormatter(pattern, formatLong2);
20556 }
20557 let dateTimeFormat;
20558 switch (datePattern) {
20559 case "P":
20560 dateTimeFormat = formatLong2.dateTime({ width: "short" });
20561 break;
20562 case "PP":
20563 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
20564 break;
20565 case "PPP":
20566 dateTimeFormat = formatLong2.dateTime({ width: "long" });
20567 break;
20568 case "PPPP":
20569 default:
20570 dateTimeFormat = formatLong2.dateTime({ width: "full" });
20571 break;
20572 }
20573 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
20574 };
20575 var longFormatters = {
20576 p: timeLongFormatter,
20577 P: dateTimeLongFormatter
20578 };
20579
20580 // node_modules/date-fns/_lib/protectedTokens.js
20581 var dayOfYearTokenRE = /^D+$/;
20582 var weekYearTokenRE = /^Y+$/;
20583 var throwTokens = ["D", "DD", "YY", "YYYY"];
20584 function isProtectedDayOfYearToken(token) {
20585 return dayOfYearTokenRE.test(token);
20586 }
20587 function isProtectedWeekYearToken(token) {
20588 return weekYearTokenRE.test(token);
20589 }
20590 function warnOrThrowProtectedError(token, format6, input) {
20591 const _message = message(token, format6, input);
20592 console.warn(_message);
20593 if (throwTokens.includes(token)) throw new RangeError(_message);
20594 }
20595 function message(token, format6, input) {
20596 const subject = token[0] === "Y" ? "years" : "days of the month";
20597 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`;
20598 }
20599
20600 // node_modules/date-fns/format.js
20601 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
20602 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
20603 var escapedStringRegExp = /^'([^]*?)'?$/;
20604 var doubleQuoteRegExp = /''/g;
20605 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
20606 function format(date, formatStr, options) {
20607 const defaultOptions2 = getDefaultOptions();
20608 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
20609 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20610 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
20611 const originalDate = toDate(date, options?.in);
20612 if (!isValid(originalDate)) {
20613 throw new RangeError("Invalid time value");
20614 }
20615 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
20616 const firstCharacter = substring[0];
20617 if (firstCharacter === "p" || firstCharacter === "P") {
20618 const longFormatter = longFormatters[firstCharacter];
20619 return longFormatter(substring, locale.formatLong);
20620 }
20621 return substring;
20622 }).join("").match(formattingTokensRegExp).map((substring) => {
20623 if (substring === "''") {
20624 return { isToken: false, value: "'" };
20625 }
20626 const firstCharacter = substring[0];
20627 if (firstCharacter === "'") {
20628 return { isToken: false, value: cleanEscapedString(substring) };
20629 }
20630 if (formatters[firstCharacter]) {
20631 return { isToken: true, value: substring };
20632 }
20633 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
20634 throw new RangeError(
20635 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
20636 );
20637 }
20638 return { isToken: false, value: substring };
20639 });
20640 if (locale.localize.preprocessor) {
20641 parts = locale.localize.preprocessor(originalDate, parts);
20642 }
20643 const formatterOptions = {
20644 firstWeekContainsDate,
20645 weekStartsOn,
20646 locale
20647 };
20648 return parts.map((part) => {
20649 if (!part.isToken) return part.value;
20650 const token = part.value;
20651 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
20652 warnOrThrowProtectedError(token, formatStr, String(date));
20653 }
20654 const formatter = formatters[token[0]];
20655 return formatter(originalDate, token, locale.localize, formatterOptions);
20656 }).join("");
20657 }
20658 function cleanEscapedString(input) {
20659 const matched = input.match(escapedStringRegExp);
20660 if (!matched) {
20661 return input;
20662 }
20663 return matched[1].replace(doubleQuoteRegExp, "'");
20664 }
20665
20666 // node_modules/date-fns/subDays.js
20667 function subDays(date, amount, options) {
20668 return addDays(date, -amount, options);
20669 }
20670
20671 // node_modules/date-fns/subMonths.js
20672 function subMonths(date, amount, options) {
20673 return addMonths(date, -amount, options);
20674 }
20675
20676 // node_modules/date-fns/subWeeks.js
20677 function subWeeks(date, amount, options) {
20678 return addWeeks(date, -amount, options);
20679 }
20680
20681 // node_modules/date-fns/subYears.js
20682 function subYears(date, amount, options) {
20683 return addYears(date, -amount, options);
20684 }
20685
20686 // packages/dataviews/build-module/utils/operators.mjs
20687 var import_i18n29 = __toESM(require_i18n(), 1);
20688 var import_element41 = __toESM(require_element(), 1);
20689 var import_date = __toESM(require_date(), 1);
20690 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
20691 var filterTextWrappers = {
20692 Name: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
20693 Value: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
20694 };
20695 function getRelativeDate(value, unit) {
20696 switch (unit) {
20697 case "days":
20698 return subDays(/* @__PURE__ */ new Date(), value);
20699 case "weeks":
20700 return subWeeks(/* @__PURE__ */ new Date(), value);
20701 case "months":
20702 return subMonths(/* @__PURE__ */ new Date(), value);
20703 case "years":
20704 return subYears(/* @__PURE__ */ new Date(), value);
20705 default:
20706 return /* @__PURE__ */ new Date();
20707 }
20708 }
20709 var isNoneOperatorDefinition = {
20710 /* translators: DataViews operator name */
20711 label: (0, import_i18n29.__)("Is none of"),
20712 filterText: (filter, activeElements) => (0, import_element41.createInterpolateElement)(
20713 (0, import_i18n29.sprintf)(
20714 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
20715 (0, import_i18n29.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
20716 filter.name,
20717 activeElements.map((element) => element.label).join(", ")
20718 ),
20719 filterTextWrappers
20720 ),
20721 filter: ((item, field, filterValue) => {
20722 if (!filterValue?.length) {
20723 return true;
20724 }
20725 const fieldValue = field.getValue({ item });
20726 if (Array.isArray(fieldValue)) {
20727 return !filterValue.some(
20728 (fv) => fieldValue.includes(fv)
20729 );
20730 } else if (typeof fieldValue === "string") {
20731 return !filterValue.includes(fieldValue);
20732 }
20733 return false;
20734 }),
20735 selection: "multi"
20736 };
20737 var OPERATORS = [
20738 {
20739 name: OPERATOR_IS_ANY,
20740 /* translators: DataViews operator name */
20741 label: (0, import_i18n29.__)("Includes"),
20742 filterText: (filter, activeElements) => (0, import_element41.createInterpolateElement)(
20743 (0, import_i18n29.sprintf)(
20744 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
20745 (0, import_i18n29.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
20746 filter.name,
20747 activeElements.map((element) => element.label).join(", ")
20748 ),
20749 filterTextWrappers
20750 ),
20751 filter(item, field, filterValue) {
20752 if (!filterValue?.length) {
20753 return true;
20754 }
20755 const fieldValue = field.getValue({ item });
20756 if (Array.isArray(fieldValue)) {
20757 return filterValue.some(
20758 (fv) => fieldValue.includes(fv)
20759 );
20760 } else if (typeof fieldValue === "string") {
20761 return filterValue.includes(fieldValue);
20762 }
20763 return false;
20764 },
20765 selection: "multi"
20766 },
20767 {
20768 name: OPERATOR_IS_NONE,
20769 ...isNoneOperatorDefinition
20770 },
20771 {
20772 name: OPERATOR_IS_ALL,
20773 /* translators: DataViews operator name */
20774 label: (0, import_i18n29.__)("Includes all"),
20775 filterText: (filter, activeElements) => (0, import_element41.createInterpolateElement)(
20776 (0, import_i18n29.sprintf)(
20777 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
20778 (0, import_i18n29.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
20779 filter.name,
20780 activeElements.map((element) => element.label).join(", ")
20781 ),
20782 filterTextWrappers
20783 ),
20784 filter(item, field, filterValue) {
20785 if (!filterValue?.length) {
20786 return true;
20787 }
20788 return filterValue.every((value) => {
20789 return field.getValue({ item })?.includes(value);
20790 });
20791 },
20792 selection: "multi"
20793 },
20794 {
20795 name: OPERATOR_IS_NOT_ALL,
20796 ...isNoneOperatorDefinition
20797 },
20798 {
20799 name: OPERATOR_BETWEEN,
20800 /* translators: DataViews operator name */
20801 label: (0, import_i18n29.__)("Between (inc)"),
20802 filterText: (filter, activeElements) => (0, import_element41.createInterpolateElement)(
20803 (0, import_i18n29.sprintf)(
20804 /* 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". */
20805 (0, import_i18n29.__)(
20806 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
20807 ),
20808 filter.name,
20809 activeElements[0].label[0],
20810 activeElements[0].label[1]
20811 ),
20812 filterTextWrappers
20813 ),
20814 filter(item, field, filterValue) {
20815 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
20816 return true;
20817 }
20818 const fieldValue = field.getValue({ item });
20819 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
20820 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
20821 }
20822 return false;
20823 },
20824 selection: "custom"
20825 },
20826 {
20827 name: OPERATOR_IN_THE_PAST,
20828 /* translators: DataViews operator name */
20829 label: (0, import_i18n29.__)("In the past"),
20830 filterText: (filter, activeElements) => (0, import_element41.createInterpolateElement)(
20831 (0, import_i18n29.sprintf)(
20832 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
20833 (0, import_i18n29.__)(
20834 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
20835 ),
20836 filter.name,
20837 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
20838 ),
20839 filterTextWrappers
20840 ),
20841 filter(item, field, filterValue) {
20842 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
20843 return true;
20844 }
20845 const targetDate = getRelativeDate(
20846 filterValue.value,
20847 filterValue.unit
20848 );
20849 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
20850 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
20851 },
20852 selection: "custom"
20853 },
20854 {
20855 name: OPERATOR_OVER,
20856 /* translators: DataViews operator name */
20857 label: (0, import_i18n29.__)("Over"),
20858 filterText: (filter, activeElements) => (0, import_element41.createInterpolateElement)(
20859 (0, import_i18n29.sprintf)(
20860 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
20861 (0, import_i18n29.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
20862 filter.name,
20863 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
20864 ),
20865 filterTextWrappers
20866 ),
20867 filter(item, field, filterValue) {
20868 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
20869 return true;
20870 }
20871 const targetDate = getRelativeDate(
20872 filterValue.value,
20873 filterValue.unit
20874 );
20875 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
20876 return fieldValue < targetDate;
20877 },
20878 selection: "custom"
20879 },
20880 {
20881 name: OPERATOR_IS,
20882 /* translators: DataViews operator name */
20883 label: (0, import_i18n29.__)("Is"),
20884 filterText: (filter, activeElements) => (0, import_element41.createInterpolateElement)(
20885 (0, import_i18n29.sprintf)(
20886 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
20887 (0, import_i18n29.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
20888 filter.name,
20889 activeElements[0].label
20890 ),
20891 filterTextWrappers
20892 ),
20893 filter(item, field, filterValue) {
20894 return filterValue === field.getValue({ item }) || filterValue === void 0;
20895 },
20896 selection: "single"
20897 },
20898 {
20899 name: OPERATOR_IS_NOT,
20900 /* translators: DataViews operator name */
20901 label: (0, import_i18n29.__)("Is not"),
20902 filterText: (filter, activeElements) => (0, import_element41.createInterpolateElement)(
20903 (0, import_i18n29.sprintf)(
20904 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
20905 (0, import_i18n29.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
20906 filter.name,
20907 activeElements[0].label
20908 ),
20909 filterTextWrappers
20910 ),
20911 filter(item, field, filterValue) {
20912 return filterValue !== field.getValue({ item });
20913 },
20914 selection: "single"
20915 },
20916 {
20917 name: OPERATOR_LESS_THAN,
20918 /* translators: DataViews operator name */
20919 label: (0, import_i18n29.__)("Less than"),
20920 filterText: (filter, activeElements) => (0, import_element41.createInterpolateElement)(
20921 (0, import_i18n29.sprintf)(
20922 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
20923 (0, import_i18n29.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
20924 filter.name,
20925 activeElements[0].label
20926 ),
20927 filterTextWrappers
20928 ),
20929 filter(item, field, filterValue) {
20930 if (filterValue === void 0) {
20931 return true;
20932 }
20933 const fieldValue = field.getValue({ item });
20934 return fieldValue < filterValue;
20935 },
20936 selection: "single"
20937 },
20938 {
20939 name: OPERATOR_GREATER_THAN,
20940 /* translators: DataViews operator name */
20941 label: (0, import_i18n29.__)("Greater than"),
20942 filterText: (filter, activeElements) => (0, import_element41.createInterpolateElement)(
20943 (0, import_i18n29.sprintf)(
20944 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
20945 (0, import_i18n29.__)(
20946 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
20947 ),
20948 filter.name,
20949 activeElements[0].label
20950 ),
20951 filterTextWrappers
20952 ),
20953 filter(item, field, filterValue) {
20954 if (filterValue === void 0) {
20955 return true;
20956 }
20957 const fieldValue = field.getValue({ item });
20958 return fieldValue > filterValue;
20959 },
20960 selection: "single"
20961 },
20962 {
20963 name: OPERATOR_LESS_THAN_OR_EQUAL,
20964 /* translators: DataViews operator name */
20965 label: (0, import_i18n29.__)("Less than or equal"),
20966 filterText: (filter, activeElements) => (0, import_element41.createInterpolateElement)(
20967 (0, import_i18n29.sprintf)(
20968 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
20969 (0, import_i18n29.__)(
20970 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
20971 ),
20972 filter.name,
20973 activeElements[0].label
20974 ),
20975 filterTextWrappers
20976 ),
20977 filter(item, field, filterValue) {
20978 if (filterValue === void 0) {
20979 return true;
20980 }
20981 const fieldValue = field.getValue({ item });
20982 return fieldValue <= filterValue;
20983 },
20984 selection: "single"
20985 },
20986 {
20987 name: OPERATOR_GREATER_THAN_OR_EQUAL,
20988 /* translators: DataViews operator name */
20989 label: (0, import_i18n29.__)("Greater than or equal"),
20990 filterText: (filter, activeElements) => (0, import_element41.createInterpolateElement)(
20991 (0, import_i18n29.sprintf)(
20992 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
20993 (0, import_i18n29.__)(
20994 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
20995 ),
20996 filter.name,
20997 activeElements[0].label
20998 ),
20999 filterTextWrappers
21000 ),
21001 filter(item, field, filterValue) {
21002 if (filterValue === void 0) {
21003 return true;
21004 }
21005 const fieldValue = field.getValue({ item });
21006 return fieldValue >= filterValue;
21007 },
21008 selection: "single"
21009 },
21010 {
21011 name: OPERATOR_BEFORE,
21012 /* translators: DataViews operator name */
21013 label: (0, import_i18n29.__)("Before"),
21014 filterText: (filter, activeElements) => (0, import_element41.createInterpolateElement)(
21015 (0, import_i18n29.sprintf)(
21016 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
21017 (0, import_i18n29.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
21018 filter.name,
21019 activeElements[0].label
21020 ),
21021 filterTextWrappers
21022 ),
21023 filter(item, field, filterValue) {
21024 if (filterValue === void 0) {
21025 return true;
21026 }
21027 const filterDate = (0, import_date.getDate)(filterValue);
21028 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21029 return fieldDate < filterDate;
21030 },
21031 selection: "single"
21032 },
21033 {
21034 name: OPERATOR_AFTER,
21035 /* translators: DataViews operator name */
21036 label: (0, import_i18n29.__)("After"),
21037 filterText: (filter, activeElements) => (0, import_element41.createInterpolateElement)(
21038 (0, import_i18n29.sprintf)(
21039 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
21040 (0, import_i18n29.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
21041 filter.name,
21042 activeElements[0].label
21043 ),
21044 filterTextWrappers
21045 ),
21046 filter(item, field, filterValue) {
21047 if (filterValue === void 0) {
21048 return true;
21049 }
21050 const filterDate = (0, import_date.getDate)(filterValue);
21051 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21052 return fieldDate > filterDate;
21053 },
21054 selection: "single"
21055 },
21056 {
21057 name: OPERATOR_BEFORE_INC,
21058 /* translators: DataViews operator name */
21059 label: (0, import_i18n29.__)("Before (inc)"),
21060 filterText: (filter, activeElements) => (0, import_element41.createInterpolateElement)(
21061 (0, import_i18n29.sprintf)(
21062 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
21063 (0, import_i18n29.__)(
21064 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
21065 ),
21066 filter.name,
21067 activeElements[0].label
21068 ),
21069 filterTextWrappers
21070 ),
21071 filter(item, field, filterValue) {
21072 if (filterValue === void 0) {
21073 return true;
21074 }
21075 const filterDate = (0, import_date.getDate)(filterValue);
21076 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21077 return fieldDate <= filterDate;
21078 },
21079 selection: "single"
21080 },
21081 {
21082 name: OPERATOR_AFTER_INC,
21083 /* translators: DataViews operator name */
21084 label: (0, import_i18n29.__)("After (inc)"),
21085 filterText: (filter, activeElements) => (0, import_element41.createInterpolateElement)(
21086 (0, import_i18n29.sprintf)(
21087 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
21088 (0, import_i18n29.__)(
21089 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
21090 ),
21091 filter.name,
21092 activeElements[0].label
21093 ),
21094 filterTextWrappers
21095 ),
21096 filter(item, field, filterValue) {
21097 if (filterValue === void 0) {
21098 return true;
21099 }
21100 const filterDate = (0, import_date.getDate)(filterValue);
21101 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21102 return fieldDate >= filterDate;
21103 },
21104 selection: "single"
21105 },
21106 {
21107 name: OPERATOR_CONTAINS,
21108 /* translators: DataViews operator name */
21109 label: (0, import_i18n29.__)("Contains"),
21110 filterText: (filter, activeElements) => (0, import_element41.createInterpolateElement)(
21111 (0, import_i18n29.sprintf)(
21112 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
21113 (0, import_i18n29.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
21114 filter.name,
21115 activeElements[0].label
21116 ),
21117 filterTextWrappers
21118 ),
21119 filter(item, field, filterValue) {
21120 if (filterValue === void 0) {
21121 return true;
21122 }
21123 const fieldValue = field.getValue({ item });
21124 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21125 },
21126 selection: "single"
21127 },
21128 {
21129 name: OPERATOR_NOT_CONTAINS,
21130 /* translators: DataViews operator name */
21131 label: (0, import_i18n29.__)("Doesn't contain"),
21132 filterText: (filter, activeElements) => (0, import_element41.createInterpolateElement)(
21133 (0, import_i18n29.sprintf)(
21134 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
21135 (0, import_i18n29.__)(
21136 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
21137 ),
21138 filter.name,
21139 activeElements[0].label
21140 ),
21141 filterTextWrappers
21142 ),
21143 filter(item, field, filterValue) {
21144 if (filterValue === void 0) {
21145 return true;
21146 }
21147 const fieldValue = field.getValue({ item });
21148 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21149 },
21150 selection: "single"
21151 },
21152 {
21153 name: OPERATOR_STARTS_WITH,
21154 /* translators: DataViews operator name */
21155 label: (0, import_i18n29.__)("Starts with"),
21156 filterText: (filter, activeElements) => (0, import_element41.createInterpolateElement)(
21157 (0, import_i18n29.sprintf)(
21158 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
21159 (0, import_i18n29.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
21160 filter.name,
21161 activeElements[0].label
21162 ),
21163 filterTextWrappers
21164 ),
21165 filter(item, field, filterValue) {
21166 if (filterValue === void 0) {
21167 return true;
21168 }
21169 const fieldValue = field.getValue({ item });
21170 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
21171 },
21172 selection: "single"
21173 },
21174 {
21175 name: OPERATOR_ON,
21176 /* translators: DataViews operator name */
21177 label: (0, import_i18n29.__)("On"),
21178 filterText: (filter, activeElements) => (0, import_element41.createInterpolateElement)(
21179 (0, import_i18n29.sprintf)(
21180 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
21181 (0, import_i18n29.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21182 filter.name,
21183 activeElements[0].label
21184 ),
21185 filterTextWrappers
21186 ),
21187 filter(item, field, filterValue) {
21188 if (filterValue === void 0) {
21189 return true;
21190 }
21191 const filterDate = (0, import_date.getDate)(filterValue);
21192 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21193 return filterDate.getTime() === fieldDate.getTime();
21194 },
21195 selection: "single"
21196 },
21197 {
21198 name: OPERATOR_NOT_ON,
21199 /* translators: DataViews operator name */
21200 label: (0, import_i18n29.__)("Not on"),
21201 filterText: (filter, activeElements) => (0, import_element41.createInterpolateElement)(
21202 (0, import_i18n29.sprintf)(
21203 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
21204 (0, import_i18n29.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21205 filter.name,
21206 activeElements[0].label
21207 ),
21208 filterTextWrappers
21209 ),
21210 filter(item, field, filterValue) {
21211 if (filterValue === void 0) {
21212 return true;
21213 }
21214 const filterDate = (0, import_date.getDate)(filterValue);
21215 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21216 return filterDate.getTime() !== fieldDate.getTime();
21217 },
21218 selection: "single"
21219 }
21220 ];
21221 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
21222 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
21223 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
21224 (op) => op.name === name
21225 );
21226 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
21227
21228 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
21229 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
21230 var ENTER = "Enter";
21231 var SPACE = " ";
21232 var FilterText = ({
21233 activeElements,
21234 filterInView,
21235 filter
21236 }) => {
21237 if (activeElements === void 0 || activeElements.length === 0) {
21238 return filter.name;
21239 }
21240 const operator = getOperatorByName(filterInView?.operator);
21241 if (operator !== void 0) {
21242 return operator.filterText(filter, activeElements);
21243 }
21244 return (0, import_i18n30.sprintf)(
21245 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
21246 (0, import_i18n30.__)("Unknown status for %1$s"),
21247 filter.name
21248 );
21249 };
21250 function OperatorSelector({
21251 filter,
21252 view,
21253 onChangeView
21254 }) {
21255 const operatorOptions = filter.operators?.map((operator) => ({
21256 value: operator,
21257 label: getOperatorByName(operator)?.label || operator
21258 }));
21259 const currentFilter = view.filters?.find(
21260 (_filter) => _filter.field === filter.field
21261 );
21262 const value = currentFilter?.operator || filter.operators[0];
21263 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
21264 Stack,
21265 {
21266 direction: "row",
21267 gap: "sm",
21268 justify: "flex-start",
21269 className: "dataviews-filters__summary-operators-container",
21270 align: "center",
21271 children: [
21272 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components20.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
21273 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21274 import_components20.SelectControl,
21275 {
21276 className: "dataviews-filters__summary-operators-filter-select",
21277 label: (0, import_i18n30.__)("Conditions"),
21278 value,
21279 options: operatorOptions,
21280 onChange: (newValue) => {
21281 const newOperator = newValue;
21282 const currentOperator = currentFilter?.operator;
21283 const newFilters = currentFilter ? [
21284 ...(view.filters ?? []).map(
21285 (_filter) => {
21286 if (_filter.field === filter.field) {
21287 const currentOpSelectionModel = getOperatorByName(
21288 currentOperator
21289 )?.selection;
21290 const newOpSelectionModel = getOperatorByName(
21291 newOperator
21292 )?.selection;
21293 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
21294 currentOpSelectionModel,
21295 newOpSelectionModel
21296 ].includes("custom");
21297 return {
21298 ..._filter,
21299 value: shouldResetValue ? void 0 : _filter.value,
21300 operator: newOperator
21301 };
21302 }
21303 return _filter;
21304 }
21305 )
21306 ] : [
21307 ...view.filters ?? [],
21308 {
21309 field: filter.field,
21310 operator: newOperator,
21311 value: void 0
21312 }
21313 ];
21314 onChangeView({
21315 ...view,
21316 page: 1,
21317 filters: newFilters
21318 });
21319 },
21320 size: "small",
21321 variant: "minimal",
21322 hideLabelFromVision: true
21323 }
21324 )
21325 ]
21326 }
21327 );
21328 }
21329 function Filter({
21330 addFilterRef,
21331 openedFilter,
21332 fields,
21333 ...commonProps
21334 }) {
21335 const toggleRef = (0, import_element42.useRef)(null);
21336 const { filter, view, onChangeView } = commonProps;
21337 const filterInView = view.filters?.find(
21338 (f2) => f2.field === filter.field
21339 );
21340 let activeElements = [];
21341 const field = (0, import_element42.useMemo)(() => {
21342 const currentField = fields.find((f2) => f2.id === filter.field);
21343 if (currentField) {
21344 return {
21345 ...currentField,
21346 // Configure getValue as if Item was a plain object.
21347 // See related input-widget.tsx
21348 getValue: ({ item }) => item[currentField.id]
21349 };
21350 }
21351 return currentField;
21352 }, [fields, filter.field]);
21353 const { elements } = useElements({
21354 elements: filter.elements,
21355 getElements: filter.getElements
21356 });
21357 if (elements.length > 0) {
21358 activeElements = elements.filter((element) => {
21359 if (filter.singleSelection) {
21360 return element.value === filterInView?.value;
21361 }
21362 return filterInView?.value?.includes(element.value);
21363 });
21364 } else if (Array.isArray(filterInView?.value)) {
21365 const label = filterInView.value.map((v2) => {
21366 const formattedValue = field?.getValueFormatted({
21367 item: { [field.id]: v2 },
21368 field
21369 });
21370 return formattedValue || String(v2);
21371 });
21372 activeElements = [
21373 {
21374 value: filterInView.value,
21375 // @ts-ignore
21376 label
21377 }
21378 ];
21379 } else if (typeof filterInView?.value === "object") {
21380 activeElements = [
21381 { value: filterInView.value, label: filterInView.value }
21382 ];
21383 } else if (filterInView?.value !== void 0) {
21384 const label = field !== void 0 ? field.getValueFormatted({
21385 item: { [field.id]: filterInView.value },
21386 field
21387 }) : String(filterInView.value);
21388 activeElements = [
21389 {
21390 value: filterInView.value,
21391 label
21392 }
21393 ];
21394 }
21395 const isPrimary = filter.isPrimary;
21396 const isLocked = filterInView?.isLocked;
21397 const hasValues = !isLocked && filterInView?.value !== void 0;
21398 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
21399 const resetOrRemoveLabel = isPrimary ? (0, import_i18n30.__)("Reset") : (0, import_i18n30.__)("Remove");
21400 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21401 import_components20.Dropdown,
21402 {
21403 defaultOpen: openedFilter === filter.field,
21404 contentClassName: "dataviews-filters__summary-popover",
21405 popoverProps: { placement: "bottom-start", role: "dialog" },
21406 onClose: () => {
21407 toggleRef.current?.focus();
21408 },
21409 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
21410 /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(tooltip_exports.Root, { children: [
21411 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21412 tooltip_exports.Trigger,
21413 {
21414 render: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21415 "div",
21416 {
21417 className: clsx_default(
21418 "dataviews-filters__summary-chip",
21419 {
21420 "has-reset": canResetOrRemove,
21421 "has-values": hasValues,
21422 "is-not-clickable": isLocked
21423 }
21424 ),
21425 role: "button",
21426 tabIndex: isLocked ? -1 : 0,
21427 onClick: () => {
21428 if (!isLocked) {
21429 onToggle();
21430 }
21431 },
21432 onKeyDown: (event) => {
21433 if (!isLocked && [ENTER, SPACE].includes(
21434 event.key
21435 )) {
21436 onToggle();
21437 event.preventDefault();
21438 }
21439 },
21440 "aria-disabled": isLocked,
21441 "aria-pressed": isOpen,
21442 "aria-expanded": isOpen,
21443 ref: toggleRef,
21444 children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21445 FilterText,
21446 {
21447 activeElements,
21448 filterInView,
21449 filter
21450 }
21451 )
21452 }
21453 )
21454 }
21455 ),
21456 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(tooltip_exports.Popup, { children: (0, import_i18n30.sprintf)(
21457 /* translators: 1: Filter name. */
21458 (0, import_i18n30.__)("Filter by: %1$s"),
21459 filter.name.toLowerCase()
21460 ) })
21461 ] }),
21462 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(tooltip_exports.Root, { children: [
21463 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21464 tooltip_exports.Trigger,
21465 {
21466 render: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21467 "button",
21468 {
21469 className: clsx_default(
21470 "dataviews-filters__summary-chip-remove",
21471 { "has-values": hasValues }
21472 ),
21473 "aria-label": resetOrRemoveLabel,
21474 onClick: () => {
21475 onChangeView({
21476 ...view,
21477 page: 1,
21478 filters: view.filters?.filter(
21479 (_filter) => _filter.field !== filter.field
21480 )
21481 });
21482 if (!isPrimary) {
21483 addFilterRef.current?.focus();
21484 } else {
21485 toggleRef.current?.focus();
21486 }
21487 },
21488 children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components20.Icon, { icon: close_small_default })
21489 }
21490 )
21491 }
21492 ),
21493 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
21494 ] })
21495 ] }),
21496 renderContent: () => {
21497 return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
21498 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(OperatorSelector, { ...commonProps }),
21499 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21500 SearchWidget,
21501 {
21502 ...commonProps,
21503 filter: {
21504 ...commonProps.filter,
21505 elements
21506 }
21507 }
21508 ) : /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(InputWidget, { ...commonProps, fields })
21509 ] });
21510 }
21511 }
21512 );
21513 }
21514
21515 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
21516 var import_components21 = __toESM(require_components(), 1);
21517 var import_i18n31 = __toESM(require_i18n(), 1);
21518 var import_element43 = __toESM(require_element(), 1);
21519 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
21520 var { Menu: Menu4 } = unlock2(import_components21.privateApis);
21521 function AddFilterMenu({
21522 filters,
21523 view,
21524 onChangeView,
21525 setOpenedFilter,
21526 triggerProps
21527 }) {
21528 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21529 return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(Menu4, { children: [
21530 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Menu4.TriggerButton, { ...triggerProps }),
21531 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
21532 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21533 Menu4.Item,
21534 {
21535 onClick: () => {
21536 setOpenedFilter(filter.field);
21537 onChangeView({
21538 ...view,
21539 page: 1,
21540 filters: [
21541 ...view.filters || [],
21542 {
21543 field: filter.field,
21544 value: void 0,
21545 operator: filter.operators[0]
21546 }
21547 ]
21548 });
21549 },
21550 children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Menu4.ItemLabel, { children: filter.name })
21551 },
21552 filter.field
21553 );
21554 }) })
21555 ] });
21556 }
21557 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
21558 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
21559 return null;
21560 }
21561 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21562 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21563 AddFilterMenu,
21564 {
21565 triggerProps: {
21566 render: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21567 import_components21.Button,
21568 {
21569 accessibleWhenDisabled: true,
21570 size: "compact",
21571 className: "dataviews-filters-button",
21572 variant: "tertiary",
21573 disabled: !inactiveFilters.length,
21574 ref
21575 }
21576 ),
21577 children: (0, import_i18n31.__)("Add filter")
21578 },
21579 ...{ filters, view, onChangeView, setOpenedFilter }
21580 }
21581 );
21582 }
21583 var add_filter_default = (0, import_element43.forwardRef)(AddFilter);
21584
21585 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
21586 var import_components22 = __toESM(require_components(), 1);
21587 var import_i18n32 = __toESM(require_i18n(), 1);
21588 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
21589 function ResetFilter({
21590 filters,
21591 view,
21592 onChangeView
21593 }) {
21594 const isPrimary = (field) => filters.some(
21595 (_filter) => _filter.field === field && _filter.isPrimary
21596 );
21597 const isDisabled = !view.search && !view.filters?.some(
21598 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
21599 );
21600 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21601 import_components22.Button,
21602 {
21603 disabled: isDisabled,
21604 accessibleWhenDisabled: true,
21605 size: "compact",
21606 variant: "tertiary",
21607 className: "dataviews-filters__reset-button",
21608 onClick: () => {
21609 onChangeView({
21610 ...view,
21611 page: 1,
21612 search: "",
21613 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
21614 });
21615 },
21616 children: (0, import_i18n32.__)("Reset")
21617 }
21618 );
21619 }
21620
21621 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
21622 var import_element44 = __toESM(require_element(), 1);
21623 function useFilters(fields, view) {
21624 return (0, import_element44.useMemo)(() => {
21625 const filters = [];
21626 fields.forEach((field) => {
21627 if (field.filterBy === false || !field.hasElements && !field.Edit) {
21628 return;
21629 }
21630 const operators = field.filterBy.operators;
21631 const isPrimary = !!field.filterBy?.isPrimary;
21632 const isLocked = view.filters?.some(
21633 (f2) => f2.field === field.id && !!f2.isLocked
21634 ) ?? false;
21635 filters.push({
21636 field: field.id,
21637 name: field.label,
21638 elements: field.elements,
21639 getElements: field.getElements,
21640 hasElements: field.hasElements,
21641 singleSelection: operators.some(
21642 (op) => isSingleSelectionOperator(op)
21643 ),
21644 operators,
21645 isVisible: isLocked || isPrimary || !!view.filters?.some(
21646 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
21647 ),
21648 isPrimary,
21649 isLocked
21650 });
21651 });
21652 filters.sort((a2, b2) => {
21653 if (a2.isLocked && !b2.isLocked) {
21654 return -1;
21655 }
21656 if (!a2.isLocked && b2.isLocked) {
21657 return 1;
21658 }
21659 if (a2.isPrimary && !b2.isPrimary) {
21660 return -1;
21661 }
21662 if (!a2.isPrimary && b2.isPrimary) {
21663 return 1;
21664 }
21665 return a2.name.localeCompare(b2.name);
21666 });
21667 return filters;
21668 }, [fields, view]);
21669 }
21670 var use_filters_default = useFilters;
21671
21672 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
21673 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
21674 function Filters({ className }) {
21675 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element45.useContext)(dataviews_context_default);
21676 const addFilterRef = (0, import_element45.useRef)(null);
21677 const filters = use_filters_default(fields, view);
21678 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21679 add_filter_default,
21680 {
21681 filters,
21682 view,
21683 onChangeView,
21684 ref: addFilterRef,
21685 setOpenedFilter
21686 },
21687 "add-filter"
21688 );
21689 const visibleFilters = filters.filter((filter) => filter.isVisible);
21690 if (visibleFilters.length === 0) {
21691 return null;
21692 }
21693 const filterComponents = [
21694 ...visibleFilters.map((filter) => {
21695 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21696 Filter,
21697 {
21698 filter,
21699 view,
21700 fields,
21701 onChangeView,
21702 addFilterRef,
21703 openedFilter
21704 },
21705 filter.field
21706 );
21707 }),
21708 addFilter
21709 ];
21710 filterComponents.push(
21711 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21712 ResetFilter,
21713 {
21714 filters,
21715 view,
21716 onChangeView
21717 },
21718 "reset-filters"
21719 )
21720 );
21721 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21722 Stack,
21723 {
21724 direction: "row",
21725 justify: "flex-start",
21726 gap: "sm",
21727 style: { width: "fit-content" },
21728 wrap: "wrap",
21729 className,
21730 children: filterComponents
21731 }
21732 );
21733 }
21734 var filters_default = (0, import_element45.memo)(Filters);
21735
21736 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
21737 var import_element46 = __toESM(require_element(), 1);
21738 var import_components23 = __toESM(require_components(), 1);
21739 var import_i18n33 = __toESM(require_i18n(), 1);
21740 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
21741 function FiltersToggle() {
21742 const {
21743 filters,
21744 view,
21745 onChangeView,
21746 setOpenedFilter,
21747 isShowingFilter,
21748 setIsShowingFilter
21749 } = (0, import_element46.useContext)(dataviews_context_default);
21750 const buttonRef = (0, import_element46.useRef)(null);
21751 const onChangeViewWithFilterVisibility = (0, import_element46.useCallback)(
21752 (_view) => {
21753 onChangeView(_view);
21754 setIsShowingFilter(true);
21755 },
21756 [onChangeView, setIsShowingFilter]
21757 );
21758 if (filters.length === 0) {
21759 return null;
21760 }
21761 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
21762 const addFilterButtonProps = {
21763 label: (0, import_i18n33.__)("Add filter"),
21764 "aria-expanded": false,
21765 isPressed: false
21766 };
21767 const toggleFiltersButtonProps = {
21768 label: (0, import_i18n33._x)("Filter", "verb"),
21769 "aria-expanded": isShowingFilter,
21770 isPressed: isShowingFilter,
21771 onClick: () => {
21772 if (!isShowingFilter) {
21773 setOpenedFilter(null);
21774 }
21775 setIsShowingFilter(!isShowingFilter);
21776 }
21777 };
21778 const hasPrimaryOrLockedFilters = filters.some(
21779 (filter) => filter.isPrimary || filter.isLocked
21780 );
21781 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
21782 import_components23.Button,
21783 {
21784 ref: buttonRef,
21785 className: "dataviews-filters__visibility-toggle",
21786 size: "compact",
21787 icon: funnel_default,
21788 disabled: hasPrimaryOrLockedFilters,
21789 accessibleWhenDisabled: true,
21790 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
21791 }
21792 );
21793 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
21794 AddFilterMenu,
21795 {
21796 filters,
21797 view,
21798 onChangeView: onChangeViewWithFilterVisibility,
21799 setOpenedFilter,
21800 triggerProps: { render: buttonComponent }
21801 }
21802 ) : /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
21803 FilterVisibilityToggle,
21804 {
21805 buttonRef,
21806 filtersCount: view.filters?.length,
21807 children: buttonComponent
21808 }
21809 ) });
21810 }
21811 function FilterVisibilityToggle({
21812 buttonRef,
21813 filtersCount,
21814 children
21815 }) {
21816 (0, import_element46.useEffect)(
21817 () => () => {
21818 buttonRef.current?.focus();
21819 },
21820 [buttonRef]
21821 );
21822 return /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(import_jsx_runtime85.Fragment, { children: [
21823 children,
21824 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
21825 ] });
21826 }
21827 var toggle_default = FiltersToggle;
21828
21829 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
21830 var import_element47 = __toESM(require_element(), 1);
21831 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
21832 function FiltersToggled(props) {
21833 const { isShowingFilter } = (0, import_element47.useContext)(dataviews_context_default);
21834 if (!isShowingFilter) {
21835 return null;
21836 }
21837 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(filters_default, { ...props });
21838 }
21839 var filters_toggled_default = FiltersToggled;
21840
21841 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
21842 var import_element48 = __toESM(require_element(), 1);
21843 var import_components24 = __toESM(require_components(), 1);
21844 var import_i18n34 = __toESM(require_i18n(), 1);
21845 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
21846 function DataViewsLayout({ className }) {
21847 const {
21848 actions = [],
21849 data,
21850 fields,
21851 getItemId,
21852 getItemLevel,
21853 hasInitiallyLoaded,
21854 isLoading,
21855 view,
21856 onChangeView,
21857 selection,
21858 onChangeSelection,
21859 setOpenedFilter,
21860 onClickItem,
21861 isItemClickable: isItemClickable2,
21862 renderItemLink,
21863 defaultLayouts: defaultLayouts2,
21864 containerRef,
21865 empty = /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("p", { children: (0, import_i18n34.__)("No results") })
21866 } = (0, import_element48.useContext)(dataviews_context_default);
21867 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
21868 delay: 200
21869 });
21870 if (!hasInitiallyLoaded) {
21871 if (!isDelayedInitialLoading) {
21872 return null;
21873 }
21874 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(import_components24.Spinner, {}) }) });
21875 }
21876 const ViewComponent = VIEW_LAYOUTS.find(
21877 (v2) => v2.type === view.type && defaultLayouts2[v2.type]
21878 )?.component;
21879 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
21880 ViewComponent,
21881 {
21882 className,
21883 actions,
21884 data,
21885 fields,
21886 getItemId,
21887 getItemLevel,
21888 isLoading,
21889 onChangeView,
21890 onChangeSelection,
21891 selection,
21892 setOpenedFilter,
21893 onClickItem,
21894 renderItemLink,
21895 isItemClickable: isItemClickable2,
21896 view,
21897 empty
21898 }
21899 ) });
21900 }
21901
21902 // packages/dataviews/build-module/components/dataviews-search/index.mjs
21903 var import_i18n35 = __toESM(require_i18n(), 1);
21904 var import_element49 = __toESM(require_element(), 1);
21905 var import_components25 = __toESM(require_components(), 1);
21906 var import_compose9 = __toESM(require_compose(), 1);
21907 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
21908 var DataViewsSearch = (0, import_element49.memo)(function Search({ label }) {
21909 const { view, onChangeView } = (0, import_element49.useContext)(dataviews_context_default);
21910 const [search, setSearch, debouncedSearch] = (0, import_compose9.useDebouncedInput)(
21911 view.search
21912 );
21913 (0, import_element49.useEffect)(() => {
21914 if (view.search !== debouncedSearch) {
21915 setSearch(view.search ?? "");
21916 }
21917 }, [view.search, setSearch]);
21918 const onChangeViewRef = (0, import_element49.useRef)(onChangeView);
21919 const viewRef = (0, import_element49.useRef)(view);
21920 (0, import_element49.useEffect)(() => {
21921 onChangeViewRef.current = onChangeView;
21922 viewRef.current = view;
21923 }, [onChangeView, view]);
21924 (0, import_element49.useEffect)(() => {
21925 if (debouncedSearch !== viewRef.current?.search) {
21926 onChangeViewRef.current({
21927 ...viewRef.current,
21928 page: view.page ? 1 : void 0,
21929 startPosition: view.startPosition ? 1 : void 0,
21930 search: debouncedSearch
21931 });
21932 }
21933 }, [debouncedSearch]);
21934 const searchLabel = label || (0, import_i18n35.__)("Search");
21935 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
21936 import_components25.SearchControl,
21937 {
21938 className: "dataviews-search",
21939 onChange: setSearch,
21940 value: search,
21941 label: searchLabel,
21942 placeholder: searchLabel,
21943 size: "compact"
21944 }
21945 );
21946 });
21947 var dataviews_search_default = DataViewsSearch;
21948
21949 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
21950 var import_components26 = __toESM(require_components(), 1);
21951 var import_i18n36 = __toESM(require_i18n(), 1);
21952 var import_element50 = __toESM(require_element(), 1);
21953 var import_warning = __toESM(require_warning(), 1);
21954 var import_compose10 = __toESM(require_compose(), 1);
21955 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
21956 var { Menu: Menu5 } = unlock2(import_components26.privateApis);
21957 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
21958 className: "dataviews-config__popover",
21959 placement: "bottom-end",
21960 offset: 9
21961 };
21962 function ViewTypeMenu() {
21963 const { view, onChangeView, defaultLayouts: defaultLayouts2 } = (0, import_element50.useContext)(dataviews_context_default);
21964 const availableLayouts = Object.keys(defaultLayouts2);
21965 if (availableLayouts.length <= 1) {
21966 return null;
21967 }
21968 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
21969 return /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(Menu5, { children: [
21970 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
21971 Menu5.TriggerButton,
21972 {
21973 render: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
21974 import_components26.Button,
21975 {
21976 size: "compact",
21977 icon: activeView?.icon,
21978 label: (0, import_i18n36.__)("Layout")
21979 }
21980 )
21981 }
21982 ),
21983 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
21984 const config = VIEW_LAYOUTS.find(
21985 (v2) => v2.type === layout
21986 );
21987 if (!config) {
21988 return null;
21989 }
21990 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
21991 Menu5.RadioItem,
21992 {
21993 value: layout,
21994 name: "view-actions-available-view",
21995 checked: layout === view.type,
21996 hideOnClick: true,
21997 onChange: (e2) => {
21998 switch (e2.target.value) {
21999 case "list":
22000 case "grid":
22001 case "table":
22002 case "pickerGrid":
22003 case "pickerTable":
22004 case "activity":
22005 const viewWithoutLayout = { ...view };
22006 if ("layout" in viewWithoutLayout) {
22007 delete viewWithoutLayout.layout;
22008 }
22009 return onChangeView({
22010 ...viewWithoutLayout,
22011 type: e2.target.value,
22012 ...defaultLayouts2[e2.target.value]
22013 });
22014 }
22015 (0, import_warning.default)("Invalid dataview");
22016 },
22017 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Menu5.ItemLabel, { children: config.label })
22018 },
22019 layout
22020 );
22021 }) })
22022 ] });
22023 }
22024 function SortFieldControl() {
22025 const { view, fields, onChangeView } = (0, import_element50.useContext)(dataviews_context_default);
22026 const orderOptions = (0, import_element50.useMemo)(() => {
22027 const sortableFields = fields.filter(
22028 (field) => field.enableSorting !== false
22029 );
22030 return sortableFields.map((field) => {
22031 return {
22032 label: field.label,
22033 value: field.id
22034 };
22035 });
22036 }, [fields]);
22037 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22038 import_components26.SelectControl,
22039 {
22040 __next40pxDefaultSize: true,
22041 label: (0, import_i18n36.__)("Sort by"),
22042 value: view.sort?.field,
22043 options: orderOptions,
22044 onChange: (value) => {
22045 onChangeView({
22046 ...view,
22047 sort: {
22048 direction: view?.sort?.direction || "desc",
22049 field: value
22050 },
22051 showLevels: false
22052 });
22053 }
22054 }
22055 );
22056 }
22057 function SortDirectionControl() {
22058 const { view, fields, onChangeView } = (0, import_element50.useContext)(dataviews_context_default);
22059 const sortableFields = fields.filter(
22060 (field) => field.enableSorting !== false
22061 );
22062 if (sortableFields.length === 0) {
22063 return null;
22064 }
22065 let value = view.sort?.direction;
22066 if (!value && view.sort?.field) {
22067 value = "desc";
22068 }
22069 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22070 import_components26.__experimentalToggleGroupControl,
22071 {
22072 className: "dataviews-view-config__sort-direction",
22073 __next40pxDefaultSize: true,
22074 isBlock: true,
22075 label: (0, import_i18n36.__)("Order"),
22076 value,
22077 onChange: (newDirection) => {
22078 if (newDirection === "asc" || newDirection === "desc") {
22079 onChangeView({
22080 ...view,
22081 sort: {
22082 direction: newDirection,
22083 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
22084 fields.find(
22085 (field) => field.enableSorting !== false
22086 )?.id || ""
22087 },
22088 showLevels: false
22089 });
22090 return;
22091 }
22092 (0, import_warning.default)("Invalid direction");
22093 },
22094 children: SORTING_DIRECTIONS.map((direction) => {
22095 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22096 import_components26.__experimentalToggleGroupControlOptionIcon,
22097 {
22098 value: direction,
22099 icon: sortIcons[direction],
22100 label: sortLabels[direction]
22101 },
22102 direction
22103 );
22104 })
22105 }
22106 );
22107 }
22108 function ItemsPerPageControl() {
22109 const { view, config, onChangeView } = (0, import_element50.useContext)(dataviews_context_default);
22110 const { infiniteScrollEnabled } = view;
22111 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
22112 return null;
22113 }
22114 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22115 import_components26.__experimentalToggleGroupControl,
22116 {
22117 __next40pxDefaultSize: true,
22118 isBlock: true,
22119 label: (0, import_i18n36.__)("Items per page"),
22120 value: view.perPage || 10,
22121 disabled: !view?.sort?.field,
22122 onChange: (newItemsPerPage) => {
22123 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
22124 onChangeView({
22125 ...view,
22126 perPage: newItemsPerPageNumber,
22127 page: 1
22128 });
22129 },
22130 children: config.perPageSizes.map((value) => {
22131 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22132 import_components26.__experimentalToggleGroupControlOption,
22133 {
22134 value,
22135 label: value.toString()
22136 },
22137 value
22138 );
22139 })
22140 }
22141 );
22142 }
22143 function ResetViewButton() {
22144 const { onReset } = (0, import_element50.useContext)(dataviews_context_default);
22145 if (onReset === void 0) {
22146 return null;
22147 }
22148 const isDisabled = onReset === false;
22149 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22150 import_components26.Button,
22151 {
22152 variant: "tertiary",
22153 size: "compact",
22154 disabled: isDisabled,
22155 accessibleWhenDisabled: true,
22156 className: "dataviews-view-config__reset-button",
22157 onClick: () => {
22158 if (typeof onReset === "function") {
22159 onReset();
22160 }
22161 },
22162 children: (0, import_i18n36.__)("Reset view")
22163 }
22164 );
22165 }
22166 function DataviewsViewConfigDropdown() {
22167 const { view, onReset } = (0, import_element50.useContext)(dataviews_context_default);
22168 const popoverId = (0, import_compose10.useInstanceId)(
22169 _DataViewsViewConfig,
22170 "dataviews-view-config-dropdown"
22171 );
22172 const activeLayout = VIEW_LAYOUTS.find(
22173 (layout) => layout.type === view.type
22174 );
22175 const isModified = typeof onReset === "function";
22176 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22177 import_components26.Dropdown,
22178 {
22179 expandOnMobile: true,
22180 popoverProps: {
22181 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
22182 id: popoverId
22183 },
22184 renderToggle: ({ onToggle, isOpen }) => {
22185 return /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
22186 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22187 import_components26.Button,
22188 {
22189 size: "compact",
22190 icon: cog_default,
22191 label: (0, import_i18n36._x)(
22192 "View options",
22193 "View is used as a noun"
22194 ),
22195 onClick: onToggle,
22196 "aria-expanded": isOpen ? "true" : "false",
22197 "aria-controls": popoverId
22198 }
22199 ),
22200 isModified && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
22201 ] });
22202 },
22203 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22204 import_components26.__experimentalDropdownContentWrapper,
22205 {
22206 paddingSize: "medium",
22207 className: "dataviews-config__popover-content-wrapper",
22208 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
22209 Stack,
22210 {
22211 direction: "column",
22212 className: "dataviews-view-config",
22213 gap: "xl",
22214 children: [
22215 /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
22216 Stack,
22217 {
22218 direction: "row",
22219 justify: "space-between",
22220 align: "center",
22221 className: "dataviews-view-config__header",
22222 children: [
22223 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22224 import_components26.__experimentalHeading,
22225 {
22226 level: 2,
22227 className: "dataviews-settings-section__title",
22228 children: (0, import_i18n36.__)("Appearance")
22229 }
22230 ),
22231 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(ResetViewButton, {})
22232 ]
22233 }
22234 ),
22235 /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22236 /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
22237 Stack,
22238 {
22239 direction: "row",
22240 gap: "sm",
22241 className: "dataviews-view-config__sort-controls",
22242 children: [
22243 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(SortFieldControl, {}),
22244 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(SortDirectionControl, {})
22245 ]
22246 }
22247 ),
22248 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(activeLayout.viewConfigOptions, {}),
22249 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(ItemsPerPageControl, {}),
22250 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(PropertiesSection, {})
22251 ] })
22252 ]
22253 }
22254 )
22255 }
22256 )
22257 }
22258 );
22259 }
22260 function _DataViewsViewConfig() {
22261 return /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(import_jsx_runtime89.Fragment, { children: [
22262 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(ViewTypeMenu, {}),
22263 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(DataviewsViewConfigDropdown, {})
22264 ] });
22265 }
22266 var DataViewsViewConfig = (0, import_element50.memo)(_DataViewsViewConfig);
22267 var dataviews_view_config_default = DataViewsViewConfig;
22268
22269 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22270 var import_components27 = __toESM(require_components(), 1);
22271 var import_element51 = __toESM(require_element(), 1);
22272
22273 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
22274 function getCustomValidity(isValid2, validity) {
22275 let customValidity;
22276 if (isValid2?.required && validity?.required) {
22277 customValidity = validity?.required?.message ? validity.required : void 0;
22278 } else if (isValid2?.pattern && validity?.pattern) {
22279 customValidity = validity.pattern;
22280 } else if (isValid2?.min && validity?.min) {
22281 customValidity = validity.min;
22282 } else if (isValid2?.max && validity?.max) {
22283 customValidity = validity.max;
22284 } else if (isValid2?.minLength && validity?.minLength) {
22285 customValidity = validity.minLength;
22286 } else if (isValid2?.maxLength && validity?.maxLength) {
22287 customValidity = validity.maxLength;
22288 } else if (isValid2?.elements && validity?.elements) {
22289 customValidity = validity.elements;
22290 } else if (validity?.custom) {
22291 customValidity = validity.custom;
22292 }
22293 return customValidity;
22294 }
22295
22296 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22297 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
22298 var { ValidatedCheckboxControl } = unlock2(import_components27.privateApis);
22299 function Checkbox({
22300 field,
22301 onChange,
22302 data,
22303 hideLabelFromVision,
22304 markWhenOptional,
22305 validity
22306 }) {
22307 const { getValue, setValue, label, description, isValid: isValid2 } = field;
22308 const disabled2 = field.isDisabled({ item: data, field });
22309 const onChangeControl = (0, import_element51.useCallback)(() => {
22310 onChange(
22311 setValue({ item: data, value: !getValue({ item: data }) })
22312 );
22313 }, [data, getValue, onChange, setValue]);
22314 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22315 ValidatedCheckboxControl,
22316 {
22317 required: !!field.isValid?.required,
22318 markWhenOptional,
22319 customValidity: getCustomValidity(isValid2, validity),
22320 hidden: hideLabelFromVision,
22321 label,
22322 help: description,
22323 checked: getValue({ item: data }),
22324 onChange: onChangeControl,
22325 disabled: disabled2
22326 }
22327 );
22328 }
22329
22330 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
22331 var import_components28 = __toESM(require_components(), 1);
22332 var import_element52 = __toESM(require_element(), 1);
22333 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
22334 var { ValidatedComboboxControl } = unlock2(import_components28.privateApis);
22335 function Combobox3({
22336 data,
22337 field,
22338 onChange,
22339 hideLabelFromVision,
22340 validity
22341 }) {
22342 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
22343 const value = getValue({ item: data }) ?? "";
22344 const onChangeControl = (0, import_element52.useCallback)(
22345 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
22346 [data, onChange, setValue]
22347 );
22348 const { elements, isLoading } = useElements({
22349 elements: field.elements,
22350 getElements: field.getElements
22351 });
22352 if (isLoading) {
22353 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_components28.Spinner, {});
22354 }
22355 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22356 ValidatedComboboxControl,
22357 {
22358 required: !!field.isValid?.required,
22359 customValidity: getCustomValidity(isValid2, validity),
22360 label,
22361 value,
22362 help: description,
22363 placeholder,
22364 options: elements,
22365 onChange: onChangeControl,
22366 hideLabelFromVision,
22367 allowReset: true,
22368 expandOnFocus: true
22369 }
22370 );
22371 }
22372
22373 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22374 var import_components30 = __toESM(require_components(), 1);
22375 var import_element55 = __toESM(require_element(), 1);
22376 var import_i18n38 = __toESM(require_i18n(), 1);
22377 var import_date3 = __toESM(require_date(), 1);
22378
22379 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
22380 var import_components29 = __toESM(require_components(), 1);
22381 var import_element53 = __toESM(require_element(), 1);
22382 var import_i18n37 = __toESM(require_i18n(), 1);
22383 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
22384 var TIME_UNITS_OPTIONS = {
22385 [OPERATOR_IN_THE_PAST]: [
22386 { value: "days", label: (0, import_i18n37.__)("Days") },
22387 { value: "weeks", label: (0, import_i18n37.__)("Weeks") },
22388 { value: "months", label: (0, import_i18n37.__)("Months") },
22389 { value: "years", label: (0, import_i18n37.__)("Years") }
22390 ],
22391 [OPERATOR_OVER]: [
22392 { value: "days", label: (0, import_i18n37.__)("Days ago") },
22393 { value: "weeks", label: (0, import_i18n37.__)("Weeks ago") },
22394 { value: "months", label: (0, import_i18n37.__)("Months ago") },
22395 { value: "years", label: (0, import_i18n37.__)("Years ago") }
22396 ]
22397 };
22398 function RelativeDateControl({
22399 className,
22400 data,
22401 field,
22402 onChange,
22403 hideLabelFromVision,
22404 operator
22405 }) {
22406 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
22407 const { id, label, description, getValue, setValue } = field;
22408 const disabled2 = field.isDisabled({ item: data, field });
22409 const fieldValue = getValue({ item: data });
22410 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
22411 const onChangeValue = (0, import_element53.useCallback)(
22412 (newValue) => onChange(
22413 setValue({
22414 item: data,
22415 value: { value: Number(newValue), unit }
22416 })
22417 ),
22418 [onChange, setValue, data, unit]
22419 );
22420 const onChangeUnit = (0, import_element53.useCallback)(
22421 (newUnit) => onChange(
22422 setValue({
22423 item: data,
22424 value: { value: relValue, unit: newUnit }
22425 })
22426 ),
22427 [onChange, setValue, data, relValue]
22428 );
22429 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22430 import_components29.BaseControl,
22431 {
22432 id,
22433 className: clsx_default(className, "dataviews-controls__relative-date"),
22434 label,
22435 hideLabelFromVision,
22436 help: description,
22437 children: /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(Stack, { direction: "row", gap: "sm", children: [
22438 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22439 import_components29.__experimentalNumberControl,
22440 {
22441 __next40pxDefaultSize: true,
22442 className: "dataviews-controls__relative-date-number",
22443 spinControls: "none",
22444 min: 1,
22445 step: 1,
22446 value: relValue,
22447 onChange: onChangeValue,
22448 disabled: disabled2
22449 }
22450 ),
22451 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22452 import_components29.SelectControl,
22453 {
22454 className: "dataviews-controls__relative-date-unit",
22455 __next40pxDefaultSize: true,
22456 label: (0, import_i18n37.__)("Unit"),
22457 value: unit,
22458 options,
22459 onChange: onChangeUnit,
22460 hideLabelFromVision: true,
22461 disabled: disabled2
22462 }
22463 )
22464 ] })
22465 }
22466 );
22467 }
22468
22469 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
22470 var import_element54 = __toESM(require_element(), 1);
22471 function useDisabledDateMatchers(isValid2, parseDateFn) {
22472 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
22473 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
22474 const disabledMatchers = (0, import_element54.useMemo)(() => {
22475 const matchers = [];
22476 if (minConstraint) {
22477 const minDate = parseDateFn(minConstraint);
22478 if (minDate) {
22479 matchers.push({ before: minDate });
22480 }
22481 }
22482 if (maxConstraint) {
22483 const maxDate = parseDateFn(maxConstraint);
22484 if (maxDate) {
22485 matchers.push({ after: maxDate });
22486 }
22487 }
22488 return matchers.length > 0 ? matchers : void 0;
22489 }, [minConstraint, maxConstraint, parseDateFn]);
22490 return { minConstraint, maxConstraint, disabledMatchers };
22491 }
22492
22493 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
22494 var import_date2 = __toESM(require_date(), 1);
22495 function parseDateTime(dateTimeString) {
22496 if (!dateTimeString) {
22497 return null;
22498 }
22499 const parsed = (0, import_date2.getDate)(dateTimeString);
22500 return parsed && isValid(parsed) ? parsed : null;
22501 }
22502
22503 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22504 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
22505 var { DateCalendar, ValidatedInputControl } = unlock2(import_components30.privateApis);
22506 var formatDateTime = (value) => {
22507 if (!value) {
22508 return "";
22509 }
22510 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
22511 };
22512 function CalendarDateTimeControl({
22513 data,
22514 field,
22515 onChange,
22516 hideLabelFromVision,
22517 markWhenOptional,
22518 validity,
22519 config
22520 }) {
22521 const { compact } = config || {};
22522 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
22523 const disabled2 = field.isDisabled({ item: data, field });
22524 const fieldValue = getValue({ item: data });
22525 const value = typeof fieldValue === "string" ? fieldValue : void 0;
22526 const [calendarMonth, setCalendarMonth] = (0, import_element55.useState)(() => {
22527 const parsedDate = parseDateTime(value);
22528 return parsedDate || /* @__PURE__ */ new Date();
22529 });
22530 const inputControlRef = (0, import_element55.useRef)(null);
22531 const validationTimeoutRef = (0, import_element55.useRef)(void 0);
22532 const previousFocusRef = (0, import_element55.useRef)(null);
22533 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
22534 const onChangeCallback = (0, import_element55.useCallback)(
22535 (newValue) => onChange(setValue({ item: data, value: newValue })),
22536 [data, onChange, setValue]
22537 );
22538 (0, import_element55.useEffect)(() => {
22539 return () => {
22540 if (validationTimeoutRef.current) {
22541 clearTimeout(validationTimeoutRef.current);
22542 }
22543 };
22544 }, []);
22545 const onSelectDate = (0, import_element55.useCallback)(
22546 (newDate) => {
22547 let dateTimeValue;
22548 if (newDate) {
22549 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
22550 let wpTime;
22551 if (value) {
22552 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
22553 } else {
22554 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
22555 }
22556 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
22557 dateTimeValue = finalDateTime.toISOString();
22558 onChangeCallback(dateTimeValue);
22559 if (validationTimeoutRef.current) {
22560 clearTimeout(validationTimeoutRef.current);
22561 }
22562 } else {
22563 onChangeCallback(void 0);
22564 }
22565 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
22566 validationTimeoutRef.current = setTimeout(() => {
22567 if (inputControlRef.current) {
22568 inputControlRef.current.focus();
22569 inputControlRef.current.blur();
22570 onChangeCallback(dateTimeValue);
22571 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
22572 previousFocusRef.current.focus();
22573 }
22574 }
22575 }, 0);
22576 },
22577 [onChangeCallback, value]
22578 );
22579 const handleManualDateTimeChange = (0, import_element55.useCallback)(
22580 (newValue) => {
22581 if (newValue) {
22582 const dateTime = (0, import_date3.getDate)(newValue);
22583 onChangeCallback(dateTime.toISOString());
22584 const parsedDate = parseDateTime(dateTime.toISOString());
22585 if (parsedDate) {
22586 setCalendarMonth(parsedDate);
22587 }
22588 } else {
22589 onChangeCallback(void 0);
22590 }
22591 },
22592 [onChangeCallback]
22593 );
22594 const { format: fieldFormat } = field;
22595 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
22596 const {
22597 timezone: { string: timezoneString }
22598 } = (0, import_date3.getSettings)();
22599 let displayLabel = label;
22600 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
22601 displayLabel = `${label} (${(0, import_i18n38.__)("Required")})`;
22602 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
22603 displayLabel = `${label} (${(0, import_i18n38.__)("Optional")})`;
22604 }
22605 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
22606 import_components30.BaseControl,
22607 {
22608 id,
22609 label: displayLabel,
22610 help: description,
22611 hideLabelFromVision,
22612 children: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22613 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
22614 ValidatedInputControl,
22615 {
22616 ref: inputControlRef,
22617 __next40pxDefaultSize: true,
22618 required: !!isValid2?.required,
22619 customValidity: getCustomValidity(isValid2, validity),
22620 type: "datetime-local",
22621 label: (0, import_i18n38.__)("Date time"),
22622 hideLabelFromVision: true,
22623 value: formatDateTime(value),
22624 onChange: handleManualDateTimeChange,
22625 disabled: disabled2,
22626 min: minConstraint ? formatDateTime(minConstraint) : void 0,
22627 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
22628 }
22629 ),
22630 !compact && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
22631 DateCalendar,
22632 {
22633 style: { width: "100%" },
22634 selected: value ? parseDateTime(value) || void 0 : void 0,
22635 onSelect: onSelectDate,
22636 month: calendarMonth,
22637 onMonthChange: setCalendarMonth,
22638 timeZone: timezoneString || void 0,
22639 weekStartsOn,
22640 disabled: disabled2 || disabledMatchers
22641 }
22642 )
22643 ] })
22644 }
22645 );
22646 }
22647 function DateTime({
22648 data,
22649 field,
22650 onChange,
22651 hideLabelFromVision,
22652 markWhenOptional,
22653 operator,
22654 validity,
22655 config
22656 }) {
22657 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
22658 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
22659 RelativeDateControl,
22660 {
22661 className: "dataviews-controls__datetime",
22662 data,
22663 field,
22664 onChange,
22665 hideLabelFromVision,
22666 operator
22667 }
22668 );
22669 }
22670 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
22671 CalendarDateTimeControl,
22672 {
22673 data,
22674 field,
22675 onChange,
22676 hideLabelFromVision,
22677 markWhenOptional,
22678 validity,
22679 config
22680 }
22681 );
22682 }
22683
22684 // packages/dataviews/build-module/components/dataform-controls/date.mjs
22685 var import_components31 = __toESM(require_components(), 1);
22686 var import_element56 = __toESM(require_element(), 1);
22687 var import_i18n39 = __toESM(require_i18n(), 1);
22688 var import_date4 = __toESM(require_date(), 1);
22689 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
22690 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components31.privateApis);
22691 var DATE_PRESETS = [
22692 {
22693 id: "today",
22694 label: (0, import_i18n39.__)("Today"),
22695 getValue: () => (0, import_date4.getDate)(null)
22696 },
22697 {
22698 id: "yesterday",
22699 label: (0, import_i18n39.__)("Yesterday"),
22700 getValue: () => {
22701 const today = (0, import_date4.getDate)(null);
22702 return subDays(today, 1);
22703 }
22704 },
22705 {
22706 id: "past-week",
22707 label: (0, import_i18n39.__)("Past week"),
22708 getValue: () => {
22709 const today = (0, import_date4.getDate)(null);
22710 return subDays(today, 7);
22711 }
22712 },
22713 {
22714 id: "past-month",
22715 label: (0, import_i18n39.__)("Past month"),
22716 getValue: () => {
22717 const today = (0, import_date4.getDate)(null);
22718 return subMonths(today, 1);
22719 }
22720 }
22721 ];
22722 var DATE_RANGE_PRESETS = [
22723 {
22724 id: "last-7-days",
22725 label: (0, import_i18n39.__)("Last 7 days"),
22726 getValue: () => {
22727 const today = (0, import_date4.getDate)(null);
22728 return [subDays(today, 7), today];
22729 }
22730 },
22731 {
22732 id: "last-30-days",
22733 label: (0, import_i18n39.__)("Last 30 days"),
22734 getValue: () => {
22735 const today = (0, import_date4.getDate)(null);
22736 return [subDays(today, 30), today];
22737 }
22738 },
22739 {
22740 id: "month-to-date",
22741 label: (0, import_i18n39.__)("Month to date"),
22742 getValue: () => {
22743 const today = (0, import_date4.getDate)(null);
22744 return [startOfMonth(today), today];
22745 }
22746 },
22747 {
22748 id: "last-year",
22749 label: (0, import_i18n39.__)("Last year"),
22750 getValue: () => {
22751 const today = (0, import_date4.getDate)(null);
22752 return [subYears(today, 1), today];
22753 }
22754 },
22755 {
22756 id: "year-to-date",
22757 label: (0, import_i18n39.__)("Year to date"),
22758 getValue: () => {
22759 const today = (0, import_date4.getDate)(null);
22760 return [startOfYear(today), today];
22761 }
22762 }
22763 ];
22764 var parseDate = (dateString) => {
22765 if (!dateString) {
22766 return null;
22767 }
22768 const parsed = (0, import_date4.getDate)(dateString);
22769 return parsed && isValid(parsed) ? parsed : null;
22770 };
22771 var formatDate = (date) => {
22772 if (!date) {
22773 return "";
22774 }
22775 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
22776 };
22777 function ValidatedDateControl({
22778 field,
22779 validity,
22780 inputRefs,
22781 isTouched,
22782 setIsTouched,
22783 children
22784 }) {
22785 const { isValid: isValid2 } = field;
22786 const [customValidity, setCustomValidity] = (0, import_element56.useState)(void 0);
22787 const validateRefs = (0, import_element56.useCallback)(() => {
22788 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
22789 for (const ref of refs) {
22790 const input = ref.current;
22791 if (input && !input.validity.valid) {
22792 setCustomValidity({
22793 type: "invalid",
22794 message: input.validationMessage
22795 });
22796 return;
22797 }
22798 }
22799 setCustomValidity(void 0);
22800 }, [inputRefs]);
22801 (0, import_element56.useEffect)(() => {
22802 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
22803 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
22804 for (const ref of refs) {
22805 const input = ref.current;
22806 if (input) {
22807 input.setCustomValidity(
22808 result?.type === "invalid" && result.message ? result.message : ""
22809 );
22810 }
22811 }
22812 }, [inputRefs, isValid2, validity]);
22813 (0, import_element56.useEffect)(() => {
22814 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
22815 const handleInvalid = (event) => {
22816 event.preventDefault();
22817 setIsTouched(true);
22818 };
22819 for (const ref of refs) {
22820 ref.current?.addEventListener("invalid", handleInvalid);
22821 }
22822 return () => {
22823 for (const ref of refs) {
22824 ref.current?.removeEventListener("invalid", handleInvalid);
22825 }
22826 };
22827 }, [inputRefs, setIsTouched]);
22828 (0, import_element56.useEffect)(() => {
22829 if (!isTouched) {
22830 return;
22831 }
22832 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
22833 if (result) {
22834 setCustomValidity(result);
22835 } else {
22836 validateRefs();
22837 }
22838 }, [isTouched, isValid2, validity, validateRefs]);
22839 const onBlur = (event) => {
22840 if (isTouched) {
22841 return;
22842 }
22843 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
22844 setIsTouched(true);
22845 }
22846 };
22847 return /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { onBlur, children: [
22848 children,
22849 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(
22850 "p",
22851 {
22852 className: clsx_default(
22853 "components-validated-control__indicator",
22854 customValidity.type === "invalid" ? "is-invalid" : void 0
22855 ),
22856 children: [
22857 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22858 import_components31.Icon,
22859 {
22860 className: "components-validated-control__indicator-icon",
22861 icon: error_default,
22862 size: 16,
22863 fill: "currentColor"
22864 }
22865 ),
22866 customValidity.message
22867 ]
22868 }
22869 ) })
22870 ] });
22871 }
22872 function CalendarDateControl({
22873 data,
22874 field,
22875 onChange,
22876 hideLabelFromVision,
22877 markWhenOptional,
22878 validity
22879 }) {
22880 const {
22881 id,
22882 label,
22883 description,
22884 setValue,
22885 getValue,
22886 isValid: isValid2,
22887 format: fieldFormat
22888 } = field;
22889 const disabled2 = field.isDisabled({ item: data, field });
22890 const [selectedPresetId, setSelectedPresetId] = (0, import_element56.useState)(
22891 null
22892 );
22893 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
22894 const fieldValue = getValue({ item: data });
22895 const value = typeof fieldValue === "string" ? fieldValue : void 0;
22896 const [calendarMonth, setCalendarMonth] = (0, import_element56.useState)(() => {
22897 const parsedDate = parseDate(value);
22898 return parsedDate || /* @__PURE__ */ new Date();
22899 });
22900 const [isTouched, setIsTouched] = (0, import_element56.useState)(false);
22901 const validityTargetRef = (0, import_element56.useRef)(null);
22902 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
22903 const onChangeCallback = (0, import_element56.useCallback)(
22904 (newValue) => onChange(setValue({ item: data, value: newValue })),
22905 [data, onChange, setValue]
22906 );
22907 const onSelectDate = (0, import_element56.useCallback)(
22908 (newDate) => {
22909 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
22910 onChangeCallback(dateValue);
22911 setSelectedPresetId(null);
22912 setIsTouched(true);
22913 },
22914 [onChangeCallback]
22915 );
22916 const handlePresetClick = (0, import_element56.useCallback)(
22917 (preset) => {
22918 const presetDate = preset.getValue();
22919 const dateValue = formatDate(presetDate);
22920 setCalendarMonth(presetDate);
22921 onChangeCallback(dateValue);
22922 setSelectedPresetId(preset.id);
22923 setIsTouched(true);
22924 },
22925 [onChangeCallback]
22926 );
22927 const handleManualDateChange = (0, import_element56.useCallback)(
22928 (newValue) => {
22929 onChangeCallback(newValue);
22930 if (newValue) {
22931 const parsedDate = parseDate(newValue);
22932 if (parsedDate) {
22933 setCalendarMonth(parsedDate);
22934 }
22935 }
22936 setSelectedPresetId(null);
22937 setIsTouched(true);
22938 },
22939 [onChangeCallback]
22940 );
22941 const {
22942 timezone: { string: timezoneString }
22943 } = (0, import_date4.getSettings)();
22944 let displayLabel = label;
22945 if (isValid2?.required && !markWhenOptional) {
22946 displayLabel = `${label} (${(0, import_i18n39.__)("Required")})`;
22947 } else if (!isValid2?.required && markWhenOptional) {
22948 displayLabel = `${label} (${(0, import_i18n39.__)("Optional")})`;
22949 }
22950 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22951 ValidatedDateControl,
22952 {
22953 field,
22954 validity,
22955 inputRefs: validityTargetRef,
22956 isTouched,
22957 setIsTouched,
22958 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22959 import_components31.BaseControl,
22960 {
22961 id,
22962 className: "dataviews-controls__date",
22963 label: displayLabel,
22964 help: description,
22965 hideLabelFromVision,
22966 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22967 /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(
22968 Stack,
22969 {
22970 direction: "row",
22971 gap: "sm",
22972 wrap: "wrap",
22973 justify: "flex-start",
22974 children: [
22975 DATE_PRESETS.map((preset) => {
22976 const isSelected2 = selectedPresetId === preset.id;
22977 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22978 import_components31.Button,
22979 {
22980 className: "dataviews-controls__date-preset",
22981 variant: "tertiary",
22982 isPressed: isSelected2,
22983 size: "small",
22984 disabled: disabled2,
22985 accessibleWhenDisabled: true,
22986 onClick: () => handlePresetClick(preset),
22987 children: preset.label
22988 },
22989 preset.id
22990 );
22991 }),
22992 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22993 import_components31.Button,
22994 {
22995 className: "dataviews-controls__date-preset",
22996 variant: "tertiary",
22997 isPressed: !selectedPresetId,
22998 size: "small",
22999 disabled: !!selectedPresetId || disabled2,
23000 accessibleWhenDisabled: true,
23001 children: (0, import_i18n39.__)("Custom")
23002 }
23003 )
23004 ]
23005 }
23006 ),
23007 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23008 import_components31.__experimentalInputControl,
23009 {
23010 __next40pxDefaultSize: true,
23011 ref: validityTargetRef,
23012 type: "date",
23013 label: (0, import_i18n39.__)("Date"),
23014 hideLabelFromVision: true,
23015 value,
23016 onChange: handleManualDateChange,
23017 required: !!field.isValid?.required,
23018 disabled: disabled2,
23019 min: minConstraint,
23020 max: maxConstraint
23021 }
23022 ),
23023 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23024 DateCalendar2,
23025 {
23026 style: { width: "100%" },
23027 selected: value ? parseDate(value) || void 0 : void 0,
23028 onSelect: onSelectDate,
23029 month: calendarMonth,
23030 onMonthChange: setCalendarMonth,
23031 timeZone: timezoneString || void 0,
23032 weekStartsOn,
23033 disabled: disabled2 || disabledMatchers,
23034 disableNavigation: disabled2
23035 }
23036 )
23037 ] })
23038 }
23039 )
23040 }
23041 );
23042 }
23043 function CalendarDateRangeControl({
23044 data,
23045 field,
23046 onChange,
23047 hideLabelFromVision,
23048 markWhenOptional,
23049 validity
23050 }) {
23051 const {
23052 id,
23053 label,
23054 description,
23055 getValue,
23056 setValue,
23057 isValid: isValid2,
23058 format: fieldFormat
23059 } = field;
23060 const disabled2 = field.isDisabled({ item: data, field });
23061 let value;
23062 const fieldValue = getValue({ item: data });
23063 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
23064 value = fieldValue;
23065 }
23066 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23067 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23068 const onChangeCallback = (0, import_element56.useCallback)(
23069 (newValue) => {
23070 onChange(
23071 setValue({
23072 item: data,
23073 value: newValue
23074 })
23075 );
23076 },
23077 [data, onChange, setValue]
23078 );
23079 const [selectedPresetId, setSelectedPresetId] = (0, import_element56.useState)(
23080 null
23081 );
23082 const selectedRange = (0, import_element56.useMemo)(() => {
23083 if (!value) {
23084 return { from: void 0, to: void 0 };
23085 }
23086 const [from, to] = value;
23087 return {
23088 from: parseDate(from) || void 0,
23089 to: parseDate(to) || void 0
23090 };
23091 }, [value]);
23092 const [calendarMonth, setCalendarMonth] = (0, import_element56.useState)(() => {
23093 return selectedRange.from || /* @__PURE__ */ new Date();
23094 });
23095 const [isTouched, setIsTouched] = (0, import_element56.useState)(false);
23096 const fromInputRef = (0, import_element56.useRef)(null);
23097 const toInputRef = (0, import_element56.useRef)(null);
23098 const updateDateRange = (0, import_element56.useCallback)(
23099 (fromDate, toDate2) => {
23100 if (fromDate && toDate2) {
23101 onChangeCallback([
23102 formatDate(fromDate),
23103 formatDate(toDate2)
23104 ]);
23105 } else if (!fromDate && !toDate2) {
23106 onChangeCallback(void 0);
23107 }
23108 },
23109 [onChangeCallback]
23110 );
23111 const onSelectCalendarRange = (0, import_element56.useCallback)(
23112 (newRange) => {
23113 updateDateRange(newRange?.from, newRange?.to);
23114 setSelectedPresetId(null);
23115 setIsTouched(true);
23116 },
23117 [updateDateRange]
23118 );
23119 const handlePresetClick = (0, import_element56.useCallback)(
23120 (preset) => {
23121 const [startDate, endDate] = preset.getValue();
23122 setCalendarMonth(startDate);
23123 updateDateRange(startDate, endDate);
23124 setSelectedPresetId(preset.id);
23125 setIsTouched(true);
23126 },
23127 [updateDateRange]
23128 );
23129 const handleManualDateChange = (0, import_element56.useCallback)(
23130 (fromOrTo, newValue) => {
23131 const [currentFrom, currentTo] = value || [
23132 void 0,
23133 void 0
23134 ];
23135 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
23136 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
23137 updateDateRange(updatedFrom, updatedTo);
23138 if (newValue) {
23139 const parsedDate = parseDate(newValue);
23140 if (parsedDate) {
23141 setCalendarMonth(parsedDate);
23142 }
23143 }
23144 setSelectedPresetId(null);
23145 setIsTouched(true);
23146 },
23147 [value, updateDateRange]
23148 );
23149 const { timezone } = (0, import_date4.getSettings)();
23150 let displayLabel = label;
23151 if (field.isValid?.required && !markWhenOptional) {
23152 displayLabel = `${label} (${(0, import_i18n39.__)("Required")})`;
23153 } else if (!field.isValid?.required && markWhenOptional) {
23154 displayLabel = `${label} (${(0, import_i18n39.__)("Optional")})`;
23155 }
23156 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23157 ValidatedDateControl,
23158 {
23159 field,
23160 validity,
23161 inputRefs: [fromInputRef, toInputRef],
23162 isTouched,
23163 setIsTouched,
23164 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23165 import_components31.BaseControl,
23166 {
23167 id,
23168 className: "dataviews-controls__date",
23169 label: displayLabel,
23170 help: description,
23171 hideLabelFromVision,
23172 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23173 /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(
23174 Stack,
23175 {
23176 direction: "row",
23177 gap: "sm",
23178 wrap: "wrap",
23179 justify: "flex-start",
23180 children: [
23181 DATE_RANGE_PRESETS.map((preset) => {
23182 const isSelected2 = selectedPresetId === preset.id;
23183 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23184 import_components31.Button,
23185 {
23186 className: "dataviews-controls__date-preset",
23187 variant: "tertiary",
23188 isPressed: isSelected2,
23189 size: "small",
23190 disabled: disabled2,
23191 accessibleWhenDisabled: true,
23192 onClick: () => handlePresetClick(preset),
23193 children: preset.label
23194 },
23195 preset.id
23196 );
23197 }),
23198 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23199 import_components31.Button,
23200 {
23201 className: "dataviews-controls__date-preset",
23202 variant: "tertiary",
23203 isPressed: !selectedPresetId,
23204 size: "small",
23205 accessibleWhenDisabled: true,
23206 disabled: !!selectedPresetId || disabled2,
23207 children: (0, import_i18n39.__)("Custom")
23208 }
23209 )
23210 ]
23211 }
23212 ),
23213 /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(
23214 Stack,
23215 {
23216 direction: "row",
23217 gap: "sm",
23218 justify: "space-between",
23219 className: "dataviews-controls__date-range-inputs",
23220 children: [
23221 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23222 import_components31.__experimentalInputControl,
23223 {
23224 __next40pxDefaultSize: true,
23225 ref: fromInputRef,
23226 type: "date",
23227 label: (0, import_i18n39.__)("From"),
23228 hideLabelFromVision: true,
23229 value: value?.[0],
23230 onChange: (newValue) => handleManualDateChange("from", newValue),
23231 required: !!field.isValid?.required,
23232 disabled: disabled2,
23233 min: minConstraint,
23234 max: maxConstraint
23235 }
23236 ),
23237 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23238 import_components31.__experimentalInputControl,
23239 {
23240 __next40pxDefaultSize: true,
23241 ref: toInputRef,
23242 type: "date",
23243 label: (0, import_i18n39.__)("To"),
23244 hideLabelFromVision: true,
23245 value: value?.[1],
23246 onChange: (newValue) => handleManualDateChange("to", newValue),
23247 required: !!field.isValid?.required,
23248 disabled: disabled2,
23249 min: minConstraint,
23250 max: maxConstraint
23251 }
23252 )
23253 ]
23254 }
23255 ),
23256 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23257 DateRangeCalendar,
23258 {
23259 style: { width: "100%" },
23260 selected: selectedRange,
23261 onSelect: onSelectCalendarRange,
23262 month: calendarMonth,
23263 onMonthChange: setCalendarMonth,
23264 timeZone: timezone.string || void 0,
23265 weekStartsOn,
23266 disabled: disabled2 || disabledMatchers
23267 }
23268 )
23269 ] })
23270 }
23271 )
23272 }
23273 );
23274 }
23275 function DateControl({
23276 data,
23277 field,
23278 onChange,
23279 hideLabelFromVision,
23280 markWhenOptional,
23281 operator,
23282 validity
23283 }) {
23284 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23285 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23286 RelativeDateControl,
23287 {
23288 className: "dataviews-controls__date",
23289 data,
23290 field,
23291 onChange,
23292 hideLabelFromVision,
23293 operator
23294 }
23295 );
23296 }
23297 if (operator === OPERATOR_BETWEEN) {
23298 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23299 CalendarDateRangeControl,
23300 {
23301 data,
23302 field,
23303 onChange,
23304 hideLabelFromVision,
23305 markWhenOptional,
23306 validity
23307 }
23308 );
23309 }
23310 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23311 CalendarDateControl,
23312 {
23313 data,
23314 field,
23315 onChange,
23316 hideLabelFromVision,
23317 markWhenOptional,
23318 validity
23319 }
23320 );
23321 }
23322
23323 // packages/dataviews/build-module/components/dataform-controls/select.mjs
23324 var import_components32 = __toESM(require_components(), 1);
23325 var import_element57 = __toESM(require_element(), 1);
23326 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
23327 var { ValidatedSelectControl } = unlock2(import_components32.privateApis);
23328 function Select({
23329 data,
23330 field,
23331 onChange,
23332 hideLabelFromVision,
23333 markWhenOptional,
23334 validity
23335 }) {
23336 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
23337 const disabled2 = field.isDisabled({ item: data, field });
23338 const isMultiple = type === "array";
23339 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
23340 const onChangeControl = (0, import_element57.useCallback)(
23341 (newValue) => onChange(setValue({ item: data, value: newValue })),
23342 [data, onChange, setValue]
23343 );
23344 const { elements, isLoading } = useElements({
23345 elements: field.elements,
23346 getElements: field.getElements
23347 });
23348 if (isLoading) {
23349 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(import_components32.Spinner, {});
23350 }
23351 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23352 ValidatedSelectControl,
23353 {
23354 required: !!field.isValid?.required,
23355 markWhenOptional,
23356 customValidity: getCustomValidity(isValid2, validity),
23357 label,
23358 value,
23359 help: description,
23360 options: elements,
23361 onChange: onChangeControl,
23362 __next40pxDefaultSize: true,
23363 hideLabelFromVision,
23364 multiple: isMultiple,
23365 disabled: disabled2
23366 }
23367 );
23368 }
23369
23370 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
23371 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
23372 var ELEMENTS_THRESHOLD = 10;
23373 function AdaptiveSelect(props) {
23374 const { field } = props;
23375 const { elements } = useElements({
23376 elements: field.elements,
23377 getElements: field.getElements
23378 });
23379 if (elements.length >= ELEMENTS_THRESHOLD) {
23380 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(Combobox3, { ...props });
23381 }
23382 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(Select, { ...props });
23383 }
23384
23385 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23386 var import_components34 = __toESM(require_components(), 1);
23387
23388 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
23389 var import_components33 = __toESM(require_components(), 1);
23390 var import_element58 = __toESM(require_element(), 1);
23391 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
23392 var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components33.privateApis);
23393 function ValidatedText({
23394 data,
23395 field,
23396 onChange,
23397 hideLabelFromVision,
23398 markWhenOptional,
23399 type,
23400 prefix,
23401 suffix,
23402 validity
23403 }) {
23404 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
23405 const value = getValue({ item: data });
23406 const disabled2 = field.isDisabled({ item: data, field });
23407 const onChangeControl = (0, import_element58.useCallback)(
23408 (newValue) => onChange(
23409 setValue({
23410 item: data,
23411 value: newValue
23412 })
23413 ),
23414 [data, setValue, onChange]
23415 );
23416 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23417 ValidatedInputControl2,
23418 {
23419 required: !!isValid2.required,
23420 markWhenOptional,
23421 customValidity: getCustomValidity(isValid2, validity),
23422 label,
23423 placeholder,
23424 value: value ?? "",
23425 help: description,
23426 onChange: onChangeControl,
23427 hideLabelFromVision,
23428 type,
23429 prefix,
23430 suffix,
23431 disabled: disabled2,
23432 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
23433 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
23434 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
23435 __next40pxDefaultSize: true
23436 }
23437 );
23438 }
23439
23440 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23441 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
23442 function Email({
23443 data,
23444 field,
23445 onChange,
23446 hideLabelFromVision,
23447 markWhenOptional,
23448 validity
23449 }) {
23450 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
23451 ValidatedText,
23452 {
23453 ...{
23454 data,
23455 field,
23456 onChange,
23457 hideLabelFromVision,
23458 markWhenOptional,
23459 validity,
23460 type: "email",
23461 prefix: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_components34.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_components34.Icon, { icon: envelope_default }) })
23462 }
23463 }
23464 );
23465 }
23466
23467 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
23468 var import_components35 = __toESM(require_components(), 1);
23469 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
23470 function Telephone({
23471 data,
23472 field,
23473 onChange,
23474 hideLabelFromVision,
23475 markWhenOptional,
23476 validity
23477 }) {
23478 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
23479 ValidatedText,
23480 {
23481 ...{
23482 data,
23483 field,
23484 onChange,
23485 hideLabelFromVision,
23486 markWhenOptional,
23487 validity,
23488 type: "tel",
23489 prefix: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_components35.Icon, { icon: mobile_default }) })
23490 }
23491 }
23492 );
23493 }
23494
23495 // packages/dataviews/build-module/components/dataform-controls/url.mjs
23496 var import_components36 = __toESM(require_components(), 1);
23497 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
23498 function Url({
23499 data,
23500 field,
23501 onChange,
23502 hideLabelFromVision,
23503 markWhenOptional,
23504 validity
23505 }) {
23506 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
23507 ValidatedText,
23508 {
23509 ...{
23510 data,
23511 field,
23512 onChange,
23513 hideLabelFromVision,
23514 markWhenOptional,
23515 validity,
23516 type: "url",
23517 prefix: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components36.Icon, { icon: link_default }) })
23518 }
23519 }
23520 );
23521 }
23522
23523 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
23524 var import_components37 = __toESM(require_components(), 1);
23525 var import_element59 = __toESM(require_element(), 1);
23526 var import_i18n40 = __toESM(require_i18n(), 1);
23527 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
23528 var { ValidatedNumberControl } = unlock2(import_components37.privateApis);
23529 function toNumberOrEmpty(value) {
23530 if (value === "" || value === void 0) {
23531 return "";
23532 }
23533 const number = Number(value);
23534 return Number.isFinite(number) ? number : "";
23535 }
23536 function BetweenControls({
23537 value,
23538 onChange,
23539 hideLabelFromVision,
23540 step
23541 }) {
23542 const [min2 = "", max2 = ""] = value;
23543 const onChangeMin = (0, import_element59.useCallback)(
23544 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
23545 [onChange, max2]
23546 );
23547 const onChangeMax = (0, import_element59.useCallback)(
23548 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
23549 [onChange, min2]
23550 );
23551 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
23552 import_components37.BaseControl,
23553 {
23554 help: (0, import_i18n40.__)("The max. value must be greater than the min. value."),
23555 children: /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(import_components37.Flex, { direction: "row", gap: 4, children: [
23556 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
23557 import_components37.__experimentalNumberControl,
23558 {
23559 label: (0, import_i18n40.__)("Min."),
23560 value: min2,
23561 max: max2 ? Number(max2) - step : void 0,
23562 onChange: onChangeMin,
23563 __next40pxDefaultSize: true,
23564 hideLabelFromVision,
23565 step
23566 }
23567 ),
23568 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
23569 import_components37.__experimentalNumberControl,
23570 {
23571 label: (0, import_i18n40.__)("Max."),
23572 value: max2,
23573 min: min2 ? Number(min2) + step : void 0,
23574 onChange: onChangeMax,
23575 __next40pxDefaultSize: true,
23576 hideLabelFromVision,
23577 step
23578 }
23579 )
23580 ] })
23581 }
23582 );
23583 }
23584 function ValidatedNumber({
23585 data,
23586 field,
23587 onChange,
23588 hideLabelFromVision,
23589 markWhenOptional,
23590 operator,
23591 validity
23592 }) {
23593 const decimals = field.format?.decimals ?? 0;
23594 const step = Math.pow(10, Math.abs(decimals) * -1);
23595 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23596 const value = getValue({ item: data }) ?? "";
23597 const disabled2 = field.isDisabled({ item: data, field });
23598 const onChangeControl = (0, import_element59.useCallback)(
23599 (newValue) => {
23600 onChange(
23601 setValue({
23602 item: data,
23603 // Do not convert an empty string or undefined to a number,
23604 // otherwise there's a mismatch between the UI control (empty)
23605 // and the data relied by onChange (0).
23606 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
23607 })
23608 );
23609 },
23610 [data, onChange, setValue]
23611 );
23612 const onChangeBetweenControls = (0, import_element59.useCallback)(
23613 (newValue) => {
23614 onChange(
23615 setValue({
23616 item: data,
23617 value: newValue
23618 })
23619 );
23620 },
23621 [data, onChange, setValue]
23622 );
23623 if (operator === OPERATOR_BETWEEN) {
23624 let valueBetween = ["", ""];
23625 if (Array.isArray(value) && value.length === 2 && value.every(
23626 (element) => typeof element === "number" || element === ""
23627 )) {
23628 valueBetween = value;
23629 }
23630 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
23631 BetweenControls,
23632 {
23633 value: valueBetween,
23634 onChange: onChangeBetweenControls,
23635 hideLabelFromVision,
23636 step
23637 }
23638 );
23639 }
23640 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
23641 ValidatedNumberControl,
23642 {
23643 required: !!isValid2.required,
23644 markWhenOptional,
23645 customValidity: getCustomValidity(isValid2, validity),
23646 label,
23647 help: description,
23648 value,
23649 onChange: onChangeControl,
23650 __next40pxDefaultSize: true,
23651 hideLabelFromVision,
23652 step,
23653 min: isValid2.min ? isValid2.min.constraint : void 0,
23654 max: isValid2.max ? isValid2.max.constraint : void 0,
23655 disabled: disabled2
23656 }
23657 );
23658 }
23659
23660 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
23661 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
23662 function Integer(props) {
23663 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(ValidatedNumber, { ...props });
23664 }
23665
23666 // packages/dataviews/build-module/components/dataform-controls/number.mjs
23667 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
23668 function Number2(props) {
23669 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(ValidatedNumber, { ...props });
23670 }
23671
23672 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
23673 var import_components38 = __toESM(require_components(), 1);
23674 var import_element60 = __toESM(require_element(), 1);
23675 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
23676 var { ValidatedRadioControl } = unlock2(import_components38.privateApis);
23677 function Radio({
23678 data,
23679 field,
23680 onChange,
23681 hideLabelFromVision,
23682 markWhenOptional,
23683 validity
23684 }) {
23685 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23686 const disabled2 = field.isDisabled({ item: data, field });
23687 const { elements, isLoading } = useElements({
23688 elements: field.elements,
23689 getElements: field.getElements
23690 });
23691 const value = getValue({ item: data });
23692 const onChangeControl = (0, import_element60.useCallback)(
23693 (newValue) => onChange(setValue({ item: data, value: newValue })),
23694 [data, onChange, setValue]
23695 );
23696 if (isLoading) {
23697 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_components38.Spinner, {});
23698 }
23699 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
23700 ValidatedRadioControl,
23701 {
23702 required: !!field.isValid?.required,
23703 markWhenOptional,
23704 customValidity: getCustomValidity(isValid2, validity),
23705 label,
23706 help: description,
23707 onChange: onChangeControl,
23708 options: elements,
23709 selected: value,
23710 hideLabelFromVision,
23711 disabled: disabled2
23712 }
23713 );
23714 }
23715
23716 // packages/dataviews/build-module/components/dataform-controls/text.mjs
23717 var import_element61 = __toESM(require_element(), 1);
23718 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
23719 function Text({
23720 data,
23721 field,
23722 onChange,
23723 hideLabelFromVision,
23724 markWhenOptional,
23725 config,
23726 validity
23727 }) {
23728 const { prefix, suffix } = config || {};
23729 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
23730 ValidatedText,
23731 {
23732 ...{
23733 data,
23734 field,
23735 onChange,
23736 hideLabelFromVision,
23737 markWhenOptional,
23738 validity,
23739 prefix: prefix ? (0, import_element61.createElement)(prefix) : void 0,
23740 suffix: suffix ? (0, import_element61.createElement)(suffix) : void 0
23741 }
23742 }
23743 );
23744 }
23745
23746 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
23747 var import_components39 = __toESM(require_components(), 1);
23748 var import_element62 = __toESM(require_element(), 1);
23749 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
23750 var { ValidatedToggleControl } = unlock2(import_components39.privateApis);
23751 function Toggle({
23752 field,
23753 onChange,
23754 data,
23755 hideLabelFromVision,
23756 markWhenOptional,
23757 validity
23758 }) {
23759 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23760 const disabled2 = field.isDisabled({ item: data, field });
23761 const onChangeControl = (0, import_element62.useCallback)(() => {
23762 onChange(
23763 setValue({ item: data, value: !getValue({ item: data }) })
23764 );
23765 }, [onChange, setValue, data, getValue]);
23766 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
23767 ValidatedToggleControl,
23768 {
23769 required: !!isValid2.required,
23770 markWhenOptional,
23771 customValidity: getCustomValidity(isValid2, validity),
23772 hidden: hideLabelFromVision,
23773 label,
23774 help: description,
23775 checked: getValue({ item: data }),
23776 onChange: onChangeControl,
23777 disabled: disabled2
23778 }
23779 );
23780 }
23781
23782 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
23783 var import_components40 = __toESM(require_components(), 1);
23784 var import_element63 = __toESM(require_element(), 1);
23785 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
23786 var { ValidatedTextareaControl } = unlock2(import_components40.privateApis);
23787 function Textarea({
23788 data,
23789 field,
23790 onChange,
23791 hideLabelFromVision,
23792 markWhenOptional,
23793 config,
23794 validity
23795 }) {
23796 const { rows = 4 } = config || {};
23797 const disabled2 = field.isDisabled({ item: data, field });
23798 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
23799 const value = field.getValue({ item: data });
23800 const onChangeControl = (0, import_element63.useCallback)(
23801 (newValue) => onChange(setValue({ item: data, value: newValue })),
23802 [data, onChange, setValue]
23803 );
23804 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
23805 ValidatedTextareaControl,
23806 {
23807 required: !!isValid2.required,
23808 markWhenOptional,
23809 customValidity: getCustomValidity(isValid2, validity),
23810 label,
23811 placeholder,
23812 value: value ?? "",
23813 help: description,
23814 onChange: onChangeControl,
23815 rows,
23816 disabled: disabled2,
23817 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
23818 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
23819 __next40pxDefaultSize: true,
23820 hideLabelFromVision
23821 }
23822 );
23823 }
23824
23825 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
23826 var import_components41 = __toESM(require_components(), 1);
23827 var import_element64 = __toESM(require_element(), 1);
23828 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
23829 var { ValidatedToggleGroupControl } = unlock2(import_components41.privateApis);
23830 function ToggleGroup({
23831 data,
23832 field,
23833 onChange,
23834 hideLabelFromVision,
23835 markWhenOptional,
23836 validity
23837 }) {
23838 const { getValue, setValue, isValid: isValid2 } = field;
23839 const disabled2 = field.isDisabled({ item: data, field });
23840 const value = getValue({ item: data });
23841 const onChangeControl = (0, import_element64.useCallback)(
23842 (newValue) => onChange(setValue({ item: data, value: newValue })),
23843 [data, onChange, setValue]
23844 );
23845 const { elements, isLoading } = useElements({
23846 elements: field.elements,
23847 getElements: field.getElements
23848 });
23849 if (isLoading) {
23850 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(import_components41.Spinner, {});
23851 }
23852 if (elements.length === 0) {
23853 return null;
23854 }
23855 const selectedOption = elements.find((el) => el.value === value);
23856 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
23857 ValidatedToggleGroupControl,
23858 {
23859 required: !!field.isValid?.required,
23860 markWhenOptional,
23861 customValidity: getCustomValidity(isValid2, validity),
23862 __next40pxDefaultSize: true,
23863 isBlock: true,
23864 label: field.label,
23865 help: selectedOption?.description || field.description,
23866 onChange: onChangeControl,
23867 value,
23868 hideLabelFromVision,
23869 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
23870 import_components41.__experimentalToggleGroupControlOption,
23871 {
23872 label: el.label,
23873 value: el.value,
23874 disabled: disabled2
23875 },
23876 el.value
23877 ))
23878 }
23879 );
23880 }
23881
23882 // packages/dataviews/build-module/components/dataform-controls/array.mjs
23883 var import_components42 = __toESM(require_components(), 1);
23884 var import_element65 = __toESM(require_element(), 1);
23885 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
23886 var { ValidatedFormTokenField } = unlock2(import_components42.privateApis);
23887 function ArrayControl({
23888 data,
23889 field,
23890 onChange,
23891 hideLabelFromVision,
23892 markWhenOptional,
23893 validity
23894 }) {
23895 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
23896 const value = getValue({ item: data });
23897 const disabled2 = field.isDisabled({ item: data, field });
23898 const { elements, isLoading } = useElements({
23899 elements: field.elements,
23900 getElements: field.getElements
23901 });
23902 const arrayValueAsElements = (0, import_element65.useMemo)(
23903 () => Array.isArray(value) ? value.map((token) => {
23904 const element = elements?.find(
23905 (suggestion) => suggestion.value === token
23906 );
23907 return element || { value: token, label: token };
23908 }) : [],
23909 [value, elements]
23910 );
23911 const onChangeControl = (0, import_element65.useCallback)(
23912 (tokens) => {
23913 const valueTokens = tokens.map((token) => {
23914 if (typeof token === "object" && "value" in token) {
23915 return token.value;
23916 }
23917 return token;
23918 });
23919 onChange(setValue({ item: data, value: valueTokens }));
23920 },
23921 [onChange, setValue, data]
23922 );
23923 if (isLoading) {
23924 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_components42.Spinner, {});
23925 }
23926 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
23927 ValidatedFormTokenField,
23928 {
23929 required: !!isValid2?.required,
23930 markWhenOptional,
23931 customValidity: getCustomValidity(isValid2, validity),
23932 label: hideLabelFromVision ? void 0 : label,
23933 value: arrayValueAsElements,
23934 onChange: onChangeControl,
23935 placeholder,
23936 suggestions: elements?.map((element) => element.value),
23937 disabled: disabled2,
23938 __experimentalValidateInput: (token) => {
23939 if (field.isValid?.elements && elements) {
23940 return elements.some(
23941 (element) => element.value === token || element.label === token
23942 );
23943 }
23944 return true;
23945 },
23946 __experimentalExpandOnFocus: elements && elements.length > 0,
23947 help: description ?? (field.isValid?.elements ? "" : void 0),
23948 displayTransform: (token) => {
23949 if (typeof token === "object" && "label" in token) {
23950 return token.label;
23951 }
23952 if (typeof token === "string" && elements) {
23953 const element = elements.find(
23954 (el) => el.value === token
23955 );
23956 return element?.label || token;
23957 }
23958 return token;
23959 },
23960 __experimentalRenderItem: ({ item }) => {
23961 if (typeof item === "string" && elements) {
23962 const element = elements.find(
23963 (el) => el.value === item
23964 );
23965 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { children: element?.label || item });
23966 }
23967 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { children: item });
23968 }
23969 }
23970 );
23971 }
23972
23973 // node_modules/colord/index.mjs
23974 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
23975 var t = function(r3) {
23976 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
23977 };
23978 var n = function(r3, t2, n2) {
23979 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
23980 };
23981 var e = function(r3, t2, n2) {
23982 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
23983 };
23984 var u = function(r3) {
23985 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
23986 };
23987 var a = function(r3) {
23988 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
23989 };
23990 var o = function(r3) {
23991 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
23992 };
23993 var i = /^#([0-9a-f]{3,8})$/i;
23994 var s = function(r3) {
23995 var t2 = r3.toString(16);
23996 return t2.length < 2 ? "0" + t2 : t2;
23997 };
23998 var h = function(r3) {
23999 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;
24000 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
24001 };
24002 var b = function(r3) {
24003 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
24004 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
24005 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;
24006 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 };
24007 };
24008 var g = function(r3) {
24009 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
24010 };
24011 var d = function(r3) {
24012 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
24013 };
24014 var f = function(r3) {
24015 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 }));
24016 var t2, n2, e2;
24017 };
24018 var c = function(r3) {
24019 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 };
24020 var t2, n2, e2, u2;
24021 };
24022 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24023 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24024 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24025 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24026 var y = { string: [[function(r3) {
24027 var t2 = i.exec(r3);
24028 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;
24029 }, "hex"], [function(r3) {
24030 var t2 = v.exec(r3) || m.exec(r3);
24031 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;
24032 }, "rgb"], [function(t2) {
24033 var n2 = l.exec(t2) || p.exec(t2);
24034 if (!n2) return null;
24035 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) });
24036 return f(a2);
24037 }, "hsl"]], object: [[function(r3) {
24038 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
24039 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
24040 }, "rgb"], [function(r3) {
24041 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
24042 if (!t(n2) || !t(e2) || !t(u2)) return null;
24043 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
24044 return f(i2);
24045 }, "hsl"], [function(r3) {
24046 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
24047 if (!t(n2) || !t(a2) || !t(o2)) return null;
24048 var h2 = (function(r4) {
24049 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
24050 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
24051 return b(h2);
24052 }, "hsv"]] };
24053 var N = function(r3, t2) {
24054 for (var n2 = 0; n2 < t2.length; n2++) {
24055 var e2 = t2[n2][0](r3);
24056 if (e2) return [e2, t2[n2][1]];
24057 }
24058 return [null, void 0];
24059 };
24060 var x = function(r3) {
24061 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
24062 };
24063 var M = function(r3, t2) {
24064 var n2 = c(r3);
24065 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
24066 };
24067 var H = function(r3) {
24068 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
24069 };
24070 var $ = function(r3, t2) {
24071 var n2 = c(r3);
24072 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
24073 };
24074 var j = (function() {
24075 function r3(r4) {
24076 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
24077 }
24078 return r3.prototype.isValid = function() {
24079 return null !== this.parsed;
24080 }, r3.prototype.brightness = function() {
24081 return n(H(this.rgba), 2);
24082 }, r3.prototype.isDark = function() {
24083 return H(this.rgba) < 0.5;
24084 }, r3.prototype.isLight = function() {
24085 return H(this.rgba) >= 0.5;
24086 }, r3.prototype.toHex = function() {
24087 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;
24088 var r4, t2, e2, u2, a2, i2;
24089 }, r3.prototype.toRgb = function() {
24090 return o(this.rgba);
24091 }, r3.prototype.toRgbString = function() {
24092 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 + ")";
24093 var r4, t2, n2, e2, u2;
24094 }, r3.prototype.toHsl = function() {
24095 return d(c(this.rgba));
24096 }, r3.prototype.toHslString = function() {
24097 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 + "%)";
24098 var r4, t2, n2, e2, u2;
24099 }, r3.prototype.toHsv = function() {
24100 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
24101 var r4;
24102 }, r3.prototype.invert = function() {
24103 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
24104 var r4;
24105 }, r3.prototype.saturate = function(r4) {
24106 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
24107 }, r3.prototype.desaturate = function(r4) {
24108 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
24109 }, r3.prototype.grayscale = function() {
24110 return w(M(this.rgba, -1));
24111 }, r3.prototype.lighten = function(r4) {
24112 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
24113 }, r3.prototype.darken = function(r4) {
24114 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
24115 }, r3.prototype.rotate = function(r4) {
24116 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
24117 }, r3.prototype.alpha = function(r4) {
24118 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
24119 var t2;
24120 }, r3.prototype.hue = function(r4) {
24121 var t2 = c(this.rgba);
24122 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
24123 }, r3.prototype.isEqual = function(r4) {
24124 return this.toHex() === w(r4).toHex();
24125 }, r3;
24126 })();
24127 var w = function(r3) {
24128 return r3 instanceof j ? r3 : new j(r3);
24129 };
24130
24131 // packages/dataviews/build-module/components/dataform-controls/color.mjs
24132 var import_components43 = __toESM(require_components(), 1);
24133 var import_element66 = __toESM(require_element(), 1);
24134 var import_i18n41 = __toESM(require_i18n(), 1);
24135 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
24136 var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components43.privateApis);
24137 var ColorPickerDropdown = ({
24138 color,
24139 onColorChange,
24140 disabled: disabled2
24141 }) => {
24142 const validColor = color && w(color).isValid() ? color : "#ffffff";
24143 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
24144 import_components43.Dropdown,
24145 {
24146 className: "dataviews-controls__color-picker-dropdown",
24147 popoverProps: { resize: false },
24148 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
24149 import_components43.Button,
24150 {
24151 onClick: onToggle,
24152 "aria-label": (0, import_i18n41.__)("Open color picker"),
24153 size: "small",
24154 disabled: disabled2,
24155 accessibleWhenDisabled: true,
24156 icon: () => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_components43.ColorIndicator, { colorValue: validColor })
24157 }
24158 ),
24159 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_components43.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
24160 import_components43.ColorPicker,
24161 {
24162 color: validColor,
24163 onChange: onColorChange,
24164 enableAlpha: true
24165 }
24166 ) })
24167 }
24168 );
24169 };
24170 function Color({
24171 data,
24172 field,
24173 onChange,
24174 hideLabelFromVision,
24175 markWhenOptional,
24176 validity
24177 }) {
24178 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24179 const disabled2 = field.isDisabled({ item: data, field });
24180 const value = field.getValue({ item: data }) || "";
24181 const handleColorChange = (0, import_element66.useCallback)(
24182 (newColor) => {
24183 onChange(setValue({ item: data, value: newColor }));
24184 },
24185 [data, onChange, setValue]
24186 );
24187 const handleInputChange = (0, import_element66.useCallback)(
24188 (newValue) => {
24189 onChange(setValue({ item: data, value: newValue || "" }));
24190 },
24191 [data, onChange, setValue]
24192 );
24193 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
24194 ValidatedInputControl3,
24195 {
24196 required: !!field.isValid?.required,
24197 markWhenOptional,
24198 customValidity: getCustomValidity(isValid2, validity),
24199 label,
24200 placeholder,
24201 value,
24202 help: description,
24203 onChange: handleInputChange,
24204 hideLabelFromVision,
24205 type: "text",
24206 disabled: disabled2,
24207 prefix: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_components43.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
24208 ColorPickerDropdown,
24209 {
24210 color: value,
24211 onColorChange: handleColorChange,
24212 disabled: disabled2
24213 }
24214 ) })
24215 }
24216 );
24217 }
24218
24219 // packages/dataviews/build-module/components/dataform-controls/password.mjs
24220 var import_components44 = __toESM(require_components(), 1);
24221 var import_element67 = __toESM(require_element(), 1);
24222 var import_i18n42 = __toESM(require_i18n(), 1);
24223 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
24224 function Password({
24225 data,
24226 field,
24227 onChange,
24228 hideLabelFromVision,
24229 markWhenOptional,
24230 validity
24231 }) {
24232 const [isVisible2, setIsVisible] = (0, import_element67.useState)(false);
24233 const disabled2 = field.isDisabled({ item: data, field });
24234 const toggleVisibility = (0, import_element67.useCallback)(() => {
24235 setIsVisible((prev) => !prev);
24236 }, []);
24237 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24238 ValidatedText,
24239 {
24240 ...{
24241 data,
24242 field,
24243 onChange,
24244 hideLabelFromVision,
24245 markWhenOptional,
24246 validity,
24247 type: isVisible2 ? "text" : "password",
24248 suffix: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components44.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24249 import_components44.Button,
24250 {
24251 icon: isVisible2 ? unseen_default : seen_default,
24252 onClick: toggleVisibility,
24253 size: "small",
24254 label: isVisible2 ? (0, import_i18n42.__)("Hide password") : (0, import_i18n42.__)("Show password"),
24255 disabled: disabled2,
24256 accessibleWhenDisabled: true
24257 }
24258 ) })
24259 }
24260 }
24261 );
24262 }
24263
24264 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
24265 function hasElements(field) {
24266 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
24267 }
24268
24269 // packages/dataviews/build-module/components/dataform-controls/index.mjs
24270 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
24271 var FORM_CONTROLS = {
24272 adaptiveSelect: AdaptiveSelect,
24273 array: ArrayControl,
24274 checkbox: Checkbox,
24275 color: Color,
24276 combobox: Combobox3,
24277 datetime: DateTime,
24278 date: DateControl,
24279 email: Email,
24280 telephone: Telephone,
24281 url: Url,
24282 integer: Integer,
24283 number: Number2,
24284 password: Password,
24285 radio: Radio,
24286 select: Select,
24287 text: Text,
24288 toggle: Toggle,
24289 textarea: Textarea,
24290 toggleGroup: ToggleGroup
24291 };
24292 function isEditConfig(value) {
24293 return value && typeof value === "object" && typeof value.control === "string";
24294 }
24295 function createConfiguredControl(config) {
24296 const { control, ...controlConfig } = config;
24297 const BaseControlType = getControlByType(control);
24298 if (BaseControlType === null) {
24299 return null;
24300 }
24301 return function ConfiguredControl(props) {
24302 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(BaseControlType, { ...props, config: controlConfig });
24303 };
24304 }
24305 function getControl(field, fallback) {
24306 if (typeof field.Edit === "function") {
24307 return field.Edit;
24308 }
24309 if (typeof field.Edit === "string") {
24310 return getControlByType(field.Edit);
24311 }
24312 if (isEditConfig(field.Edit)) {
24313 return createConfiguredControl(field.Edit);
24314 }
24315 if (hasElements(field) && field.type !== "array") {
24316 return getControlByType("adaptiveSelect");
24317 }
24318 if (fallback === null) {
24319 return null;
24320 }
24321 return getControlByType(fallback);
24322 }
24323 function getControlByType(type) {
24324 if (Object.keys(FORM_CONTROLS).includes(type)) {
24325 return FORM_CONTROLS[type];
24326 }
24327 return null;
24328 }
24329
24330 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
24331 function getFilterBy(field, defaultOperators, validOperators) {
24332 if (field.filterBy === false) {
24333 return false;
24334 }
24335 const operators = field.filterBy?.operators?.filter(
24336 (op) => validOperators.includes(op)
24337 ) ?? defaultOperators;
24338 if (operators.length === 0) {
24339 return false;
24340 }
24341 return {
24342 isPrimary: !!field.filterBy?.isPrimary,
24343 operators
24344 };
24345 }
24346 var get_filter_by_default = getFilterBy;
24347
24348 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
24349 var getValueFromId = (id) => ({ item }) => {
24350 const path = id.split(".");
24351 let value = item;
24352 for (const segment of path) {
24353 if (value.hasOwnProperty(segment)) {
24354 value = value[segment];
24355 } else {
24356 value = void 0;
24357 }
24358 }
24359 return value;
24360 };
24361 var get_value_from_id_default = getValueFromId;
24362
24363 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
24364 var setValueFromId = (id) => ({ value }) => {
24365 const path = id.split(".");
24366 const result = {};
24367 let current = result;
24368 for (const segment of path.slice(0, -1)) {
24369 current[segment] = {};
24370 current = current[segment];
24371 }
24372 current[path.at(-1)] = value;
24373 return result;
24374 };
24375 var set_value_from_id_default = setValueFromId;
24376
24377 // packages/dataviews/build-module/field-types/email.mjs
24378 var import_i18n43 = __toESM(require_i18n(), 1);
24379
24380 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
24381 function RenderFromElements({
24382 item,
24383 field
24384 }) {
24385 const { elements, isLoading } = useElements({
24386 elements: field.elements,
24387 getElements: field.getElements
24388 });
24389 const value = field.getValue({ item });
24390 if (isLoading) {
24391 return value;
24392 }
24393 if (elements.length === 0) {
24394 return value;
24395 }
24396 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
24397 }
24398
24399 // packages/dataviews/build-module/field-types/utils/render-default.mjs
24400 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
24401 function render({
24402 item,
24403 field
24404 }) {
24405 if (field.hasElements) {
24406 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(RenderFromElements, { item, field });
24407 }
24408 return field.getValueFormatted({ item, field });
24409 }
24410
24411 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
24412 var sort_text_default = (a2, b2, direction) => {
24413 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
24414 };
24415
24416 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
24417 function isValidRequired(item, field) {
24418 const value = field.getValue({ item });
24419 return ![void 0, "", null].includes(value);
24420 }
24421
24422 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
24423 function isValidMinLength(item, field) {
24424 if (typeof field.isValid.minLength?.constraint !== "number") {
24425 return false;
24426 }
24427 const value = field.getValue({ item });
24428 if ([void 0, "", null].includes(value)) {
24429 return true;
24430 }
24431 return String(value).length >= field.isValid.minLength.constraint;
24432 }
24433
24434 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
24435 function isValidMaxLength(item, field) {
24436 if (typeof field.isValid.maxLength?.constraint !== "number") {
24437 return false;
24438 }
24439 const value = field.getValue({ item });
24440 if ([void 0, "", null].includes(value)) {
24441 return true;
24442 }
24443 return String(value).length <= field.isValid.maxLength.constraint;
24444 }
24445
24446 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
24447 function isValidPattern(item, field) {
24448 if (field.isValid.pattern?.constraint === void 0) {
24449 return true;
24450 }
24451 try {
24452 const regexp = new RegExp(field.isValid.pattern.constraint);
24453 const value = field.getValue({ item });
24454 if ([void 0, "", null].includes(value)) {
24455 return true;
24456 }
24457 return regexp.test(String(value));
24458 } catch {
24459 return false;
24460 }
24461 }
24462
24463 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
24464 function isValidElements(item, field) {
24465 const elements = field.elements ?? [];
24466 const validValues = elements.map((el) => el.value);
24467 if (validValues.length === 0) {
24468 return true;
24469 }
24470 const value = field.getValue({ item });
24471 return [].concat(value).every((v2) => validValues.includes(v2));
24472 }
24473
24474 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
24475 function getValueFormatted({
24476 item,
24477 field
24478 }) {
24479 return field.getValue({ item });
24480 }
24481 var get_value_formatted_default_default = getValueFormatted;
24482
24483 // packages/dataviews/build-module/field-types/email.mjs
24484 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])?)*$/;
24485 function isValidCustom(item, field) {
24486 const value = field.getValue({ item });
24487 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
24488 return (0, import_i18n43.__)("Value must be a valid email address.");
24489 }
24490 return null;
24491 }
24492 var email_default = {
24493 type: "email",
24494 render,
24495 Edit: "email",
24496 sort: sort_text_default,
24497 enableSorting: true,
24498 enableGlobalSearch: false,
24499 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24500 validOperators: [
24501 OPERATOR_IS,
24502 OPERATOR_IS_NOT,
24503 OPERATOR_CONTAINS,
24504 OPERATOR_NOT_CONTAINS,
24505 OPERATOR_STARTS_WITH,
24506 // Multiple selection
24507 OPERATOR_IS_ANY,
24508 OPERATOR_IS_NONE,
24509 OPERATOR_IS_ALL,
24510 OPERATOR_IS_NOT_ALL
24511 ],
24512 format: {},
24513 getValueFormatted: get_value_formatted_default_default,
24514 validate: {
24515 required: isValidRequired,
24516 pattern: isValidPattern,
24517 minLength: isValidMinLength,
24518 maxLength: isValidMaxLength,
24519 elements: isValidElements,
24520 custom: isValidCustom
24521 }
24522 };
24523
24524 // packages/dataviews/build-module/field-types/integer.mjs
24525 var import_i18n44 = __toESM(require_i18n(), 1);
24526
24527 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
24528 var sort_number_default = (a2, b2, direction) => {
24529 return direction === "asc" ? a2 - b2 : b2 - a2;
24530 };
24531
24532 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
24533 function isValidMin(item, field) {
24534 if (typeof field.isValid.min?.constraint !== "number") {
24535 return false;
24536 }
24537 const value = field.getValue({ item });
24538 if ([void 0, "", null].includes(value)) {
24539 return true;
24540 }
24541 return Number(value) >= field.isValid.min.constraint;
24542 }
24543
24544 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
24545 function isValidMax(item, field) {
24546 if (typeof field.isValid.max?.constraint !== "number") {
24547 return false;
24548 }
24549 const value = field.getValue({ item });
24550 if ([void 0, "", null].includes(value)) {
24551 return true;
24552 }
24553 return Number(value) <= field.isValid.max.constraint;
24554 }
24555
24556 // packages/dataviews/build-module/field-types/integer.mjs
24557 var format2 = {
24558 separatorThousand: ","
24559 };
24560 function getValueFormatted2({
24561 item,
24562 field
24563 }) {
24564 let value = field.getValue({ item });
24565 if (value === null || value === void 0) {
24566 return "";
24567 }
24568 value = Number(value);
24569 if (!Number.isFinite(value)) {
24570 return String(value);
24571 }
24572 let formatInteger;
24573 if (field.type !== "integer") {
24574 formatInteger = format2;
24575 } else {
24576 formatInteger = field.format;
24577 }
24578 const { separatorThousand } = formatInteger;
24579 const integerValue = Math.trunc(value);
24580 if (!separatorThousand) {
24581 return String(integerValue);
24582 }
24583 return String(integerValue).replace(
24584 /\B(?=(\d{3})+(?!\d))/g,
24585 separatorThousand
24586 );
24587 }
24588 function isValidCustom2(item, field) {
24589 const value = field.getValue({ item });
24590 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
24591 return (0, import_i18n44.__)("Value must be an integer.");
24592 }
24593 return null;
24594 }
24595 var integer_default = {
24596 type: "integer",
24597 render,
24598 Edit: "integer",
24599 sort: sort_number_default,
24600 enableSorting: true,
24601 enableGlobalSearch: false,
24602 defaultOperators: [
24603 OPERATOR_IS,
24604 OPERATOR_IS_NOT,
24605 OPERATOR_LESS_THAN,
24606 OPERATOR_GREATER_THAN,
24607 OPERATOR_LESS_THAN_OR_EQUAL,
24608 OPERATOR_GREATER_THAN_OR_EQUAL,
24609 OPERATOR_BETWEEN
24610 ],
24611 validOperators: [
24612 // Single-selection
24613 OPERATOR_IS,
24614 OPERATOR_IS_NOT,
24615 OPERATOR_LESS_THAN,
24616 OPERATOR_GREATER_THAN,
24617 OPERATOR_LESS_THAN_OR_EQUAL,
24618 OPERATOR_GREATER_THAN_OR_EQUAL,
24619 OPERATOR_BETWEEN,
24620 // Multiple-selection
24621 OPERATOR_IS_ANY,
24622 OPERATOR_IS_NONE,
24623 OPERATOR_IS_ALL,
24624 OPERATOR_IS_NOT_ALL
24625 ],
24626 format: format2,
24627 getValueFormatted: getValueFormatted2,
24628 validate: {
24629 required: isValidRequired,
24630 min: isValidMin,
24631 max: isValidMax,
24632 elements: isValidElements,
24633 custom: isValidCustom2
24634 }
24635 };
24636
24637 // packages/dataviews/build-module/field-types/number.mjs
24638 var import_i18n45 = __toESM(require_i18n(), 1);
24639 var format3 = {
24640 separatorThousand: ",",
24641 separatorDecimal: ".",
24642 decimals: 2
24643 };
24644 function getValueFormatted3({
24645 item,
24646 field
24647 }) {
24648 let value = field.getValue({ item });
24649 if (value === null || value === void 0) {
24650 return "";
24651 }
24652 value = Number(value);
24653 if (!Number.isFinite(value)) {
24654 return String(value);
24655 }
24656 let formatNumber;
24657 if (field.type !== "number") {
24658 formatNumber = format3;
24659 } else {
24660 formatNumber = field.format;
24661 }
24662 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
24663 const fixedValue = value.toFixed(decimals);
24664 const [integerPart, decimalPart] = fixedValue.split(".");
24665 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
24666 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
24667 }
24668 function isEmpty2(value) {
24669 return value === "" || value === void 0 || value === null;
24670 }
24671 function isValidCustom3(item, field) {
24672 const value = field.getValue({ item });
24673 if (!isEmpty2(value) && !Number.isFinite(value)) {
24674 return (0, import_i18n45.__)("Value must be a number.");
24675 }
24676 return null;
24677 }
24678 var number_default = {
24679 type: "number",
24680 render,
24681 Edit: "number",
24682 sort: sort_number_default,
24683 enableSorting: true,
24684 enableGlobalSearch: false,
24685 defaultOperators: [
24686 OPERATOR_IS,
24687 OPERATOR_IS_NOT,
24688 OPERATOR_LESS_THAN,
24689 OPERATOR_GREATER_THAN,
24690 OPERATOR_LESS_THAN_OR_EQUAL,
24691 OPERATOR_GREATER_THAN_OR_EQUAL,
24692 OPERATOR_BETWEEN
24693 ],
24694 validOperators: [
24695 // Single-selection
24696 OPERATOR_IS,
24697 OPERATOR_IS_NOT,
24698 OPERATOR_LESS_THAN,
24699 OPERATOR_GREATER_THAN,
24700 OPERATOR_LESS_THAN_OR_EQUAL,
24701 OPERATOR_GREATER_THAN_OR_EQUAL,
24702 OPERATOR_BETWEEN,
24703 // Multiple-selection
24704 OPERATOR_IS_ANY,
24705 OPERATOR_IS_NONE,
24706 OPERATOR_IS_ALL,
24707 OPERATOR_IS_NOT_ALL
24708 ],
24709 format: format3,
24710 getValueFormatted: getValueFormatted3,
24711 validate: {
24712 required: isValidRequired,
24713 min: isValidMin,
24714 max: isValidMax,
24715 elements: isValidElements,
24716 custom: isValidCustom3
24717 }
24718 };
24719
24720 // packages/dataviews/build-module/field-types/text.mjs
24721 var text_default = {
24722 type: "text",
24723 render,
24724 Edit: "text",
24725 sort: sort_text_default,
24726 enableSorting: true,
24727 enableGlobalSearch: false,
24728 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24729 validOperators: [
24730 // Single selection
24731 OPERATOR_IS,
24732 OPERATOR_IS_NOT,
24733 OPERATOR_CONTAINS,
24734 OPERATOR_NOT_CONTAINS,
24735 OPERATOR_STARTS_WITH,
24736 // Multiple selection
24737 OPERATOR_IS_ANY,
24738 OPERATOR_IS_NONE,
24739 OPERATOR_IS_ALL,
24740 OPERATOR_IS_NOT_ALL
24741 ],
24742 format: {},
24743 getValueFormatted: get_value_formatted_default_default,
24744 validate: {
24745 required: isValidRequired,
24746 pattern: isValidPattern,
24747 minLength: isValidMinLength,
24748 maxLength: isValidMaxLength,
24749 elements: isValidElements
24750 }
24751 };
24752
24753 // packages/dataviews/build-module/field-types/datetime.mjs
24754 var import_date7 = __toESM(require_date(), 1);
24755
24756 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
24757 var import_date6 = __toESM(require_date(), 1);
24758 function parseDateLike(value) {
24759 if (!value) {
24760 return null;
24761 }
24762 if (!isValid(new Date(value))) {
24763 return null;
24764 }
24765 const parsed = (0, import_date6.getDate)(value);
24766 return parsed && isValid(parsed) ? parsed : null;
24767 }
24768 function validateDateLikeBoundary(item, field, boundary) {
24769 const constraint = field.isValid[boundary]?.constraint;
24770 if (typeof constraint !== "string") {
24771 return false;
24772 }
24773 const value = field.getValue({ item });
24774 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
24775 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
24776 return true;
24777 }
24778 const parsedConstraint = parseDateLike(constraint);
24779 const parsedValue = parseDateLike(String(boundaryValue));
24780 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
24781 }
24782 function isValidMinDate(item, field) {
24783 return validateDateLikeBoundary(item, field, "min");
24784 }
24785 function isValidMaxDate(item, field) {
24786 return validateDateLikeBoundary(item, field, "max");
24787 }
24788
24789 // packages/dataviews/build-module/field-types/datetime.mjs
24790 var format4 = {
24791 datetime: (0, import_date7.getSettings)().formats.datetime,
24792 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
24793 };
24794 function getValueFormatted4({
24795 item,
24796 field
24797 }) {
24798 const value = field.getValue({ item });
24799 if (["", void 0, null].includes(value)) {
24800 return "";
24801 }
24802 let formatDatetime;
24803 if (field.type !== "datetime") {
24804 formatDatetime = format4;
24805 } else {
24806 formatDatetime = field.format;
24807 }
24808 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
24809 }
24810 var sort = (a2, b2, direction) => {
24811 const timeA = new Date(a2).getTime();
24812 const timeB = new Date(b2).getTime();
24813 return direction === "asc" ? timeA - timeB : timeB - timeA;
24814 };
24815 var datetime_default = {
24816 type: "datetime",
24817 render,
24818 Edit: "datetime",
24819 sort,
24820 enableSorting: true,
24821 enableGlobalSearch: false,
24822 defaultOperators: [
24823 OPERATOR_ON,
24824 OPERATOR_NOT_ON,
24825 OPERATOR_BEFORE,
24826 OPERATOR_AFTER,
24827 OPERATOR_BEFORE_INC,
24828 OPERATOR_AFTER_INC,
24829 OPERATOR_IN_THE_PAST,
24830 OPERATOR_OVER
24831 ],
24832 validOperators: [
24833 OPERATOR_ON,
24834 OPERATOR_NOT_ON,
24835 OPERATOR_BEFORE,
24836 OPERATOR_AFTER,
24837 OPERATOR_BEFORE_INC,
24838 OPERATOR_AFTER_INC,
24839 OPERATOR_IN_THE_PAST,
24840 OPERATOR_OVER
24841 ],
24842 format: format4,
24843 getValueFormatted: getValueFormatted4,
24844 validate: {
24845 required: isValidRequired,
24846 elements: isValidElements,
24847 min: isValidMinDate,
24848 max: isValidMaxDate
24849 }
24850 };
24851
24852 // packages/dataviews/build-module/field-types/date.mjs
24853 var import_date8 = __toESM(require_date(), 1);
24854 var format5 = {
24855 date: (0, import_date8.getSettings)().formats.date,
24856 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
24857 };
24858 function getValueFormatted5({
24859 item,
24860 field
24861 }) {
24862 const value = field.getValue({ item });
24863 if (["", void 0, null].includes(value)) {
24864 return "";
24865 }
24866 let formatDate2;
24867 if (field.type !== "date") {
24868 formatDate2 = format5;
24869 } else {
24870 formatDate2 = field.format;
24871 }
24872 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
24873 }
24874 var sort2 = (a2, b2, direction) => {
24875 const timeA = new Date(a2).getTime();
24876 const timeB = new Date(b2).getTime();
24877 return direction === "asc" ? timeA - timeB : timeB - timeA;
24878 };
24879 var date_default = {
24880 type: "date",
24881 render,
24882 Edit: "date",
24883 sort: sort2,
24884 enableSorting: true,
24885 enableGlobalSearch: false,
24886 defaultOperators: [
24887 OPERATOR_ON,
24888 OPERATOR_NOT_ON,
24889 OPERATOR_BEFORE,
24890 OPERATOR_AFTER,
24891 OPERATOR_BEFORE_INC,
24892 OPERATOR_AFTER_INC,
24893 OPERATOR_IN_THE_PAST,
24894 OPERATOR_OVER,
24895 OPERATOR_BETWEEN
24896 ],
24897 validOperators: [
24898 OPERATOR_ON,
24899 OPERATOR_NOT_ON,
24900 OPERATOR_BEFORE,
24901 OPERATOR_AFTER,
24902 OPERATOR_BEFORE_INC,
24903 OPERATOR_AFTER_INC,
24904 OPERATOR_IN_THE_PAST,
24905 OPERATOR_OVER,
24906 OPERATOR_BETWEEN
24907 ],
24908 format: format5,
24909 getValueFormatted: getValueFormatted5,
24910 validate: {
24911 required: isValidRequired,
24912 elements: isValidElements,
24913 min: isValidMinDate,
24914 max: isValidMaxDate
24915 }
24916 };
24917
24918 // packages/dataviews/build-module/field-types/boolean.mjs
24919 var import_i18n46 = __toESM(require_i18n(), 1);
24920
24921 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
24922 function isValidRequiredForBool(item, field) {
24923 const value = field.getValue({ item });
24924 return value === true;
24925 }
24926
24927 // packages/dataviews/build-module/field-types/boolean.mjs
24928 function getValueFormatted6({
24929 item,
24930 field
24931 }) {
24932 const value = field.getValue({ item });
24933 if (value === true) {
24934 return (0, import_i18n46.__)("True");
24935 }
24936 if (value === false) {
24937 return (0, import_i18n46.__)("False");
24938 }
24939 return "";
24940 }
24941 function isValidCustom4(item, field) {
24942 const value = field.getValue({ item });
24943 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
24944 return (0, import_i18n46.__)("Value must be true, false, or undefined");
24945 }
24946 return null;
24947 }
24948 var sort3 = (a2, b2, direction) => {
24949 const boolA = Boolean(a2);
24950 const boolB = Boolean(b2);
24951 if (boolA === boolB) {
24952 return 0;
24953 }
24954 if (direction === "asc") {
24955 return boolA ? 1 : -1;
24956 }
24957 return boolA ? -1 : 1;
24958 };
24959 var boolean_default = {
24960 type: "boolean",
24961 render,
24962 Edit: "checkbox",
24963 sort: sort3,
24964 validate: {
24965 required: isValidRequiredForBool,
24966 elements: isValidElements,
24967 custom: isValidCustom4
24968 },
24969 enableSorting: true,
24970 enableGlobalSearch: false,
24971 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
24972 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
24973 format: {},
24974 getValueFormatted: getValueFormatted6
24975 };
24976
24977 // packages/dataviews/build-module/field-types/media.mjs
24978 var media_default = {
24979 type: "media",
24980 render: () => null,
24981 Edit: null,
24982 sort: () => 0,
24983 enableSorting: false,
24984 enableGlobalSearch: false,
24985 defaultOperators: [],
24986 validOperators: [],
24987 format: {},
24988 getValueFormatted: get_value_formatted_default_default,
24989 // cannot validate any constraint, so
24990 // the only available validation for the field author
24991 // would be providing a custom validator.
24992 validate: {}
24993 };
24994
24995 // packages/dataviews/build-module/field-types/array.mjs
24996 var import_i18n47 = __toESM(require_i18n(), 1);
24997
24998 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
24999 function isValidRequiredForArray(item, field) {
25000 const value = field.getValue({ item });
25001 return Array.isArray(value) && value.length > 0 && value.every(
25002 (element) => ![void 0, "", null].includes(element)
25003 );
25004 }
25005
25006 // packages/dataviews/build-module/field-types/array.mjs
25007 function getValueFormatted7({
25008 item,
25009 field
25010 }) {
25011 const value = field.getValue({ item });
25012 const arr = Array.isArray(value) ? value : [];
25013 return arr.join(", ");
25014 }
25015 function render2({ item, field }) {
25016 return getValueFormatted7({ item, field });
25017 }
25018 function isValidCustom5(item, field) {
25019 const value = field.getValue({ item });
25020 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
25021 return (0, import_i18n47.__)("Value must be an array.");
25022 }
25023 if (!value.every((v2) => typeof v2 === "string")) {
25024 return (0, import_i18n47.__)("Every value must be a string.");
25025 }
25026 return null;
25027 }
25028 var sort4 = (a2, b2, direction) => {
25029 const arrA = Array.isArray(a2) ? a2 : [];
25030 const arrB = Array.isArray(b2) ? b2 : [];
25031 if (arrA.length !== arrB.length) {
25032 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
25033 }
25034 const joinedA = arrA.join(",");
25035 const joinedB = arrB.join(",");
25036 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
25037 };
25038 var array_default = {
25039 type: "array",
25040 render: render2,
25041 Edit: "array",
25042 sort: sort4,
25043 enableSorting: true,
25044 enableGlobalSearch: false,
25045 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25046 validOperators: [
25047 OPERATOR_IS_ANY,
25048 OPERATOR_IS_NONE,
25049 OPERATOR_IS_ALL,
25050 OPERATOR_IS_NOT_ALL
25051 ],
25052 format: {},
25053 getValueFormatted: getValueFormatted7,
25054 validate: {
25055 required: isValidRequiredForArray,
25056 elements: isValidElements,
25057 custom: isValidCustom5
25058 }
25059 };
25060
25061 // packages/dataviews/build-module/field-types/password.mjs
25062 function getValueFormatted8({
25063 item,
25064 field
25065 }) {
25066 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
25067 }
25068 var password_default = {
25069 type: "password",
25070 render,
25071 Edit: "password",
25072 sort: () => 0,
25073 // Passwords should not be sortable for security reasons
25074 enableSorting: false,
25075 enableGlobalSearch: false,
25076 defaultOperators: [],
25077 validOperators: [],
25078 format: {},
25079 getValueFormatted: getValueFormatted8,
25080 validate: {
25081 required: isValidRequired,
25082 pattern: isValidPattern,
25083 minLength: isValidMinLength,
25084 maxLength: isValidMaxLength,
25085 elements: isValidElements
25086 }
25087 };
25088
25089 // packages/dataviews/build-module/field-types/telephone.mjs
25090 var telephone_default = {
25091 type: "telephone",
25092 render,
25093 Edit: "telephone",
25094 sort: sort_text_default,
25095 enableSorting: true,
25096 enableGlobalSearch: false,
25097 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25098 validOperators: [
25099 OPERATOR_IS,
25100 OPERATOR_IS_NOT,
25101 OPERATOR_CONTAINS,
25102 OPERATOR_NOT_CONTAINS,
25103 OPERATOR_STARTS_WITH,
25104 // Multiple selection
25105 OPERATOR_IS_ANY,
25106 OPERATOR_IS_NONE,
25107 OPERATOR_IS_ALL,
25108 OPERATOR_IS_NOT_ALL
25109 ],
25110 format: {},
25111 getValueFormatted: get_value_formatted_default_default,
25112 validate: {
25113 required: isValidRequired,
25114 pattern: isValidPattern,
25115 minLength: isValidMinLength,
25116 maxLength: isValidMaxLength,
25117 elements: isValidElements
25118 }
25119 };
25120
25121 // packages/dataviews/build-module/field-types/color.mjs
25122 var import_i18n48 = __toESM(require_i18n(), 1);
25123 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
25124 function render3({ item, field }) {
25125 if (field.hasElements) {
25126 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(RenderFromElements, { item, field });
25127 }
25128 const value = get_value_formatted_default_default({ item, field });
25129 if (!value || !w(value).isValid()) {
25130 return value;
25131 }
25132 return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
25133 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25134 "div",
25135 {
25136 style: {
25137 width: "16px",
25138 height: "16px",
25139 borderRadius: "50%",
25140 backgroundColor: value,
25141 border: "1px solid #ddd",
25142 flexShrink: 0
25143 }
25144 }
25145 ),
25146 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)("span", { children: value })
25147 ] });
25148 }
25149 function isValidCustom6(item, field) {
25150 const value = field.getValue({ item });
25151 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
25152 return (0, import_i18n48.__)("Value must be a valid color.");
25153 }
25154 return null;
25155 }
25156 var sort5 = (a2, b2, direction) => {
25157 const colorA = w(a2);
25158 const colorB = w(b2);
25159 if (!colorA.isValid() && !colorB.isValid()) {
25160 return 0;
25161 }
25162 if (!colorA.isValid()) {
25163 return direction === "asc" ? 1 : -1;
25164 }
25165 if (!colorB.isValid()) {
25166 return direction === "asc" ? -1 : 1;
25167 }
25168 const hslA = colorA.toHsl();
25169 const hslB = colorB.toHsl();
25170 if (hslA.h !== hslB.h) {
25171 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
25172 }
25173 if (hslA.s !== hslB.s) {
25174 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
25175 }
25176 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
25177 };
25178 var color_default = {
25179 type: "color",
25180 render: render3,
25181 Edit: "color",
25182 sort: sort5,
25183 enableSorting: true,
25184 enableGlobalSearch: false,
25185 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25186 validOperators: [
25187 OPERATOR_IS,
25188 OPERATOR_IS_NOT,
25189 OPERATOR_IS_ANY,
25190 OPERATOR_IS_NONE
25191 ],
25192 format: {},
25193 getValueFormatted: get_value_formatted_default_default,
25194 validate: {
25195 required: isValidRequired,
25196 elements: isValidElements,
25197 custom: isValidCustom6
25198 }
25199 };
25200
25201 // packages/dataviews/build-module/field-types/url.mjs
25202 var url_default = {
25203 type: "url",
25204 render,
25205 Edit: "url",
25206 sort: sort_text_default,
25207 enableSorting: true,
25208 enableGlobalSearch: false,
25209 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25210 validOperators: [
25211 OPERATOR_IS,
25212 OPERATOR_IS_NOT,
25213 OPERATOR_CONTAINS,
25214 OPERATOR_NOT_CONTAINS,
25215 OPERATOR_STARTS_WITH,
25216 // Multiple selection
25217 OPERATOR_IS_ANY,
25218 OPERATOR_IS_NONE,
25219 OPERATOR_IS_ALL,
25220 OPERATOR_IS_NOT_ALL
25221 ],
25222 format: {},
25223 getValueFormatted: get_value_formatted_default_default,
25224 validate: {
25225 required: isValidRequired,
25226 pattern: isValidPattern,
25227 minLength: isValidMinLength,
25228 maxLength: isValidMaxLength,
25229 elements: isValidElements
25230 }
25231 };
25232
25233 // packages/dataviews/build-module/field-types/no-type.mjs
25234 var sort6 = (a2, b2, direction) => {
25235 if (typeof a2 === "number" && typeof b2 === "number") {
25236 return sort_number_default(a2, b2, direction);
25237 }
25238 return sort_text_default(a2, b2, direction);
25239 };
25240 var no_type_default = {
25241 // type: no type for this one
25242 render,
25243 Edit: null,
25244 sort: sort6,
25245 enableSorting: true,
25246 enableGlobalSearch: false,
25247 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25248 validOperators: getAllOperatorNames(),
25249 format: {},
25250 getValueFormatted: get_value_formatted_default_default,
25251 validate: {
25252 required: isValidRequired,
25253 elements: isValidElements
25254 }
25255 };
25256
25257 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
25258 function supportsNumericRangeConstraint(type) {
25259 return type === "integer" || type === "number";
25260 }
25261 function supportsDateRangeConstraint(type) {
25262 return type === "date" || type === "datetime";
25263 }
25264 function normalizeRangeRule(value, fieldType, key) {
25265 const validator = fieldType.validate[key];
25266 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
25267 return { constraint: value, validate: validator };
25268 }
25269 return void 0;
25270 }
25271 function getIsValid(field, fieldType) {
25272 const rules = field.isValid;
25273 let required;
25274 if (rules?.required === true && fieldType.validate.required !== void 0) {
25275 required = {
25276 constraint: true,
25277 validate: fieldType.validate.required
25278 };
25279 }
25280 let elements;
25281 if ((rules?.elements === true || // elements is enabled unless the field opts-out
25282 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
25283 elements = {
25284 constraint: true,
25285 validate: fieldType.validate.elements
25286 };
25287 }
25288 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
25289 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
25290 const minLengthValue = rules?.minLength;
25291 let minLength;
25292 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
25293 minLength = {
25294 constraint: minLengthValue,
25295 validate: fieldType.validate.minLength
25296 };
25297 }
25298 const maxLengthValue = rules?.maxLength;
25299 let maxLength;
25300 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
25301 maxLength = {
25302 constraint: maxLengthValue,
25303 validate: fieldType.validate.maxLength
25304 };
25305 }
25306 const patternValue = rules?.pattern;
25307 let pattern;
25308 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
25309 pattern = {
25310 constraint: patternValue,
25311 validate: fieldType.validate.pattern
25312 };
25313 }
25314 const custom = rules?.custom ?? fieldType.validate.custom;
25315 return {
25316 required,
25317 elements,
25318 min: min2,
25319 max: max2,
25320 minLength,
25321 maxLength,
25322 pattern,
25323 custom
25324 };
25325 }
25326
25327 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
25328 function getFilter(fieldType) {
25329 return fieldType.validOperators.reduce((accumulator, operator) => {
25330 const operatorObj = getOperatorByName(operator);
25331 if (operatorObj?.filter) {
25332 accumulator[operator] = operatorObj.filter;
25333 }
25334 return accumulator;
25335 }, {});
25336 }
25337
25338 // packages/dataviews/build-module/field-types/utils/get-format.mjs
25339 function getFormat(field, fieldType) {
25340 return {
25341 ...fieldType.format,
25342 ...field.format
25343 };
25344 }
25345 var get_format_default = getFormat;
25346
25347 // packages/dataviews/build-module/field-types/index.mjs
25348 function getFieldTypeByName(type) {
25349 const found = [
25350 email_default,
25351 integer_default,
25352 number_default,
25353 text_default,
25354 datetime_default,
25355 date_default,
25356 boolean_default,
25357 media_default,
25358 array_default,
25359 password_default,
25360 telephone_default,
25361 color_default,
25362 url_default
25363 ].find((fieldType) => fieldType?.type === type);
25364 if (!!found) {
25365 return found;
25366 }
25367 return no_type_default;
25368 }
25369 function normalizeFields(fields) {
25370 return fields.map((field) => {
25371 const fieldType = getFieldTypeByName(field.type);
25372 const getValue = field.getValue || get_value_from_id_default(field.id);
25373 const sort7 = function(a2, b2, direction) {
25374 const aValue = getValue({ item: a2 });
25375 const bValue = getValue({ item: b2 });
25376 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
25377 };
25378 return {
25379 id: field.id,
25380 label: field.label || field.id,
25381 header: field.header || field.label || field.id,
25382 description: field.description,
25383 placeholder: field.placeholder,
25384 getValue,
25385 setValue: field.setValue || set_value_from_id_default(field.id),
25386 elements: field.elements,
25387 getElements: field.getElements,
25388 hasElements: hasElements(field),
25389 isVisible: field.isVisible,
25390 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
25391 enableHiding: field.enableHiding ?? true,
25392 readOnly: field.readOnly ?? false,
25393 // The type provides defaults for the following props
25394 type: fieldType.type,
25395 render: field.render ?? fieldType.render,
25396 Edit: getControl(field, fieldType.Edit),
25397 sort: sort7,
25398 enableSorting: field.enableSorting ?? fieldType.enableSorting,
25399 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
25400 isValid: getIsValid(field, fieldType),
25401 filterBy: get_filter_by_default(
25402 field,
25403 fieldType.defaultOperators,
25404 fieldType.validOperators
25405 ),
25406 filter: getFilter(fieldType),
25407 format: get_format_default(field, fieldType),
25408 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
25409 };
25410 });
25411 }
25412
25413 // packages/dataviews/build-module/hooks/use-data.mjs
25414 var import_element68 = __toESM(require_element(), 1);
25415 function useData({
25416 view,
25417 data: shownData,
25418 getItemId,
25419 isLoading,
25420 paginationInfo,
25421 selection
25422 }) {
25423 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
25424 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element68.useState)(
25425 !isLoading
25426 );
25427 (0, import_element68.useEffect)(() => {
25428 if (!isLoading) {
25429 setHasInitiallyLoaded(true);
25430 }
25431 }, [isLoading]);
25432 const previousDataRef = (0, import_element68.useRef)(shownData);
25433 const previousPaginationInfoRef = (0, import_element68.useRef)(paginationInfo);
25434 (0, import_element68.useEffect)(() => {
25435 if (!isLoading) {
25436 previousDataRef.current = shownData;
25437 previousPaginationInfoRef.current = paginationInfo;
25438 }
25439 }, [shownData, isLoading, paginationInfo]);
25440 const [visibleEntries, setVisibleEntries] = (0, import_element68.useState)([]);
25441 const positionMapRef = (0, import_element68.useRef)(/* @__PURE__ */ new Map());
25442 const allLoadedRecordsRef = (0, import_element68.useRef)([]);
25443 const prevViewParamsRef = (0, import_element68.useRef)({
25444 search: void 0,
25445 filters: void 0,
25446 perPage: void 0
25447 });
25448 const scrollDirectionRef = (0, import_element68.useRef)(void 0);
25449 const prevStartPositionRef = (0, import_element68.useRef)(void 0);
25450 const hasInitializedRef = (0, import_element68.useRef)(false);
25451 const allLoadedRecords = (0, import_element68.useMemo)(() => {
25452 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
25453 if (view.startPosition < prevStartPositionRef.current) {
25454 scrollDirectionRef.current = "up";
25455 } else if (view.startPosition > prevStartPositionRef.current) {
25456 scrollDirectionRef.current = "down";
25457 }
25458 }
25459 prevStartPositionRef.current = view.startPosition;
25460 const currentFiltersKey = JSON.stringify(view.filters ?? []);
25461 const prevFiltersKey = prevViewParamsRef.current.filters;
25462 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
25463 hasInitializedRef.current = true;
25464 prevViewParamsRef.current = {
25465 search: view.search,
25466 filters: currentFiltersKey,
25467 perPage: view.perPage
25468 };
25469 if (shouldReset) {
25470 positionMapRef.current.clear();
25471 scrollDirectionRef.current = void 0;
25472 const startPosition = view.search ? 1 : view.startPosition ?? 1;
25473 const records = shownData.map((record, index2) => {
25474 const position = startPosition + index2;
25475 positionMapRef.current.set(getItemId(record), position);
25476 return {
25477 ...record,
25478 position
25479 };
25480 });
25481 allLoadedRecordsRef.current = records;
25482 return records;
25483 }
25484 const prev = allLoadedRecordsRef.current;
25485 const shownDataIds = new Set(shownData.map(getItemId));
25486 const scrollDirection = scrollDirectionRef.current;
25487 const basePosition = view.search ? 1 : view.startPosition ?? 1;
25488 const newRecords = shownData.map((record, index2) => {
25489 const itemId = getItemId(record);
25490 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
25491 if (position !== void 0) {
25492 positionMapRef.current.set(itemId, position);
25493 }
25494 return {
25495 ...record,
25496 position
25497 };
25498 });
25499 if (newRecords.length === 0) {
25500 return prev;
25501 }
25502 const prevWithoutDuplicates = prev.filter(
25503 (record) => !shownDataIds.has(getItemId(record))
25504 );
25505 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
25506 allRecords.sort((a2, b2) => {
25507 const posA = a2.position;
25508 const posB = b2.position;
25509 return posA - posB;
25510 });
25511 let result = allRecords;
25512 if (visibleEntries.length > 0) {
25513 const visibleMin = Math.min(...visibleEntries);
25514 const visibleMax = Math.max(...visibleEntries);
25515 const buffer = 20;
25516 const recordPositions = allRecords.map(
25517 (r3) => r3.position
25518 );
25519 const minRecordPos = Math.min(...recordPositions);
25520 const maxRecordPos = Math.max(...recordPositions);
25521 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
25522 if (hasOverlap) {
25523 result = allRecords.filter((record) => {
25524 const itemId = getItemId(record);
25525 const isSelected2 = selection?.includes(itemId);
25526 if (isSelected2) {
25527 return true;
25528 }
25529 const itemPosition = record.position;
25530 if (scrollDirection === "up") {
25531 return itemPosition <= visibleMax + buffer;
25532 } else if (scrollDirection === "down") {
25533 return itemPosition >= visibleMin - buffer;
25534 }
25535 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
25536 });
25537 }
25538 }
25539 allLoadedRecordsRef.current = result;
25540 return result;
25541 }, [
25542 shownData,
25543 view.search,
25544 view.filters,
25545 view.perPage,
25546 view.startPosition,
25547 view.infiniteScrollEnabled,
25548 visibleEntries,
25549 selection,
25550 getItemId
25551 ]);
25552 if (!isInfiniteScrollEnabled) {
25553 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
25554 return {
25555 data: dataToReturn.map((item) => ({
25556 ...item,
25557 position: void 0
25558 })),
25559 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
25560 hasInitiallyLoaded,
25561 setVisibleEntries: void 0
25562 };
25563 }
25564 return {
25565 data: allLoadedRecords,
25566 paginationInfo,
25567 hasInitiallyLoaded,
25568 setVisibleEntries
25569 };
25570 }
25571
25572 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
25573 var import_element69 = __toESM(require_element(), 1);
25574 var import_compose11 = __toESM(require_compose(), 1);
25575 function captureAnchorElement(container, anchorElementRef, direction) {
25576 const containerRect = container.getBoundingClientRect();
25577 const centerY = containerRect.top + containerRect.height / 2;
25578 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
25579 if (items.length === 0) {
25580 return false;
25581 }
25582 const bestAnchor = items.reduce((best, item) => {
25583 const itemRect = item.getBoundingClientRect();
25584 const itemCenterY = itemRect.top + itemRect.height / 2;
25585 const distance = Math.abs(itemCenterY - centerY);
25586 const bestRect = best.getBoundingClientRect();
25587 const bestCenterY = bestRect.top + bestRect.height / 2;
25588 const bestDistance = Math.abs(bestCenterY - centerY);
25589 return distance < bestDistance ? item : best;
25590 });
25591 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
25592 const anchorRect = bestAnchor.getBoundingClientRect();
25593 anchorElementRef.current = {
25594 posinset,
25595 viewportOffset: anchorRect.top - containerRect.top,
25596 direction
25597 };
25598 return true;
25599 }
25600 function useInfiniteScroll({
25601 view,
25602 onChangeView,
25603 isLoading,
25604 paginationInfo,
25605 containerRef,
25606 setVisibleEntries
25607 }) {
25608 const anchorElementRef = (0, import_element69.useRef)(null);
25609 const viewRef = (0, import_element69.useRef)(view);
25610 const isLoadingRef = (0, import_element69.useRef)(isLoading);
25611 const onChangeViewRef = (0, import_element69.useRef)(onChangeView);
25612 const totalItemsRef = (0, import_element69.useRef)(paginationInfo.totalItems);
25613 (0, import_element69.useLayoutEffect)(() => {
25614 viewRef.current = view;
25615 isLoadingRef.current = isLoading;
25616 onChangeViewRef.current = onChangeView;
25617 totalItemsRef.current = paginationInfo.totalItems;
25618 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
25619 const intersectionObserverCallback = (0, import_element69.useCallback)(
25620 (entries) => {
25621 if (!setVisibleEntries) {
25622 return;
25623 }
25624 setVisibleEntries((prev) => {
25625 const newVisibleEntries = new Set(prev);
25626 let hasChanged = false;
25627 entries.forEach((entry) => {
25628 const posInSet = Number(
25629 entry.target?.attributes?.getNamedItem(
25630 "aria-posinset"
25631 )?.value
25632 );
25633 if (isNaN(posInSet)) {
25634 return;
25635 }
25636 if (entry.isIntersecting) {
25637 if (!newVisibleEntries.has(posInSet)) {
25638 newVisibleEntries.add(posInSet);
25639 hasChanged = true;
25640 }
25641 } else if (newVisibleEntries.has(posInSet)) {
25642 newVisibleEntries.delete(posInSet);
25643 hasChanged = true;
25644 }
25645 });
25646 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
25647 });
25648 },
25649 [setVisibleEntries]
25650 );
25651 (0, import_element69.useLayoutEffect)(() => {
25652 const container = containerRef.current;
25653 const anchor = anchorElementRef.current;
25654 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
25655 return;
25656 }
25657 const anchorElement = container.querySelector(
25658 `[aria-posinset="${anchor.posinset}"]`
25659 );
25660 if (anchorElement) {
25661 const containerRect = container.getBoundingClientRect();
25662 const anchorRect = anchorElement.getBoundingClientRect();
25663 const currentOffset = anchorRect.top - containerRect.top;
25664 const scrollAdjustment = currentOffset - anchor.viewportOffset;
25665 if (Math.abs(scrollAdjustment) > 1) {
25666 container.scrollTop += scrollAdjustment;
25667 }
25668 }
25669 anchorElementRef.current = null;
25670 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
25671 const intersectionObserverRef = (0, import_element69.useRef)(
25672 null
25673 );
25674 (0, import_element69.useEffect)(() => {
25675 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
25676 if (intersectionObserverRef.current) {
25677 intersectionObserverRef.current.disconnect();
25678 intersectionObserverRef.current = null;
25679 }
25680 return;
25681 }
25682 intersectionObserverRef.current = new IntersectionObserver(
25683 intersectionObserverCallback,
25684 { root: null, rootMargin: "0px", threshold: 0.1 }
25685 );
25686 return () => {
25687 if (intersectionObserverRef.current) {
25688 intersectionObserverRef.current.disconnect();
25689 intersectionObserverRef.current = null;
25690 }
25691 };
25692 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
25693 (0, import_element69.useEffect)(() => {
25694 if (!view.infiniteScrollEnabled || !containerRef.current) {
25695 return;
25696 }
25697 let lastScrollTop = 0;
25698 const BOTTOM_THRESHOLD = 600;
25699 const TOP_THRESHOLD = 800;
25700 const handleScroll = (0, import_compose11.throttle)((event) => {
25701 const currentView = viewRef.current;
25702 const totalItems = totalItemsRef.current;
25703 const target = event.target;
25704 const scrollTop = target.scrollTop;
25705 const scrollHeight = target.scrollHeight;
25706 const clientHeight = target.clientHeight;
25707 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
25708 lastScrollTop = scrollTop;
25709 if (isLoadingRef.current) {
25710 return;
25711 }
25712 const currentStartPosition = currentView.startPosition || 1;
25713 const batchSize = currentView.perPage || 10;
25714 const currentEndPosition = Math.min(
25715 currentStartPosition + batchSize,
25716 totalItems
25717 );
25718 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
25719 if (currentEndPosition < totalItems) {
25720 const newStartPosition = currentEndPosition;
25721 captureAnchorElement(target, anchorElementRef, "down");
25722 onChangeViewRef.current({
25723 ...currentView,
25724 startPosition: newStartPosition
25725 });
25726 }
25727 }
25728 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
25729 if (currentStartPosition > 1) {
25730 const calculatedStartPosition = currentStartPosition - batchSize;
25731 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
25732 captureAnchorElement(target, anchorElementRef, "up");
25733 onChangeViewRef.current({
25734 ...currentView,
25735 startPosition: newStartPosition
25736 });
25737 }
25738 }
25739 }, 50);
25740 const container = containerRef.current;
25741 container.addEventListener("scroll", handleScroll);
25742 return () => {
25743 container.removeEventListener("scroll", handleScroll);
25744 handleScroll.cancel();
25745 };
25746 }, [containerRef, view.infiniteScrollEnabled]);
25747 return {
25748 intersectionObserver: intersectionObserverRef.current
25749 };
25750 }
25751
25752 // packages/dataviews/build-module/dataviews-picker/index.mjs
25753 var import_element70 = __toESM(require_element(), 1);
25754 var import_compose12 = __toESM(require_compose(), 1);
25755 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
25756 var isItemClickable = () => false;
25757 var dataViewsPickerLayouts = VIEW_LAYOUTS.filter(
25758 (viewLayout) => viewLayout.isPicker
25759 );
25760 var defaultGetItemId = (item) => item.id;
25761 var EMPTY_ARRAY5 = [];
25762 var DEFAULT_PICKER_LAYOUTS = {
25763 pickerGrid: true,
25764 pickerTable: true
25765 };
25766 function DefaultUI({
25767 search = true,
25768 searchLabel = void 0
25769 }) {
25770 const { view } = (0, import_element70.useContext)(dataviews_context_default);
25771 const isInfiniteScroll = view.infiniteScrollEnabled;
25772 return /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)(import_jsx_runtime115.Fragment, { children: [
25773 /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)(
25774 Stack,
25775 {
25776 direction: "row",
25777 align: "top",
25778 justify: "space-between",
25779 className: clsx_default("dataviews__view-actions", {
25780 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
25781 }),
25782 gap: "xs",
25783 children: [
25784 /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)(
25785 Stack,
25786 {
25787 direction: "row",
25788 gap: "sm",
25789 justify: "start",
25790 className: "dataviews__search",
25791 children: [
25792 search && /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(dataviews_search_default, { label: searchLabel }),
25793 /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(toggle_default, {})
25794 ]
25795 }
25796 ),
25797 /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(dataviews_view_config_default, {}) })
25798 ]
25799 }
25800 ),
25801 /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
25802 /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(DataViewsLayout, {}),
25803 /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(DataViewsPickerFooter, {})
25804 ] });
25805 }
25806 function DataViewsPicker({
25807 view,
25808 onChangeView,
25809 fields,
25810 search = true,
25811 searchLabel = void 0,
25812 actions = EMPTY_ARRAY5,
25813 data,
25814 getItemId = defaultGetItemId,
25815 isLoading = false,
25816 paginationInfo,
25817 defaultLayouts: defaultLayoutsProperty = DEFAULT_PICKER_LAYOUTS,
25818 selection,
25819 onChangeSelection,
25820 children,
25821 config = { perPageSizes: [10, 20, 50, 100] },
25822 itemListLabel,
25823 empty,
25824 onReset
25825 }) {
25826 const { data: displayData, setVisibleEntries } = useData({
25827 view,
25828 data,
25829 getItemId,
25830 selection,
25831 paginationInfo
25832 });
25833 const containerRef = (0, import_element70.useRef)(null);
25834 const [containerWidth, setContainerWidth] = (0, import_element70.useState)(0);
25835 const resizeObserverRef = (0, import_compose12.useResizeObserver)(
25836 (resizeObserverEntries) => {
25837 setContainerWidth(
25838 resizeObserverEntries[0].borderBoxSize[0].inlineSize
25839 );
25840 },
25841 { box: "border-box" }
25842 );
25843 const [openedFilter, setOpenedFilter] = (0, import_element70.useState)(null);
25844 function setSelectionWithChange(value) {
25845 const newValue = typeof value === "function" ? value(selection) : value;
25846 if (onChangeSelection) {
25847 onChangeSelection(newValue);
25848 }
25849 }
25850 const _fields = (0, import_element70.useMemo)(() => normalizeFields(fields), [fields]);
25851 const filters = use_filters_default(_fields, view);
25852 const hasPrimaryOrLockedFilters = (0, import_element70.useMemo)(
25853 () => (filters || []).some(
25854 (filter) => filter.isPrimary || filter.isLocked
25855 ),
25856 [filters]
25857 );
25858 const [isShowingFilter, setIsShowingFilter] = (0, import_element70.useState)(
25859 hasPrimaryOrLockedFilters
25860 );
25861 const { intersectionObserver } = useInfiniteScroll({
25862 view,
25863 onChangeView,
25864 isLoading,
25865 paginationInfo,
25866 containerRef,
25867 setVisibleEntries
25868 });
25869 (0, import_element70.useEffect)(() => {
25870 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
25871 setIsShowingFilter(true);
25872 }
25873 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
25874 const defaultLayouts2 = (0, import_element70.useMemo)(
25875 () => Object.fromEntries(
25876 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
25877 return dataViewsPickerLayouts.some(
25878 (viewLayout) => viewLayout.type === layoutType
25879 );
25880 }).map(([key, value]) => [
25881 key,
25882 value === true ? {} : value
25883 ])
25884 ),
25885 [defaultLayoutsProperty]
25886 );
25887 if (!defaultLayouts2[view.type]) {
25888 return null;
25889 }
25890 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
25891 dataviews_context_default.Provider,
25892 {
25893 value: {
25894 view,
25895 onChangeView,
25896 fields: _fields,
25897 actions,
25898 data: displayData,
25899 isLoading,
25900 paginationInfo,
25901 isItemClickable,
25902 selection,
25903 onChangeSelection: setSelectionWithChange,
25904 openedFilter,
25905 setOpenedFilter,
25906 getItemId,
25907 containerWidth,
25908 containerRef,
25909 resizeObserverRef,
25910 defaultLayouts: defaultLayouts2,
25911 filters,
25912 isShowingFilter,
25913 setIsShowingFilter,
25914 config,
25915 itemListLabel,
25916 empty,
25917 onReset,
25918 hasInitiallyLoaded: true,
25919 intersectionObserver
25920 },
25921 children: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)("div", { className: "dataviews-picker-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(DefaultUI, { search, searchLabel }) })
25922 }
25923 );
25924 }
25925 var DataViewsPickerSubComponents = DataViewsPicker;
25926 DataViewsPickerSubComponents.BulkActionToolbar = DataViewsPickerFooter;
25927 DataViewsPickerSubComponents.Filters = filters_default;
25928 DataViewsPickerSubComponents.FiltersToggled = filters_toggled_default;
25929 DataViewsPickerSubComponents.FiltersToggle = toggle_default;
25930 DataViewsPickerSubComponents.Layout = DataViewsLayout;
25931 DataViewsPickerSubComponents.LayoutSwitcher = ViewTypeMenu;
25932 DataViewsPickerSubComponents.Pagination = DataViewsPagination;
25933 DataViewsPickerSubComponents.Search = dataviews_search_default;
25934 DataViewsPickerSubComponents.ViewConfig = DataviewsViewConfigDropdown;
25935 var dataviews_picker_default = DataViewsPickerSubComponents;
25936
25937 // node_modules/dequal/dist/index.mjs
25938 var has = Object.prototype.hasOwnProperty;
25939 function find(iter, tar, key) {
25940 for (key of iter.keys()) {
25941 if (dequal(key, tar)) return key;
25942 }
25943 }
25944 function dequal(foo, bar) {
25945 var ctor, len, tmp;
25946 if (foo === bar) return true;
25947 if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
25948 if (ctor === Date) return foo.getTime() === bar.getTime();
25949 if (ctor === RegExp) return foo.toString() === bar.toString();
25950 if (ctor === Array) {
25951 if ((len = foo.length) === bar.length) {
25952 while (len-- && dequal(foo[len], bar[len])) ;
25953 }
25954 return len === -1;
25955 }
25956 if (ctor === Set) {
25957 if (foo.size !== bar.size) {
25958 return false;
25959 }
25960 for (len of foo) {
25961 tmp = len;
25962 if (tmp && typeof tmp === "object") {
25963 tmp = find(bar, tmp);
25964 if (!tmp) return false;
25965 }
25966 if (!bar.has(tmp)) return false;
25967 }
25968 return true;
25969 }
25970 if (ctor === Map) {
25971 if (foo.size !== bar.size) {
25972 return false;
25973 }
25974 for (len of foo) {
25975 tmp = len[0];
25976 if (tmp && typeof tmp === "object") {
25977 tmp = find(bar, tmp);
25978 if (!tmp) return false;
25979 }
25980 if (!dequal(len[1], bar.get(tmp))) {
25981 return false;
25982 }
25983 }
25984 return true;
25985 }
25986 if (ctor === ArrayBuffer) {
25987 foo = new Uint8Array(foo);
25988 bar = new Uint8Array(bar);
25989 } else if (ctor === DataView) {
25990 if ((len = foo.byteLength) === bar.byteLength) {
25991 while (len-- && foo.getInt8(len) === bar.getInt8(len)) ;
25992 }
25993 return len === -1;
25994 }
25995 if (ArrayBuffer.isView(foo)) {
25996 if ((len = foo.byteLength) === bar.byteLength) {
25997 while (len-- && foo[len] === bar[len]) ;
25998 }
25999 return len === -1;
26000 }
26001 if (!ctor || typeof foo === "object") {
26002 len = 0;
26003 for (ctor in foo) {
26004 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
26005 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
26006 }
26007 return Object.keys(bar).length === len;
26008 }
26009 }
26010 return foo !== foo && bar !== bar;
26011 }
26012
26013 // packages/views/build-module/use-view.mjs
26014 var import_element71 = __toESM(require_element(), 1);
26015 var import_data6 = __toESM(require_data(), 1);
26016 var import_preferences = __toESM(require_preferences(), 1);
26017
26018 // packages/views/build-module/preference-keys.mjs
26019 function generatePreferenceKey(kind, name, slug) {
26020 return `dataviews-${kind}-${name}-${slug}`;
26021 }
26022
26023 // packages/views/build-module/filter-utils.mjs
26024 var SCALAR_VALUES = [
26025 "titleField",
26026 "mediaField",
26027 "descriptionField",
26028 "showTitle",
26029 "showMedia",
26030 "showDescription",
26031 "showLevels",
26032 "infiniteScrollEnabled"
26033 ];
26034 function mergeActiveViewOverrides(view, activeViewOverrides, defaultView2) {
26035 if (!activeViewOverrides) {
26036 return view;
26037 }
26038 let result = view;
26039 for (const key of SCALAR_VALUES) {
26040 if (key in activeViewOverrides) {
26041 result = { ...result, [key]: activeViewOverrides[key] };
26042 }
26043 }
26044 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
26045 const activeFields = new Set(
26046 activeViewOverrides.filters.map((f2) => f2.field)
26047 );
26048 const preserved = (view.filters ?? []).filter(
26049 (f2) => !activeFields.has(f2.field)
26050 );
26051 result = {
26052 ...result,
26053 filters: [...preserved, ...activeViewOverrides.filters]
26054 };
26055 }
26056 if (activeViewOverrides.sort) {
26057 const isDefaultSort = defaultView2 && view.sort?.field === defaultView2.sort?.field && view.sort?.direction === defaultView2.sort?.direction;
26058 if (isDefaultSort) {
26059 result = {
26060 ...result,
26061 sort: activeViewOverrides.sort
26062 };
26063 }
26064 }
26065 if (activeViewOverrides.layout) {
26066 result = {
26067 ...result,
26068 layout: {
26069 ...result.layout,
26070 ...activeViewOverrides.layout
26071 }
26072 };
26073 }
26074 if (activeViewOverrides.groupBy) {
26075 result = {
26076 ...result,
26077 groupBy: activeViewOverrides.groupBy
26078 };
26079 }
26080 return result;
26081 }
26082 function stripActiveViewOverrides(view, activeViewOverrides, defaultView2) {
26083 if (!activeViewOverrides) {
26084 return view;
26085 }
26086 let result = view;
26087 for (const key of SCALAR_VALUES) {
26088 if (key in activeViewOverrides) {
26089 const { [key]: _, ...rest } = result;
26090 result = rest;
26091 }
26092 }
26093 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
26094 const activeFields = new Set(
26095 activeViewOverrides.filters.map((f2) => f2.field)
26096 );
26097 result = {
26098 ...result,
26099 filters: (view.filters ?? []).filter(
26100 (f2) => !activeFields.has(f2.field)
26101 )
26102 };
26103 }
26104 if (activeViewOverrides.sort && view.sort?.field === activeViewOverrides.sort.field && view.sort?.direction === activeViewOverrides.sort.direction) {
26105 result = {
26106 ...result,
26107 sort: defaultView2?.sort
26108 };
26109 }
26110 if (activeViewOverrides.layout && "layout" in result && result.layout) {
26111 const layout = { ...result.layout };
26112 for (const key of Object.keys(activeViewOverrides.layout)) {
26113 delete layout[key];
26114 }
26115 result = {
26116 ...result,
26117 layout: Object.keys(layout).length > 0 ? layout : void 0
26118 };
26119 }
26120 if (activeViewOverrides.groupBy && "groupBy" in result) {
26121 const { groupBy: _, ...rest } = result;
26122 result = rest;
26123 }
26124 return result;
26125 }
26126
26127 // packages/views/build-module/use-view.mjs
26128 function omit3(obj, keys) {
26129 const result = { ...obj };
26130 for (const key of keys) {
26131 delete result[key];
26132 }
26133 return result;
26134 }
26135 function useView(config) {
26136 const {
26137 kind,
26138 name,
26139 slug,
26140 defaultView: defaultView2,
26141 activeViewOverrides,
26142 queryParams,
26143 onChangeQueryParams
26144 } = config;
26145 const preferenceKey = generatePreferenceKey(kind, name, slug);
26146 const persistedView = (0, import_data6.useSelect)(
26147 (select2) => {
26148 return select2(import_preferences.store).get(
26149 "core/views",
26150 preferenceKey
26151 );
26152 },
26153 [preferenceKey]
26154 );
26155 const { set: set2 } = (0, import_data6.useDispatch)(import_preferences.store);
26156 const baseView = (0, import_element71.useMemo)(
26157 () => persistedView ?? defaultView2 ?? {},
26158 [persistedView, defaultView2]
26159 );
26160 const page = Number(queryParams?.page ?? baseView.page ?? 1);
26161 const search = queryParams?.search ?? baseView.search ?? "";
26162 const combinedOverrides = (0, import_element71.useMemo)(() => {
26163 const rawDefaults = config.defaultLayouts?.[baseView.type];
26164 const layoutTypeDefaults = !rawDefaults || rawDefaults === true ? {} : rawDefaults;
26165 return { ...layoutTypeDefaults, ...activeViewOverrides };
26166 }, [config.defaultLayouts, baseView.type, activeViewOverrides]);
26167 const view = (0, import_element71.useMemo)(() => {
26168 return mergeActiveViewOverrides(
26169 {
26170 ...baseView,
26171 page,
26172 search
26173 },
26174 combinedOverrides,
26175 defaultView2
26176 );
26177 }, [baseView, page, search, combinedOverrides, defaultView2]);
26178 const isModified = !!persistedView;
26179 const updateView = (0, import_element71.useCallback)(
26180 (newView) => {
26181 const urlParams = {
26182 page: newView?.page,
26183 search: newView?.search
26184 };
26185 const preferenceView = stripActiveViewOverrides(
26186 omit3(newView, ["page", "search"]),
26187 combinedOverrides,
26188 defaultView2
26189 );
26190 if (onChangeQueryParams && !dequal(urlParams, { page, search })) {
26191 onChangeQueryParams(urlParams);
26192 }
26193 const comparableBaseView = stripActiveViewOverrides(
26194 baseView,
26195 combinedOverrides,
26196 defaultView2
26197 );
26198 const comparableDefaultView = stripActiveViewOverrides(
26199 defaultView2,
26200 combinedOverrides,
26201 defaultView2
26202 );
26203 if (!dequal(comparableBaseView, preferenceView)) {
26204 if (dequal(preferenceView, comparableDefaultView)) {
26205 set2("core/views", preferenceKey, void 0);
26206 } else {
26207 set2("core/views", preferenceKey, preferenceView);
26208 }
26209 }
26210 },
26211 [
26212 onChangeQueryParams,
26213 page,
26214 search,
26215 baseView,
26216 defaultView2,
26217 combinedOverrides,
26218 set2,
26219 preferenceKey
26220 ]
26221 );
26222 const resetToDefault = (0, import_element71.useCallback)(() => {
26223 set2("core/views", preferenceKey, void 0);
26224 }, [preferenceKey, set2]);
26225 return {
26226 view,
26227 isModified,
26228 updateView,
26229 resetToDefault
26230 };
26231 }
26232
26233 // packages/views/build-module/load-view.mjs
26234 var import_data7 = __toESM(require_data(), 1);
26235 var import_preferences2 = __toESM(require_preferences(), 1);
26236
26237 // packages/views/build-module/use-view-config.mjs
26238 var import_data8 = __toESM(require_data(), 1);
26239 var import_core_data = __toESM(require_core_data(), 1);
26240
26241 // packages/views/build-module/lock-unlock.mjs
26242 var import_private_apis3 = __toESM(require_private_apis(), 1);
26243 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
26244 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
26245 "@wordpress/views"
26246 );
26247
26248 // packages/media-fields/build-module/alt_text/index.mjs
26249 var import_i18n49 = __toESM(require_i18n(), 1);
26250 var import_components45 = __toESM(require_components(), 1);
26251 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
26252 var altTextField = {
26253 id: "alt_text",
26254 type: "text",
26255 label: (0, import_i18n49.__)("Alt text"),
26256 isVisible: (item) => item?.media_type === "image",
26257 render: ({ item }) => item?.alt_text || "-",
26258 Edit: ({ field, onChange, data }) => {
26259 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
26260 import_components45.TextareaControl,
26261 {
26262 label: field.label,
26263 value: data.alt_text || "",
26264 onChange: (value) => onChange({ alt_text: value }),
26265 rows: 2
26266 }
26267 );
26268 },
26269 enableSorting: false,
26270 filterBy: false
26271 };
26272 var alt_text_default = altTextField;
26273
26274 // packages/media-fields/build-module/attached_to/index.mjs
26275 var import_i18n52 = __toESM(require_i18n(), 1);
26276
26277 // packages/media-fields/build-module/attached_to/view.mjs
26278 var import_element72 = __toESM(require_element(), 1);
26279 var import_i18n50 = __toESM(require_i18n(), 1);
26280
26281 // packages/media-fields/build-module/utils/get-rendered-content.mjs
26282 function getRenderedContent(content) {
26283 if (!content) {
26284 return "";
26285 }
26286 if (typeof content === "string") {
26287 return content;
26288 }
26289 if (typeof content === "object") {
26290 return content.rendered || content.raw || "";
26291 }
26292 return "";
26293 }
26294
26295 // packages/media-fields/build-module/attached_to/view.mjs
26296 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
26297 function MediaAttachedToView({
26298 item
26299 }) {
26300 const [attachedPostTitle, setAttachedPostTitle] = (0, import_element72.useState)(null);
26301 const parentId = item.post;
26302 const embeddedPostId = item._embedded?.["wp:attached-to"]?.[0]?.id;
26303 const embeddedPostTitle = item._embedded?.["wp:attached-to"]?.[0]?.title;
26304 (0, import_element72.useEffect)(() => {
26305 if (!!parentId && parentId === embeddedPostId) {
26306 setAttachedPostTitle(
26307 getRenderedContent(embeddedPostTitle) || (0, import_i18n50.__)("(no title)")
26308 );
26309 }
26310 if (!parentId) {
26311 setAttachedPostTitle((0, import_i18n50.__)("(Unattached)"));
26312 }
26313 }, [parentId, embeddedPostId, embeddedPostTitle]);
26314 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(import_jsx_runtime117.Fragment, { children: attachedPostTitle });
26315 }
26316
26317 // packages/media-fields/build-module/attached_to/edit.mjs
26318 var import_core_data2 = __toESM(require_core_data(), 1);
26319 var import_components46 = __toESM(require_components(), 1);
26320 var import_i18n51 = __toESM(require_i18n(), 1);
26321 var import_element73 = __toESM(require_element(), 1);
26322 var import_compose13 = __toESM(require_compose(), 1);
26323 var import_data9 = __toESM(require_data(), 1);
26324 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1);
26325 function MediaAttachedToEdit({
26326 data,
26327 onChange
26328 }) {
26329 const defaultPost = !!data.post && !!data?._embedded?.["wp:attached-to"]?.[0] ? [
26330 {
26331 label: getRenderedContent(
26332 data._embedded?.["wp:attached-to"]?.[0]?.title
26333 ),
26334 value: data.post.toString()
26335 }
26336 ] : [];
26337 const [options, setOptions] = (0, import_element73.useState)(defaultPost);
26338 const [searchResults, setSearchResults] = (0, import_element73.useState)(
26339 []
26340 );
26341 const [isLoading, setIsLoading] = (0, import_element73.useState)(false);
26342 const [value, setValue] = (0, import_element73.useState)(
26343 data?.post?.toString() ?? null
26344 );
26345 const postTypes = (0, import_data9.useSelect)(
26346 (select2) => select2(import_core_data2.store).getPostTypes(),
26347 []
26348 );
26349 const handleDetach = () => {
26350 onChange({
26351 post: 0,
26352 _embedded: { ...data?._embedded, "wp:attached-to": void 0 }
26353 });
26354 setOptions([]);
26355 };
26356 const onValueChange = async (filterValue) => {
26357 setIsLoading(true);
26358 const results = await (0, import_core_data2.__experimentalFetchLinkSuggestions)(
26359 filterValue,
26360 /*
26361 * @TODO `fetchLinkSuggestions()` should accept `perPage` as an option argument.
26362 * `isInitialSuggestions` limits the result to 3, otherwise it's hardcoded to 20.
26363 */
26364 { type: "post", isInitialSuggestions: true },
26365 {}
26366 );
26367 setSearchResults(results);
26368 const mappedSuggestions = results.map((result) => {
26369 return {
26370 label: result.title,
26371 value: result.id.toString()
26372 };
26373 });
26374 setOptions(mappedSuggestions);
26375 setIsLoading(false);
26376 };
26377 const handleSelectOption = (selectedPostId) => {
26378 if (!selectedPostId) {
26379 handleDetach();
26380 return;
26381 }
26382 setValue(selectedPostId);
26383 if (selectedPostId) {
26384 const selectedPost = searchResults.find(
26385 (result) => result.id === Number(selectedPostId)
26386 );
26387 if (selectedPost && postTypes) {
26388 const postType = postTypes.find(
26389 (_postType) => _postType.slug === selectedPost?.type
26390 );
26391 const attachedTo = {
26392 ...postType && { type: postType.slug },
26393 id: Number(selectedPostId),
26394 title: {
26395 raw: selectedPost.title,
26396 rendered: selectedPost.title
26397 }
26398 };
26399 onChange({
26400 post: Number(selectedPostId),
26401 _embedded: {
26402 ...data?._embedded,
26403 "wp:attached-to": [attachedTo]
26404 }
26405 });
26406 }
26407 }
26408 };
26409 const help = !!data.post ? (0, import_element73.createInterpolateElement)(
26410 (0, import_i18n51.__)(
26411 "Search for a post or page to attach this media to or <button>detach current</button>."
26412 ),
26413 {
26414 button: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
26415 import_components46.Button,
26416 {
26417 __next40pxDefaultSize: true,
26418 onClick: handleDetach,
26419 variant: "link",
26420 accessibleWhenDisabled: true
26421 }
26422 )
26423 }
26424 ) : (0, import_i18n51.__)("Search for a post or page to attach this media to.");
26425 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
26426 import_components46.ComboboxControl,
26427 {
26428 className: "dataviews-media-field__attached-to",
26429 __next40pxDefaultSize: true,
26430 isLoading,
26431 label: (0, import_i18n51.__)("Attached to"),
26432 help,
26433 value,
26434 options,
26435 onFilterValueChange: (0, import_compose13.debounce)(
26436 (filterValue) => onValueChange(filterValue),
26437 300
26438 ),
26439 onChange: handleSelectOption,
26440 hideLabelFromVision: true
26441 }
26442 );
26443 }
26444
26445 // packages/media-fields/build-module/attached_to/index.mjs
26446 var attachedToField = {
26447 id: "attached_to",
26448 type: "text",
26449 label: (0, import_i18n52.__)("Attached to"),
26450 Edit: MediaAttachedToEdit,
26451 render: MediaAttachedToView,
26452 enableSorting: false,
26453 filterBy: false
26454 };
26455 var attached_to_default = attachedToField;
26456
26457 // packages/media-fields/build-module/author/index.mjs
26458 var import_i18n54 = __toESM(require_i18n(), 1);
26459 var import_data10 = __toESM(require_data(), 1);
26460 var import_core_data3 = __toESM(require_core_data(), 1);
26461
26462 // packages/media-fields/build-module/author/view.mjs
26463 var import_i18n53 = __toESM(require_i18n(), 1);
26464 var import_element74 = __toESM(require_element(), 1);
26465 var import_components47 = __toESM(require_components(), 1);
26466 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1);
26467 function AuthorView({
26468 item
26469 }) {
26470 const author = item?._embedded?.author?.[0];
26471 const text = author?.name;
26472 const imageUrl = author?.avatar_urls?.[48];
26473 const [loadingState, setLoadingState] = (0, import_element74.useState)("loading");
26474 (0, import_element74.useEffect)(() => {
26475 setLoadingState("loading");
26476 }, [imageUrl]);
26477 const imgRef = (0, import_element74.useCallback)((img) => {
26478 if (img?.complete) {
26479 setLoadingState("instant");
26480 }
26481 }, []);
26482 const handleLoad = () => {
26483 if (loadingState === "loading") {
26484 setLoadingState("loaded");
26485 }
26486 };
26487 return /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)(import_components47.__experimentalHStack, { alignment: "left", spacing: 0, children: [
26488 !!imageUrl && /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
26489 "div",
26490 {
26491 className: clsx_default("media-author-field__avatar", {
26492 "is-loading": loadingState === "loading",
26493 "is-loaded": loadingState === "loaded"
26494 }),
26495 children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
26496 "img",
26497 {
26498 ref: imgRef,
26499 onLoad: handleLoad,
26500 alt: (0, import_i18n53.__)("Author avatar"),
26501 src: imageUrl
26502 }
26503 )
26504 }
26505 ),
26506 !imageUrl && /* @__PURE__ */ (0, import_jsx_runtime119.jsx)("div", { className: "media-author-field__icon", children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(import_components47.Icon, { icon: comment_author_avatar_default }) }),
26507 /* @__PURE__ */ (0, import_jsx_runtime119.jsx)("span", { className: "media-author-field__name", children: text })
26508 ] });
26509 }
26510
26511 // packages/media-fields/build-module/author/index.mjs
26512 var authorField = {
26513 label: (0, import_i18n54.__)("Author"),
26514 id: "author",
26515 type: "integer",
26516 getElements: async () => {
26517 const authors = await (0, import_data10.resolveSelect)(import_core_data3.store).getEntityRecords(
26518 "root",
26519 "user",
26520 {
26521 per_page: -1,
26522 who: "authors",
26523 _fields: "id,name",
26524 context: "view"
26525 }
26526 ) ?? [];
26527 return authors.map(({ id, name }) => ({
26528 value: id,
26529 label: name
26530 }));
26531 },
26532 render: AuthorView,
26533 sort: (a2, b2, direction) => {
26534 const nameA = a2._embedded?.author?.[0]?.name || "";
26535 const nameB = b2._embedded?.author?.[0]?.name || "";
26536 return direction === "asc" ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA);
26537 },
26538 filterBy: {
26539 operators: ["isAny", "isNone"]
26540 },
26541 readOnly: true
26542 };
26543 var author_default = authorField;
26544
26545 // packages/media-fields/build-module/caption/index.mjs
26546 var import_i18n55 = __toESM(require_i18n(), 1);
26547 var import_components48 = __toESM(require_components(), 1);
26548
26549 // packages/media-fields/build-module/utils/get-raw-content.mjs
26550 function getRawContent(content) {
26551 if (!content) {
26552 return "";
26553 }
26554 if (typeof content === "string") {
26555 return content;
26556 }
26557 if (typeof content === "object" && "raw" in content) {
26558 return content.raw || "";
26559 }
26560 return "";
26561 }
26562
26563 // packages/media-fields/build-module/caption/index.mjs
26564 var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1);
26565 var captionField = {
26566 id: "caption",
26567 type: "text",
26568 label: (0, import_i18n55.__)("Caption"),
26569 getValue: ({ item }) => getRawContent(item?.caption),
26570 render: ({ item }) => getRawContent(item?.caption) || "-",
26571 Edit: ({ field, onChange, data }) => {
26572 return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
26573 import_components48.TextareaControl,
26574 {
26575 label: field.label,
26576 value: getRawContent(data.caption) || "",
26577 onChange: (value) => onChange({ caption: value }),
26578 rows: 2
26579 }
26580 );
26581 },
26582 enableSorting: false,
26583 filterBy: false
26584 };
26585 var caption_default = captionField;
26586
26587 // packages/media-fields/build-module/date_added/index.mjs
26588 var import_i18n56 = __toESM(require_i18n(), 1);
26589 var import_date10 = __toESM(require_date(), 1);
26590 var dateAddedField = {
26591 id: "date",
26592 type: "datetime",
26593 label: (0, import_i18n56.__)("Date added"),
26594 filterBy: {
26595 operators: ["before", "after"]
26596 },
26597 format: {
26598 datetime: (0, import_date10.getSettings)().formats.datetimeAbbreviated
26599 },
26600 readOnly: true
26601 };
26602 var date_added_default = dateAddedField;
26603
26604 // packages/media-fields/build-module/date_modified/index.mjs
26605 var import_i18n57 = __toESM(require_i18n(), 1);
26606 var import_date11 = __toESM(require_date(), 1);
26607 var dateModifiedField = {
26608 id: "modified",
26609 type: "datetime",
26610 label: (0, import_i18n57.__)("Date modified"),
26611 filterBy: {
26612 operators: ["before", "after"]
26613 },
26614 format: {
26615 datetime: (0, import_date11.getSettings)().formats.datetimeAbbreviated
26616 },
26617 readOnly: true
26618 };
26619 var date_modified_default = dateModifiedField;
26620
26621 // packages/media-fields/build-module/description/index.mjs
26622 var import_i18n58 = __toESM(require_i18n(), 1);
26623 var import_components49 = __toESM(require_components(), 1);
26624 var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1);
26625 var descriptionField = {
26626 id: "description",
26627 type: "text",
26628 label: (0, import_i18n58.__)("Description"),
26629 getValue: ({ item }) => getRawContent(item?.description),
26630 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime121.jsx)("div", { children: getRawContent(item?.description) || "-" }),
26631 Edit: ({ field, onChange, data }) => {
26632 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
26633 import_components49.TextareaControl,
26634 {
26635 label: field.label,
26636 value: getRawContent(data.description) || "",
26637 onChange: (value) => onChange({ description: value }),
26638 rows: 5
26639 }
26640 );
26641 },
26642 enableSorting: false,
26643 filterBy: false
26644 };
26645 var description_default = descriptionField;
26646
26647 // packages/media-fields/build-module/filename/index.mjs
26648 var import_i18n59 = __toESM(require_i18n(), 1);
26649 var import_url4 = __toESM(require_url(), 1);
26650
26651 // packages/media-fields/build-module/filename/view.mjs
26652 var import_components50 = __toESM(require_components(), 1);
26653 var import_element75 = __toESM(require_element(), 1);
26654 var import_url3 = __toESM(require_url(), 1);
26655 var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1);
26656 var TRUNCATE_LENGTH = 15;
26657 function FileNameView({
26658 item
26659 }) {
26660 const fileName = (0, import_element75.useMemo)(
26661 () => item?.source_url ? (0, import_url3.getFilename)(item.source_url) : null,
26662 [item?.source_url]
26663 );
26664 if (!fileName) {
26665 return "";
26666 }
26667 if (fileName.length <= TRUNCATE_LENGTH) {
26668 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("span", { className: "dataviews-media-field__filename", children: fileName });
26669 }
26670 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_components50.Tooltip, { text: fileName, children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("span", { className: "dataviews-media-field__filename", tabIndex: -1, children: fileName }) });
26671 }
26672
26673 // packages/media-fields/build-module/filename/index.mjs
26674 var filenameField = {
26675 id: "filename",
26676 type: "text",
26677 label: (0, import_i18n59.__)("File name"),
26678 getValue: ({ item }) => (0, import_url4.getFilename)(item?.source_url || ""),
26679 render: FileNameView,
26680 enableSorting: false,
26681 filterBy: false,
26682 readOnly: true
26683 };
26684 var filename_default = filenameField;
26685
26686 // packages/media-fields/build-module/filesize/index.mjs
26687 var import_i18n60 = __toESM(require_i18n(), 1);
26688 var KB_IN_BYTES = 1024;
26689 var MB_IN_BYTES = 1024 * KB_IN_BYTES;
26690 var GB_IN_BYTES = 1024 * MB_IN_BYTES;
26691 var TB_IN_BYTES = 1024 * GB_IN_BYTES;
26692 var PB_IN_BYTES = 1024 * TB_IN_BYTES;
26693 var EB_IN_BYTES = 1024 * PB_IN_BYTES;
26694 var ZB_IN_BYTES = 1024 * EB_IN_BYTES;
26695 var YB_IN_BYTES = 1024 * ZB_IN_BYTES;
26696 function getBytesString(bytes, unitSymbol, decimals = 2) {
26697 return (0, import_i18n60.sprintf)(
26698 // translators: 1: Actual bytes of a file. 2: The unit symbol (e.g. MB).
26699 (0, import_i18n60._x)("%1$s %2$s", "file size"),
26700 bytes.toLocaleString(void 0, {
26701 minimumFractionDigits: 0,
26702 maximumFractionDigits: decimals
26703 }),
26704 unitSymbol
26705 );
26706 }
26707 function formatFileSize(bytes, decimals = 2) {
26708 if (bytes === 0) {
26709 return getBytesString(0, (0, import_i18n60._x)("B", "unit symbol"), decimals);
26710 }
26711 const quant = {
26712 /* translators: Unit symbol for yottabyte. */
26713 [(0, import_i18n60._x)("YB", "unit symbol")]: YB_IN_BYTES,
26714 /* translators: Unit symbol for zettabyte. */
26715 [(0, import_i18n60._x)("ZB", "unit symbol")]: ZB_IN_BYTES,
26716 /* translators: Unit symbol for exabyte. */
26717 [(0, import_i18n60._x)("EB", "unit symbol")]: EB_IN_BYTES,
26718 /* translators: Unit symbol for petabyte. */
26719 [(0, import_i18n60._x)("PB", "unit symbol")]: PB_IN_BYTES,
26720 /* translators: Unit symbol for terabyte. */
26721 [(0, import_i18n60._x)("TB", "unit symbol")]: TB_IN_BYTES,
26722 /* translators: Unit symbol for gigabyte. */
26723 [(0, import_i18n60._x)("GB", "unit symbol")]: GB_IN_BYTES,
26724 /* translators: Unit symbol for megabyte. */
26725 [(0, import_i18n60._x)("MB", "unit symbol")]: MB_IN_BYTES,
26726 /* translators: Unit symbol for kilobyte. */
26727 [(0, import_i18n60._x)("KB", "unit symbol")]: KB_IN_BYTES,
26728 /* translators: Unit symbol for byte. */
26729 [(0, import_i18n60._x)("B", "unit symbol")]: 1
26730 };
26731 for (const [unit, mag] of Object.entries(quant)) {
26732 if (bytes >= mag) {
26733 return getBytesString(bytes / mag, unit, decimals);
26734 }
26735 }
26736 return "";
26737 }
26738 var filesizeField = {
26739 id: "filesize",
26740 type: "text",
26741 label: (0, import_i18n60.__)("File size"),
26742 getValue: ({ item }) => item?.media_details?.filesize ? formatFileSize(item?.media_details?.filesize) : "",
26743 isVisible: (item) => {
26744 return !!item?.media_details?.filesize;
26745 },
26746 enableSorting: false,
26747 filterBy: false,
26748 readOnly: true
26749 };
26750 var filesize_default = filesizeField;
26751
26752 // packages/media-fields/build-module/media_dimensions/index.mjs
26753 var import_i18n61 = __toESM(require_i18n(), 1);
26754 var mediaDimensionsField = {
26755 id: "media_dimensions",
26756 type: "text",
26757 label: (0, import_i18n61.__)("Dimensions"),
26758 getValue: ({ item }) => item?.media_details?.width && item?.media_details?.height ? (0, import_i18n61.sprintf)(
26759 // translators: 1: Width. 2: Height.
26760 (0, import_i18n61._x)("%1$s \xD7 %2$s", "image dimensions"),
26761 item?.media_details?.width?.toString(),
26762 item?.media_details?.height?.toString()
26763 ) : "",
26764 isVisible: (item) => {
26765 return !!(item?.media_details?.width && item?.media_details?.height);
26766 },
26767 enableSorting: false,
26768 filterBy: false,
26769 readOnly: true
26770 };
26771 var media_dimensions_default = mediaDimensionsField;
26772
26773 // packages/media-fields/build-module/media_thumbnail/index.mjs
26774 var import_i18n63 = __toESM(require_i18n(), 1);
26775
26776 // packages/media-fields/build-module/media_thumbnail/view.mjs
26777 var import_data11 = __toESM(require_data(), 1);
26778 var import_core_data4 = __toESM(require_core_data(), 1);
26779 var import_components51 = __toESM(require_components(), 1);
26780 var import_element76 = __toESM(require_element(), 1);
26781 var import_url5 = __toESM(require_url(), 1);
26782
26783 // packages/media-fields/build-module/utils/get-media-type-from-mime-type.mjs
26784 var import_i18n62 = __toESM(require_i18n(), 1);
26785 function getMediaTypeFromMimeType(mimeType) {
26786 if (mimeType.startsWith("image/")) {
26787 return {
26788 type: "image",
26789 label: (0, import_i18n62.__)("Image"),
26790 icon: image_default
26791 };
26792 }
26793 if (mimeType.startsWith("video/")) {
26794 return {
26795 type: "video",
26796 label: (0, import_i18n62.__)("Video"),
26797 icon: video_default
26798 };
26799 }
26800 if (mimeType.startsWith("audio/")) {
26801 return {
26802 type: "audio",
26803 label: (0, import_i18n62.__)("Audio"),
26804 icon: audio_default
26805 };
26806 }
26807 return {
26808 type: "application",
26809 label: (0, import_i18n62.__)("Application"),
26810 icon: file_default
26811 };
26812 }
26813
26814 // packages/media-fields/build-module/media_thumbnail/view.mjs
26815 var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1);
26816 function getBestImageUrl(featuredMedia, configSizes) {
26817 const sizes = featuredMedia?.media_details?.sizes;
26818 if (!sizes) {
26819 return featuredMedia.source_url;
26820 }
26821 const sizeEntries = Object.values(sizes);
26822 if (!sizeEntries.length) {
26823 return featuredMedia.source_url;
26824 }
26825 const targetWidth = configSizes ? parseInt(configSizes, 10) : NaN;
26826 if (!Number.isNaN(targetWidth)) {
26827 const validEntries = sizeEntries.filter(
26828 (s2) => typeof s2.width === "number" && !Number.isNaN(s2.width)
26829 );
26830 if (!validEntries.length) {
26831 return featuredMedia.source_url;
26832 }
26833 const sorted = [...validEntries].sort(
26834 (a2, b2) => a2.width - b2.width
26835 );
26836 const match2 = sorted.find((s2) => s2.width >= targetWidth);
26837 if (match2) {
26838 return match2.source_url;
26839 }
26840 return sorted[sorted.length - 1].source_url;
26841 }
26842 return featuredMedia.source_url;
26843 }
26844 function FallbackView({
26845 item,
26846 filename
26847 }) {
26848 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: "dataviews-media-field__media-thumbnail", children: /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
26849 import_components51.__experimentalVStack,
26850 {
26851 justify: "center",
26852 alignment: "center",
26853 className: "dataviews-media-field__media-thumbnail__stack",
26854 spacing: 0,
26855 children: [
26856 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
26857 import_components51.Icon,
26858 {
26859 className: "dataviews-media-field__media-thumbnail--icon",
26860 icon: getMediaTypeFromMimeType(item.mime_type).icon,
26861 size: 24
26862 }
26863 ),
26864 !!filename && /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: "dataviews-media-field__media-thumbnail__filename", children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_components51.__experimentalTruncate, { className: "dataviews-media-field__media-thumbnail__filename__truncate", children: filename }) })
26865 ]
26866 }
26867 ) });
26868 }
26869 function ImageView({
26870 item,
26871 configSizes,
26872 onError
26873 }) {
26874 const imageUrl = getBestImageUrl(item, configSizes);
26875 const imgRef = (0, import_element76.useRef)(null);
26876 const [loadingState, setLoadingState] = (0, import_element76.useState)("loading");
26877 (0, import_element76.useLayoutEffect)(() => {
26878 if (imgRef.current?.complete) {
26879 setLoadingState("instant");
26880 } else {
26881 setLoadingState("loading");
26882 }
26883 }, [imageUrl]);
26884 const handleLoad = () => {
26885 if (loadingState === "loading") {
26886 setLoadingState("loaded");
26887 }
26888 };
26889 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
26890 "div",
26891 {
26892 className: clsx_default("dataviews-media-field__media-thumbnail", {
26893 "is-loading": loadingState === "loading",
26894 "is-loaded": loadingState === "loaded"
26895 }),
26896 children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
26897 "img",
26898 {
26899 ref: imgRef,
26900 className: "dataviews-media-field__media-thumbnail--image",
26901 src: imageUrl,
26902 alt: item.alt_text || item.title.raw,
26903 onLoad: handleLoad,
26904 onError,
26905 loading: "lazy"
26906 }
26907 )
26908 }
26909 );
26910 }
26911 function MediaThumbnailView({
26912 item,
26913 config
26914 }) {
26915 const [imageError, setImageError] = (0, import_element76.useState)(false);
26916 const _featuredMedia = (0, import_data11.useSelect)(
26917 (select2) => {
26918 if (!item.featured_media) {
26919 return;
26920 }
26921 return select2(import_core_data4.store).getEntityRecord(
26922 "postType",
26923 "attachment",
26924 item.featured_media
26925 );
26926 },
26927 [item.featured_media]
26928 );
26929 const featuredMedia = item.featured_media ? _featuredMedia : item;
26930 if (!featuredMedia) {
26931 return null;
26932 }
26933 const filename = (0, import_url5.getFilename)(featuredMedia.source_url || "");
26934 if (imageError || getMediaTypeFromMimeType(featuredMedia.mime_type).type !== "image") {
26935 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(FallbackView, { item: featuredMedia, filename: filename || "" });
26936 }
26937 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
26938 ImageView,
26939 {
26940 item: featuredMedia,
26941 configSizes: config?.sizes,
26942 onError: () => setImageError(true)
26943 }
26944 );
26945 }
26946
26947 // packages/media-fields/build-module/media_thumbnail/index.mjs
26948 var mediaThumbnailField = {
26949 id: "media_thumbnail",
26950 type: "media",
26951 label: (0, import_i18n63.__)("Thumbnail"),
26952 render: MediaThumbnailView,
26953 enableSorting: false,
26954 filterBy: false
26955 };
26956 var media_thumbnail_default = mediaThumbnailField;
26957
26958 // packages/media-fields/build-module/mime_type/index.mjs
26959 var import_i18n64 = __toESM(require_i18n(), 1);
26960 var mimeTypeField = {
26961 id: "mime_type",
26962 type: "text",
26963 label: (0, import_i18n64.__)("File type"),
26964 getValue: ({ item }) => item?.mime_type || "",
26965 render: ({ item }) => item?.mime_type || "-",
26966 // Disable sorting until REST API support for ordering my `mime_type` is added.
26967 // See: https://core.trac.wordpress.org/ticket/64073
26968 enableSorting: false,
26969 filterBy: false,
26970 readOnly: true
26971 };
26972 var mime_type_default = mimeTypeField;
26973
26974 // packages/media-utils/build-module/components/media-upload-modal/index.mjs
26975 var import_notices = __toESM(require_notices(), 1);
26976
26977 // packages/media-utils/build-module/lock-unlock.mjs
26978 var import_private_apis4 = __toESM(require_private_apis(), 1);
26979 var { lock: lock4, unlock: unlock4 } = (0, import_private_apis4.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
26980 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
26981 "@wordpress/media-utils"
26982 );
26983
26984 // packages/media-utils/build-module/components/media-upload-modal/upload-status-popover.mjs
26985 var import_element77 = __toESM(require_element(), 1);
26986 var import_i18n65 = __toESM(require_i18n(), 1);
26987 var import_components52 = __toESM(require_components(), 1);
26988 var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1);
26989 function UploadStatusPopover({
26990 uploadingFiles,
26991 onDismissError,
26992 onOpenChange
26993 }) {
26994 const [isOpen, setIsOpen] = (0, import_element77.useState)(false);
26995 const [prevHadErrors, setPrevHadErrors] = (0, import_element77.useState)(false);
26996 const triggerRef = (0, import_element77.useRef)(null);
26997 const updateIsOpen = (0, import_element77.useCallback)(
26998 (open) => {
26999 setIsOpen(open);
27000 onOpenChange?.(open);
27001 },
27002 [onOpenChange]
27003 );
27004 const activeFiles = uploadingFiles.filter(
27005 (file) => file.status === "uploading"
27006 );
27007 const errorFiles = uploadingFiles.filter(
27008 (file) => file.status === "error"
27009 );
27010 const hasErrors = errorFiles.length > 0;
27011 const isUploading = activeFiles.length > 0;
27012 (0, import_element77.useEffect)(() => {
27013 if (hasErrors && !prevHadErrors) {
27014 updateIsOpen(true);
27015 }
27016 setPrevHadErrors(hasErrors);
27017 }, [hasErrors, prevHadErrors, updateIsOpen]);
27018 if (uploadingFiles.length === 0) {
27019 return null;
27020 }
27021 let buttonLabel, popoverHeading;
27022 if (isUploading) {
27023 buttonLabel = (0, import_i18n65.sprintf)(
27024 // translators: %s: number of files being uploaded
27025 (0, import_i18n65._n)("Uploading %s file", "Uploading %s files", activeFiles.length),
27026 activeFiles.length.toLocaleString()
27027 );
27028 popoverHeading = (0, import_i18n65.__)("Uploading");
27029 } else if (hasErrors) {
27030 buttonLabel = (0, import_i18n65.sprintf)(
27031 // translators: %s: number of upload errors
27032 (0, import_i18n65._n)("%s upload error", "%s upload errors", errorFiles.length),
27033 errorFiles.length.toLocaleString()
27034 );
27035 popoverHeading = (0, import_i18n65.__)("Upload errors");
27036 } else {
27037 buttonLabel = (0, import_i18n65.__)("Upload complete");
27038 popoverHeading = (0, import_i18n65.__)("Upload complete");
27039 }
27040 return /* @__PURE__ */ (0, import_jsx_runtime124.jsxs)("div", { className: "media-upload-modal__upload-status", children: [
27041 isUploading && /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(import_components52.Spinner, {}),
27042 /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
27043 import_components52.Button,
27044 {
27045 className: "media-upload-modal__upload-status__trigger",
27046 size: "compact",
27047 icon: chevron_down_default,
27048 iconPosition: "right",
27049 onClick: () => updateIsOpen(!isOpen),
27050 "aria-expanded": isOpen,
27051 ref: triggerRef,
27052 children: buttonLabel
27053 }
27054 ),
27055 isOpen && /* @__PURE__ */ (0, import_jsx_runtime124.jsxs)(
27056 import_components52.Popover,
27057 {
27058 className: "media-upload-modal__upload-status__popover",
27059 placement: "top-start",
27060 offset: 8,
27061 anchor: triggerRef.current,
27062 focusOnMount: true,
27063 onClose: () => {
27064 if (triggerRef.current?.contains(
27065 triggerRef.current.ownerDocument.activeElement
27066 )) {
27067 return;
27068 }
27069 updateIsOpen(false);
27070 },
27071 children: [
27072 /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("div", { className: "media-upload-modal__upload-status__header", children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("h3", { children: popoverHeading }) }),
27073 /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("ul", { className: "media-upload-modal__upload-status__list", children: uploadingFiles.map((file) => /* @__PURE__ */ (0, import_jsx_runtime124.jsxs)(
27074 "li",
27075 {
27076 className: "media-upload-modal__upload-status__item",
27077 children: [
27078 file.status === "uploading" && /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(import_components52.Spinner, {}),
27079 file.status === "uploaded" && /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(import_components52.Icon, { icon: check_default, size: 16 }),
27080 (file.status === "uploading" || file.status === "uploaded") && /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
27081 "span",
27082 {
27083 className: "media-upload-modal__upload-status__filename",
27084 title: file.name,
27085 children: file.name
27086 }
27087 ),
27088 file.status === "error" && /* @__PURE__ */ (0, import_jsx_runtime124.jsxs)(
27089 import_components52.Notice,
27090 {
27091 status: "error",
27092 isDismissible: !!onDismissError,
27093 onRemove: () => onDismissError?.(file.id),
27094 children: [
27095 file.name,
27096 ": ",
27097 file.error
27098 ]
27099 }
27100 )
27101 ]
27102 },
27103 file.id
27104 )) })
27105 ]
27106 }
27107 )
27108 ] });
27109 }
27110
27111 // packages/media-utils/build-module/components/media-upload-modal/use-invalidate-attachment-resolutions.mjs
27112 var import_element78 = __toESM(require_element(), 1);
27113 var import_core_data5 = __toESM(require_core_data(), 1);
27114 var import_data12 = __toESM(require_data(), 1);
27115 function useInvalidateAttachmentResolutions() {
27116 const registry = (0, import_data12.useRegistry)();
27117 return (0, import_element78.useCallback)(() => {
27118 const resolvers = registry.select(import_core_data5.store).getCachedResolvers();
27119 const entityRecordResolutions = resolvers.getEntityRecords;
27120 entityRecordResolutions?.forEach((_value, args) => {
27121 if (args[0] === "postType" && args[1] === "attachment") {
27122 registry.dispatch(import_core_data5.store).invalidateResolution("getEntityRecords", args);
27123 }
27124 });
27125 }, [registry]);
27126 }
27127
27128 // packages/media-utils/build-module/components/media-upload-modal/use-upload-status.mjs
27129 var import_element79 = __toESM(require_element(), 1);
27130 var import_blob2 = __toESM(require_blob(), 1);
27131 var idCounter = 0;
27132 var batchIdCounter = 0;
27133 function useUploadStatus({
27134 onBatchComplete
27135 } = {}) {
27136 const [uploadingFiles, setUploadingFiles] = (0, import_element79.useState)(
27137 []
27138 );
27139 const clearCompleted = (0, import_element79.useCallback)(() => {
27140 setUploadingFiles(
27141 (prev) => prev.filter((item) => item.status !== "uploaded")
27142 );
27143 }, []);
27144 const dismissError = (0, import_element79.useCallback)((fileId) => {
27145 setUploadingFiles(
27146 (prev) => prev.filter((item) => item.id !== fileId)
27147 );
27148 }, []);
27149 const registerBatch = (0, import_element79.useCallback)(
27150 (files) => {
27151 const batchId = String(++batchIdCounter);
27152 const batchSize = files.length;
27153 const newEntries = files.map((file) => ({
27154 id: String(++idCounter),
27155 batchId,
27156 name: file.name,
27157 status: "uploading"
27158 }));
27159 setUploadingFiles((prev) => [...prev, ...newEntries]);
27160 let successCount = 0;
27161 let errorCount = 0;
27162 let batchDone = false;
27163 let successAttachments = [];
27164 const completeBatchIfDone = () => {
27165 if (batchDone || successCount + errorCount < batchSize) {
27166 return;
27167 }
27168 batchDone = true;
27169 setUploadingFiles(
27170 (prev) => prev.map(
27171 (item) => item.batchId === batchId && item.status === "uploading" ? {
27172 ...item,
27173 status: "uploaded"
27174 } : item
27175 )
27176 );
27177 onBatchComplete?.(successAttachments);
27178 };
27179 const onFileChange = (attachments) => {
27180 if (batchDone) {
27181 return;
27182 }
27183 const allReal = attachments.every(
27184 (attachment) => attachment.id && attachment.url && !(0, import_blob2.isBlobURL)(attachment.url)
27185 );
27186 if (!allReal) {
27187 return;
27188 }
27189 successCount = attachments.length;
27190 successAttachments = attachments;
27191 completeBatchIfDone();
27192 };
27193 const onError = (error) => {
27194 const fileName = error instanceof UploadError ? error.file.name : void 0;
27195 setUploadingFiles((prev) => {
27196 let matched = false;
27197 return prev.map((item) => {
27198 if (!matched && item.batchId === batchId && item.status === "uploading" && (!fileName || item.name === fileName)) {
27199 matched = true;
27200 return {
27201 ...item,
27202 status: "error",
27203 error: error.message
27204 };
27205 }
27206 return item;
27207 });
27208 });
27209 errorCount++;
27210 completeBatchIfDone();
27211 };
27212 return { onFileChange, onError };
27213 },
27214 [onBatchComplete]
27215 );
27216 const allComplete = uploadingFiles.length > 0 && uploadingFiles.every((item) => item.status !== "uploading");
27217 return {
27218 uploadingFiles,
27219 registerBatch,
27220 dismissError,
27221 clearCompleted,
27222 allComplete
27223 };
27224 }
27225
27226 // packages/media-utils/build-module/components/media-upload-modal/index.mjs
27227 var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1);
27228 var { useEntityRecordsWithPermissions } = unlock4(import_core_data6.privateApis);
27229 var LAYOUT_PICKER_GRID2 = "pickerGrid";
27230 var LAYOUT_PICKER_TABLE2 = "pickerTable";
27231 var NOTICES_CONTEXT = "media-modal";
27232 var NOTICE_ID_UPLOAD_PROGRESS = "media-modal-upload-progress";
27233 var defaultQueryParams = {
27234 page: 1,
27235 search: ""
27236 };
27237 var defaultView = {
27238 type: LAYOUT_PICKER_GRID2,
27239 fields: [],
27240 showTitle: false,
27241 titleField: "title",
27242 mediaField: "media_thumbnail",
27243 perPage: 50,
27244 filters: [],
27245 layout: {
27246 previewSize: 170,
27247 density: "compact"
27248 }
27249 };
27250 var defaultLayouts = {
27251 [LAYOUT_PICKER_GRID2]: {
27252 fields: [],
27253 showTitle: false,
27254 layout: {
27255 previewSize: 170,
27256 density: "compact"
27257 }
27258 },
27259 [LAYOUT_PICKER_TABLE2]: {
27260 fields: [
27261 "filename",
27262 "filesize",
27263 "media_dimensions",
27264 "author",
27265 "date"
27266 ],
27267 showTitle: true
27268 }
27269 };
27270 function MediaUploadModal({
27271 allowedTypes,
27272 multiple = false,
27273 value,
27274 onSelect,
27275 onClose,
27276 onUpload,
27277 title = (0, import_i18n66.__)("Select Media"),
27278 isOpen,
27279 isDismissible = true,
27280 modalClass,
27281 search = true,
27282 searchLabel = (0, import_i18n66.__)("Search media")
27283 }) {
27284 const [selection, setSelection] = (0, import_element80.useState)(() => {
27285 if (!value) {
27286 return [];
27287 }
27288 return Array.isArray(value) ? value.map(String) : [String(value)];
27289 });
27290 const { createSuccessNotice, removeAllNotices } = (0, import_data13.useDispatch)(import_notices.store);
27291 const invalidateAttachmentResolutions = useInvalidateAttachmentResolutions();
27292 const [queryParams, setQueryParams] = (0, import_element80.useState)(
27293 () => defaultQueryParams
27294 );
27295 const { view, updateView, isModified, resetToDefault } = useView({
27296 kind: "postType",
27297 name: "attachment",
27298 slug: "media-modal",
27299 defaultView,
27300 queryParams,
27301 onChangeQueryParams: setQueryParams
27302 });
27303 const handleChangeView = (0, import_element80.useCallback)(
27304 (nextView) => {
27305 const normalizedView = { ...nextView };
27306 if (normalizedView.startPosition === void 0) {
27307 delete normalizedView.startPosition;
27308 }
27309 updateView(normalizedView);
27310 },
27311 [updateView]
27312 );
27313 const queryArgs = (0, import_element80.useMemo)(() => {
27314 const filters = {};
27315 view.filters?.forEach((filter) => {
27316 if (filter.field === "media_type") {
27317 filters.media_type = filter.value;
27318 }
27319 if (filter.field === "author") {
27320 if (filter.operator === "isAny") {
27321 filters.author = filter.value;
27322 } else if (filter.operator === "isNone") {
27323 filters.author_exclude = filter.value;
27324 }
27325 }
27326 if (filter.field === "date" || filter.field === "modified") {
27327 if (filter.operator === "before") {
27328 filters.before = filter.value;
27329 } else if (filter.operator === "after") {
27330 filters.after = filter.value;
27331 }
27332 }
27333 if (filter.field === "mime_type") {
27334 filters.mime_type = filter.value;
27335 }
27336 });
27337 if (!filters.media_type && !filters.mime_type && allowedTypes && !allowedTypes.includes("*")) {
27338 const { mediaTypes, mimeTypes } = allowedTypes.reduce(
27339 (acc, type) => {
27340 if (type.endsWith("/*")) {
27341 acc.mediaTypes.push(type.replace("/*", ""));
27342 } else if (type.includes("/")) {
27343 acc.mimeTypes.push(type);
27344 } else {
27345 acc.mediaTypes.push(type);
27346 }
27347 return acc;
27348 },
27349 { mediaTypes: [], mimeTypes: [] }
27350 );
27351 if (mediaTypes.length) {
27352 filters.media_type = mediaTypes;
27353 }
27354 if (mimeTypes.length) {
27355 filters.mime_type = mimeTypes;
27356 }
27357 }
27358 return {
27359 per_page: view.perPage || 20,
27360 page: view.page || 1,
27361 status: "inherit",
27362 order: view.sort?.direction,
27363 orderby: view.sort?.field,
27364 search: view.search,
27365 _embed: "author,wp:attached-to",
27366 ...filters
27367 };
27368 }, [view, allowedTypes]);
27369 const handleBatchComplete = (0, import_element80.useCallback)(
27370 (attachments) => {
27371 const uploadedIds = attachments.map((attachment) => String(attachment.id)).filter(Boolean);
27372 if (multiple) {
27373 setSelection((prev) => {
27374 const existing = new Set(prev);
27375 const newIds = uploadedIds.filter(
27376 (id) => !existing.has(id)
27377 );
27378 return [...prev, ...newIds];
27379 });
27380 } else {
27381 setSelection(uploadedIds.slice(0, 1));
27382 }
27383 invalidateAttachmentResolutions();
27384 },
27385 [multiple, invalidateAttachmentResolutions]
27386 );
27387 const {
27388 uploadingFiles,
27389 registerBatch,
27390 dismissError,
27391 clearCompleted,
27392 allComplete
27393 } = useUploadStatus({ onBatchComplete: handleBatchComplete });
27394 const isPopoverOpenRef = (0, import_element80.useRef)(false);
27395 const handlePopoverOpenChange = (0, import_element80.useCallback)(
27396 (open) => {
27397 isPopoverOpenRef.current = open;
27398 if (!open) {
27399 clearCompleted();
27400 }
27401 },
27402 [clearCompleted]
27403 );
27404 const {
27405 records: mediaRecords,
27406 isResolving: isLoading,
27407 totalItems,
27408 totalPages
27409 } = useEntityRecordsWithPermissions("postType", "attachment", queryArgs);
27410 const fields = (0, import_element80.useMemo)(
27411 () => [
27412 // Media field definitions from @wordpress/media-fields
27413 // Cast is safe because RestAttachment has the same properties as Attachment
27414 {
27415 ...media_thumbnail_default,
27416 enableHiding: false
27417 // Within the modal, the thumbnail should always be shown.
27418 },
27419 {
27420 id: "title",
27421 type: "text",
27422 label: (0, import_i18n66.__)("Title"),
27423 getValue: ({ item }) => {
27424 const titleValue = item.title.raw || item.title.rendered;
27425 return titleValue || (0, import_i18n66.__)("(no title)");
27426 }
27427 },
27428 alt_text_default,
27429 caption_default,
27430 description_default,
27431 date_added_default,
27432 date_modified_default,
27433 author_default,
27434 filename_default,
27435 filesize_default,
27436 media_dimensions_default,
27437 mime_type_default,
27438 attached_to_default
27439 ],
27440 []
27441 );
27442 const actions = (0, import_element80.useMemo)(
27443 () => [
27444 {
27445 id: "select",
27446 label: (0, import_i18n66.__)("Select"),
27447 isPrimary: true,
27448 supportsBulk: multiple,
27449 async callback() {
27450 if (selection.length === 0) {
27451 return;
27452 }
27453 const selectedPostsQuery = {
27454 include: selection,
27455 per_page: -1
27456 };
27457 const selectedPosts = await (0, import_data13.resolveSelect)(
27458 import_core_data6.store
27459 ).getEntityRecords(
27460 "postType",
27461 "attachment",
27462 selectedPostsQuery
27463 );
27464 const transformedPosts = (selectedPosts ?? []).map(transformAttachment).filter(Boolean);
27465 const selectedItems = multiple ? transformedPosts : transformedPosts?.[0];
27466 removeAllNotices("snackbar", NOTICES_CONTEXT);
27467 onSelect(selectedItems);
27468 }
27469 }
27470 ],
27471 [multiple, onSelect, selection, removeAllNotices]
27472 );
27473 const handleModalClose = (0, import_element80.useCallback)(() => {
27474 removeAllNotices("snackbar", NOTICES_CONTEXT);
27475 onClose?.();
27476 }, [removeAllNotices, onClose]);
27477 (0, import_element80.useEffect)(() => {
27478 if (!isOpen) {
27479 setQueryParams(defaultQueryParams);
27480 }
27481 }, [isOpen]);
27482 const handleUpload = onUpload || uploadMedia;
27483 const prevAllCompleteRef = (0, import_element80.useRef)(false);
27484 (0, import_element80.useEffect)(() => {
27485 if (allComplete && !prevAllCompleteRef.current) {
27486 const completeCount = uploadingFiles.filter(
27487 (file) => file.status === "uploaded"
27488 ).length;
27489 if (completeCount > 0) {
27490 createSuccessNotice(
27491 (0, import_i18n66.sprintf)(
27492 // translators: %s: number of files
27493 (0, import_i18n66._n)(
27494 "Uploaded %s file",
27495 "Uploaded %s files",
27496 completeCount
27497 ),
27498 completeCount.toLocaleString()
27499 ),
27500 {
27501 type: "snackbar",
27502 context: NOTICES_CONTEXT,
27503 id: NOTICE_ID_UPLOAD_PROGRESS
27504 }
27505 );
27506 }
27507 if (!isPopoverOpenRef.current) {
27508 clearCompleted();
27509 }
27510 }
27511 prevAllCompleteRef.current = allComplete;
27512 }, [allComplete, uploadingFiles, createSuccessNotice, clearCompleted]);
27513 const handleFileSelect = (0, import_element80.useCallback)(
27514 (event) => {
27515 const files = event.target.files;
27516 if (files && files.length > 0) {
27517 const filesArray = Array.from(files);
27518 const { onFileChange, onError } = registerBatch(filesArray);
27519 handleUpload({
27520 allowedTypes,
27521 filesList: filesArray,
27522 onFileChange,
27523 onError
27524 });
27525 }
27526 },
27527 [allowedTypes, handleUpload, registerBatch]
27528 );
27529 const paginationInfo = (0, import_element80.useMemo)(
27530 () => ({
27531 totalItems,
27532 totalPages
27533 }),
27534 [totalItems, totalPages]
27535 );
27536 const acceptTypes = (0, import_element80.useMemo)(() => {
27537 if (allowedTypes?.includes("*")) {
27538 return void 0;
27539 }
27540 return allowedTypes?.join(",");
27541 }, [allowedTypes]);
27542 if (!isOpen) {
27543 return null;
27544 }
27545 return /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(
27546 import_components53.Modal,
27547 {
27548 title,
27549 onRequestClose: handleModalClose,
27550 isDismissible,
27551 className: modalClass,
27552 overlayClassName: "media-upload-modal",
27553 size: "fill",
27554 headerActions: /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
27555 import_components53.FormFileUpload,
27556 {
27557 accept: acceptTypes,
27558 multiple: true,
27559 onChange: handleFileSelect,
27560 __next40pxDefaultSize: true,
27561 render: ({ openFileDialog }) => /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
27562 import_components53.Button,
27563 {
27564 onClick: openFileDialog,
27565 icon: upload_default,
27566 __next40pxDefaultSize: true,
27567 children: (0, import_i18n66.__)("Upload media")
27568 }
27569 )
27570 }
27571 ),
27572 children: [
27573 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
27574 import_components53.DropZone,
27575 {
27576 onFilesDrop: (files) => {
27577 let filteredFiles = files;
27578 if (allowedTypes && !allowedTypes.includes("*")) {
27579 filteredFiles = files.filter(
27580 (file) => allowedTypes.some((allowedType) => {
27581 return file.type === allowedType || file.type.startsWith(
27582 allowedType.replace("*", "")
27583 );
27584 })
27585 );
27586 }
27587 if (filteredFiles.length > 0) {
27588 const { onFileChange, onError } = registerBatch(filteredFiles);
27589 handleUpload({
27590 allowedTypes,
27591 filesList: filteredFiles,
27592 onFileChange,
27593 onError
27594 });
27595 }
27596 },
27597 label: (0, import_i18n66.__)("Drop files to upload")
27598 }
27599 ),
27600 /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(
27601 dataviews_picker_default,
27602 {
27603 data: mediaRecords || [],
27604 fields,
27605 view,
27606 onChangeView: handleChangeView,
27607 actions,
27608 selection,
27609 onChangeSelection: setSelection,
27610 isLoading,
27611 paginationInfo,
27612 defaultLayouts,
27613 getItemId: (item) => String(item.id),
27614 itemListLabel: (0, import_i18n66.__)("Media items"),
27615 onReset: isModified ? resetToDefault : false,
27616 children: [
27617 /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(
27618 Stack,
27619 {
27620 direction: "row",
27621 align: "top",
27622 justify: "space-between",
27623 className: "dataviews__view-actions",
27624 gap: "xs",
27625 children: [
27626 /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(
27627 Stack,
27628 {
27629 direction: "row",
27630 gap: "sm",
27631 justify: "start",
27632 className: "dataviews__search",
27633 children: [
27634 search && /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(dataviews_picker_default.Search, { label: searchLabel }),
27635 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(dataviews_picker_default.FiltersToggle, {})
27636 ]
27637 }
27638 ),
27639 /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
27640 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(dataviews_picker_default.LayoutSwitcher, {}),
27641 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(dataviews_picker_default.ViewConfig, {})
27642 ] })
27643 ]
27644 }
27645 ),
27646 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(dataviews_picker_default.FiltersToggled, { className: "dataviews-filters__container" }),
27647 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(dataviews_picker_default.Layout, {}),
27648 /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(
27649 "div",
27650 {
27651 className: clsx_default("media-upload-modal__footer", {
27652 "is-uploading": uploadingFiles.length > 0
27653 }),
27654 children: [
27655 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
27656 UploadStatusPopover,
27657 {
27658 uploadingFiles,
27659 onDismissError: dismissError,
27660 onOpenChange: handlePopoverOpenChange
27661 }
27662 ),
27663 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(dataviews_picker_default.BulkActionToolbar, {})
27664 ]
27665 }
27666 )
27667 ]
27668 }
27669 ),
27670 (0, import_element80.createPortal)(
27671 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
27672 import_notices.SnackbarNotices,
27673 {
27674 className: "media-upload-modal__snackbar",
27675 context: NOTICES_CONTEXT
27676 }
27677 ),
27678 document.body
27679 )
27680 ]
27681 }
27682 );
27683 }
27684
27685 // packages/media-utils/build-module/private-apis.mjs
27686 var privateApis12 = {};
27687 lock4(privateApis12, {
27688 sideloadMedia,
27689 MediaUploadModal
27690 });
27691 return __toCommonJS(index_exports);
27692 })();
27693 /*! Bundled license information:
27694
27695 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
27696 (**
27697 * @license React
27698 * use-sync-external-store-shim.development.js
27699 *
27700 * Copyright (c) Meta Platforms, Inc. and affiliates.
27701 *
27702 * This source code is licensed under the MIT license found in the
27703 * LICENSE file in the root directory of this source tree.
27704 *)
27705
27706 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
27707 (**
27708 * @license React
27709 * use-sync-external-store-shim/with-selector.development.js
27710 *
27711 * Copyright (c) Meta Platforms, Inc. and affiliates.
27712 *
27713 * This source code is licensed under the MIT license found in the
27714 * LICENSE file in the root directory of this source tree.
27715 *)
27716 */
27717 if(wp.mediaUtils&&typeof wp.mediaUtils==='object'){wp.mediaUtils=Object.assign({},wp.mediaUtils);}
27718 //# sourceMappingURL=index.js.map
27719